icode: add IStaticCall
authorJean-Sebastien Gelinas <calestar@gmail.com>
Mon, 17 Aug 2009 19:30:31 +0000 (15:30 -0400)
committerJean Privat <jean@pryen.org>
Tue, 18 Aug 2009 23:31:22 +0000 (19:31 -0400)
Trivially-hacked-by: Jean Privat <jean@pryen.org>

Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/analysis/icode_dump.nit
src/compiling/compiling_global.nit
src/compiling/compiling_icode.nit
src/icode/icode_base.nit
src/icode/icode_tools.nit

index 7c11458..2b31da6 100644 (file)
@@ -265,6 +265,13 @@ redef class ICall
        end
 end
 
+redef class IStaticCall
+       redef fun dump_intern(icd)
+       do
+               return "STATIC_CALL {property.full_name}({icd.register_all(exprs)})"
+       end
+end
+
 redef class IClosCall
        redef fun dump_intern(icd)
        do
index e878a30..20e74c3 100644 (file)
@@ -998,9 +998,9 @@ redef class MMLocalClass
                                icb.stmt(inew)
                                var iargs = [iself]
                                iargs.add_all(iparams)
-                               icb.stmt(new INative("{p.cname}(@@@{", @@@"*iparams.length}, init_table)", iargs))
-                               icb.stmt(new INative("CHECKNEW_{name}(@@@)", [iself]))
 
+                               icb.stmt(new IStaticCall(p, iargs))
+                               icb.stmt(new INative("CHECKNEW_{name}(@@@)", [iself]))
                                var cname = "NEW_{self}_{p.global.intro.cname}"
                                var new_args = iroutine.compile_signature_to_c(v, cname, "new {self} {p.full_name}", null, null)
                                var ctx_old = v.ctx
index 7a374d3..e0be792 100644 (file)
@@ -558,6 +558,15 @@ redef class INew
        end
 end
 
+redef class IStaticCall
+       redef fun compile_call_to_c(v, args)
+       do
+               var prop = property
+               if prop.global.is_init then args.add("init_table")
+               return "{property.cname}({args.join(", ")})"
+       end
+end
+
 redef class INative
        redef fun inner_compile_to_c(v)
        do
index 3fe1b3c..3dd1184 100644 (file)
@@ -246,6 +246,12 @@ special IAbsCall
        end
 end
 
+# A static call to a specific method
+class IStaticCall
+special IAbsCall
+       init(p: MMMethod, a: Sequence[IRegister]) do super
+end
+
 # A closure call
 # exprs are the arguments
 class IClosCall
index 7c38798..9109c38 100644 (file)
@@ -298,6 +298,12 @@ redef class INew
        end
 end
 
+redef class IStaticCall
+       redef fun inner_dup_with(d)
+       do
+               return new IStaticCall(property, d.dup_iregs(exprs))
+       end
+end
 redef class IClosCall
        redef fun dup_with(d)
        do