icode: add I*Value classes
[nit.git] / src / syntax / icode_generation.nit
index af61111..0d60974 100644 (file)
@@ -39,7 +39,7 @@ special ICodeBuilder
        fun add_new_array(stype: MMType, length: Int): IRegister
        do
                var prop = visitor.get_method(stype, once "with_capacity".to_symbol)
-               var ni = expr(new INative("TAG_Int({length})", null), visitor.type_int)
+               var ni = expr(new IIntValue(length.to_s), visitor.type_int)
                return expr(new INew(stype, prop, [ni]), stype)
        end
 
@@ -58,9 +58,7 @@ special ICodeBuilder
                if _variables.has_key(v) then
                        return _variables[v]
                else
-                       var t = v.stype
-                       if t == null then t = visitor.type_object.as_nullable
-                       var reg = new_register(t)
+                       var reg = new_register(v.stype.as(not null))
                        _variables[v] = reg
                        return reg
                end
@@ -1010,21 +1008,21 @@ end
 redef class AIntExpr
        redef fun generate_icode(v)
        do
-               return v.expr(new INative("TAG_Int({n_number.text})", null), stype)
+               return v.expr(new IIntValue(n_number.text), stype)
        end
 end
 
 redef class AFloatExpr
        redef fun generate_icode(v)
        do
-               return v.expr(new INative("BOX_Float({n_float.text})", null), stype)
+               return v.expr(new IFloatValue(n_float.text), stype)
        end
 end
 
 redef class ACharExpr
        redef fun generate_icode(v)
        do
-               return v.expr(new INative("TAG_Char({n_char.text})", null), stype)
+               return v.expr(new ICharValue(n_char.text), stype)
        end
 end
 
@@ -1036,8 +1034,8 @@ redef class AStringFormExpr
                var ionce = new IOnce
                var reg = v.expr(ionce, stype)
                v.seq = ionce.body
-               var ns = v.expr(new INative("BOX_NativeString(\"{_cstring}\")", null), v.visitor.type_nativestring)
-               var ni = v.expr(new INative("TAG_Int({_cstring_length})", null), v.visitor.type_int)
+               var ns = v.expr(new IStringValue(_cstring.as(not null)), v.visitor.type_nativestring)
+               var ni = v.expr(new IIntValue(_cstring_length.to_s), v.visitor.type_int)
                var prop = v.visitor.get_method(stype, once "with_native".to_symbol)
                var e = v.expr(new INew(stype, prop, [ns, ni]), stype)
                v.add_assignment(reg, e)