public override void Visit(IfStatementNode node) { string ElseLabel = ElseLabelGenerator.GetNewLabel(); string ElseEndLabel = ElseLabel + "End"; node.expression.Accept(this); Gen("cmp", "eax", "0"); Gen("je", ElseLabel); node.thenStatement.Accept(this); Gen("jmp", ElseEndLabel); GenText(ElseLabel + ":"); node.elseStatement.Accept(this); GenText(ElseEndLabel + ":"); }
public override void Visit(IfStatementNode node) { try { node.expression.Accept(this); if (!AreTypeCompatible(node.expression.ExpressionType.GetType(), typeof(BooleanType))) throw new Exception("If condition expression is not of type Boolean!"); } catch (Exception e) { Analysis.LogSemanticError(e.Message, node.lineNumber); } node.thenStatement.Accept(this); node.elseStatement.Accept(this); }
public virtual void Visit(IfStatementNode node) { node.expression.Accept(this); node.thenStatement.Accept(this); node.elseStatement.Accept(this); }
public override void Visit(IfStatementNode node) { Console.WriteLine(this.indentation + "If --- Statement ----"); indentation = indentation + " "; node.expression.Accept(this); indentation = indentation.Substring(0, indentation.Length - 3); Console.WriteLine(this.indentation + "Then"); indentation = indentation + " "; node.thenStatement.Accept(this); indentation = indentation.Substring(0, indentation.Length - 3); Console.WriteLine(this.indentation + "Else"); indentation = indentation + " "; node.elseStatement.Accept(this); indentation = indentation.Substring(0, indentation.Length - 3); }