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


C# CljILGen.Emit方法代码示例

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


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

示例1: Emit

 public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     ilg.EmitBoolean(_val);
     ilg.Emit(OpCodes.Box,typeof(bool));
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:7,代码来源:BooleanExpr.cs

示例2: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     objx.EmitVar(ilg, _var);
     if (_isDynamic)
     {
         ilg.Emit(OpCodes.Call, Compiler.Method_Var_setDynamic0);
     }
     if (_meta != null)
     {
         if (_initProvided || true) //IncludesExplicitMetadata((MapExpr)_meta))
         {
             ilg.Emit(OpCodes.Dup);
             _meta.Emit(RHC.Expression, objx, ilg);
             ilg.Emit(OpCodes.Castclass, typeof(IPersistentMap));
             ilg.Emit(OpCodes.Call, Compiler.Method_Var_setMeta);
         }
     }
     if (_initProvided)
     {
         ilg.Emit(OpCodes.Dup);
         if (_init is FnExpr)
             ((FnExpr)_init).EmitForDefn(objx, ilg);
         else
             _init.Emit(RHC.Expression, objx, ilg);
         ilg.Emit(OpCodes.Call,Compiler.Method_Var_bindRoot);
     }
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:robertlj,项目名称:clojure-clr,代码行数:29,代码来源:DefExpr.cs

示例3: EmitAssign

 public void EmitAssign(RHC rhc, ObjExpr objx, CljILGen ilg, Expr val)
 {
     objx.EmitVar(ilg, _var);
     val.Emit(RHC.Expression, objx, ilg);
     ilg.Emit(OpCodes.Call, Compiler.Method_Var_set);
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:8,代码来源:VarExpr.cs

示例4: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     ilg.Emit(OpCodes.Call,Compiler.Method_Compiler_CurrentNamespace.GetGetMethod());
     ilg.Emit(OpCodes.Ldstr, _c);
     ilg.Emit(OpCodes.Call, Compiler.Method_RT_classForName);
     ilg.Emit(OpCodes.Call, Compiler.Method_Namespace_importClass1);
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:JvJ,项目名称:clojure-clr,代码行数:9,代码来源:ImportExpr.cs

示例5: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     _expr.Emit(RHC.Expression, objx, ilg);
     ilg.Emit(OpCodes.Castclass, typeof(IObj));
     _meta.Emit(RHC.Expression, objx, ilg);
     ilg.Emit(OpCodes.Castclass, typeof(IPersistentMap));
     ilg.EmitCall(Compiler.Method_IObj_withMeta);
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:10,代码来源:MetaExpr.cs

示例6: Emit

 public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     if (_excExpr == null)
     {
         ilg.Emit(OpCodes.Rethrow);
     }
     else
     {
         _excExpr.Emit(RHC.Expression, objx, ilg);
         ilg.Emit(OpCodes.Castclass, typeof(Exception));
         ilg.Emit(OpCodes.Throw);
     }
 }
开发者ID:mjmcaulay,项目名称:clojure-clr,代码行数:13,代码来源:ThrowExpr.cs

示例7: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     EmitUnboxed(rhc, objx, ilg);
     HostExpr.EmitBoxReturn(objx, ilg, typeof(bool));
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:chrisortman,项目名称:clojure-clr,代码行数:7,代码来源:InstanceOfExpr.cs

