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


C# CodeGen.MarkLabel方法代码示例

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


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

示例1: Emit

        public override void Emit(CodeGen cg) {
            Label startTarget = cg.DefineLabel();
            Label breakTarget = cg.DefineLabel();
            Label continueTarget = cg.DefineLabel();

            cg.MarkLabel(startTarget);                        
            cg.PushTargets(breakTarget, continueTarget, this);
            _body.Emit(cg);

            cg.MarkLabel(continueTarget);
            // TODO: Check if we need to emit position somewhere else also.
            //cg.EmitPosition(Start, _header);

            _test.Emit(cg);
            cg.Emit(OpCodes.Brtrue, startTarget);

            cg.PopTargets();            
            cg.MarkLabel(breakTarget);
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:19,代码来源:DoStatement.cs

示例2: Emit

        public override void Emit(CodeGen cg)
        {
            if (_statement == null) {
                throw new InvalidOperationException("Incomplete LabelStatement");
            }

            Label label = cg.DefineLabel();
            Label label2 = cg.DefineLabel();

            cg.MarkLabel(label2);
            cg.PushTargets(label, label2, this);

            _statement.Emit(cg);

            cg.MarkLabel(label);

            cg.PopTargets();
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:18,代码来源:LabeledStatement.cs

示例3: Emit

        public override void Emit(CodeGen cg) {
            bool eoiused = false;
            Label eoi = cg.DefineLabel();
            foreach (IfStatementTest t in _tests) {
                Label next = cg.DefineLabel();

                if (t.Test.Span.IsValid)
                {
                  cg.EmitPosition(t.Test.Start, t.Test.End);
                }
                
                t.Test.EmitBranchFalse(cg, next);

                //cg.Emit(OpCodes.Nop);

                t.Body.Emit(cg);

                //cg.EmitSequencePointNone();

                // optimize no else case
                if (IsNotIfOrReturn(t.Body))
                {
                  eoiused |= true;
                  cg.Emit(OpCodes.Br, eoi);
                }
                cg.MarkLabel(next);
            }
            if (_else != null) {
                _else.Emit(cg);
                //cg.EmitSequencePointNone();
            }
            if (eoiused)
            {
              cg.MarkLabel(eoi);
            }
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:36,代码来源:IfStatement.cs

示例4: EmitBaseClassCallCheckForProperties

        /// <summary>
        /// Emits code to check if the class has overriden this specific
        /// function.  For example:
        /// 
        /// MyDerivedType.SomeVirtualFunction = ...
        ///     or
        /// 
        /// class MyDerivedType(MyBaseType):
        ///     def SomeVirtualFunction(self, ...):
        /// 
        /// </summary>
        internal Slot EmitBaseClassCallCheckForProperties(CodeGen cg, MethodInfo baseMethod, VTableEntry methField)
        {
            Label instanceCall = cg.DefineLabel();
            Slot callTarget = cg.GetLocalTmp(typeof(object));

            typeField.EmitGet(cg);
            cg.EmitInt(methField.index);
            callTarget.EmitGetAddr(cg);
            cg.EmitCall(typeof(UserType), "TryGetNonInheritedValueHelper");
            cg.Emit(OpCodes.Brtrue, instanceCall);

            EmitBaseMethodDispatch(baseMethod, cg);

            cg.MarkLabel(instanceCall);

            return callTarget;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:28,代码来源:NewTypeMaker.cs

示例5: Emit

 internal override void Emit(CodeGen cg)
 {
     left.Emit(cg);
     cg.Emit(OpCodes.Dup);
     cg.EmitCall(typeof(Ops), "IsTrue");
     //cg.emitNonzero(left);
     Label l = cg.DefineLabel();
     cg.Emit(OpCodes.Brfalse, l);
     cg.Emit(OpCodes.Pop);
     right.Emit(cg);
     cg.MarkLabel(l);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:12,代码来源:Expressions.cs

示例6: Emit

        internal override void Emit(CodeGen cg)
        {
            Label eol = cg.DefineLabel();
            Label breakTarget = cg.DefineLabel();
            Label continueTarget = cg.DefineLabel();

            cg.EmitPosition(Start, header);

            list.Emit(cg);
            cg.EmitCall(typeof(Ops), "GetEnumeratorForIteration");

            Slot iter;
            if (cg.IsGenerator()) {
                iter = cg.Names.GetTempSlot("iter", typeof(IEnumerator));
            } else {
                iter = cg.GetLocalTmp(typeof(IEnumerator));
            }

            iter.EmitSet(cg);

            cg.MarkLabel(continueTarget);
            iter.EmitGet(cg);
            cg.EmitCall(typeof(IEnumerator), "MoveNext");

            cg.Emit(OpCodes.Brfalse, eol);

            cg.PushTargets(breakTarget, continueTarget);

            iter.EmitGet(cg);
            cg.EmitCall(typeof(IEnumerator).GetProperty("Current").GetGetMethod());
            lhs.EmitSet(cg);

            body.Emit(cg);

            cg.Emit(OpCodes.Br, continueTarget);

            cg.PopTargets();

            cg.MarkLabel(eol);
            if (elseStmt != null) {
                elseStmt.Emit(cg);
            }
            cg.MarkLabel(breakTarget);

            if (!cg.IsGenerator()) {
                cg.FreeLocalTmp(iter);
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:48,代码来源:Statements.cs

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

示例8: Emit

 public override void Emit(CodeGen cg) {
     Label eoi = cg.DefineLabel();
     Label next = cg.DefineLabel();
     _test.Emit(cg);
     //cg.EmitSequencePointNone();
     //cg.Emit(OpCodes.Nop);
     cg.Emit(OpCodes.Brfalse, next);
     _true.Emit(cg);
     //cg.EmitSequencePointNone();
     //cg.Emit(OpCodes.Nop);
     cg.Emit(OpCodes.Br, eoi);
     cg.MarkLabel(next);
     _false.Emit(cg);
     //cg.EmitSequencePointNone();
     //cg.Emit(OpCodes.Nop);
     cg.MarkLabel(eoi);
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:17,代码来源:ConditionalExpression.cs

示例9: EmitTopYieldTargetLabels

        private void EmitTopYieldTargetLabels(List<YieldTarget> yieldTargets, Slot choiceVar, CodeGen cg)
        {
            if (IsBlockYieldable(yieldTargets)) {
                Label label = cg.DefineLabel();
                cg.EmitInt(-1);
                choiceVar.EmitSet(cg);
                cg.Emit(OpCodes.Br, label);

                int index = 0;
                foreach (YieldTarget yt in yieldTargets) {
                    cg.MarkLabel(yt.TopBranchTarget);
                    cg.EmitInt(index++);
                    choiceVar.EmitSet(cg);
                    cg.Emit(OpCodes.Br, label);
                }
                cg.MarkLabel(label);
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:18,代码来源:Statements.cs

示例10: EmitBooleanOperator

        private void EmitBooleanOperator(CodeGen cg, bool isAnd) {
            Label otherwise = cg.DefineLabel();
            Label endif = cg.DefineLabel();

            // if (_left) 
            _left.EmitBranchFalse(cg, otherwise);
            // then

            EmitLocation(cg);

            if (isAnd) {
                _right.EmitAs(cg, typeof(bool));
            } else {
                cg.EmitInt(1);
            }

            cg.Emit(OpCodes.Br, endif);
            // otherwise
            cg.MarkLabel(otherwise);

            if (isAnd) {
                cg.EmitInt(0);
            } else {
                _right.EmitAs(cg, typeof(bool));
            }

            // endif
            cg.MarkLabel(endif);
            return;
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:30,代码来源:BinaryExpression.cs

示例11: EmitAddress

 internal override void EmitAddress(CodeGen cg, Type asType) {
     Label eoi = cg.DefineLabel();
     Label next = cg.DefineLabel();
     _test.Emit(cg);
     cg.Emit(OpCodes.Brfalse, next);
     _true.EmitAddress(cg, asType);
     cg.Emit(OpCodes.Br, eoi);
     cg.MarkLabel(next);
     _false.EmitAddress(cg, asType);
     cg.MarkLabel(eoi);
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:11,代码来源:ConditionalExpression.cs

示例12: EmitBranchFalse

        public override void EmitBranchFalse(CodeGen cg, Label label) {
            switch (NodeType) {
                case AstNodeType.Equal:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.NotEqual, label);
                    if (ScriptDomainManager.Options.LightweightDebugging)
                    {
                      if (!cg.IsDynamicMethod)
                      {
                        var s = SpanToLong(Span);
                        cg.EmitConstant(s);
                        cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
                      }
                    }
                    break;

                case AstNodeType.NotEqual:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.Equal, label);
                    if (ScriptDomainManager.Options.LightweightDebugging)
                    {
                      if (!cg.IsDynamicMethod)
                      {
                        var s = SpanToLong(Span);
                        cg.EmitConstant(s);
                        cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
                      }
                    }
                    break;

                case AstNodeType.AndAlso:
                    // if NOT (left AND right) branch label

                    if (_left.IsConstant(false)) {
                        cg.Emit(OpCodes.Br, label);
                    } else {
                        if (!_left.IsConstant(true)) {
                            _left.EmitBranchFalse(cg, label);
                        }

                        if (_right.IsConstant(false)) {
                            cg.Emit(OpCodes.Br, label);
                        } else if (!_right.IsConstant(true)) {
                            _right.EmitBranchFalse(cg, label);
                        }
                    }
                    break;

                case AstNodeType.OrElse:
                    // if NOT left AND NOT right branch label

                    if (!_left.IsConstant(true) && !_right.IsConstant(true)) {
                        if (_left.IsConstant(false)) {
                            _right.EmitBranchFalse(cg, label);
                        } else if (_right.IsConstant(false)) {
                            _left.EmitBranchFalse(cg, label);
                        } else {
                            // if (NOT left) then 
                            //   if (NOT right) branch label
                            // endif

                            Label endif = cg.DefineLabel();
                            _left.EmitBranchTrue(cg, endif);
                            _right.EmitBranchFalse(cg, label);
                            cg.MarkLabel(endif);
                        }
                    }
                    break;
                case AstNodeType.LessThan:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.GreaterThanOrEqual, label);      
                    break;
                case AstNodeType.LessThanOrEqual:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.GreaterThan, label);
                    break;
                case AstNodeType.GreaterThan:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.LessThanOrEqual, label);
                    break;
                case AstNodeType.GreaterThanOrEqual:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.LessThan, label);
                    break;
                default:

                    base.EmitBranchFalse(cg, label);
                    break;
            }
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:90,代码来源:BinaryExpression.cs

示例13: EmitBranchTrue

        private bool EmitBranchTrue(CodeGen cg, AstNodeType nodeType, Label label) {
            switch (nodeType) {
              case AstNodeType.GreaterThan:
                _left.EmitAs(cg, GetEmitType());
                _right.EmitAs(cg, GetEmitType());
                cg.EmitSequencePointNone();
                cg.Emit(OpCodes.Bgt, label);
                cg.EmitSequencePointNone();
                return true;
              case AstNodeType.GreaterThanOrEqual:
                _left.EmitAs(cg, GetEmitType());
                _right.EmitAs(cg, GetEmitType());
                cg.EmitSequencePointNone();
                cg.Emit(OpCodes.Bge, label);
                cg.EmitSequencePointNone();
                return true;
              case AstNodeType.LessThan:
                _left.EmitAs(cg, GetEmitType());
                _right.EmitAs(cg, GetEmitType());
                cg.EmitSequencePointNone();
                cg.Emit(OpCodes.Blt, label);
                cg.EmitSequencePointNone();
                return true;
              case AstNodeType.LessThanOrEqual:
                _left.EmitAs(cg, GetEmitType());
                _right.EmitAs(cg, GetEmitType());
                cg.EmitSequencePointNone();
                cg.Emit(OpCodes.Ble, label);
                cg.EmitSequencePointNone();
                return true;
                case AstNodeType.Equal:
                    if (_left.IsConstant(null)) {
                        _right.EmitAsObject(cg);
                        cg.EmitSequencePointNone();
                        cg.Emit(OpCodes.Brfalse, label);
                        cg.EmitSequencePointNone();
                    } else if (_right.IsConstant(null)) {
                        _left.EmitAsObject(cg);
                        cg.EmitSequencePointNone();
                        cg.Emit(OpCodes.Brfalse, label);
                        cg.EmitSequencePointNone();
                    } else {
                        _left.EmitAs(cg, GetEmitType());
                        _right.EmitAs(cg, GetEmitType());
                        cg.EmitSequencePointNone();
                        cg.Emit(OpCodes.Beq, label);
                        cg.EmitSequencePointNone();
                    }
                    return true;

                case AstNodeType.NotEqual:
                    if (_left.IsConstant(null)) {
                        _right.EmitAsObject(cg);
                        cg.EmitSequencePointNone();
                        cg.Emit(OpCodes.Brtrue, label);
                        cg.EmitSequencePointNone();
                    } else if (_right.IsConstant(null)) {
                        _left.EmitAsObject(cg);
                        cg.EmitSequencePointNone();
                        cg.Emit(OpCodes.Brtrue, label);
                        cg.EmitSequencePointNone();
                    } else {
                        _left.EmitAs(cg, GetEmitType());
                        _right.EmitAs(cg, GetEmitType());
                        //cg.Emit(OpCodes.Ceq);
                        cg.EmitSequencePointNone();
                        cg.Emit(OpCodes.Bne_Un, label);
                        cg.EmitSequencePointNone();
                    }
                    return true;

                case AstNodeType.AndAlso:
                    // if (left AND right) branch label

                    // if (left) then 
                    //   if (right) branch label
                    // endif
                    Label endif = cg.DefineLabel();
                    _left.EmitBranchFalse(cg, endif);
                    _right.EmitBranchTrue(cg, label);
                    cg.MarkLabel(endif);
                    return true;

                case AstNodeType.OrElse:
                    // if (left OR right) branch label

                    // if (left) then branch label endif
                    // if (right) then branch label endif
                    _left.EmitBranchTrue(cg, label);
                    _right.EmitBranchTrue(cg, label);
                    return true;
                default:
                    return false;
            }
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:95,代码来源:BinaryExpression.cs

示例14: Emit

        public override void Emit(CodeGen cg)
        {
            Nullable<Label> firstTime = null;
            Label eol = cg.DefineLabel();
            Label breakTarget = cg.DefineLabel();
            Label continueTarget = cg.DefineLabel();

            if (_increment != null) {
                firstTime = cg.DefineLabel();
                cg.Emit(OpCodes.Br, firstTime.Value);
            }

            if (_header.IsValid) {
                //cg.EmitPosition(Start, _header);
            }
            cg.MarkLabel(continueTarget);

            if (_increment != null) {
                _increment.EmitAs(cg, typeof(void));
                cg.MarkLabel(firstTime.Value);
            }

            if (_test != null) {
                _test.Emit(cg);
                cg.Emit(OpCodes.Brfalse, eol);
            }

            cg.PushTargets(breakTarget, continueTarget, this);

            _body.Emit(cg);

            cg.Emit(OpCodes.Br, continueTarget);

            cg.PopTargets();

            cg.MarkLabel(eol);
            if (_else != null) {
                _else.Emit(cg);
            }
            cg.MarkLabel(breakTarget);
        }
开发者ID:kkirstein,项目名称:IronScheme,代码行数:41,代码来源:LoopStatement.cs

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


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