예제 #1
0
 public override void Visit(WhileStatementNode node)
 {
     string WhileLabel = WhileLabelGenerator.GetNewLabel();
     string WhileLabelLoop = WhileLabel + "Loop";
     string WhileLabelTest = WhileLabel + "Test";
     Gen("jmp", WhileLabelTest);
     GenText(WhileLabelLoop + ":");
     node.statement.Accept(this);
     GenText(WhileLabelTest + ":");
     node.expression.Accept(this);
     Gen("cmp", "eax", "0");
     Gen("jg", WhileLabelLoop);
 }
예제 #2
0
        public override void Visit(WhileStatementNode node)
        {
            try
            {
                node.expression.Accept(this);

                if (!AreTypeCompatible(node.expression.ExpressionType.GetType(), typeof(BooleanType)))
                    throw new Exception("While condition expression is not of type Boolean!");
            }
            catch (Exception e)
            {
                Analysis.LogSemanticError(e.Message, node.lineNumber);
            }
            node.statement.Accept(this);
        }
예제 #3
0
 public virtual void Visit(WhileStatementNode node)
 {
     node.expression.Accept(this);
     node.statement.Accept(this);
 }
예제 #4
0
 public override void Visit(WhileStatementNode node)
 {
     Console.WriteLine(this.indentation + "While           ---- Statement ----");
     indentation = indentation + "   ";
     node.expression.Accept(this);
     node.statement.Accept(this);
     indentation = indentation.Substring(0, indentation.Length - 3);
 }