File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
src/vm/jvm/runtime/org/perl6/nqp/truffle/nodes Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .perl6 .nqp .truffle .nodes ;
2
+
3
+ import com .oracle .truffle .api .dsl .Specialization ;
4
+ import org .perl6 .nqp .truffle .runtime .NQPListIterator ;
5
+ import org .perl6 .nqp .truffle .runtime .NQPNull ;
6
+
7
+ public abstract class NQPToBooleanNode extends NQPBaseNode {
8
+ public abstract boolean executeBoolean (Object value );
9
+
10
+ @ Specialization
11
+ protected boolean doString (String value ) {
12
+ return ((String ) value != "" ) ? true : false ;
13
+ }
14
+
15
+ @ Specialization
16
+ protected boolean doLong (Long value ) {
17
+ return ((long ) value ) != 0 ? true : false ;
18
+ }
19
+
20
+ @ Specialization
21
+ protected boolean doDouble (Double value ) {
22
+ return ((double ) value ) != 0 ? true : false ;
23
+ }
24
+
25
+ @ Specialization
26
+ protected boolean doNQPListIterator (NQPListIterator value ) {
27
+ return ((NQPListIterator ) value ).boolify ();
28
+ }
29
+
30
+ @ Specialization
31
+ protected boolean doNQPNull (Object value ) {
32
+ return false ;
33
+ }
34
+
35
+ protected final boolean isNull (Object value ) {
36
+ return value == NQPNull .SINGLETON ;
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments