Skip to content

Commit 9ae1528

Browse files
committed
Add Primitive.true? and Primitive.false? primitives
1 parent 4dea5a3 commit 9ae1528

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/java/org/truffleruby/core/support/TypeNodes.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,32 @@ protected boolean other(Object value) {
222222
}
223223
}
224224

225+
@Primitive(name = "true?")
226+
public abstract static class IsTrue extends PrimitiveArrayArgumentsNode {
227+
@Specialization
228+
protected boolean bool(boolean value) {
229+
return value;
230+
}
231+
232+
@Fallback
233+
protected boolean other(Object value) {
234+
return false;
235+
}
236+
}
237+
238+
@Primitive(name = "false?")
239+
public abstract static class IsFalse extends PrimitiveArrayArgumentsNode {
240+
@Specialization
241+
protected boolean bool(boolean value) {
242+
return !value;
243+
}
244+
245+
@Fallback
246+
protected boolean other(Object value) {
247+
return false;
248+
}
249+
}
250+
225251
@Primitive(name = "object_ivars")
226252
public abstract static class ObjectInstanceVariablesNode extends PrimitiveArrayArgumentsNode {
227253

0 commit comments

Comments
 (0)