Skip to content
Permalink
Browse files
[Truffle] Simplified and consolidated a nil object guard.
  • Loading branch information
nirvdrum committed Nov 24, 2014
1 parent d5a78a4 commit 89bdf823d3d7bc9bcc91628521989e6927c3296e
Showing 3 changed files with 6 additions and 14 deletions.
@@ -222,4 +222,7 @@ public static void notDesignedForCompilation() {
CompilerAsserts.neverPartOfCompilation();
}

public static boolean isNil(RubyObject o) {
return o instanceof RubyNilClass;
}
}
@@ -55,14 +55,11 @@ public boolean or(RubyNilClass other) {
return false;
}

@Specialization(guards = "isNotNil")
@Specialization(guards = "!isNil")
public boolean or(RubyObject other) {
return true;
}

static boolean isNotNil(RubyObject o) {
return ! (o instanceof RubyNilClass);
}
}

@CoreMethod(names = "^", needsSelf = false, required = 1)
@@ -86,15 +83,11 @@ public boolean xor(RubyNilClass other) {
return false;
}

@Specialization(guards = "isNotNil")
@Specialization(guards = "!isNil")
public boolean xor(RubyObject other) {
return true;
}

static boolean isNotNil(RubyObject o) {
return ! (o instanceof RubyNilClass);
}

}

@CoreMethod(names = {"to_s", "inspect"}, needsSelf = false)
@@ -38,14 +38,10 @@ public boolean and(RubyNilClass other) {
return false;
}

@Specialization(guards = "isNotNil")
@Specialization(guards = "!isNil")
public boolean and(RubyObject other) {
return true;
}

static boolean isNotNil(RubyObject o) {
return ! (o instanceof RubyNilClass);
}
}

@CoreMethod(names = "|", needsSelf = false, required = 1)

0 comments on commit 89bdf82

Please sign in to comment.