public bool Visit(AST_Let node) { bool solve = true; foreach (var item in node.props.Propertys) { solve &= item.Visit(this); } return(solve & node.expr.Visit(this)); }
public string Visit(AST_Let node) { List <string> exprresult = new List <string>(); foreach (var item in node.props.Propertys) { if (item.exp != null) { var s1 = item.exp.Visit(this); exprresult.Add(s1); } else { exprresult.Add(null); } } methodcontext.AddContext("Let"); for (int i = 0; i < node.props.Propertys.Count; i++) { string id = methodcontext.GenLocal(node.props.Propertys[i].decl.id.Id, false); if (exprresult[i] != null) { methodcontext.Staments.Add(new CIL_Asig(id, exprresult[i], "var")); } } var s = methodcontext.GenLocal("exp", true); var x = node.expr.Visit(this); methodcontext.Staments.Add(new CIL_Asig(s, x, "var")); methodcontext.ClearContext(); return(s); }
public bool Visit(AST_Let node) { CurrContext = CurrContext.CreateChild(); if (node.props.Propertys.Count == 0) { return(false); } foreach (var prop in node.props.Propertys) { if (prop.exp != null && !prop.exp.Visit(this)) { return(false); } CurrContext.Define(prop.decl.id.Id); } bool flag = node.expr.Visit(this); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(flag); }
public bool Visit(AST_Let node) { bool solve = true; CurrContext = CurrContext.CreateChild(); foreach (var arg in node.props.Propertys) { //if (arg.decl.type.Type == "int") // arg.decl.type.Type = "Int"; //if (arg.decl.type.Type == "string") // arg.decl.type.Type = "String"; //if (arg.decl.type.Type == "bool") // arg.decl.type.Type = "Bool"; if (!All_Types.ContainsKey(arg.decl.type.Type)) { CurrErrorLoger.LogError(node.row, node.col, "El tipo de la declaracion de la variable no existe"); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } if (arg.exp != null) { if (!arg.exp.Visit(this)) { if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } if (SemanticType.LCA(arg.exp.MyType, All_Types[arg.decl.type.Type]).Name != All_Types[arg.decl.type.Type].Name) { CurrErrorLoger.LogError(node.row, node.col, "El tipo de la expresion no es un subtipo del tipo de la declaracion"); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } } if (CurrContext.GetTypeInMe(arg.decl.id.Id) == null) { CurrContext.SetType(arg.decl.id.Id, All_Types[arg.decl.type.Type]); } else { CurrContext.ChangeType(arg.decl.id.Id, All_Types[arg.decl.type.Type]); } } if (!node.expr.Visit(this)) { if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } node.MyType = node.expr.MyType; if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(true); }
public bool Visit(AST_Let node) { throw new NotImplementedException(); }
public Base_Object_Value Visit(AST_Let node) { throw new NotImplementedException(); }