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
@@ -17,6 +17,28 @@
@CoreClass(name = "FalseClass")
public abstract class FalseClassNodes {

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

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

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

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

@Specialization
public boolean and(RubyObject other) {
return false;
}
}

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

Original file line number Diff line number Diff line change
@@ -17,6 +17,37 @@
@CoreClass(name = "TrueClass")
public abstract class TrueClassNodes {

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

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

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

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

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

@Specialization(guards = "isNotNil")
public boolean and(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 {

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

This file was deleted.

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

This file was deleted.

0 comments on commit f34f2c9

Please sign in to comment.