compiler: add Visitor::bool_instance
authorJean Privat <jean@pryen.org>
Fri, 10 Oct 2014 01:49:22 +0000 (21:49 -0400)
committerJean Privat <jean@pryen.org>
Fri, 10 Oct 2014 01:49:22 +0000 (21:49 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit

index df39d60..c8fd126 100644 (file)
@@ -1355,6 +1355,18 @@ abstract class AbstractCompilerVisitor
                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
+               return res
+       end
+
        # Generate a string value
        fun string_instance(string: String): RuntimeVariable
        do