File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
src/main/java/org/truffleruby/language/control Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -34,18 +34,19 @@ public AndNode(RubyNode left, RubyNode right) {
34
34
public Object execute (VirtualFrame frame ) {
35
35
final Object leftValue = left .execute (frame );
36
36
37
- if (leftCast == null ) {
38
- CompilerDirectives .transferToInterpreterAndInvalidate ();
39
- leftCast = insert (BooleanCastNodeGen .create (null ));
40
- }
41
-
42
- final boolean leftBoolean = leftCast .executeToBoolean (leftValue );
43
-
44
- if (conditionProfile .profile (leftBoolean )) {
37
+ if (conditionProfile .profile (castToBoolean (leftValue ))) {
45
38
return right .execute (frame );
46
39
} else {
47
40
return leftValue ;
48
41
}
49
42
}
50
43
44
+ private boolean castToBoolean (final Object value ) {
45
+ if (leftCast == null ) {
46
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
47
+ leftCast = insert (BooleanCastNodeGen .create (null ));
48
+ }
49
+ return leftCast .executeToBoolean (value );
50
+ }
51
+
51
52
}
Original file line number Diff line number Diff line change 9
9
*/
10
10
package org .truffleruby .language .control ;
11
11
12
+ import com .oracle .truffle .api .CompilerDirectives ;
12
13
import com .oracle .truffle .api .frame .VirtualFrame ;
13
14
import com .oracle .truffle .api .profiles .ConditionProfile ;
14
15
import org .truffleruby .core .cast .BooleanCastNode ;
@@ -27,19 +28,25 @@ public class OrNode extends RubyNode {
27
28
public OrNode (RubyNode left , RubyNode right ) {
28
29
this .left = left ;
29
30
this .right = right ;
30
- leftCast = BooleanCastNodeGen .create (null );
31
31
}
32
32
33
33
@ Override
34
34
public Object execute (VirtualFrame frame ) {
35
35
final Object leftValue = left .execute (frame );
36
- final boolean leftBoolean = leftCast .executeToBoolean (leftValue );
37
36
38
- if (conditionProfile .profile (leftBoolean )) {
37
+ if (conditionProfile .profile (castToBoolean ( leftValue ) )) {
39
38
return leftValue ;
40
39
} else {
41
40
return right .execute (frame );
42
41
}
43
42
}
44
43
44
+ private boolean castToBoolean (final Object value ) {
45
+ if (leftCast == null ) {
46
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
47
+ leftCast = insert (BooleanCastNodeGen .create (null ));
48
+ }
49
+ return leftCast .executeToBoolean (value );
50
+ }
51
+
45
52
}
You can’t perform that action at this time.
0 commit comments