9
9
*/
10
10
package org .truffleruby .core .cast ;
11
11
12
+ import com .oracle .truffle .api .dsl .GenerateCached ;
13
+ import com .oracle .truffle .api .dsl .GenerateInline ;
14
+ import com .oracle .truffle .api .nodes .Node ;
12
15
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
13
16
import org .truffleruby .core .hash .RubyHash ;
14
17
import org .truffleruby .language .RubyBaseNode ;
25
28
26
29
import static org .truffleruby .language .dispatch .DispatchConfiguration .PRIVATE_RETURN_MISSING ;
27
30
31
+ @ GenerateCached (false )
32
+ @ GenerateInline
28
33
public abstract class HashCastNode extends RubyBaseNode {
29
34
30
- public abstract RubyHash execute (Object value );
35
+ public abstract RubyHash execute (Node node , Object value );
31
36
32
37
@ Specialization
33
- RubyHash castHash (RubyHash hash ) {
38
+ static RubyHash castHash (RubyHash hash ) {
34
39
return hash ;
35
40
}
36
41
37
42
@ Specialization (guards = "!isRubyHash(object)" )
38
- RubyHash cast (Object object ,
43
+ static RubyHash cast (Node node , Object object ,
39
44
@ Cached InlinedBranchProfile errorProfile ,
40
- @ Cached DispatchNode toHashNode ) {
45
+ @ Cached ( inline = false ) DispatchNode toHashNode ) {
41
46
final Object result = toHashNode .call (PRIVATE_RETURN_MISSING , object , "to_hash" );
42
47
43
48
if (result == DispatchNode .MISSING ) {
44
- errorProfile .enter (this );
49
+ errorProfile .enter (node );
45
50
throw new RaiseException (
46
- getContext (),
47
- coreExceptions ().typeErrorNoImplicitConversion (object , "Hash" , this ));
51
+ getContext (node ),
52
+ coreExceptions (node ).typeErrorNoImplicitConversion (object , "Hash" , node ));
48
53
}
49
54
50
55
if (!RubyGuards .isRubyHash (result )) {
51
- errorProfile .enter (this );
56
+ errorProfile .enter (node );
52
57
throw new RaiseException (
53
- getContext (),
54
- coreExceptions ().typeErrorCantConvertTo (object , "Hash" , "to_hash" , result , this ));
58
+ getContext (node ),
59
+ coreExceptions (node ).typeErrorCantConvertTo (object , "Hash" , "to_hash" , result , node ));
55
60
}
56
61
57
62
return (RubyHash ) result ;
@@ -66,7 +71,7 @@ public abstract static class HashCastASTNode extends RubyContextSourceNode {
66
71
@ Specialization
67
72
RubyHash cast (Object object ,
68
73
@ Cached HashCastNode hashCastNode ) {
69
- return hashCastNode .execute (object );
74
+ return hashCastNode .execute (this , object );
70
75
71
76
}
72
77
0 commit comments