public bool Visit(AST_ListClass node) { bool solve = true; Types.Add("Object"); Types.Add("String"); Types.Add("IO"); Types.Add("Int"); Types.Add("Bool"); foreach (var item in node.Class_list) { if (!Types.Add(item.Id.Id)) { return(false); } } foreach (var item in node.Class_list) { solve &= item.Visit(this); } return(solve); }
public bool Visit(AST_ListClass node) { bool main = false; foreach (var item in node.Class_list) { if (item.Id.Id == "Main") { main = true; break; } } if (!main) { CurrErrorLoger.LogError(node.row, node.col, "Tiene que exisitir una clase Main"); return(false); } HashSet <string> hs = new HashSet <string>(); bool visit_result = true; foreach (var class_def in node.Class_list) { if (!hs.Add(class_def.Id.Id)) { visit_result = false; } visit_result &= class_def.Visit(this); } return(visit_result); }
public string Visit(AST_ListClass node) { foreach (var item in node.Class_list) { Visit(item); } return(""); }
public bool Visit(AST_ListClass node) { bool visit_result = true; foreach (var class_def in node.Class_list) { visit_result &= class_def.Visit(this); } return(visit_result); }
public Base_Object_Value Visit(AST_ListClass node) { throw new NotImplementedException(); }
public static Dictionary <string, SemanticType> BuildAllType(AST_ListClass list) { // Create SystemTypes var solve = BuildSystemType(); // Create All Types; foreach (var item in list.Class_list) { solve.Add(item.Id.Id, new SemanticType(item.Id.Id)); } // Set Parent foreach (var item in list.Class_list) { solve[item.Id.Id].Father = solve[item.Inherits.Type]; } // Create ATTR foreach (var item in list.Class_list) { string name = item.Id.Id; foreach (var attr in item.Property_list.Propertys) { solve[name].Attrs.Add(new SemanticAttr(attr.decl.id.Id, solve[attr.decl.type.Type])); } foreach (var method in item.Method_list.Methods) { List <SemanticAttr> v = new List <SemanticAttr>(); foreach (var attr in method.Propertys.Propertys) { v.Add(new SemanticAttr(attr.decl.id.Id, solve[attr.decl.type.Type])); } solve[name].Methods.Add(new SemanticMethod(method.Id.Id, solve[method.type.Type], v)); } } // Set Self in all methods foreach (var item in solve) { foreach (var method in item.Value.Methods) { method.Self = item.Value; } } // Set Self in all attr foreach (var item in solve) { foreach (var method in item.Value.Attrs) { method.Self = item.Value; } } // SetLevels Dictionary <string, bool> mark = new Dictionary <string, bool>(); foreach (var item in solve) { mark.Add(item.Key, false); } foreach (var item in solve) { SetLevels(item.Value, mark); } return(solve); }