src: implement unary plus
[nit.git] / src / nitni / nitni_utilities.nit
index 80c6691..631421a 100644 (file)
@@ -53,7 +53,8 @@ redef class MMethod
        # * The `call_context` identifying which types and casts to use (see `CallContext` and its instances)
        fun build_csignature(recv_mtype: MClassType, from_mmodule: MModule, suffix: nullable String, length: SignatureLength, call_context: CallContext): String
        do
-               var signature = self.intro.msignature
+               var mmethoddef = lookup_first_definition(from_mmodule, recv_mtype)
+               var signature = mmethoddef.msignature
                assert signature != null
 
                var creturn_type
@@ -93,7 +94,8 @@ redef class MMethod
        do
                if param_suffix == null then param_suffix = ""
 
-               var signature = self.intro.msignature
+               var mmethoddef = lookup_first_definition(from_mmodule, recv_mtype)
+               var signature = mmethoddef.msignature
                assert signature != null
 
                var return_mtype = null
@@ -101,6 +103,7 @@ redef class MMethod
                        return_mtype = recv_mtype
                else if signature.return_mtype != null then
                        return_mtype = signature.return_mtype
+                       return_mtype = return_mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
                end
 
                var cname = build_cname(recv_mtype, from_mmodule, suffix, length)
@@ -111,7 +114,8 @@ redef class MMethod
                end
 
                for p in signature.mparameters do
-                       cparams.add(call_context.cast_to(p.mtype, "{p.name}{param_suffix}"))
+                       var param_mtype = p.mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
+                       cparams.add(call_context.cast_to(param_mtype, "{p.name}{param_suffix}"))
                end
 
                var joined_cparams = cparams.join(", ")
@@ -146,5 +150,6 @@ end
 # Length of the signature of a C function (long version hase the module name as prefix)
 class SignatureLength
        private var long: Bool
-       private init(long: Bool) do self.long = long
+
+       # TODO: private init because singleton class.
 end