//TODO: Исправить коллекцию модулей. public PascalABCCompiler.TreeRealization.common_unit_node CompileInterface(SyntaxTree.compilation_unit SyntaxUnit, PascalABCCompiler.TreeRealization.unit_node_list UsedUnits, List<Errors.Error> ErrorsList, List<Errors.CompilerWarning> WarningsList, PascalABCCompiler.Errors.SyntaxError parser_error, System.Collections.Hashtable bad_nodes, TreeRealization.using_namespace_list namespaces, Dictionary<SyntaxTree.syntax_tree_node,string> docs, bool debug, bool debugging) { //convertion_data_and_alghoritms.__i = 0; stv.parser_error=parser_error; stv.bad_nodes_in_syntax_tree = bad_nodes; stv.referenced_units=UsedUnits; //stv.comp_units=UsedUnits; //stv.visit(SyntaxUnit //stv.interface_using_list = namespaces; stv.using_list.clear(); stv.interface_using_list.clear(); stv.using_list.AddRange(namespaces); stv.current_document = new TreeRealization.document(SyntaxUnit.file_name); stv.ErrorsList = ErrorsList; stv.WarningsList = WarningsList; stv.SymbolTable.CaseSensitive = SemanticRules.SymbolTableCaseSensitive; stv.docs = docs; stv.debug = debug; stv.debugging = debugging; SystemLibrary.SystemLibrary.syn_visitor = stv; SetSemanticRules(SyntaxUnit); foreach (SyntaxTree.compiler_directive cd in SyntaxUnit.compiler_directives) cd.visit(stv); stv.DirectivesToNodesLinks = CompilerDirectivesToSyntaxTreeNodesLinker.BuildLinks(SyntaxUnit, ErrorsList); //MikhailoMMX добавил передачу списка ошибок (02.10.10) SyntaxUnit.visit(stv); /*SyntaxTree.program_module pmod=SyntaxUnit as SyntaxTree.program_module; if (pmod!=null) { stv.visit(pmod); } else { SyntaxTree.unit_module umod=SyntaxUnit as SyntaxTree.unit_module; if (umod==null) { throw new PascalABCCompiler.TreeConverter.CompilerInternalError("Undefined module type (not program and not unit)"); } stv.visit(umod); }*/ //stv.visit(SyntaxUnit); //if (ErrorsList.Count>0) throw ErrorsList[0]; return stv.compiled_unit; }
public void AddNamespaces(TreeRealization.using_namespace_list using_list, SyntaxTree.using_list ul) { if (ul != null) AddNamespaces(using_list, ul.namespaces, false); }
public void AddNamespaces(TreeRealization.using_namespace_list using_list, List<SyntaxTree.unit_or_namespace> namespaces, bool possible_is_units) { foreach (SyntaxTree.unit_or_namespace ns in namespaces) using_list.AddElement(GetNamespace(using_list, SyntaxTree.Utils.IdentListToString(ns.name.idents, "."), ns, possible_is_units)); }
private TreeRealization.using_namespace GetNamespace(TreeRealization.using_namespace_list using_list, string full_namespace_name, SyntaxTree.unit_or_namespace _name_space, bool possible_is_unit) { if (!NetHelper.NetHelper.NamespaceExists(full_namespace_name)) { if (possible_is_unit) if (!full_namespace_name.Contains(".")) throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, full_namespace_name, _name_space.source_context); throw new TreeConverter.NamespaceNotFound(full_namespace_name, get_location_from_treenode(_name_space.name, CurrentCompilationUnit.SyntaxTree.file_name)); } return new TreeRealization.using_namespace(full_namespace_name); }
private CompilationUnit CompileReference(PascalABCCompiler.TreeRealization.unit_node_list Units, TreeRealization.compiler_directive cd) { TreeRealization.location loc = cd.location; SyntaxTree.SourceContext sc = null; if (loc!=null) sc = new SyntaxTree.SourceContext(loc.begin_line_num,loc.begin_column_num,loc.end_line_num,loc.end_column_num,0,0); string UnitName = null; try { UnitName = GetReferenceFileName(cd.directive, sc); } catch (AssemblyNotFound ex) { throw; } catch(Exception ex) { throw new InvalidAssemblyPathError(CurrentCompilationUnit.SyntaxTree.file_name, sc); } CompilationUnit CurrentUnit = null; if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); if ((CurrentUnit = ReadDLL(UnitName)) != null) { Units.AddElement(CurrentUnit.SemanticTree); UnitTable[UnitName] = CurrentUnit; return CurrentUnit; } else //throw new DLLReadingError(UnitName); throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name,UnitName,sc); }
public ResourceFileNotFound(string ResFileName, TreeRealization.location sl) : base(string.Format(StringResources.Get("COMPILATIONERROR_RESOURCEFILE_{0}_NOT_FOUND"), ResFileName), sl.doc.file_name) { this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num,sl.end_column_num); }
public void CompileImplementation(PascalABCCompiler.TreeRealization.common_unit_node SemanticUnit, SyntaxTree.compilation_unit SyntaxUnit,PascalABCCompiler.TreeRealization.unit_node_list UsedUnits,List<Errors.Error> ErrorsList,List<Errors.CompilerWarning> WarningsList, PascalABCCompiler.Errors.SyntaxError parser_error, System.Collections.Hashtable bad_nodes, TreeRealization.using_namespace_list interface_namespaces, TreeRealization.using_namespace_list imlementation_namespaces, Dictionary<SyntaxTree.syntax_tree_node,string> docs, bool debug, bool debugging) { //if (ErrorsList.Count>0) throw ErrorsList[0]; stv.parser_error=parser_error; stv.bad_nodes_in_syntax_tree = bad_nodes; stv.referenced_units = UsedUnits; stv.using_list.clear(); stv.using_list.AddRange(interface_namespaces); stv.interface_using_list.AddRange(interface_namespaces); stv.using_list.AddRange(imlementation_namespaces); stv.ErrorsList = ErrorsList; stv.WarningsList = WarningsList; stv.SymbolTable.CaseSensitive = SemanticRules.SymbolTableCaseSensitive; if (docs != null) stv.docs = docs; stv.debug = debug; stv.debugging = debugging; SystemLibrary.SystemLibrary.syn_visitor = stv; SetSemanticRules(SyntaxUnit); SyntaxTree.unit_module umod = SyntaxUnit as SyntaxTree.unit_module; if (umod==null) { throw new PascalABCCompiler.TreeConverter.CompilerInternalError("Program has not implementation part"); } //TODO: Переделать, чтобы Сашин код работал с common_unit_node. stv.compiled_unit=(PascalABCCompiler.TreeRealization.common_unit_node)SemanticUnit; stv.current_document = new TreeRealization.document(SyntaxUnit.file_name); foreach (SyntaxTree.compiler_directive cd in umod.compiler_directives) cd.visit(stv); stv.visit_implementation(umod); //stv.visit(SyntaxUnit); //return stv.compiled_unit; }
public MainResourceNotAllowed(TreeRealization.location sl) : base(string.Format(StringResources.Get("COMPILATIONERROR_MAINRESOURCE_NOT_ALLOWED")), sl.doc.file_name) { this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num, sl.end_column_num); }