# Something that store color of table elements
class ColorContext
- attr _colors: HashMap[TableElt, Int]
+ attr _colors: HashMap[TableElt, Int] = null
# The color of a table element.
meth color(e: TableElt): Int
if not has_global_class_named(sysname) then
print("No main")
else
- var sys = class_by_name(sysname).get_type
- var main = sys.select_method(once "init".to_symbol)
- if main == null then
- main = sys.select_method(once "main".to_symbol)
- end
- if main == null then
+ var sys = class_by_name(sysname)
+ # var initm = sys.select_method(once "init".to_symbol)
+ var mainm = sys.select_method(once "main".to_symbol)
+ if mainm == null then
print("No main")
else
+ #v.add_instr("G_sys = NEW_{initm.cname}();")
v.add_instr("G_sys = NEW_Sys();")
- v.add_instr("{main.cname}(G_sys);")
+ v.add_instr("{mainm.cname}(G_sys);")
end
end
v.add_instr("return 0;")
# Compile sep files
meth compile_mod_to_c(v: CompilerVisitor)
do
- v.add_decl("#define LOCATE_{name} \"{filename}\"")
+ v.add_decl("extern const char *LOCATE_{name};")
if not v.tc.global then
v.add_decl("extern const int SFT_{name}[];")
end
v.add_decl("#define {pg.attr_access}(recv) ATTR(recv, {pg.color_id})")
end
end
- assert p isa MMSrcLocalProperty
p.compile_property_to_c(v)
end
end
# Compile module file for the current module
meth compile_local_table_to_c(v: CompilerVisitor)
do
+ v.add_instr("const char *LOCATE_{name} = \"{filename}\";")
+
if v.tc.global or _local_table.is_empty then
return
end
class TableEltPropPos
special LocalTableElt
- attr _property: MMSrcLocalProperty
+ attr _property: MMLocalProperty
redef meth symbol do return _property.global.color_id
redef meth value(ga) do return "{ga.color(self)} /* Property {_property} */"
- init(p: MMSrcLocalProperty)
+ init(p: MMLocalProperty)
do
_property = p
end
found = true
else if found and c.che < s then
var p = s[g]
- if p != null and p isa MMConcreteProperty then
+ if p != null then
#print "found {s.module}::{s}::{p}"
return p.cname
end
if e == null then
v.add_instr("\{0} /* Class Hole :( */,")
else
- v.add_instr("\{(int) {e.compile_to_c(v, self)}},")
+ v.add_instr("\{(bigint) {e.compile_to_c(v, self)}},")
end
end
if clen > ctab.length then
var t = p.signature.return_type
if p isa MMAttribute and t != null then
# FIXME: Not compatible with sep compilation
- var pi = p.concrete_property
- assert pi isa MMSrcAttribute
- var np = pi.node
+ assert p isa MMSrcAttribute
+ var np = p.node
assert np isa AAttrPropdef
var ne = np.n_expr
if ne != null then
v.indent
v.add_instr(init_table_decl)
v.add_instr("val_t self = NEW_{name}();")
- v.add_instr("{p.concrete_property.cname}({args.join(", ")});")
+ v.add_instr("{p.cname}({args.join(", ")});")
v.add_instr("return self;")
v.unindent
v.add_instr("}")