コード例 #1
0
 public void Visit(WhileStatementNode statement)
 {
     Emit("do {");
     ++_indentationLevel;
     statement.Condition.Accept(this);
     Emit("if (!stack.pop()) break;");
     statement.Body.Accept(this);
     --_indentationLevel;
     Emit("} while (1);");
 }
コード例 #2
0
        public void Visit(WhileStatementNode statement)
        {
            int labelIndex = _labelCount++;
            int?previousInnermostWhileLabelIndex = _innermostWhileLabelIndex;

            _innermostWhileLabelIndex = labelIndex;
            string conditionLabel = "while_condition_" + labelIndex;
            string endLabel       = "while_end_" + labelIndex;

            EmitComment("While: condition");
            EmitLabel(conditionLabel);
            statement.Condition.Accept(this);
            Emit("brfalse", endLabel);
            EmitComment("While: body");
            statement.Body.Accept(this);
            Emit("br", conditionLabel);
            EmitLabel(endLabel);
            _innermostWhileLabelIndex = previousInnermostWhileLabelIndex;
        }
コード例 #3
0
 public void Visit(WhileStatementNode statement)
 {
     int labelIndex = _labelCount++;
     int? previousInnermostWhileLabelIndex = _innermostWhileLabelIndex;
     _innermostWhileLabelIndex = labelIndex;
     string conditionLabel = "while_condition_" + labelIndex;
     string endLabel = "while_end_" + labelIndex;
     EmitComment("While: condition");
     EmitLabel(conditionLabel);
     statement.Condition.Accept(this);
     Emit("ifeq", endLabel);
     EmitComment("While: body");
     statement.Body.Accept(this);
     Emit("goto", conditionLabel);
     EmitLabel(endLabel);
     _innermostWhileLabelIndex = previousInnermostWhileLabelIndex;
 }
コード例 #4
0
 public void Visit(WhileStatementNode statement)
 {
     Emit("do {");
     ++_indentationLevel;
     statement.Condition.Accept(this);
     Emit("if (!stack.pop()) break;");
     statement.Body.Accept(this);
     --_indentationLevel;
     Emit("} while (1);");
 }