nitg: detect if a compiler supports the FFI
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 29 Jan 2014 16:01:55 +0000 (11:01 -0500)
committerJean Privat <jean@pryen.org>
Mon, 17 Feb 2014 19:11:38 +0000 (14:11 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/abstract_compiler.nit
src/compiler_ffi.nit
src/global_compiler.nit

index db36ff9..6a4923b 100644 (file)
@@ -631,6 +631,9 @@ abstract class AbstractCompiler
                nmodule.finalize_ffi(visitor, modelbuilder)
                nmodule.finalize_nitni(visitor)
        end
+
+       # Does this compiler support the FFI?
+       fun supports_ffi: Bool do return false
 end
 
 # A file unit (may be more than one file if
index efb3fec..91b8f0b 100644 (file)
@@ -124,6 +124,11 @@ redef class AExternMethPropdef
                        return
                end
 
+               if not v.compiler.supports_ffi then
+                       super
+                       return
+               end
+
                amodule.mmodule.uses_ffi = true
 
                var mclass_type = mpropdef.mclassdef.bound_mtype
@@ -191,6 +196,11 @@ redef class AExternInitPropdef
                        return
                end
 
+               if not v.compiler.supports_ffi then
+                       super
+                       return
+               end
+
                amodule.mmodule.uses_ffi = true
 
                var mclass_type = mpropdef.mclassdef.bound_mtype
index b25c934..9b05fe5 100644 (file)
@@ -247,6 +247,8 @@ class GlobalCompiler
        do
                self.header.add_decl("struct nitni_instance \{ val *value; \};")
        end
+
+       redef fun supports_ffi do return true
 end
 
 # A visitor on the AST of property definition that generate the C code.