abstract_compiler: attach compiler and toolchain
[nit.git] / src / compiler / compiler_ffi / light.nit
index c7e3b0e..01579b0 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# FFI support for the compilers
+# Light FFI support for the compiler
 module light
 
 intrude import abstract_compiler
 intrude import ffi::light_ffi
 
 redef class MModule
+       # `CCompilationUnit` used for nitni signatures and code specific to the compiler
        var nitni_ccu: nullable CCompilationUnit = null
 
        private fun nmodule(v: AbstractCompilerVisitor): nullable AModule
@@ -36,7 +37,7 @@ redef class MModule
                var n = nmodule(v)
                if n == null then return
                n.ensure_compile_ffi_wrapper
-               finalize_ffi_wrapper(v.compiler.modelbuilder.compile_dir, v.compiler.mainmodule)
+               finalize_ffi_wrapper(v.compiler.toolchain.compile_dir, v.compiler.mainmodule)
                for file in ffi_files do v.compiler.extern_bodies.add(file)
 
                ensure_compile_nitni_base(v)
@@ -48,7 +49,7 @@ extern void nitni_global_ref_decr(void*);
 """
 
                var cflags = self.cflags[""].join(" ")
-               nitni_ccu.write_as_nitni(self, v.compiler.modelbuilder.compile_dir)
+               nitni_ccu.write_as_nitni(self, v.compiler.toolchain.compile_dir)
 
                for file in nitni_ccu.files do
                        var f = new ExternCFile(file, cflags)
@@ -82,7 +83,6 @@ redef class AMethPropdef
        private fun compile_ffi_support_to_c(v: AbstractCompilerVisitor)
        do
                var mmodule = mpropdef.mclassdef.mmodule
-               var mainmodule = v.compiler.mainmodule
                var amodule = v.compiler.modelbuilder.mmodule2node(mmodule)
                var mclass_type = mpropdef.mclassdef.bound_mtype
 
@@ -220,6 +220,7 @@ redef class AMethPropdef
 end
 
 redef class CCompilationUnit
+       # Compile a `_nitni` files, used to implement nitni features for the compiler
        fun write_as_nitni(mmodule: MModule, compdir: String)
        do
                var base_name = "{mmodule.c_name}._nitni"