Skip to content

Commit

Permalink
[Truffle] Simplified and consolidated a nil object guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Nov 24, 2014
1 parent d5a78a4 commit 89bdf82
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Expand Up @@ -222,4 +222,7 @@ public static void notDesignedForCompilation() {
CompilerAsserts.neverPartOfCompilation();
}

public static boolean isNil(RubyObject o) {
return o instanceof RubyNilClass;
}
}
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Expand Up @@ -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)
Expand Down

0 comments on commit 89bdf82

Please sign in to comment.