示例#1
0
        public static void _EmitWhileDo(WhileDoStatement wd, List<ILInstuction> il)
        {
            var begin = new ILDummy();
            begin.Line = GetLabel();
            il.Add(begin);
            var condtitionVariable = _EmitExpression(wd.Condition, il);

            CurrentFunction.AddLocal(condtitionVariable, wd.Condition.ResultType);

            var conditionIl = new ILBranch();
            conditionIl.Condition = _constructVariableAccess(condtitionVariable);
            il.Add(conditionIl);

            var bodyBegin = new ILDummy();
            bodyBegin.Line = GetLabel();
            var bodyEnd = new ILDummy();
            bodyEnd.Line = GetLabel();

            il.Add(bodyBegin);
            _EmitStatementList(wd.Statements, il);
            var gotoBeginIl = new ILGoto(begin.Line);
            il.Add(gotoBeginIl);
            il.Add(bodyEnd);

            conditionIl.FailJump = bodyEnd.Line;
            conditionIl.SuccessJump = bodyBegin.Line;;
        }
示例#2
0
        public static void EmitWhileDo(WhileDoStatement wd, List<ILInstuction> il)
        {
            ILBranch branch = new ILBranch();
            branch.Line = GetLabel();
            branch.Condition = ConstructILExpression(wd.Condition);
            ILDummy succ = new ILDummy();
            succ.Line = GetLabel();
            ILDummy fail = new ILDummy();
            fail.Line = GetLabel();
            ILGoto gotoBegin = new ILGoto(branch.Line);

            branch.SuccessJump = succ.Line;
            branch.FailJump = fail.Line;
            il.Add(branch);
            il.Add(succ);
            EmitStatementList(wd.Statements, il);
            il.Add(gotoBegin);
            il.Add(fail);
        }