//----------------------------------------------------------- public static void exit( ) { if (current_context == null) { ERROR.SystemErrorIn("exit", "attempt to exit from empty context"); return; } current_context = (DECLARATION)current_context.enclosing; if (current_context is NAMESPACE_DECL) { current_namespace_decl = (NAMESPACE_DECL)current_context; current_program_unit = null; } if (current_context is UNIT_DECL && !(current_context is NAMESPACE_DECL)) { current_program_unit = (UNIT_DECL)current_context; } else { current_program_unit = null; } // For the case if we exit from a nested routine... if (current_context is ROUTINE_DECL) { current_routine = (ROUTINE_DECL)current_context; } else { current_routine = null; } }
public NAMESPACE_DECL find(Identifier name) { NAMESPACE_DECL result = null; for (int i = 0, n = Length; i < n; i++) { if (namespaces[i].name.Name == name.Name) { result = namespaces[i]; break; } } return(result); }
public NAMESPACE_DECL find(NAMESPACE_DECL ns) { NAMESPACE_DECL result = null; for (int i = 0, n = Length; i < n; i++) { if (namespaces[i] == ns) { result = namespaces[i]; break; } } return(result); }
//----------------------------------------------------------- public static void init( ) { last_label_no = 0; last_temp_no_internal = 0; current_context = null; current_program_unit = null; current_routine_decl = null; string suffix = ""; string output = ""; if (options.Output != null) { output = options.Output.Substring(0); } else if (options.OutputAssembly != null) { output = options.OutputAssembly.Substring(0); } int slash_index = output.LastIndexOf('/'); if (slash_index == -1) { slash_index = output.LastIndexOf('\\'); } int dot_index = output.LastIndexOf('.'); if (dot_index == -1) { dot_index = output.Length; } if (slash_index == -1) { suffix = output.Substring(slash_index + 1, dot_index); } else { suffix = output.Substring(slash_index + 1, dot_index - slash_index + 1); } suffix.Replace("-", "_minus_"); globalMath = new MathGenerator(suffix); _kernelRegistry = new KernelRegistry(); _operationRegistry = new OperationRegistry(); // current_namespace_decl = null; globalTree = null; //-- do not do: it's required afterwards for reporting }
public void init( ) { globalTree = new NAMESPACE_DECL(Identifier.For("Zonnon")); // null); globalTree.enclosing = null; // the only global namespace Zonnon.EXTERNALS.clear(); if (this.CompilationUnits == null || this.CompilationUnits.Length == 0) { return; } for (int i = 0, n = this.CompilationUnits.Length; i < n; i++) { this.CompilationUnits[i].Compilation = this; } }
public void Add(NAMESPACE_DECL ns) { int n = this.namespaces.Length; int i = this.length++; if (i == n) { NAMESPACE_DECL[] new_namespaces = new NAMESPACE_DECL[n + 8]; for (int j = 0; j < n; j++) { new_namespaces[j] = namespaces[j]; } this.namespaces = new_namespaces; } this.namespaces[i] = ns; }
public static void enter(DECLARATION block) { if (current_context != null && current_context != block.enclosing) // System error { ERROR.SystemErrorIn("enter", "attempt to enter to an unrelated scope"); return; } current_context = block; if (block is UNIT_DECL && !(block is NAMESPACE_DECL)) { current_program_unit = (UNIT_DECL)block; current_routine_decl = null; } if (block is ROUTINE_DECL) { current_routine_decl = (ROUTINE_DECL)block; } else if (block is NAMESPACE_DECL) { current_namespace_decl = (NAMESPACE_DECL)block; } }
protected override void Visit_NAMESPACE_DECL(NAMESPACE_DECL node) { /* MOVE CODE HERE */ }
protected virtual void Visit_NAMESPACE_DECL(NAMESPACE_DECL node) { }