本文整理汇总了C#中clojure.lang.CljCompiler.Ast.CljILGen.EmitStoreElement方法的典型用法代码示例。如果您正苦于以下问题:C# CljILGen.EmitStoreElement方法的具体用法?C# CljILGen.EmitStoreElement怎么用?C# CljILGen.EmitStoreElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clojure.lang.CljCompiler.Ast.CljILGen
的用法示例。
在下文中一共展示了CljILGen.EmitStoreElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LightEmit
void LightEmit(RHC rhc, ObjExpr objx, CljILGen ilg)
{
//emitting a Fn means constructing an instance, feeding closed-overs from enclosing scope, if any
//objx arg is enclosing objx, not this
// Create the function instance
LocalBuilder fnLocal = ilg.DeclareLocal(CompiledType);
if (CompiledType == typeof(RestFnImpl))
{
ilg.EmitInt(_variadicMethod.RequiredArity);
ilg.EmitNew(Compiler.Ctor_RestFnImpl_1);
}
else
{
ilg.EmitNew(Compiler.Ctor_AFnImpl);
}
ilg.Emit(OpCodes.Stloc, fnLocal);
//ilg.EmitString(String.Format("Creating fn {0}", Name));
//ilg.Emit(OpCodes.Call, typeof(System.Console).GetMethod("WriteLine", new Type[] { typeof(string) }));
// Set up the methods
for (ISeq s = RT.seq(_methods); s != null; s = s.next())
{
FnMethod method = (FnMethod)s.first();
int key = GetMethodKey(method);
string fieldName = IsVariadic && method.IsVariadic
? "_fnDo" + (key - 1) // because key is arity+1 for variadic
: "_fn" + key;
FieldInfo fi = CompiledType.GetField(fieldName);
ilg.Emit(OpCodes.Ldloc, fnLocal);
EmitGetDynMethod(key, ilg);
ilg.EmitType(fi.FieldType);
ilg.Emit(OpCodes.Ldloc, fnLocal);
ilg.Emit(OpCodes.Callvirt, Method_DynamicMethod_CreateDelegate);
ilg.Emit(OpCodes.Castclass, fi.FieldType);
ilg.EmitFieldSet(fi);
}
// setup the constants and locals
ilg.Emit(OpCodes.Ldloc, fnLocal);
if (Constants.count() > 0)
{
EmitGetCompiledConstants(ilg);
}
else
{
ilg.EmitInt(0);
ilg.EmitArray(typeof(Object[]));
}
if (Closes.count() > 0)
{
int maxIndex = Closes.Max(c => ((LocalBinding)c.key()).Index);
ilg.EmitInt(maxIndex + 1);
ilg.Emit(OpCodes.Newarr, typeof(object));
for (ISeq s = RT.keys(Closes); s != null; s = s.next())
{
LocalBinding lb = (LocalBinding)s.first();
ilg.Emit(OpCodes.Dup);
ilg.EmitInt(lb.Index);
objx.EmitLocal(ilg, lb);
ilg.EmitStoreElement(typeof(object));
}
}
else
{
ilg.EmitInt(0);
ilg.EmitArray(typeof(Object[]));
}
// Create the closure
ilg.EmitNew(Compiler.Ctor_Closure_2);
// Assign the clojure
ilg.EmitCall(Compiler.Method_IFnClosure_SetClosure);
// Leave the instance on the stack.
ilg.Emit(OpCodes.Ldloc, fnLocal);
}