9
9
*/
10
10
package org .truffleruby .language .locals ;
11
11
12
+ import com .oracle .truffle .api .frame .FrameUtil ;
12
13
import org .truffleruby .language .RubyBaseWithoutContextNode ;
13
14
14
15
import com .oracle .truffle .api .dsl .Specialization ;
15
16
import com .oracle .truffle .api .frame .Frame ;
16
17
import com .oracle .truffle .api .frame .FrameSlot ;
17
- import com .oracle .truffle .api .frame .FrameSlotTypeException ;
18
18
19
19
public abstract class ReadFrameSlotNode extends RubyBaseWithoutContextNode {
20
20
@@ -26,38 +26,29 @@ public ReadFrameSlotNode(FrameSlot slot) {
26
26
27
27
public abstract Object executeRead (Frame frame );
28
28
29
- @ Specialization (rewriteOn = FrameSlotTypeException . class )
30
- protected boolean readBoolean (Frame frame ) throws FrameSlotTypeException {
31
- return frame . getBoolean ( frameSlot );
29
+ @ Specialization (guards = "frame.isBoolean(frameSlot)" )
30
+ protected boolean readBoolean (Frame frame ) {
31
+ return FrameUtil . getBooleanSafe ( frame , frameSlot );
32
32
}
33
33
34
- @ Specialization (rewriteOn = FrameSlotTypeException . class )
35
- protected int readInt (Frame frame ) throws FrameSlotTypeException {
36
- return frame . getInt ( frameSlot );
34
+ @ Specialization (guards = "frame.isInt(frameSlot)" )
35
+ protected int readInt (Frame frame ) {
36
+ return FrameUtil . getIntSafe ( frame , frameSlot );
37
37
}
38
38
39
- @ Specialization (rewriteOn = FrameSlotTypeException . class )
40
- protected long readLong (Frame frame ) throws FrameSlotTypeException {
41
- return frame . getLong ( frameSlot );
39
+ @ Specialization (guards = "frame.isLong(frameSlot)" )
40
+ protected long readLong (Frame frame ) {
41
+ return FrameUtil . getLongSafe ( frame , frameSlot );
42
42
}
43
43
44
- @ Specialization (rewriteOn = FrameSlotTypeException . class )
45
- protected double readDouble (Frame frame ) throws FrameSlotTypeException {
46
- return frame . getDouble ( frameSlot );
44
+ @ Specialization (guards = "frame.isDouble(frameSlot)" )
45
+ protected double readDouble (Frame frame ) {
46
+ return FrameUtil . getDoubleSafe ( frame , frameSlot );
47
47
}
48
48
49
- @ Specialization (rewriteOn = FrameSlotTypeException .class )
50
- protected Object readObject (Frame frame ) throws FrameSlotTypeException {
51
- return frame .getObject (frameSlot );
52
- }
53
-
54
- @ Specialization (replaces = { "readBoolean" , "readInt" , "readLong" , "readDouble" , "readObject" })
55
- protected Object readAny (Frame frame ) {
56
- return frame .getValue (frameSlot );
57
- }
58
-
59
- public final FrameSlot getFrameSlot () {
60
- return frameSlot ;
49
+ @ Specialization (guards = "frame.isObject(frameSlot)" )
50
+ protected Object readObject (Frame frame ) {
51
+ return FrameUtil .getObjectSafe (frame , frameSlot );
61
52
}
62
53
63
54
}
0 commit comments