本文整理汇总了C#中IPersistentVector.nth方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistentVector.nth方法的具体用法?C# IPersistentVector.nth怎么用?C# IPersistentVector.nth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistentVector
的用法示例。
在下文中一共展示了IPersistentVector.nth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineMethod
private static void DefineMethod(TypeBuilder proxyTB, IPersistentVector sig)
{
string mname = (string)sig.nth(0);
Type[] paramTypes = GenClass.CreateTypeArray((ISeq)sig.nth(1));
Type retType = (Type)sig.nth(2);
MethodBuilder mb = proxyTB.DefineMethod(mname, MethodAttributes.Abstract | MethodAttributes.Public| MethodAttributes.Virtual, retType, paramTypes);
}
示例2: Parse
public static Expr Parse(ParserContext pcon, IPersistentVector form)
{
ParserContext pconToUse = pcon.EvEx();
bool constant = true;
IPersistentVector args = PersistentVector.EMPTY;
for (int i = 0; i < form.count(); i++ )
{
Expr v = Compiler.Analyze(pconToUse, form.nth(i));
args = (IPersistentVector)args.cons(v);
if ( !(v is LiteralExpr) )
constant = false;
}
Expr ret = new VectorExpr(args);
if ( form is IObj && ((IObj)form).meta() != null )
return Compiler.OptionallyGenerateMetaInit(pcon,form, ret);
else if ( constant )
{
IPersistentVector rv = PersistentVector.EMPTY;
for ( int i=0; i<args.count(); i++ )
{
LiteralExpr ve = (LiteralExpr)args.nth(i);
rv = (IPersistentVector)rv.cons(ve.Val);
}
return new ConstantExpr(rv);
}
else
return ret;
}
示例3: GenTypedArgs
internal static Expression[] GenTypedArgs(GenContext context, ParameterInfo[] parms, IPersistentVector args)
{
Expression[] exprs = new Expression[parms.Length];
for (int i = 0; i < parms.Length; i++)
exprs[i] = GenTypedArg(context,parms[i].ParameterType, (Expr)args.nth(i));
return exprs;
}
示例4: Parse
public static Expr Parse(IPersistentVector form)
{
IPersistentVector args = PersistentVector.EMPTY;
for (int i = 0; i < form.count(); i++ )
args = (IPersistentVector)args.cons(Compiler.GenerateAST(form.nth(i),false));
Expr ret = new VectorExpr(args);
return Compiler.OptionallyGenerateMetaInit(form, ret);
}
示例5: GenerateFnClass
private void GenerateFnClass(IPersistentVector interfaces, GenContext context)
{
string publicTypeName = IsDefType || (IsStatic && Compiler.IsCompiling) ? _internalName : _internalName + "__" + RT.nextID();
//Console.WriteLine("DefFn {0}, {1}", publicTypeName, context.AssemblyBuilder.GetName().Name);
_typeBuilder = context.AssemblyGen.DefinePublicType(publicTypeName, _baseType, true);
for (int i = 0; i < interfaces.count(); i++)
_typeBuilder.AddInterfaceImplementation((Type)interfaces.nth(i));
MarkAsSerializable(_typeBuilder);
GenInterface.SetCustomAttributes(_typeBuilder, _classMeta);
GenerateStaticConstructor(_typeBuilder, _baseType, context.IsDebuggable);
_ctorInfo = GenerateConstructor(_typeBuilder, _baseType);
if (_altCtorDrops > 0)
GenerateFieldOnlyConstructor(_typeBuilder, _baseType);
if (SupportsMeta)
{
_nonmetaCtorInfo = GenerateNonMetaConstructor(_typeBuilder, _baseType);
}
GenerateMetaFunctions(_typeBuilder);
//GenerateReloadVarsMethod(_typeBuilder, context);
// The incoming context holds info on the containing function.
// That is the one that holds the closed-over variable values.
//GenContext newContext = CreateContext(context, _typeBuilder, _baseType);
//GenerateMethods(newContext);
GenerateStatics(context);
GenerateMethods(context);
}
示例6: doEquiv
static bool doEquiv(IPersistentVector v, object obj)
{
if (obj is IList || obj is IPersistentVector)
{
ICollection ma = (ICollection)obj;
if (ma.Count != v.count())
return false;
IEnumerator ima = ma.GetEnumerator();
foreach (object ov in ((IList)v))
{
ima.MoveNext();
if (!Util.equiv(ov, ima.Current))
return false;
}
return true;
}
else
{
// Example in Java of Sequential / IPersistentCollection conflation
//if (!(obj is Sequential))
// return false;
//ISeq ms = ((IPersistentCollection)obj).seq();
ISeq ms = obj as ISeq;
if (ms == null)
{
IPersistentCollection mc = obj as IPersistentCollection;
if (mc == null)
return false;
ms = mc.seq();
}
// Once we have the ISeq, we're ready to go.
for (int i = 0; i < v.count(); i++, ms = ms.rest())
{
if (ms == null || !Util.equiv(v.nth(i), ms.first()))
return false;
}
if (ms != null)
return false;
}
return true;
}
示例7: GenArgArray
internal static Expression GenArgArray(GenContext context, IPersistentVector args)
{
Expression[] exprs = new Expression[args.count()];
for (int i = 0; i < args.count(); i++)
{
Expr arg = (Expr)args.nth(i);
exprs[i] = Compiler.MaybeBox(arg.GenDlr(context));
}
Expression argArray = Expression.NewArrayInit(typeof(object), exprs);
return argArray;
}
示例8: GetCtorArgs
private static object[] GetCtorArgs(IPersistentVector v)
{
object[] args = new object[v.length()];
for (int i = 0; i < v.length(); i++)
args[i] = v.nth(i);
return args;
}
示例9: GenTypedArgs
internal static Expression[] GenTypedArgs(ObjExpr objx, GenContext context, Type[] paramTypes, IPersistentVector args)
{
Expression[] exprs = new Expression[paramTypes.Length];
for (int i = 0; i < paramTypes.Length; i++)
exprs[i] = GenTypedArg(objx, context, paramTypes[i], (Expr)args.nth(i));
return exprs;
}
示例10: SeqToTypeArray
private static Type[] SeqToTypeArray(IPersistentVector interfaces)
{
Type[] types = new Type[interfaces.count()];
for (int i = 0; i < interfaces.count(); i++)
types[i] = (Type)interfaces.nth(i);
return types;
}
示例11: doEquiv
static bool doEquiv(IPersistentVector v, object obj)
{
if (obj is IList || obj is IPersistentVector)
{
ICollection ma = (ICollection)obj;
if (ma.Count != v.count())
return false;
IEnumerator ima = ma.GetEnumerator();
foreach (object ov in ((IList)v))
{
ima.MoveNext();
if (!Util.equiv(ov, ima.Current))
return false;
}
return true;
}
else
{
if (!(obj is Sequential))
return false;
ISeq ms = RT.seq(obj);
for (int i = 0; i < v.count(); i++, ms = ms.next())
{
if (ms == null || !Util.equiv(v.nth(i), ms.first()))
return false;
}
if (ms != null)
return false;
}
return true;
}
示例12: doEquals
/// <summary>
/// Compares an <see cref="IPersistentVector">IPersistentVector</see> to another object for equality.
/// </summary>
/// <param name="v">The <see cref="IPersistentVector">IPersistentVector</see> to compare.</param>
/// <param name="obj">The other object to compare.</param>
/// <returns><value>true</value> if the specified Object is equal to the current Object;
/// otherwise, <value>false</value>.
/// </returns>
public static bool doEquals(IPersistentVector v, object obj)
{
if (obj is IList || obj is IPersistentVector)
{
IList ma = obj as IList;
if (ma.Count != v.count() || ma.GetHashCode() != v.GetHashCode())
return false;
for (int i = 0; i < v.count(); i++)
{
if (!Util.equals(v.nth(i), ma[i]))
return false;
}
return true;
}
else
{
if (!(obj is Sequential))
return false;
ISeq ms = RT.seq(obj);
for (int i = 0; i < v.count(); i++, ms = ms.next())
{
if (ms == null || !Util.equals(v.nth(i), ms.first()))
return false;
}
if (ms != null)
return false;
}
return true;
}
示例13: PrimInterface
public static string PrimInterface(IPersistentVector arglist)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < arglist.count(); i++)
sb.Append(TypeChar(Compiler.TagOf(arglist.nth(i))));
sb.Append(TypeChar(Compiler.TagOf(arglist)));
string ret = sb.ToString();
bool prim = ret.Contains("L") || ret.Contains("D");
if (prim && arglist.count() > 4)
throw new ArgumentException("fns taking primitives support only 4 or fewer args");
if (prim)
return "clojure.lang.primifs." + ret;
return null;
}
示例14: IsPrimInterface
public static bool IsPrimInterface(IPersistentVector arglist)
{
if (arglist.count() > 4)
return false;
for (int i = 0; i < arglist.count(); i++)
if (IsPrimType(Compiler.TagOf(arglist.nth(i))))
return true;
if (IsPrimType(Compiler.TagOf(arglist)))
return true;
return false;
}
示例15: GenerateVectorExpr
private static Expression GenerateVectorExpr(IPersistentVector v)
{
int n = v.count();
Expression[] args = new Expression[v.count()];
for (int i = 0; i < n; i++)
args[i] = Generate(v.nth(i));
Expression arrayExpr = Expression.NewArrayInit(typeof(object), MaybeBox(args));
Expression ret = Expression.Call(Method_RT_vector, arrayExpr);
ret = OptionallyGenerateMetaInit(v,ret);
return ret;
}