Merge branch 'pu/class_name' into wip
[nit.git] / src / compiling / compiling_icode.nit
index 4623ed3..4bc53ab 100644 (file)
@@ -168,7 +168,7 @@ class I2CCompilerVisitor
                if l != null then
                        visitor.add_indent(w)
                        w.add("/* ")
-                       w.add(l.file)
+                       w.add(l.file.filename)
                        w.add(":")
                        w.add(l.line_start.to_s)
                        w.add(" */\n")
@@ -289,7 +289,7 @@ redef class IRoutine
                        v.add_decl("struct \{struct stack_frame_t me;\} fra;")
                end
                v.add_instr("fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;")
-               v.add_instr("fra.me.file = LOCATE_{v.visitor.module.name};")
+               v.add_instr("fra.me.file = LOCATE_{v.visitor.mmmodule.name};")
                v.add_instr("fra.me.line = {ll};")
                v.add_instr("fra.me.meth = LOCATE_{v.basecname};")
                v.add_instr("fra.me.has_broke = 0;")
@@ -577,16 +577,10 @@ redef class ICall
                var w = new Writer
                var prop = property
                if prop.global.is_init then args.add("init_table")
-               if prop.name == (once ("add".to_symbol)) and prop.local_class.name == (once ("Array".to_symbol)) then
-                       w.add(prop.cname)
-                       w.add("(")
-               else
-                       w.add(prop.global.meth_call)
-                       w.add("(")
-                       w.add(args.first)
-                       w.add(")(")
-               end
-               var first = true
+               w.add(prop.global.meth_call)
+               w.add("(")
+               w.add(args.first)
+               w.add(")(")
                w.add_all(args, ", ")
                w.add(")")
                return w
@@ -870,7 +864,14 @@ redef class INative
                        s = "NEW_NativeArray(UNTAG_Int({regs[1]}), sizeof(val_t))"
                else if n == once "calloc_string".to_symbol then
                        s = "BOX_NativeString((char*)raw_alloc((UNTAG_Int({regs[1]}) * sizeof(char))))"
+               # Add output_class_name native implementation
+               else if n == once "output_class_name".to_symbol then
+                       s = "printf(\"%s\\n\", VAL2VFT({regs[0]})[2].cname);"
+               # Add class_name implementation
+               else if n == once "native_class_name".to_symbol then
+                       s = "BOX_NativeString(VAL2VFT({regs[0]})[2].cname);"
                end
+
                if s == null then
                        var ll = location
                        if ll != null then v.add_instr("fprintf(stderr, \"{ll.to_s}: \");")