public Base_Object_Value Visit(AST_BinaryOp node) { Base_Object_Value l = node.Left.Visit(this); Base_Object_Value r = node.Right.Visit(this); return(l.CallMethod(node.Op.Text, new Base_Object_Value[] { r })); }
public bool Visit(AST_BinaryOp node) { bool visit_left = node.Left.Visit(this); bool visit_right = node.Right.Visit(this); return(visit_right && visit_left); }
public string Visit(AST_BinaryOp node) { string l = node.Left.Visit(this); string r = node.Right.Visit(this); string s = methodcontext.GenLocal("exp", true); if (node.Op.Text == "/") { methodcontext.Staments.Add(new CIL_ExceptionCond(r, "0", "error_div0")); } methodcontext.Staments.Add(new CIL_ExpBin(l, r, node.Op.Text, s)); return(s); }
public bool Visit(AST_BinaryOp node) { return(node.Left.Visit(this) && node.Right.Visit(this)); }
public bool Visit(AST_BinaryOp node) { bool solve = true; bool visit_right = node.Right.Visit(this); bool visit_left = node.Left.Visit(this); if (!visit_left || !visit_right) { return(false); } if (!All_Types.ContainsKey(node.Right.MyType.Name)) { CurrErrorLoger.LogError(node.Right.row, node.Right.col, "Tipo inexistente"); return(false); } if (!All_Types.ContainsKey(node.Left.MyType.Name)) { CurrErrorLoger.LogError(node.Left.row, node.Left.col, "Tipo inexistente"); return(false); } if (node.Op.Text == "=") { bool ok = true; if (node.Right.MyType.Name == "String" || node.Right.MyType.Name == "Int" || node.Right.MyType.Name == "Bool" || node.Left.MyType.Name == "String" || node.Left.MyType.Name == "Int" || node.Left.MyType.Name == "Bool" || node.Left.MyType.Name == "Object" || node.Right.MyType.Name == "Object") { ok = node.Right.MyType.Name == node.Left.MyType.Name; } //else solve &= false; node.MyType = All_Types["Bool"]; if (node.Right.MyType == null || node.Left.MyType == null || !ok) { return(false); } var lca = SemanticType.LCA(node.Right.MyType, node.Left.MyType); if (lca.Name != node.Right.MyType.Name && lca.Name != node.Left.MyType.Name) { CurrErrorLoger.LogError(node.row, node.col, "No se encuentran en la misma rama del arbol de herencia"); return(false); } return(true); } else { if (node.Right.MyType.Name != node.Left.MyType.Name) { CurrErrorLoger.LogError(node.row, node.col, "Los tipos de la expresion deben ser iguales"); return(false); } if (node.Right.MyType.Name != "Int") { CurrErrorLoger.LogError(node.Right.row, node.Right.col, "El tipo de la expresion debe ser INT"); return(false); } if (node.Left.MyType.Name != "Int") { CurrErrorLoger.LogError(node.Left.row, node.Left.col, "El tipo de la expresion debe ser INT"); return(false); } if (node.Op.Text == "<" || node.Op.Text == "<=") { node.MyType = All_Types["Bool"]; } else { node.MyType = All_Types["Int"]; } return(true); } }
public bool Visit(AST_BinaryOp node) { throw new NotImplementedException(); }