public override void Compile(CompileContext context)
        {
            if (context.Options.Optimize && !ElseBranch.IsUsed)
            {
                IfBranch.Compile(context);
                return;
            }
            else if (context.Options.Optimize && !IfBranch.IsUsed)
            {
                ElseBranch.Compile(context);
                return;
            }
            Label elseStart = context.ILGenerator.DefineLabel();
            Label elseEnd   = context.ILGenerator.DefineLabel();

            context.MarkSequencePoint(Expression.LexicalInfo);
            this.Expression.Compile(context);
            context.ILGenerator.Emit(OpCodes.Brfalse, elseStart);
            IfBranch.Compile(context);
            context.ILGenerator.Emit(OpCodes.Br, elseEnd);
            context.ILGenerator.MarkLabel(elseStart);
            ElseBranch.Compile(context);
            context.ILGenerator.MarkLabel(elseEnd);
            if (context.Options.Debug && ElseBranch.LexicalInfo.EndLine != 0)
            {
                LexicalInfo l = ElseBranch.LexicalInfo;
                context.ILGenerator.MarkSequencePoint(context.DebugWriter, l.EndLine, l.EndColumn + 1, l.EndLine, l.EndColumn + 1);
            }
        }
Ejemplo n.º 2
0
        public override void Compile(ILGenerator il)
        {
            EmitDebugInfo(il, 0, false);
            Expression.Compile(il);
            Label ifFalseLabel = il.DefineLabel();
            Label endLabel     = il.DefineLabel();

            il.Emit(OpCodes.Brfalse, ifFalseLabel);
            IfBranch.Compile(il);
            il.Emit(OpCodes.Br, endLabel);
            il.MarkLabel(ifFalseLabel);
            if (ElseBranch != null)
            {
                ElseBranch.Compile(il);
            }
            il.MarkLabel(endLabel);
        }