var i = 0
for vis in compiler.visitors do
count += vis.lines.length
- if file == null or count > 10000 then
+ if file == null or count > 10000 or vis.file_break then
i += 1
if file != null then file.close
var cfilename = ".nit_compile/{mainmodule.name}.{i}.c"
end
end
+ # Force the creation of a new file
+ # The point is to avoid contamination between must-be-compiled-separately files
+ fun new_file
+ do
+ var v = self.new_visitor
+ v.file_break = true
+ end
+
fun compile_header do
var v = self.header
self.header.add_decl("#include <stdlib.h>")
compiler.visitors.add(self)
end
+ var file_break: Bool = false
+
# Alias for self.compiler.mainmodule.object_type
fun object_type: MClassType do return self.compiler.mainmodule.object_type
self.add("/* skip, no method {m} */")
return res
end
- var propdefs = m.lookup_definitions(self.compiler.mainmodule, mclasstype)
- if propdefs.length == 0 then
- self.add("/* skip, no method {m} */")
- return res
- end
- assert propdefs.length == 1
- var propdef = propdefs.first
+ var propdef = m.lookup_first_definition(self.compiler.mainmodule, mclasstype)
var res2 = self.call(propdef, mclasstype, args)
if res != null then self.assign(res, res2.as(not null))
return res
var last = types.last
var defaultpropdef: nullable MMethodDef = null
for t in types do
- var propdefs = m.lookup_definitions(self.compiler.mainmodule, t)
- if propdefs.length == 0 then
- self.add("/* skip {t}, no method {m} */")
- continue
- end
- if propdefs.length > 1 then
- self.debug("NOT YET IMPLEMENTED conflict for {t}.{m}: {propdefs.join(" ")}. choose the first")
- end
- var propdef = propdefs.first
+ var propdef = m.lookup_first_definition(self.compiler.mainmodule, t)
if propdef.mclassdef.mclass.name == "Object" and t.ctype == "val*" then
defaultpropdef = propdef
continue
fun monomorphic_send(m: MMethod, t: MType, args: Array[RuntimeVariable]): nullable RuntimeVariable
do
assert t isa MClassType
- var propdefs = m.lookup_definitions(self.compiler.mainmodule, t)
- if propdefs.length == 0 then
- abort
- end
- if propdefs.length > 1 then
- self.debug("NOT YET IMPLEMENTED conflict for {t}.{m}: {propdefs.join(" ")}. choose the first")
- end
- var propdef = propdefs.first
+ var propdef = m.lookup_first_definition(self.compiler.mainmodule, t)
return self.call(propdef, t, args)
end