@@ -29,13 +29,15 @@ public class RubyProc extends RubyBasicObject implements MethodLike {
29
29
public static final boolean PROC_BINDING = Options .TRUFFLE_PROC_BINDING .load ();
30
30
31
31
public static enum Type {
32
- PROC , LAMBDA
32
+ BLOCK , PROC , LAMBDA
33
33
}
34
34
35
35
private final Type type ;
36
36
@ CompilationFinal private SharedMethodInfo sharedMethodInfo ;
37
- /** Call target for procs, which have special arguments destructuring */
38
- @ CompilationFinal private CallTarget callTarget ;
37
+ /** Call target for blocks, which have special arguments destructuring */
38
+ @ CompilationFinal private CallTarget callTargetForBlocks ;
39
+ /** Call target for actual Proc arguments, which handle break differently */
40
+ @ CompilationFinal private CallTarget callTargetForProcs ;
39
41
/** Call target for lambdas and methods, which have strict arguments destructuring */
40
42
@ CompilationFinal private CallTarget callTargetForMethods ;
41
43
@ CompilationFinal private MaterializedFrame declarationFrame ;
@@ -49,16 +51,20 @@ public RubyProc(RubyClass procClass, Type type) {
49
51
this .type = type ;
50
52
}
51
53
52
- public RubyProc (RubyClass procClass , Type type , SharedMethodInfo sharedMethodInfo , CallTarget callTarget ,
53
- CallTarget callTargetForMethods , MaterializedFrame declarationFrame , RubyModule declaringModule , MethodLike method , Object self , RubyProc block ) {
54
+ public RubyProc (RubyClass procClass , Type type , SharedMethodInfo sharedMethodInfo , CallTarget callTargetForBlocks ,
55
+ CallTarget callTargetForProcs , CallTarget callTargetForMethods , MaterializedFrame declarationFrame ,
56
+ RubyModule declaringModule , MethodLike method , Object self , RubyProc block ) {
54
57
this (procClass , type );
55
- initialize (sharedMethodInfo , callTarget , callTargetForMethods , declarationFrame , declaringModule , method , self , block );
58
+ initialize (sharedMethodInfo , callTargetForBlocks , callTargetForProcs , callTargetForMethods , declarationFrame ,
59
+ declaringModule , method , self , block );
56
60
}
57
61
58
- public void initialize (SharedMethodInfo sharedMethodInfo , CallTarget callTarget , CallTarget callTargetForMethods ,
59
- MaterializedFrame declarationFrame , RubyModule declaringModule , MethodLike method , Object self , RubyProc block ) {
62
+ public void initialize (SharedMethodInfo sharedMethodInfo , CallTarget callTargetForBlocks , CallTarget callTargetForProcs ,
63
+ CallTarget callTargetForMethods , MaterializedFrame declarationFrame , RubyModule declaringModule ,
64
+ MethodLike method , Object self , RubyProc block ) {
60
65
this .sharedMethodInfo = sharedMethodInfo ;
61
- this .callTarget = callTarget ;
66
+ this .callTargetForBlocks = callTargetForBlocks ;
67
+ this .callTargetForProcs = callTargetForProcs ;
62
68
this .callTargetForMethods = callTargetForMethods ;
63
69
this .declarationFrame = declarationFrame ;
64
70
this .declaringModule = declaringModule ;
@@ -69,8 +75,10 @@ public void initialize(SharedMethodInfo sharedMethodInfo, CallTarget callTarget,
69
75
70
76
public CallTarget getCallTargetForType () {
71
77
switch (type ) {
78
+ case BLOCK :
79
+ return callTargetForBlocks ;
72
80
case PROC :
73
- return callTarget ;
81
+ return callTargetForProcs ;
74
82
case LAMBDA :
75
83
return callTargetForMethods ;
76
84
}
@@ -94,8 +102,12 @@ public SharedMethodInfo getSharedMethodInfo() {
94
102
return sharedMethodInfo ;
95
103
}
96
104
97
- public CallTarget getCallTarget () {
98
- return callTarget ;
105
+ public CallTarget getCallTargetForBlocks () {
106
+ return callTargetForBlocks ;
107
+ }
108
+
109
+ public CallTarget getCallTargetForProcs () {
110
+ return callTargetForProcs ;
99
111
}
100
112
101
113
public CallTarget getCallTargetForMethods () {
0 commit comments