From: Jean Privat Date: Mon, 23 Mar 2015 13:58:55 +0000 (+0700) Subject: sepcomp: tag values when storing it with opt_no_union_attribute X-Git-Tag: v0.7.3~13^2~3 X-Git-Url: http://nitlanguage.org sepcomp: tag values when storing it with opt_no_union_attribute Signed-off-by: Jean Privat --- diff --git a/src/compiler/separate_compiler.nit b/src/compiler/separate_compiler.nit index 8cb75e7..15da8c1 100644 --- a/src/compiler/separate_compiler.nit +++ b/src/compiler/separate_compiler.nit @@ -1661,7 +1661,11 @@ class SeparateCompilerVisitor self.require_declaration(a.const_color) if self.compiler.modelbuilder.toolcontext.opt_no_union_attribute.value then var attr = "{recv}->attrs[{a.const_color}]" - if mtype.is_c_primitive then + if mtype.is_tagged then + # The attribute is not primitive, thus store it as tagged + var tv = autobox(value, compiler.mainmodule.object_type) + self.add("{attr} = {tv}; /* {a} on {recv.inspect} */") + else if mtype.is_c_primitive then assert mtype isa MClassType # The attribute is primitive, thus we store it in a box # The trick is to create the box the first time then resuse the box