示例8: Emit

        public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
        {
            objx.EmitVar(ilg, _var);

            if ( _shadowsCoreMapping )
            {
                LocalBuilder locNs = ilg.DeclareLocal(typeof(Namespace));
                GenContext.SetLocalName(locNs, "ns");

                ilg.Emit(OpCodes.Dup);
                ilg.EmitFieldGet(VarNsFI);
                ilg.Emit(OpCodes.Stloc,locNs);

                LocalBuilder locSym = ilg.DeclareLocal(typeof(Symbol));
                GenContext.SetLocalName(locSym, "sym");

                ilg.Emit(OpCodes.Dup);
                ilg.EmitFieldGet(VarSymFI);
                ilg.Emit(OpCodes.Stloc, locSym);

                ilg.Emit(OpCodes.Ldloc, locNs);
                ilg.Emit(OpCodes.Ldloc, locSym);
                ilg.Emit(OpCodes.Call, NamespaceReferMI);
            }

            if (_isDynamic)
            {
                ilg.Emit(OpCodes.Call, Compiler.Method_Var_setDynamic0);
            }
            if (_meta != null)
            {
                if (_initProvided || true) //IncludesExplicitMetadata((MapExpr)_meta))
                {
                    ilg.Emit(OpCodes.Dup);
                    _meta.Emit(RHC.Expression, objx, ilg);
                    ilg.Emit(OpCodes.Castclass, typeof(IPersistentMap));
                    ilg.Emit(OpCodes.Call, Compiler.Method_Var_setMeta);
                }
            }
            if (_initProvided)
            {
                ilg.Emit(OpCodes.Dup);
                if (_init is FnExpr)
                    ((FnExpr)_init).EmitForDefn(objx, ilg);
                else
                    _init.Emit(RHC.Expression, objx, ilg);
                ilg.Emit(OpCodes.Call,Compiler.Method_Var_bindRoot);
            }
            if (rhc == RHC.Statement)
                ilg.Emit(OpCodes.Pop);
        }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:51,代码来源:DefExpr.cs

示例9: Emit

        public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
        {
            int n = _bindingInits.count();

            // Define our locals
            for (int i = 0; i < n; i++)
            {
                BindingInit bi = (BindingInit)_bindingInits.nth(i);
                LocalBuilder local = ilg.DeclareLocal(typeof(IFn));
                bi.Binding.LocalVar = local;
                ilg.Emit(OpCodes.Ldnull);
                ilg.Emit(OpCodes.Stloc, local);
            }

            // Then initialize

            IPersistentSet lbset = PersistentHashSet.EMPTY;

            for (int i = 0; i < n; i++)
            {
                BindingInit bi = (BindingInit)_bindingInits.nth(i);
                lbset = (IPersistentSet)lbset.cons(bi.Binding);

                bi.Init.Emit(RHC.Expression, objx, ilg);
                ilg.Emit(OpCodes.Stloc,bi.Binding.LocalVar);
            }

            for (int i = 0; i < n; i++)
            {
                BindingInit bi = (BindingInit)_bindingInits.nth(i);
                ObjExpr fe = (ObjExpr)bi.Init;

                ilg.Emit(OpCodes.Ldloc, bi.Binding.LocalVar);
                fe.EmitLetFnInits(ilg, bi.Binding.LocalVar, objx, lbset);
            }

            _body.Emit(rhc, objx, ilg);
        }
开发者ID:clojure,项目名称:clojure-clr,代码行数:38,代码来源:LetFnExpr.cs

示例10: Emit

        public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
        {
            if (_catchExprs.count() == 0 && _finallyExpr == null)
            {
                // degenerate case
                _tryExpr.Emit(rhc, objx, ilg);
                return;
            }

            LocalBuilder retLocal = ilg.DeclareLocal(typeof(Object));

            ilg.BeginExceptionBlock();
            _tryExpr.Emit(rhc, objx, ilg);
            if (rhc != RHC.Statement)
                ilg.Emit(OpCodes.Stloc, retLocal);

            for (int i = 0; i < _catchExprs.count(); i++)
            {
                CatchClause clause = (CatchClause)_catchExprs.nth(i);
                ilg.BeginCatchBlock(clause.Type);
                // Exception should be on the stack.  Put in clause local
                clause.Lb.LocalVar = ilg.DeclareLocal(clause.Type);
                ilg.Emit(OpCodes.Stloc, clause.Lb.LocalVar);
                clause.Handler.Emit(rhc, objx, ilg);
                if (clause.Handler.HasNormalExit() && rhc != RHC.Statement)
                    ilg.Emit(OpCodes.Stloc, retLocal);
            }

            if (_finallyExpr != null)
            {
                ilg.BeginFinallyBlock();
                _finallyExpr.Emit(RHC.Statement, objx, ilg);
            }
            ilg.EndExceptionBlock();
            if (rhc != RHC.Statement)
                ilg.Emit(OpCodes.Ldloc, retLocal);
        }
