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


C# CodeGen.EmitCodeContext方法代码示例

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


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

示例1: Emit

 public override void Emit(CodeGen cg) {
     // RuntimeHelpers.LookupName(CodeContext, name)
     cg.EmitCodeContext();
     cg.EmitSymbolId(_name);
     cg.EmitUnbox(typeof(SymbolId));
     cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:UnboundExpression.cs

示例2: Emit

 public override void Emit(CodeGen cg)
 {
     // RuntimeHelpers.RemoveName(CodeContext, name)
     cg.EmitCodeContext();
     cg.EmitSymbolId(_name);
     cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:DeleteUnboundExpression.cs

示例3: Emit

 public override void Emit(CodeGen cg) {
   //EmitLocation(cg);
     _value.EmitAsObject(cg);
     cg.EmitCodeContext();
     cg.EmitSymbolId(_name);
     cg.EmitCall(typeof(RuntimeHelpers), "SetNameReorder");
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:UnboundAssignment.cs

示例4: Emit

        public override void Emit(CodeGen cg) {
            Slot tempContext = cg.ContextSlot;
            Slot newContext = cg.GetLocalTmp(typeof(CodeContext));

            _scope.Emit(cg);            //Locals dictionary
            cg.EmitCodeContext();       //CodeContext
            //cg.EmitBoolean(true);       //Visible = true
            cg.EmitCall(typeof(RuntimeHelpers), "CreateNestedCodeContext");

            newContext.EmitSet(cg);

            cg.ContextSlot = newContext;
            _body.Emit(cg);
            cg.ContextSlot = tempContext;
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:15,代码来源:ScopeStatment.cs

示例5: EmitClrCallStub

        /// <summary>
        /// Generates stub to receive the CLR call and then call the dynamic language code.
        /// </summary>
        public static void  EmitClrCallStub(CodeGen cg, Slot callTarget, int firstArg, CallType functionAttributes) {
            List<ReturnFixer> fixers = new List<ReturnFixer>(0);
            IList<Slot> args = cg.ArgumentSlots;
            int nargs = args.Count - firstArg;
            
            CallAction action;
            if ((functionAttributes & CallType.ArgumentList) != 0) {
                ArgumentInfo[] infos = CompilerHelpers.MakeRepeatedArray(ArgumentInfo.Simple, nargs);
                infos[nargs - 1] = new ArgumentInfo(ArgumentKind.List);

                action = CallAction.Make(new CallSignature(infos));
            } else {
                action = CallAction.Make(nargs);
            }

            bool fast;
            Slot site = cg.CreateDynamicSite(action, 
                CompilerHelpers.MakeRepeatedArray(typeof(object), nargs + 2), 
                out fast);

            site.EmitGet(cg);
            if (!fast) cg.EmitCodeContext();

            if (DynamicSiteHelpers.IsBigTarget(site.Type)) {
                cg.EmitTuple(site.Type.GetGenericArguments()[0], args.Count + 1, delegate(int index) {
                    if (index == 0) {
                        callTarget.EmitGet(cg);
                    } else {
                        ReturnFixer rf = ReturnFixer.EmitArgument(cg, args[index - 1]);
                        if (rf != null) fixers.Add(rf);
                    }
                });
            } else {
                callTarget.EmitGet(cg);

                for (int i = firstArg; i < args.Count; i++) {
                    ReturnFixer rf = ReturnFixer.EmitArgument(cg, args[i]);
                    if (rf != null) fixers.Add(rf);
                }
            }

            cg.EmitCall(site.Type, "Invoke"); 

            foreach (ReturnFixer rf in fixers) {
                rf.FixReturn(cg);
            }
            cg.EmitReturnFromObject();
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:51,代码来源:StubGenerator.cs

示例6: EmitCheck

        public virtual void EmitCheck(CodeGen cg, SymbolId name)
        {
            Contract.RequiresNotNull(cg, "cg");

            Label endCheck = cg.DefineLabel();
            cg.Emit(OpCodes.Dup);
            cg.EmitUninitialized();
            cg.Emit(OpCodes.Bne_Un_S, endCheck);
            if (_local) {
                cg.EmitSymbolId(name);
                cg.EmitUnbox(typeof(SymbolId));
                cg.EmitCall(typeof(RuntimeHelpers), "ThrowUnboundLocalError");
            } else {
                cg.Emit(OpCodes.Pop);
                cg.EmitCodeContext();
                cg.EmitSymbolId(name);
                cg.EmitUnbox(typeof(SymbolId));
                cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
            }
            cg.MarkLabel(endCheck);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:21,代码来源:Slot.cs

示例7: Emit

 public override void Emit(CodeGen cg) {
     cg.EmitCodeContext();
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:3,代码来源:CodeContextExpression.cs

示例8: EmitGetStorageFromContext

 public override void EmitGetStorageFromContext(CodeGen cg)
 {
     cg.EmitCodeContext();
       cg.EmitPropertyGet(typeof(CodeContext), "Scope");
       cg.EmitCall(typeof(RuntimeHelpers).GetMethod("GetStorageData").MakeGenericMethod(StorageType));
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:6,代码来源:PropertyEnvironmentFactory.cs

示例9: Emit

        // Action expression is different in that it mutates its
        // Type based on the need of the outer codegen.
        // Therefore, unless asked explicitly, it will emit itself as object.
        public override void Emit(CodeGen cg) {
            bool fast;
            Slot site = cg.CreateDynamicSite(_action, GetSiteTypes(), out fast);
            MethodInfo method = site.Type.GetMethod("Invoke");

            Debug.Assert(!method.IsStatic);

            // Emit "this" - the site
            site.EmitGet(cg);
            ParameterInfo[] parameters = method.GetParameters();

            int first = 0;

            // Emit code context for unoptimized sites only
            if (!fast) {
                Debug.Assert(parameters[0].ParameterType == typeof(CodeContext));

                cg.EmitCodeContext();

                // skip the CodeContext parameter
                first = 1;
            }

            if (parameters.Length < _arguments.Count + first) {
                // tuple parameters
                Debug.Assert(parameters.Length == first + 1);

                cg.EmitTuple(site.Type.GetGenericArguments()[0], _arguments.Count, delegate(int index) { _arguments[index].Emit(cg); });
            } else {
                // Emit the arguments
                for (int arg = 0; arg < _arguments.Count; arg++) {
                    Debug.Assert(parameters[arg + first].ParameterType == _arguments[arg].Type);
                    _arguments[arg].Emit(cg);
                }
            }


            // Emit the site invoke
            cg.EmitCall(site.Type, "Invoke", tailcall);
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:43,代码来源:ActionExpression.cs


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