Skip to content

Commit

Permalink
Showing 4 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -39,6 +39,37 @@ public boolean and(RubyObject other) {
}
}

@CoreMethod(names = "|", needsSelf = false, required = 1)
public abstract static class OrNode extends CoreMethodNode {

public OrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public OrNode(OrNode prev) {
super(prev);
}

@Specialization
public boolean or(boolean other) {
return other;
}

@Specialization
public boolean or(RubyNilClass other) {
return false;
}

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

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

@CoreMethod(names = "^", needsSelf = false, required = 1)
public abstract static class XorNode extends CoreMethodNode {

Original file line number Diff line number Diff line change
@@ -48,6 +48,28 @@ static boolean isNotNil(RubyObject o) {
}
}

@CoreMethod(names = "|", needsSelf = false, required = 1)
public abstract static class OrNode extends CoreMethodNode {

public OrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public OrNode(OrNode prev) {
super(prev);
}

@Specialization
public boolean or(boolean other) {
return true;
}

@Specialization
public boolean or(RubyObject other) {
return true;
}
}

@CoreMethod(names = "^", needsSelf = false, required = 1)
public abstract static class XorNode extends CoreMethodNode {

1 change: 0 additions & 1 deletion spec/truffle/tags/core/false/or_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/true/or_tags.txt

This file was deleted.

0 comments on commit a265e27

Please sign in to comment.