Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public virtual void Visit(WhileStatementNode node)
 {
     node.expression.Accept(this);
     node.statement.Accept(this);
 }
Ejemplo n.º 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);
 }