28
28
import com .oracle .truffle .api .library .CachedLibrary ;
29
29
30
30
public class CoreModuleChecks {
31
- static void checks (
32
- CoreModuleProcessor processor ,
33
- int [] lowerFixnum ,
34
- CoreMethod coreMethod ,
35
- TypeElement klass ,
36
- boolean hasZeroArgument ) {
31
+
32
+ final CoreModuleProcessor processor ;
33
+
34
+ CoreModuleChecks (CoreModuleProcessor processor ) {
35
+ this .processor = processor ;
36
+ }
37
+
38
+ void checks (int [] lowerFixnum , CoreMethod coreMethod , TypeElement klass , boolean hasZeroArgument ) {
37
39
byte [] lowerArgs = null ;
38
40
List <ExecutableElement > specializationMethods = new ArrayList <>();
39
41
@@ -52,10 +54,9 @@ static void checks(
52
54
}
53
55
specializationMethods .add (specializationMethod );
54
56
55
- lowerArgs = checkLowerFixnumArguments (processor , specializationMethod , lowerArgs );
57
+ lowerArgs = checkLowerFixnumArguments (specializationMethod , lowerArgs );
56
58
if (coreMethod != null ) {
57
59
checkAmbiguousOptionalArguments (
58
- processor ,
59
60
coreMethod ,
60
61
specializationMethod ,
61
62
specializationAnnotation );
@@ -75,7 +76,7 @@ static void checks(
75
76
}
76
77
77
78
if (coreMethod == null ) { // @Primitive
78
- checkPrimitiveArguments (processor , specializationMethods );
79
+ checkPrimitiveArguments (specializationMethods );
79
80
}
80
81
81
82
// Verify against the lowerFixnum annotation
@@ -87,10 +88,7 @@ static void checks(
87
88
}
88
89
}
89
90
90
- private static byte [] checkLowerFixnumArguments (
91
- CoreModuleProcessor processor ,
92
- ExecutableElement specializationMethod ,
93
- byte [] lowerArgs ) {
91
+ private byte [] checkLowerFixnumArguments (ExecutableElement specializationMethod , byte [] lowerArgs ) {
94
92
List <? extends VariableElement > parameters = specializationMethod .getParameters ();
95
93
int start = 0 ;
96
94
@@ -135,8 +133,7 @@ private static boolean contains(int[] array, int value) {
135
133
return false ;
136
134
}
137
135
138
- private static void checkAmbiguousOptionalArguments (
139
- CoreModuleProcessor processor ,
136
+ private void checkAmbiguousOptionalArguments (
140
137
CoreMethod coreMethod ,
141
138
ExecutableElement specializationMethod ,
142
139
Specialization specializationAnnotation ) {
@@ -148,7 +145,7 @@ private static void checkAmbiguousOptionalArguments(
148
145
processor .error ("invalid block method parameter position for" , specializationMethod );
149
146
return ;
150
147
}
151
- isParameterBlock (processor , parameters .get (n ));
148
+ isParameterBlock (parameters .get (n ));
152
149
n --; // Ignore block argument.
153
150
}
154
151
@@ -170,13 +167,11 @@ private static void checkAmbiguousOptionalArguments(
170
167
processor .error ("invalid optional parameter count for" , specializationMethod );
171
168
continue ;
172
169
}
173
- isParameterUnguarded (processor , specializationAnnotation , parameters .get (n ));
170
+ isParameterUnguarded (specializationAnnotation , parameters .get (n ));
174
171
}
175
172
}
176
173
177
- private static void checkPrimitiveArguments (
178
- CoreModuleProcessor processor ,
179
- List <ExecutableElement > specializationMethods ) {
174
+ private void checkPrimitiveArguments (List <ExecutableElement > specializationMethods ) {
180
175
boolean hasRubyProcLastArgument = false ;
181
176
for (ExecutableElement specialization : specializationMethods ) {
182
177
List <? extends VariableElement > parameters = specialization .getParameters ();
@@ -214,10 +209,7 @@ private static int getLastParameterIndex(List<? extends VariableElement> paramet
214
209
return n ;
215
210
}
216
211
217
- private static void isParameterUnguarded (
218
- CoreModuleProcessor processor ,
219
- Specialization specializationAnnotation ,
220
- VariableElement parameter ) {
212
+ private void isParameterUnguarded (Specialization specializationAnnotation , VariableElement parameter ) {
221
213
String name = parameter .getSimpleName ().toString ();
222
214
223
215
// A specialization will only be called if the types of the arguments match its declared parameter
@@ -257,7 +249,7 @@ private static boolean isGuarded(String name, String[] guards) {
257
249
return false ;
258
250
}
259
251
260
- private static void isParameterBlock (CoreModuleProcessor processor , VariableElement parameter ) {
252
+ private void isParameterBlock (VariableElement parameter ) {
261
253
final TypeMirror blockType = parameter .asType ();
262
254
263
255
if (!(processor .isSameType (blockType , processor .nilType ) ||
0 commit comments