当前位置: 首页>>代码示例>>C#>>正文


C# ObjExpr.EmitLocal方法代码示例

本文整理汇总了C#中clojure.lang.CljCompiler.Ast.ObjExpr.EmitLocal方法的典型用法代码示例。如果您正苦于以下问题:C# ObjExpr.EmitLocal方法的具体用法?C# ObjExpr.EmitLocal怎么用?C# ObjExpr.EmitLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clojure.lang.CljCompiler.Ast.ObjExpr的用法示例。


在下文中一共展示了ObjExpr.EmitLocal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitLetFnInits

        internal void EmitLetFnInits(CljILGen ilg, LocalBuilder localBuilder, ObjExpr objx, IPersistentSet letFnLocals)
        {
            if (_typeBuilder != null)
            {
                // Full compile
                ilg.Emit(OpCodes.Castclass, _typeBuilder);

                for (ISeq s = RT.keys(Closes); s != null; s = s.next())
                {
                    LocalBinding lb = (LocalBinding)s.first();
                    if (letFnLocals.contains(lb))
                    {
                        FieldBuilder fb;
                        _closedOverFieldsMap.TryGetValue(lb, out fb);

                        Type primt = lb.PrimitiveType;
                        ilg.Emit(OpCodes.Dup);  // this
                        if (primt != null)
                        {
                            objx.EmitUnboxedLocal(ilg, lb);
                            ilg.MaybeEmitVolatileOp(IsVolatile(lb));
                            ilg.Emit(OpCodes.Stfld, fb);
                        }
                        else
                        {
                            objx.EmitLocal(ilg, lb);
                            ilg.MaybeEmitVolatileOp(IsVolatile(lb));
                            ilg.Emit(OpCodes.Stfld, fb);
                        }
                    }
                }
                ilg.Emit(OpCodes.Pop);
            }
        }
开发者ID:EricThorsen,项目名称:clojure-clr,代码行数:34,代码来源:ObjExpr.cs

示例2: Emit

        public virtual void Emit(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

            if (IsDefType)
                ilg.Emit(OpCodes.Ldnull);
            else
            {
                if (SupportsMeta)
                {
                    ilg.Emit(OpCodes.Ldnull);
                    ilg.Emit(OpCodes.Castclass, typeof(IPersistentMap));
                }

                for (ISeq s = RT.keys(Closes); s != null; s = s.next())
                {
                    LocalBinding lb = (LocalBinding)s.first();
                    if (lb.PrimitiveType != null)
                        objx.EmitUnboxedLocal(ilg, lb);
                    else
                        objx.EmitLocal(ilg, lb);
                }

                ilg.Emit(OpCodes.Newobj, _ctorInfo);
            }

            if (rhc == RHC.Statement)
                ilg.Emit(OpCodes.Pop);
        }
开发者ID:EricThorsen,项目名称:clojure-clr,代码行数:30,代码来源:ObjExpr.cs

示例3: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     if (rhc != RHC.Statement)
         objx.EmitLocal(ilg, _b);
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:5,代码来源:LocalBindingExpr.cs

示例4: 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);
        }
开发者ID:kocubinski,项目名称:clojure-clr,代码行数:97,代码来源:FnExpr.cs

示例5: EmitAssign

 public void EmitAssign(RHC rhc, ObjExpr objx, CljILGen ilg, Expr val)
 {
     objx.EmitAssignLocal(ilg, _b, val);
     if (rhc != RHC.Statement)
         objx.EmitLocal(ilg, _b);
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:6,代码来源:LocalBindingExpr.cs


注:本文中的clojure.lang.CljCompiler.Ast.ObjExpr.EmitLocal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。