start removing implicit properties
[nit.git] / src / compiling / compiling_methods.nit
index 8a95a4a..274ffa4 100644 (file)
@@ -171,7 +171,7 @@ redef class CompilerVisitor
                        end
                        j += 1
                end
-               var stop_prop: MMMethod
+               var stop_prop: MMMethod = null
                if j < n.explicit_super_init_calls.length then
                        stop_prop = n.explicit_super_init_calls[j]
                end
@@ -272,7 +272,7 @@ redef class MMAttribute
        end
 end
 
-redef class MMSrcLocalProperty
+redef class MMConcreteProperty
        # Compile the property as a C property
        meth compile_property_to_c(v: CompilerVisitor) do end
 end
@@ -282,7 +282,7 @@ redef class MMSrcMethod
        protected meth decl_csignature(v: CompilerVisitor, args: Array[String]): String
        do
                var params = new Array[String]
-               var params_new: Array[String]
+               var params_new: Array[String] = null
                if global.is_init then
                        params_new = new Array[String]
                end
@@ -399,7 +399,7 @@ redef class AConcreteMethPropdef
        redef meth do_compile_inside(v, method, params)
        do
                var orig_meth: MMLocalProperty = method.global.intro
-               var orig_sig = orig_meth.signature.adaptation_to(method.signature.recv)
+               var orig_sig = orig_meth.signature_for(method.signature.recv)
                if n_signature != null then
                        var sig = n_signature
                        assert sig isa ASignature
@@ -421,7 +421,7 @@ redef class AConcreteMethPropdef
                var old_return_value = v.return_value
                var old_has_return = v.has_return
 
-               var itpos: String
+               var itpos: String = null
                if self isa AConcreteInitPropdef then
                        itpos = "VAL2OBJ({params[0]})->vft[{method.local_class.global.init_table_pos_id}].i"
                        # v.add_instr("printf(\"{method.full_name}: inittable[%d] = %d\\n\", {itpos}, init_table[{itpos}]);")
@@ -505,7 +505,7 @@ redef class AInternMethPropdef
        do
                var c = method.local_class.name
                var n = method.name
-               var s: String
+               var s: String = null
                if c == once "Int".to_symbol then
                        if n == once "object_id".to_symbol then
                                s = "{p[0]}"
@@ -550,13 +550,13 @@ redef class AInternMethPropdef
                        end
                else if c == once "Float".to_symbol then
                        if n == once "object_id".to_symbol then
-                               s = "TAG_Int((int)UNBOX_Float({p[0]}))"
+                               s = "TAG_Int((bigint)UNBOX_Float({p[0]}))"
                        else if n == once "unary -".to_symbol then
                                s = "BOX_Float(-UNBOX_Float({p[0]}))"
                        else if n == once "output".to_symbol then
                                v.add_instr("printf(\"%f\\n\", UNBOX_Float({p[0]}));")
                        else if n == once "to_i".to_symbol then
-                               s = "TAG_Int((int)UNBOX_Float({p[0]}))"
+                               s = "TAG_Int((bigint)UNBOX_Float({p[0]}))"
                        else if n == once "+".to_symbol then
                                s = "BOX_Float(UNBOX_Float({p[0]})+UNBOX_Float({p[1]}))" 
                        else if n == once "-".to_symbol then
@@ -651,7 +651,7 @@ redef class AInternMethPropdef
                                v.add_instr("(void)memcpy(UNBOX_NativeString({p[1]})+UNTAG_Int({p[4]}), UNBOX_NativeString({p[0]})+UNTAG_Int({p[3]}), UNTAG_Int({p[2]}));")
                        end
                else if n == once "object_id".to_symbol then
-                       s = "TAG_Int((int){p[0]})"
+                       s = "TAG_Int((bigint){p[0]})"
                else if n == once "sys".to_symbol then
                        s = "(G_sys)"
                else if n == once "is_same_type".to_symbol then
@@ -995,6 +995,15 @@ redef class AIsaExpr
        end
 end
 
+redef class AAsCastExpr
+       redef meth compile_expr(v)
+       do
+               var e = v.compile_expr(n_expr)
+               n_type.stype.compile_type_check(v, e, self)
+               return e
+       end
+end
+
 redef class ATrueExpr
        redef meth compile_expr(v)
        do