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


C# CodeGen.EmitCallerContext方法代码示例

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


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

示例1: Emit

        internal override void Emit(CodeGen cg)
        {
            cg.EmitPosition(this);

            if (names == star) {
                cg.EmitCallerContext();
                cg.EmitString(root.MakeString());

                cg.EmitCall(typeof(Ops), "ImportStar");
            } else {
                cg.EmitModuleInstance();
                cg.EmitString(root.MakeString());

                Slot fromObj = cg.GetLocalTmp(typeof(object));
                cg.EmitStringArray(SymbolTable.IdsToStrings(names));

                if (asNames != null) {
                    cg.EmitStringArray(SymbolTable.IdsToStrings(asNames));
                    cg.EmitCall(typeof(Ops), "ImportFromAs");
                } else {
                    cg.EmitCall(typeof(Ops), "ImportFrom");
                }

                fromObj.EmitSet(cg);

                for (int i = 0; i < names.Count; i++) {
                    cg.EmitCallerContext();
                    fromObj.EmitGet(cg);
                    cg.EmitString(names[i].GetString());
                    cg.EmitCall(typeof(Ops), "ImportOneFrom");

                    SymbolId asName;
                    if (i < asNames.Count && asNames[i] != SymbolTable.Empty)
                        asName = asNames[i];
                    else
                        asName = names[i];

                    cg.EmitSet(asName);
                }
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:41,代码来源:Statements.cs

示例2: EmitWithFinallyBlock

        private void EmitWithFinallyBlock(CodeGen cg, Slot exc, Slot exit, Slot isTryYielded)
        {
            // we are certain that Finally will never yield
            cg.PushFinallyBlock(null, null);
            cg.BeginFinallyBlock();

            //finally body
            Label endOfFinally = cg.DefineLabel();

            // isTryYielded == True ?
            isTryYielded.EmitGet(cg);
            cg.EmitTestTrue();
            cg.Emit(OpCodes.Brtrue, endOfFinally);

            // exc == False ?
            exc.EmitGet(cg);
            cg.EmitTestTrue();
            cg.Emit(OpCodes.Brfalse, endOfFinally);

            //exit(None, None, None)
            cg.EmitCallerContext();
            exit.EmitGet(cg);
            cg.Emit(OpCodes.Ldnull);
            cg.Emit(OpCodes.Ldnull);
            cg.Emit(OpCodes.Ldnull);
            cg.EmitCall(typeof(Ops), "CallWithContext", new Type[] { typeof(ICallerContext), typeof(object), typeof(object), typeof(object), typeof(object) });
            cg.Emit(OpCodes.Pop);

            cg.MarkLabel(endOfFinally);
            cg.PopTargets();

            // finally end
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:33,代码来源:Statements.cs

示例3: EmitWithCatchBlock

        private void EmitWithCatchBlock(CodeGen cg, Slot exc, Slot exit)
        {
            cg.BeginCatchBlock(typeof(Exception));
            // Extract state from the carrier exception
            cg.EmitCallerContext();
            cg.EmitCall(typeof(Ops), "ExtractException",
                new Type[] { typeof(Exception), typeof(ICallerContext) });
            cg.Emit(OpCodes.Pop);

            // except body
            cg.PushExceptionBlock(Targets.TargetBlockType.Catch, null, null);
            cg.EmitConstantBoxed(false);
            exc.EmitSet(cg);

            cg.EmitCallerContext();
            exit.EmitGet(cg);
            cg.EmitObjectArray(new Expression[0]);
            cg.EmitCallerContext();
            cg.EmitCall(typeof(Ops), "ExtractSysExcInfo");
            cg.EmitCall(typeof(Ops), "CallWithArgsTupleAndContext", new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(object) });

            Label afterRaise = cg.DefineLabel();

            cg.EmitTestTrue();
            cg.Emit(OpCodes.Brtrue, afterRaise);
            cg.EmitCall(typeof(Ops), "Raise", new Type[0]); //, new Type[] { typeof(object), typeof(SymbolId) });
            cg.MarkLabel(afterRaise);
            cg.EmitCallerContext();
            cg.EmitCall(typeof(Ops), "ClearException", new Type[] { typeof(ICallerContext) });
            cg.PopTargets();
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:31,代码来源:Statements.cs

示例4: CreateEnvironment

        internal Slot CreateEnvironment(CodeGen cg)
        {
            // Get the environment size
            int size = CalculateEnvironmentSize();

            // Find the right environment type
            ConstructorInfo ctor;
            EnvironmentFactory esf;
            Type envType = GetEnvironmentType(size, cg, out ctor, out esf);

            // Emit the static link for the environment constructor
            cg.EmitStaticLinkOrNull();
            cg.EmitCallerContext();
            // Emit the names array for the environment constructor
            EmitEnvironmentIDs(cg);
            EmitOuterLocalIDs(cg);
            cg.EmitNew(ctor);

            // Store the environment reference in the local
            Slot environmentSlot = cg.GetFrameSlot(envType);
            environmentSlot.EmitSet(cg);

            // Remember the environment factory for parent access
            environmentFactory = esf;

            // Create environment references
            environment = new Dictionary<SymbolId, EnvironmentReference>();

            foreach (KeyValuePair<SymbolId, Binding> kv in names) {
                if (!kv.Value.IsEnvironment) continue;
                SymbolId name = kv.Key;
                EnvironmentReference er = esf.MakeEnvironmentReference(name);
                Slot slot = er.CreateSlot(environmentSlot);
                Slot current;
                if (cg.Names.Slots.TryGetValue(name, out current)) {
                    slot.EmitSet(cg, current);
                } else {
                    slot.EmitSetUninitialized(cg, name);
                }

                // The full slot goes to the codegen's namespace
                cg.Names.SetSlot(name, slot);
                // Environment reference goes to the environment
                environment[name] = er;
            }

            return environmentSlot;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:48,代码来源:ScopeStatement.cs

示例5: EmitSet

 internal override void EmitSet(CodeGen cg)
 {
     target.Emit(cg);
     cg.EmitSymbolId(name);
     cg.EmitCallerContext();
     cg.EmitCall(typeof(Ops), "SetAttrStackHelper");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Expressions.cs

示例6: EmitDel

 internal override void EmitDel(CodeGen cg)
 {
     cg.EmitCallerContext();
     target.Emit(cg);
     cg.EmitSymbolId(name);
     cg.EmitCall(typeof(Ops), "DelAttr");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Expressions.cs

示例7: Emit

        internal override void Emit(CodeGen cg)
        {
            cg.EmitCallerContext();
            target.Emit(cg);

            cg.EmitSymbolId(name);

            cg.EmitCall(typeof(Ops), "GetAttr"); //, new Type[] { typeof(object), typeof(SymbolId) });
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:9,代码来源:Expressions.cs

示例8: EmitCheck

 public virtual void EmitCheck(CodeGen cg, SymbolId name)
 {
     if (Options.CheckInitialized) {
         if (local) {
             Label endCheck = cg.DefineLabel();
             cg.Emit(OpCodes.Dup);
             cg.EmitUninitialized();
             cg.Emit(OpCodes.Bne_Un_S, endCheck);
             cg.EmitName(name);
             cg.EmitCall(typeof(Ops), "ThrowUnboundLocalError");
             cg.MarkLabel(endCheck);
         } else {
             cg.EmitCallerContext();
             cg.EmitName(name);
             cg.EmitCall(typeof(Ops), "CheckInitializedOrBuiltin");
         }
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:18,代码来源:Slot.cs


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