syntax: remove local variable masking
[nit.git] / src / compiling / compiling_icode.nit
index 5f44ca1..d355bb1 100644 (file)
@@ -46,7 +46,7 @@ class I2CCompilerVisitor
                        else
                                var s: String
                                var strs: HashMap[Int, String]
-                               if e.in_bool_slots then
+                               if e.in_tag_slots then
                                        strs = once new HashMap[Int, String]
                                        if not strs.has_key(i) then strs[i] = "REGB{i}"
                                else if closure and not e.is_local then
@@ -274,7 +274,7 @@ redef class IRoutine
                else
                        v.add_decl("val_t REG[{std_slots_nb}];")
                end
-               for i in [0..bool_slots_nb[ do
+               for i in [0..tag_slots_nb[ do
                        v.add_decl("val_t REGB{i};")
                end
                var iclosdecls = closure_decls
@@ -283,12 +283,11 @@ redef class IRoutine
                else
                        v.add_decl("struct WBT_ **CREG = NULL;")
                end
-               var i = 0
+               var k = 0
                for r in params do
-                       if r.slot_index != null then v.add_assignment(v.register(r), args[i])
-                       i += 1
+                       if r.slot_index != null then v.add_assignment(v.register(r), args[k])
+                       k += 1
                end
-               var iclosdecls = closure_decls
                if iclosdecls != null then
                        for i in [0..iclosdecls.length[ do
                                var iclosdecl = iclosdecls[i]
@@ -358,7 +357,9 @@ redef class ICode
                if r != null and r.slot_index != null then
                        assert s != null
                        v.add_assignment(v.register(r), s)
-               else if s != null and not self isa IMove then
+               else if s != null and not is_pure then
+                       # ICode with side effects must be evaluated
+                       # even if the result is not wanted
                        v.add_instr(s + ";")
                end
        end