//----------------------------------------------------------- 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 static void clean( ) { last_label_no = 0; last_temp_no_internal = 0; current_context = null; current_program_unit = null; current_routine_decl = null; // Keep global tree for reporting!! // CONTEXT.enter(TREE.global); }
public UNIT_DECL find(Identifier name) { UNIT_DECL result = null; for (int i = 0, n = Length; i < n; i++) { if (units[i].name.Name == name.Name) { result = units[i]; break; } } return(result); }
public UNIT_DECL find(UNIT_DECL unit) { UNIT_DECL result = null; for (int i = 0, n = Length; i < n; i++) { if (units[i] == unit) { result = units[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 Add(UNIT_DECL unit) { int n = this.units.Length; int i = this.length++; if (i == n) { UNIT_DECL[] newUnits = new UNIT_DECL[n + 8]; for (int j = 0; j < n; j++) { newUnits[j] = units[j]; } this.units = newUnits; } this.units[i] = unit; }
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; } }