public bool Visit(AST_MethodDef node) { bool solve = true; foreach (var item in node.Propertys.Propertys) { solve &= item.Visit(this); } return(solve & node.Statament.Visit(this)); }
public bool Visit(AST_MethodDef node) { CurrContext = CurrContext.CreateChild(); foreach (var arg in node.Propertys.Propertys) { CurrContext.Define(arg.decl.id.Id); } bool visit_result = node.Statament.Visit(this); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(visit_result); }
public string Visit(AST_MethodDef node) { var method = methodcontext.actual_type.GetMethod(node.Id.Id); var tags = method.Label(); //List<string> par = new List<string>(method.AttrParams.Select(x => x.Id)); methodcontext.arg = new List <string>(method.AttrParams.Select(x => x.Id)); methodcontext.arg.Insert(0, "self"); var solve = node.Statament.Visit(this); methodcontext.Staments.Add(new CIL_Return(solve, "var")); methods.Add(new CIL_FunctionDef(tags, new CIL_Params(methodcontext.arg), new CIL_Params(new List <string>(methodcontext.Locals)), new CIL_StamentList(methodcontext.Staments))); return(""); }
public bool Visit(AST_MethodDef node) { bool solve = true; if (!CurrType.HasMethod(node.Id.Id)) { CurrErrorLoger.LogError(node.row, node.col, "El tipo de retorno del metodo no existe"); return(false); } CurrContext = CurrContext.CreateChild(); //if (node.type.Type == "int") // node.type.Type = "Int"; //if (node.type.Type == "string") // node.type.Type = "String"; //if (node.type.Type == "bool") // node.type.Type = "Bool"; if (!All_Types.ContainsKey(node.type.Type)) { CurrErrorLoger.LogError(node.row, node.col, "El tipo de retorno del metodo no existe"); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } foreach (var arg in node.Propertys.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") // node.type.Type = "Bool"; if (!All_Types.ContainsKey(arg.decl.type.Type)) { CurrErrorLoger.LogError(node.row, node.col, "El tipo de la declaracion del argumento no existe"); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } if (CurrContext.GetType(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]); } } var visit = node.Statament.Visit(this); if (!visit) { if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } SemanticType lca = SemanticType.LCA(All_Types[node.type.Type], node.Statament.MyType); if (lca.Name == node.type.Type) { solve &= true; } else { CurrErrorLoger.LogError(node.row, node.col, "El tipo " + node.Statament.MyType + " no se conforma a " + node.type.Type); if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(false); } if (!CurrContext.NullFather()) { CurrContext = CurrContext.GetParent(); } return(solve); }
public bool Visit(AST_MethodDef node) { throw new NotImplementedException(); }
public Base_Object_Value Visit(AST_MethodDef node) { throw new NotImplementedException(); }