From fc8bb1ba14577b64d41f6964a528098b1c90ab7d Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 23 Mar 2015 20:58:55 +0700 Subject: [PATCH] sepcomp: tag values when storing it with opt_no_union_attribute Signed-off-by: Jean Privat --- src/compiler/separate_compiler.nit | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- 1.7.9.5