开发者ID:corvusalba,项目名称:clojure-clr,代码行数:37,代码来源:TryExpr.cs

示例11: EmitUnboxed

        public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg)
        {
            _expr.Emit(RHC.Expression, objx, ilg);

            // This corresponds to the most general case code in System.Linq.Expressions.Compiler.LambdaCompiler

            Type opType = _expr.HasClrType && _expr.ClrType != null ? _expr.ClrType : typeof(object);
            if (opType.IsValueType)
            {
                ilg.Emit(OpCodes.Box, opType);
            }
            ilg.Emit(OpCodes.Isinst, _t);
            ilg.Emit(OpCodes.Ldnull);
            ilg.Emit(OpCodes.Cgt_Un);
        }
开发者ID:JvJ,项目名称:clojure-clr,代码行数:15,代码来源:InstanceOfExpr.cs

示例12: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     if (_coll is IPersistentList)
         ilg.EmitFieldGet(ListEmptyFI);
     else if (_coll is IPersistentVector)
         ilg.EmitFieldGet(VectorEmptyFI);
     else if (_coll is IPersistentMap)
         ilg.EmitFieldGet(HashMapEmptyFI);
     else if (_coll is IPersistentSet)
         ilg.EmitFieldGet(HashSetEmptyFI);
     else
         throw new InvalidOperationException("Unknown collection type.");
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:stuman08,项目名称:clojure-clr,代码行数:15,代码来源:EmptyExpr.cs

示例13: Emit

 public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
 {
     if (_coll is IPersistentList || _coll is LazySeq) // JVM does not include LazySeq test.  I'm getting it in some places.  LazySeq of 0 size got us here, we'll treat as an empty list
         ilg.EmitFieldGet(ListEmptyFI);
     else if (_coll is IPersistentVector)
         ilg.EmitFieldGet(VectorEmptyFI);
     else if (_coll is IPersistentMap)
         ilg.EmitFieldGet(HashMapEmptyFI);
     else if (_coll is IPersistentSet)
         ilg.EmitFieldGet(HashSetEmptyFI);
     else
         throw new InvalidOperationException("Unknown collection type.");
     if (rhc == RHC.Statement)
         ilg.Emit(OpCodes.Pop);
 }
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:15,代码来源:EmptyExpr.cs

示例14: EmitMetaFunctions

        private void EmitMetaFunctions(TypeBuilder fnTB)
        {
            // IPersistentMap meta()
            MethodBuilder metaMB = fnTB.DefineMethod("meta", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.ReuseSlot, typeof(IPersistentMap), Type.EmptyTypes);
            CljILGen gen = new CljILGen(metaMB.GetILGenerator());
            if (SupportsMeta)
            {
                gen.EmitLoadArg(0);
                gen.EmitFieldGet(_metaField);
            }
            else
                gen.EmitNull();
            gen.Emit(OpCodes.Ret);

            // IObj withMeta(IPersistentMap)
            MethodBuilder withMB = fnTB.DefineMethod("withMeta", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.ReuseSlot, typeof(IObj), new Type[] { typeof(IPersistentMap) });
            gen = new CljILGen(withMB.GetILGenerator());

            if (SupportsMeta)
            {
                gen.EmitLoadArg(1);   // meta arg
                foreach (FieldBuilder fb in _closedOverFields)
                {
                    gen.EmitLoadArg(0);
                    gen.MaybeEmitVolatileOp(fb);
                    gen.EmitFieldGet(fb);
                }

                gen.EmitNew(_ctorInfo);
            }
            else
                gen.EmitLoadArg(0);  //this
            gen.Emit(OpCodes.Ret);
        }
开发者ID:EricThorsen,项目名称:clojure-clr,代码行数:34,代码来源:ObjExpr.cs

示例15: 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


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