import table_computation
private import compiling_icode
-class GlobalCompilerVisitor
-special CompilerVisitor
- # The global analysis result
- readable var _program: Program
- init(m: MMModule, tc: ToolContext, prog: Program)
- do
- super(m, tc)
- _program = prog
- end
-end
-
redef class Program
# Compile module and class tables
- fun compile_tables_to_c(v: GlobalCompilerVisitor)
+ fun compile_tables_to_c(v: CompilerVisitor)
do
for m in module.mhe.greaters_and_self do
m.compile_local_table_to_c(v)
end
# Compile main part (for _table.c)
- fun compile_main_part(v: GlobalCompilerVisitor)
+ fun compile_main_part(v: CompilerVisitor)
do
v.add_instr("int main(int argc, char **argv) \{")
v.indent
end
redef class MMModule
- # Declare class table (for _sep.h)
- fun declare_class_tables_to_c(v: GlobalCompilerVisitor)
+ # Declare class table (for _sep.h or _glob.h)
+ fun declare_class_tables_to_c(v: CompilerVisitor)
do
for c in local_classes do
if c.global.module == self then
end
# Compile sep files
- fun compile_mod_to_c(v: GlobalCompilerVisitor)
+ fun compile_mod_to_c(v: CompilerVisitor)
do
v.add_decl("extern const char *LOCATE_{name};")
- if not v.tc.global then
+ if not v.program.tc.use_SFT_optimization then
v.add_decl("extern const int SFT_{name}[];")
end
var i = 0
for e in local_table do
var value: String
- if v.tc.global then
+ if v.program.tc.use_SFT_optimization then
value = "{e.value(v.program)}"
else
value = "SFT_{name}[{i}]"
end
# Compile module file for the current module
- fun compile_local_table_to_c(v: GlobalCompilerVisitor)
+ fun compile_local_table_to_c(v: CompilerVisitor)
do
v.add_instr("const char *LOCATE_{name} = \"{location.file}\";")
- if v.tc.global or local_table.is_empty then
+ if v.program.tc.use_SFT_optimization or local_table.is_empty then
return
end
redef class AbsTableElt
# Compile the macro needed to use the element and other related elements
- fun compile_macros(v: GlobalCompilerVisitor, value: String) is abstract
+ fun compile_macros(v: CompilerVisitor, value: String) is abstract
end
redef class TableElt
# Return the value of the element for a given class
- fun compile_to_c(v: GlobalCompilerVisitor, c: MMLocalClass): String is abstract
+ fun compile_to_c(v: CompilerVisitor, c: MMLocalClass): String is abstract
end
redef class ModuleTableElt
redef class MMLocalClass
# Declaration and macros related to the class table
- fun declare_tables_to_c(v: GlobalCompilerVisitor)
+ fun declare_tables_to_c(v: CompilerVisitor)
do
v.add_decl("")
var pi = primitive_info
end
# Compilation of table and new (or box)
- fun compile_tables_to_c(v: GlobalCompilerVisitor)
+ fun compile_tables_to_c(v: CompilerVisitor)
do
var cc = v.program.compiled_classes[self.global]
var ctab = cc.class_table