X-Git-Url: http://nitlanguage.org diff --git a/src/global_compiler.nit b/src/global_compiler.nit index 3e309a5..e09d040 100644 --- a/src/global_compiler.nit +++ b/src/global_compiler.nit @@ -149,7 +149,7 @@ redef class ModelBuilder 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" @@ -258,6 +258,14 @@ class GlobalCompiler 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 ") @@ -1016,6 +1024,8 @@ class GlobalCompilerVisitor 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 @@ -1361,13 +1371,7 @@ class GlobalCompilerVisitor 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 @@ -1411,15 +1415,7 @@ class GlobalCompilerVisitor 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 @@ -1449,14 +1445,7 @@ class GlobalCompilerVisitor 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