From 9c53a2c3ef0ced79530017618415b4c1a049f511 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sat, 21 Mar 2015 12:04:47 +0700 Subject: [PATCH] compiler: `int_instance` and `bool_instance` return a inlined runtimevariable Signed-off-by: Jean Privat --- src/compiler/abstract_compiler.nit | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 3432385..40ac105 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -1421,20 +1421,16 @@ abstract class AbstractCompilerVisitor # Generate an integer value fun int_instance(value: Int): RuntimeVariable do - var res = self.new_var(self.get_class("Int").mclass_type) - self.add("{res} = {value};") + var t = mmodule.int_type + var res = new RuntimeVariable("{value.to_s}l", t, t) return res end # Generate an integer value fun bool_instance(value: Bool): RuntimeVariable do - var res = self.new_var(self.get_class("Bool").mclass_type) - if value then - self.add("{res} = 1;") - else - self.add("{res} = 0;") - end + var s = if value then "1" else "0" + var res = new RuntimeVariable(s, bool_type, bool_type) return res end -- 1.7.9.5