public override void visit(unit_module _unit_module) { prepare_node(_unit_module.unit_name, "unit name"); prepare_node(_unit_module.interface_part, "interface"); prepare_node(_unit_module.implementation_part, "implementation"); prepare_node(_unit_module.initialization_part, "initialization"); prepare_node(_unit_module.finalization_part, "finalization"); prepare_collection(_unit_module.compiler_directives, "compiler_directives"); }
public void CompileImplementation(PascalSharp.Internal.TreeConverter.TreeRealization.common_unit_node SemanticUnit, compilation_unit SyntaxUnit, PascalSharp.Internal.TreeConverter.TreeRealization.unit_node_list UsedUnits, List <Error> ErrorsList, List <CompilerWarning> WarningsList, SyntaxError parser_error, System.Collections.Hashtable bad_nodes, using_namespace_list interface_namespaces, using_namespace_list imlementation_namespaces, Dictionary <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.syn_visitor = stv; SetSemanticRules(SyntaxUnit); unit_module umod = SyntaxUnit as unit_module; if (umod == null) { throw new PascalSharp.Internal.TreeConverter.CompilerInternalError("Program has not implementation part"); } //TODO: Переделать, чтобы Сашин код работал с common_unit_node. stv.compiled_unit = (PascalSharp.Internal.TreeConverter.TreeRealization.common_unit_node)SemanticUnit; stv.current_document = new document(SyntaxUnit.file_name); foreach (compiler_directive cd in umod.compiler_directives) { cd.visit(stv); } stv.visit_implementation(umod); //stv.visit(SyntaxUnit); //return stv.compiled_unit; }
public override void visit(unit_module _unit_module) { _unit_module.unit_name.visit(this); if (_unit_module.interface_part != null) { _unit_module.interface_part.visit(this); } if (_unit_module.implementation_part != null) { _unit_module.implementation_part.visit(this); } if (_unit_module.initialization_part != null) { _unit_module.initialization_part.visit(this); } if (_unit_module.finalization_part != null) { _unit_module.finalization_part.visit(this); } }
public override void visit(unit_module _unit_module) { text = System.IO.Path.GetFileName(_unit_module.file_name); }
public virtual void visit(unit_module _unit_module) { DefaultVisit(_unit_module); }
public virtual void post_do_visit(unit_module _unit_module) { }
public override void visit(unit_module _unit_module) { DefaultVisit(_unit_module); pre_do_visit(_unit_module); visit(unit_module.unit_name); visit(unit_module.interface_part); visit(unit_module.implementation_part); visit(unit_module.initialization_part); visit(unit_module.finalization_part); visit(unit_module.attributes); post_do_visit(_unit_module); }
public virtual void visit(unit_module _unit_module) { }
public override void visit(unit_module _unit_module) { connect(_unit_module.unit_name); visit_node(_unit_module.interface_part); visit_node(_unit_module.implementation_part); }
public virtual void visit(unit_module _unit_module) { }
public virtual void visit(unit_module _unit_module) { DefaultVisit(_unit_module); }
private void add_module_members(unit_module mod, ICSharpCode.NRefactory.Ast.TypeDeclaration td) { foreach (ICSharpCode.NRefactory.Ast.INode node in td.Children) { if (node is ICSharpCode.NRefactory.Ast.FieldDeclaration) { ICSharpCode.NRefactory.Ast.FieldDeclaration vd = node as ICSharpCode.NRefactory.Ast.FieldDeclaration; if ((vd.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Dim) == ICSharpCode.NRefactory.Ast.Modifiers.Dim) { foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration vard in vd.Fields) { var_def_statement vds = new var_def_statement(); vds.source_context = get_source_context(vd); vds.vars_type = get_type_reference(vard.TypeReference); ident_list idents = new ident_list(); ident name = new ident(vard.Name); name.source_context = vds.source_context; idents.idents.Add(name); vds.vars = idents; mod.interface_part.interface_definitions.defs.Add(vds); } } else if ((vd.Modifier & ICSharpCode.NRefactory.Ast.Modifiers.Const) == ICSharpCode.NRefactory.Ast.Modifiers.Const) { foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration vard in vd.Fields) { const_definition tcd = null; if (vard.TypeReference is ICSharpCode.NRefactory.Ast.TypeReference) { tcd = new simple_const_definition(); } else { tcd = new typed_const_definition(); } tcd.source_context = get_source_context(vd); if (tcd is typed_const_definition) { (tcd as typed_const_definition).const_type = get_type_reference(vard.TypeReference); } tcd.const_name = new ident(vard.Name); tcd.const_name.source_context = tcd.source_context; tcd.const_value = get_expression(vard.Initializer); mod.interface_part.interface_definitions.defs.Add(tcd); } } } else if (node is ICSharpCode.NRefactory.Ast.TypeDeclaration) { mod.interface_part.interface_definitions.defs.Add(get_type_declaration(node as ICSharpCode.NRefactory.Ast.TypeDeclaration)); } else if (node is ICSharpCode.NRefactory.Ast.MethodDeclaration) { ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node as ICSharpCode.NRefactory.Ast.MethodDeclaration; if (!meth.Body.IsNull) { mod.interface_part.interface_definitions.defs.Add(get_method_declaration(meth)); } else { mod.interface_part.interface_definitions.defs.Add(get_method_header(meth)); } } } }
public syntax_tree_node get_syntax_tree(ICSharpCode.NRefactory.Ast.CompilationUnit unit, string FileName) { unit_module mod = null; List <string> imports = new List <string>(); foreach (ICSharpCode.NRefactory.Ast.INode cu in unit.Children) { if (cu is ICSharpCode.NRefactory.Ast.TypeDeclaration) { ICSharpCode.NRefactory.Ast.TypeDeclaration td = cu as ICSharpCode.NRefactory.Ast.TypeDeclaration; if (td.Type == ICSharpCode.NRefactory.Ast.ClassType.Module) { mod = new unit_module(); mod.Language = LanguageId.VBNET; mod.file_name = FileName; mod.unit_name = new unit_name(); mod.unit_name.idunit_name = new ident(td.Name); mod.compiler_directives = new List <compiler_directive>(); mod.compiler_directives.Add(new compiler_directive(new token_info("reference"), new token_info("System.dll"))); mod.compiler_directives.Add(new compiler_directive(new token_info("reference"), new token_info("Microsoft.VisualBasic.dll"))); mod.compiler_directives.Add(new compiler_directive(new token_info("reference"), new token_info("System.Windows.Forms.dll"))); mod.compiler_directives.Add(new compiler_directive(new token_info("reference"), new token_info("System.Drawing.dll"))); mod.source_context = get_source_context(td); mod.interface_part = new interface_node(); mod.interface_part.interface_definitions = new declarations(); //mod.interface_part.source_context = new SourceContext(td.StartLocation.Line,td.StartLocation.Column,td.EndLocation.Line,td.EndLocation.Column); mod.interface_part.uses_modules = new uses_list(); foreach (string s in imports) { List <ident> id_name = new List <ident>(); id_name.Add(new ident(s)); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(id_name))); } List <ident> ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.Strings")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("System")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("System.Collections.Generic")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.Constants")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.VBMath")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.Information")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.Interaction")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.FileSystem")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.Financial")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); ids = new List <ident>(); ids.Add(new ident("Microsoft.VisualBasic.DateAndTime")); mod.interface_part.uses_modules.units.Add(new unit_or_namespace(new ident_list(ids))); add_module_members(mod, td); } } else if (cu is ICSharpCode.NRefactory.Ast.UsingDeclaration) { ICSharpCode.NRefactory.Ast.UsingDeclaration usings = cu as ICSharpCode.NRefactory.Ast.UsingDeclaration; for (int i = 0; i < usings.Usings.Count; i++) { imports.Add(usings.Usings[i].Name); } } } return(mod); }
public override void visit(unit_module _unit_module) { executer.visit(_unit_module); if (_unit_module.unit_name != null) this.visit((dynamic)_unit_module.unit_name); if (_unit_module.interface_part != null) this.visit((dynamic)_unit_module.interface_part); if (_unit_module.implementation_part != null) this.visit((dynamic)_unit_module.implementation_part); if (_unit_module.initialization_part != null) this.visit((dynamic)_unit_module.initialization_part); if (_unit_module.finalization_part != null) this.visit((dynamic)_unit_module.finalization_part); if (_unit_module.compiler_directives != null) foreach (dynamic x in _unit_module.compiler_directives) if(x != null) this.visit(x); }