public List <IDeclContainer> GetVisibleDecls(List <string> currentNamespace, bool includeUsings) { List <IDeclContainer> returner = new List <IDeclContainer>(); List <List <string> > usings = new List <List <string> >(); if (currentNamespace.Count > 0) { usings.Add(currentNamespace); } if (includeUsings) { foreach (List <string> list in Usings) { usings.Add(list); } } if (compiler == null) { compiler = Form1.Form.compiler; } foreach (SourceFileContents sourceFile in compiler.ParsedSourceFiles) { returner.Add(sourceFile); foreach (NamespaceDescription ns in sourceFile.Namespaces) { Visit(ns, usings, returner); } } return(returner); }
public static bool Fold(GalaxyCompiler compiler) { bool changes = false; for (int i = 0; i < compiler.ParsedSourceFiles.Count; i++) { SourceFileContents file = compiler.ParsedSourceFiles[i]; foreach (VariableDescription field in file.Fields) { if (field.Const) { PExp init = field.init; string typeStr; if (init == null) { typeStr = null; } else { ConstantFolder folder = new ConstantFolder(); field.init.Apply(folder); typeStr = folder.Value; } if (field.initStr != typeStr) { changes = true; field.initStr = typeStr; } } } } return(changes); }
public static bool Fold(GalaxyCompiler compiler) { bool changes = false; for (int i = 0; i < compiler.ParsedSourceFiles.Count; i++) { SourceFileContents file = compiler.ParsedSourceFiles[i]; foreach (VariableDescription field in file.Fields) { if (field.Const) { PExp init = field.init; string typeStr; if (init == null) typeStr = null; else { ConstantFolder folder = new ConstantFolder(); field.init.Apply(folder); typeStr = folder.Value; } if (field.initStr != typeStr) { changes = true; field.initStr = typeStr; } } } } return changes; }
public SuggestionBoxForm(GalaxyCompiler compiler, Form1 form1) { form1.Move += form1_Move; InitializeComponent(); myListbox1.ParentForm = this; myListbox1.SetCompiler(compiler); form1.Deactivate += form1_Deactivate; Activated += SuggestionBoxForm_Activated; //UpdateScrollBar(); }
public bool Parse(Start ast, GalaxyCompiler compiler) { this.compiler = compiler; Parser parser = new Parser(ast); //Includes = parser.Includes; //To save time, only update if there has been changes //I assume that the Elements are in the same order //Check if recouluring is needed List <StructDescription> preUpdateStructs = GetAllStructs(); List <StructDescription> postUpdateStructs = new List <StructDescription>(); postUpdateStructs.AddRange(parser.Structs); List <IDeclContainer> list = new List <IDeclContainer>(); list.AddRange(parser.Namespaces); while (list.Count > 0) { List <IDeclContainer> nextList = new List <IDeclContainer>(); foreach (IDeclContainer declContainer in list) { postUpdateStructs.AddRange(declContainer.Structs); nextList.AddRange(declContainer.Namespaces); } list = nextList; } bool restyle = preUpdateStructs.Count != postUpdateStructs.Count; if (!restyle) { for (int i = 0; i < preUpdateStructs.Count; i++) { if (preUpdateStructs[i].Name != postUpdateStructs[i].Name) { restyle = true; break; } } } if (restyle && Form1.Form.CurrentOpenFile != null && Form1.Form.CurrentOpenFile.OpenFile != null) { Form1.Form.CurrentOpenFile.OpenFile.Editor.Restyle(); } bool needUpdate = Methods.Count != parser.Methods.Count || Fields.Count != parser.Fields.Count || Structs.Count != parser.Structs.Count || Enrichments.Count != parser.Enrichments.Count || Usings.Count != parser.Usings.Count || Typedefs.Count != parser.Typedefs.Count || Namespaces.Count != parser.Namespaces.Count; if (!needUpdate) { needUpdate = Methods.Where((t, i) => !t.Equals(parser.Methods[i])).Any() || Fields.Where((t, i) => !t.Equals(parser.Fields[i])).Any() || Structs.Where((t, i) => !t.Equals(parser.Structs[i])).Any() || Enrichments.Where((t, i) => !t.Equals(parser.Enrichments[i])).Any() || Usings.Where((t, i) => t != parser.Usings[i]).Any() || Typedefs.Where((t, i) => !t.Equals(parser.Typedefs[i])).Any() || Namespaces.Where((t, i) => !t.Equals(parser.Namespaces[i])).Any(); } if (needUpdate) { Methods = parser.Methods; foreach (MethodDescription method in Methods) { method.ParentFile = this; } Fields = parser.Fields; foreach (VariableDescription field in Fields) { field.ParentFile = this; } Structs = parser.Structs; foreach (StructDescription structDescription in Structs) { foreach (MethodDescription method in structDescription.Methods) { method.ParentFile = this; } foreach (VariableDescription field in structDescription.Fields) { field.ParentFile = this; } structDescription.ParentFile = this; } Enrichments = parser.Enrichments; foreach (EnrichmentDescription structDescription in Enrichments) { structDescription.ParentFile = this; foreach (MethodDescription method in structDescription.Methods) { method.ParentFile = this; } foreach (VariableDescription field in structDescription.Fields) { field.ParentFile = this; } } Typedefs = parser.Typedefs; foreach (TypedefDescription typedef in Typedefs) { typedef.ParentFile = this; } Usings = parser.Usings; Namespaces = parser.Namespaces; foreach (NamespaceDescription namespaceDescription in Namespaces) { namespaceDescription.Parent = this; } if (SourceFileChanged != null) { SourceFileChanged(this); } } return(needUpdate); }
public bool Parse(Start ast, GalaxyCompiler compiler) { this.compiler = compiler; Parser parser = new Parser(ast); //Includes = parser.Includes; //To save time, only update if there has been changes //I assume that the Elements are in the same order //Check if recouluring is needed List<StructDescription> preUpdateStructs = GetAllStructs(); List<StructDescription> postUpdateStructs = new List<StructDescription>(); postUpdateStructs.AddRange(parser.Structs); List<IDeclContainer> list = new List<IDeclContainer>(); list.AddRange(parser.Namespaces); while (list.Count > 0) { List<IDeclContainer> nextList = new List<IDeclContainer>(); foreach (IDeclContainer declContainer in list) { postUpdateStructs.AddRange(declContainer.Structs); nextList.AddRange(declContainer.Namespaces); } list = nextList; } bool restyle = preUpdateStructs.Count != postUpdateStructs.Count; if (!restyle) { for (int i = 0; i < preUpdateStructs.Count; i++) { if (preUpdateStructs[i].Name != postUpdateStructs[i].Name) { restyle = true; break; } } } if (restyle && Form1.Form.CurrentOpenFile != null && Form1.Form.CurrentOpenFile.OpenFile != null) Form1.Form.CurrentOpenFile.OpenFile.Editor.Restyle(); bool needUpdate = Methods.Count != parser.Methods.Count || Fields.Count != parser.Fields.Count || Structs.Count != parser.Structs.Count || Enrichments.Count != parser.Enrichments.Count || Usings.Count != parser.Usings.Count || Typedefs.Count != parser.Typedefs.Count || Namespaces.Count != parser.Namespaces.Count; if (!needUpdate) { needUpdate = Methods.Where((t, i) => !t.Equals(parser.Methods[i])).Any() || Fields.Where((t, i) => !t.Equals(parser.Fields[i])).Any() || Structs.Where((t, i) => !t.Equals(parser.Structs[i])).Any() || Enrichments.Where((t, i) => !t.Equals(parser.Enrichments[i])).Any() || Usings.Where((t, i) => t != parser.Usings[i]).Any() || Typedefs.Where((t, i) => !t.Equals(parser.Typedefs[i])).Any() || Namespaces.Where((t, i) => !t.Equals(parser.Namespaces[i])).Any(); } if (needUpdate) { Methods = parser.Methods; foreach (MethodDescription method in Methods) { method.ParentFile = this; } Fields = parser.Fields; foreach (VariableDescription field in Fields) { field.ParentFile = this; } Structs = parser.Structs; foreach (StructDescription structDescription in Structs) { foreach (MethodDescription method in structDescription.Methods) { method.ParentFile = this; } foreach (VariableDescription field in structDescription.Fields) { field.ParentFile = this; } structDescription.ParentFile = this; } Enrichments = parser.Enrichments; foreach (EnrichmentDescription structDescription in Enrichments) { structDescription.ParentFile = this; foreach (MethodDescription method in structDescription.Methods) { method.ParentFile = this; } foreach (VariableDescription field in structDescription.Fields) { field.ParentFile = this; } } Typedefs = parser.Typedefs; foreach (TypedefDescription typedef in Typedefs) { typedef.ParentFile = this; } Usings = parser.Usings; Namespaces = parser.Namespaces; foreach (NamespaceDescription namespaceDescription in Namespaces) { namespaceDescription.Parent = this; } if (SourceFileChanged != null) SourceFileChanged(this); } return needUpdate; }
public List<IDeclContainer> GetVisibleDecls(List<string> currentNamespace, bool includeUsings) { List<IDeclContainer> returner = new List<IDeclContainer>(); List<List<string>> usings = new List<List<string>>(); if (currentNamespace.Count > 0) usings.Add(currentNamespace); if (includeUsings) { foreach (List<string> list in Usings) { usings.Add(list); } } if (compiler == null) compiler = Form1.Form.compiler; foreach (SourceFileContents sourceFile in compiler.ParsedSourceFiles) { returner.Add(sourceFile); foreach (NamespaceDescription ns in sourceFile.Namespaces) { Visit(ns, usings, returner); } } return returner; }