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


C# CodeGen.GetNamedLocal方法代码示例

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


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

示例1: CreateSlot

        internal Slot CreateSlot(CodeGen cg)
        {
            switch (_kind) {
                case VariableKind.Local:
                    if (_storage == null) {
                        // Fall back on a runtime lookup if this variable does not have storage associated with it
                        // (e.g. if the variable belongs to a block in interpreted mode).
                        return new LocalNamedFrameSlot(cg.ContextSlot, _name);
                    } else {
                        return CreateSlotForVariable(cg);
                    }

                case VariableKind.Parameter:
                    if (_lift) {
                        if (_storage == null) {
                            return new LocalNamedFrameSlot(cg.ContextSlot, _name);
                        } else {
                            return CreateSlotForVariable(cg);
                        }
                    } else {
                        //Debug.Assert(cg.Allocator.ActiveScope == _block);
                        return MarkLocal(GetArgumentSlot(cg));
                    }

                case VariableKind.Global:
                    if (_storage == null) {
                        return new NamedFrameSlot(cg.ContextSlot, _name);
                    } else {
                        // Globals are accessed via context slot
                        return _storage.CreateSlot(cg.ContextSlot);
                    }

                case VariableKind.Temporary:
                    return cg.GetNamedLocal(_type, SymbolTable.IdToString(_name));

                case VariableKind.GeneratorTemporary:
                    if (!cg.IsGenerator) {
                        goto case VariableKind.Temporary;
                    }

                    // Allocate in environment if emitting generator.
                    // This must be done here for now because the environment
                    // allocation, which is generally done in Allocate(),
                    // is done in the context of the outer generator codegen,
                    // which is not marked IsGenerator so the generator temps
                    // would go onto CLR stack rather than environment.
                    // TODO: Fix this once we have lifetime analysis in place.
                    _storage = _block.EnvironmentFactory.MakeEnvironmentReference(_name, _type);
                    return CreateSlotForVariable(cg);
            }

            Debug.Assert(false, "Unexpected variable kind: " + _kind.ToString());
            return null;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:54,代码来源:Variable.cs

示例2: CreateEnvironmentSlot

 public override EnvironmentSlot CreateEnvironmentSlot(CodeGen cg)
 {
     return new ClassEnvironmentSlot(cg.GetNamedLocal(StorageType, "$environment"), StorageType);
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:4,代码来源:PropertyEnvironmentFactory.cs

示例3: EmitConditionalBranches

        // Emits the switch as if stmts
        private void EmitConditionalBranches(CodeGen cg, Label[] labels)
        {
            Slot testValueSlot = cg.GetNamedLocal(typeof(int), "switchTestValue");
            testValueSlot.EmitSet(cg);

            // For all the "cases" create their conditional branches
            for (int i = 0; i < _cases.Count; i++) {
                // Not default case emit the condition
                if (!_cases[i].IsDefault) {
                    // Test for equality of case value and the test expression
                    cg.EmitInt(_cases[i].Value);
                    testValueSlot.EmitGet(cg);
                    cg.Emit(OpCodes.Beq, labels[i]);
                }
            }
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:17,代码来源:SwitchStatement.cs


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