public string Visit(AST_If node) { var x = node.Cond.Visit(this); var s = methodcontext.GenLocal("resultif", true); var If = methodcontext.GenLabel("if"); var endif = methodcontext.GenLabel("endif"); methodcontext.Staments.Add(new CIL_If_Goto(x, If)); var y = ""; if (node.ElseCorpus != null) { y = node.ElseCorpus.Visit(this); methodcontext.Staments.Add(new CIL_Asig(s, y, "var")); methodcontext.Staments.Add(new CIL_Goto(endif)); } methodcontext.Staments.Add(new CIL_Label(If)); y = node.IfCorpus.Visit(this); methodcontext.Staments.Add(new CIL_Asig(s, y, "var")); methodcontext.Staments.Add(new CIL_Label(endif)); return(s); }
public bool Visit(AST_If node) { bool solve = true; bool visit_if = node.IfCorpus.Visit(this); bool visit_else = node.ElseCorpus.Visit(this); bool visit_cond = node.Cond.Visit(this); if (!visit_cond) { return(false); } if (node.Cond.MyType.Name != "Bool") { CurrErrorLoger.LogError(node.Cond.row, node.Cond.col, "La condicion debe ser Bool"); return(false); } if (!visit_if || !visit_else || !visit_cond) { return(false); } var if_type = SemanticType.LCA(node.IfCorpus.MyType, node.ElseCorpus.MyType); node.MyType = if_type; if (if_type == null) { CurrErrorLoger.LogError(node.row, node.col, "No se puede asignar el tipo"); return(false); } return(true); }
public bool Visit(AST_If node) { bool visit_result = true; foreach (var child in node.Children) { visit_result &= child.Visit(this); } return(visit_result); }
public Base_Object_Value Visit(AST_If node) { Base_Object_Value t = node.Cond.Visit(this); if (t.IsTrue()) { return(node.IfCorpus.Visit(this)); } if (node.ElseCorpus != null) { return(node.ElseCorpus.Visit(this)); } return(Type_OBJECT.Singleton().Instanciate()); }
public bool Visit(AST_If node) { return(node.Cond.Visit(this) && node.IfCorpus.Visit(this) && node.ElseCorpus.Visit(this)); }
public bool Visit(AST_If node) { throw new NotImplementedException(); }