From ad9551f1df5c69e4f56528a31b42158dad065c09 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sun, 4 Jan 2015 22:01:20 -0500 Subject: [PATCH] separate_compiler: `shortcut_equate` works on `is_same_instance` Signed-off-by: Jean Privat --- src/compiler/separate_compiler.nit | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/separate_compiler.nit b/src/compiler/separate_compiler.nit index 297b1ba..33e8d8a 100644 --- a/src/compiler/separate_compiler.nit +++ b/src/compiler/separate_compiler.nit @@ -1142,15 +1142,15 @@ class SeparateCompilerVisitor else self.add("\{") end - if not self.compiler.modelbuilder.toolcontext.opt_no_shortcut_equate.value and (mmethod.name == "==" or mmethod.name == "!=") then + if not self.compiler.modelbuilder.toolcontext.opt_no_shortcut_equate.value and (mmethod.name == "==" or mmethod.name == "!=" or mmethod.name == "is_same_instance") then # Recv is not null, thus if arg is, it is easy to conclude (and respect the invariants) var arg = arguments[1] if arg.mcasttype isa MNullType then if res == null then res = self.new_var(bool_type) - if mmethod.name == "==" then - self.add("{res} = 0; /* arg is null but recv is not */") - else + if mmethod.name == "!=" then self.add("{res} = 1; /* arg is null and recv is not */") + else # `==` and `is_same_instance` + self.add("{res} = 0; /* arg is null but recv is not */") end self.add("\}") # closes the null case self.add("if (0) \{") # what follow is useless, CC will drop it -- 1.7.9.5