comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/TemplateMethodParser.java @ 13532:85b485b1e8e1

Truffle-DSL: removed support for implicit parameters. not needed anymore.
author Christian Humer <christian.humer@gmail.com>
date Tue, 07 Jan 2014 20:06:27 +0100
parents 5a0c694ef735
children e8ef44830b50
comparison
equal deleted inserted replaced
13531:1f870eaf1e96 13532:85b485b1e8e1
149 return parseImpl(methodSpecification, id, method, annotation, returnType, parameterTypes); 149 return parseImpl(methodSpecification, id, method, annotation, returnType, parameterTypes);
150 } 150 }
151 151
152 private E parseImpl(MethodSpec methodSpecification, String id, ExecutableElement method, AnnotationMirror annotation, TypeMirror returnType, List<TypeMirror> parameterTypes) { 152 private E parseImpl(MethodSpec methodSpecification, String id, ExecutableElement method, AnnotationMirror annotation, TypeMirror returnType, List<TypeMirror> parameterTypes) {
153 ParameterSpec returnTypeSpec = methodSpecification.getReturnType(); 153 ParameterSpec returnTypeSpec = methodSpecification.getReturnType();
154 ActualParameter returnTypeMirror = matchParameter(returnTypeSpec, returnType, template, -1, -1, false); 154 ActualParameter returnTypeMirror = matchParameter(returnTypeSpec, returnType, template, -1, -1);
155 if (returnTypeMirror == null) { 155 if (returnTypeMirror == null) {
156 if (emitErrors) { 156 if (emitErrors) {
157 E invalidMethod = create(new TemplateMethod(id, template, methodSpecification, method, annotation, returnTypeMirror, Collections.<ActualParameter> emptyList()), true); 157 E invalidMethod = create(new TemplateMethod(id, template, methodSpecification, method, annotation, returnTypeMirror, Collections.<ActualParameter> emptyList()), true);
158 String expectedReturnType = returnTypeSpec.toSignatureString(true); 158 String expectedReturnType = returnTypeSpec.toSignatureString(true);
159 String actualReturnType = Utils.getSimpleName(returnType); 159 String actualReturnType = Utils.getSimpleName(returnType);
246 List<ParameterSpec> specifications = spec.getOptional(); 246 List<ParameterSpec> specifications = spec.getOptional();
247 outer: for (int specIndex = 0; specIndex < specifications.size(); specIndex++) { 247 outer: for (int specIndex = 0; specIndex < specifications.size(); specIndex++) {
248 ParameterSpec specification = specifications.get(specIndex); 248 ParameterSpec specification = specifications.get(specIndex);
249 for (int typeIndex = typeStartIndex; typeIndex < types.size(); typeIndex++) { 249 for (int typeIndex = typeStartIndex; typeIndex < types.size(); typeIndex++) {
250 TypeMirror actualType = types.get(typeIndex); 250 TypeMirror actualType = types.get(typeIndex);
251 ActualParameter optionalParam = matchParameter(specification, actualType, template, -1, -1, false); 251 ActualParameter optionalParam = matchParameter(specification, actualType, template, -1, -1);
252 if (optionalParam != null) { 252 if (optionalParam != null) {
253 parsedParams.add(optionalParam); 253 parsedParams.add(optionalParam);
254 typeStartIndex = typeIndex + 1; 254 typeStartIndex = typeIndex + 1;
255 continue outer; 255 continue outer;
256 } 256 }
279 break; 279 break;
280 } 280 }
281 return null; 281 return null;
282 } 282 }
283 283
284 boolean implicit = typeIndex < spec.getImplicitRequiredTypes().size();
285 int typeVarArgsIndex = typeVarArgs ? typeIndex - types.size() + 1 : -1; 284 int typeVarArgsIndex = typeVarArgs ? typeIndex - types.size() + 1 : -1;
286 int specVarArgsIndex = specVarArgs ? specificationIndex - specifications.size() + 1 : -1; 285 int specVarArgsIndex = specVarArgs ? specificationIndex - specifications.size() + 1 : -1;
287 286
288 if (typeVarArgsIndex >= 0 && specVarArgsIndex >= 0) { 287 if (typeVarArgsIndex >= 0 && specVarArgsIndex >= 0) {
289 // both specifications and types have a variable number of arguments 288 // both specifications and types have a variable number of arguments
290 // we would get into an endless loop if we would continue 289 // we would get into an endless loop if we would continue
291 break; 290 break;
292 } 291 }
293 292
294 ActualParameter resolvedParameter = matchParameter(specification, actualType, template, specVarArgsIndex, typeVarArgsIndex, implicit); 293 ActualParameter resolvedParameter = matchParameter(specification, actualType, template, specVarArgsIndex, typeVarArgsIndex);
295 if (resolvedParameter == null) { 294 if (resolvedParameter == null) {
296 return null; 295 return null;
297 } 296 }
298 parsedParams.add(resolvedParameter); 297 parsedParams.add(resolvedParameter);
299 typeIndex++; 298 typeIndex++;
335 } else { 334 } else {
336 return null; 335 return null;
337 } 336 }
338 } 337 }
339 338
340 protected final ActualParameter matchParameter(ParameterSpec specification, TypeMirror mirror, Template originalTemplate, int specificationIndex, int varArgsIndex, boolean implicit) { 339 protected final ActualParameter matchParameter(ParameterSpec specification, TypeMirror mirror, Template originalTemplate, int specificationIndex, int varArgsIndex) {
341 TypeMirror resolvedType = mirror; 340 TypeMirror resolvedType = mirror;
342 if (hasError(resolvedType)) { 341 if (hasError(resolvedType)) {
343 resolvedType = context.resolveNotYetCompiledType(mirror, originalTemplate); 342 resolvedType = context.resolveNotYetCompiledType(mirror, originalTemplate);
344 } 343 }
345 344
347 return null; 346 return null;
348 } 347 }
349 348
350 TypeData resolvedTypeData = getTypeSystem().findTypeData(resolvedType); 349 TypeData resolvedTypeData = getTypeSystem().findTypeData(resolvedType);
351 if (resolvedTypeData != null) { 350 if (resolvedTypeData != null) {
352 return new ActualParameter(specification, resolvedTypeData, specificationIndex, varArgsIndex, implicit); 351 return new ActualParameter(specification, resolvedTypeData, specificationIndex, varArgsIndex);
353 } else { 352 } else {
354 return new ActualParameter(specification, resolvedType, specificationIndex, varArgsIndex, implicit); 353 return new ActualParameter(specification, resolvedType, specificationIndex, varArgsIndex);
355 } 354 }
356 } 355 }
357 356
358 public final E create(String id, ExecutableElement methodMetadata, AnnotationMirror mirror, TypeMirror returnType, List<TypeMirror> parameterTypes) { 357 public final E create(String id, ExecutableElement methodMetadata, AnnotationMirror mirror, TypeMirror returnType, List<TypeMirror> parameterTypes) {
359 return parseImpl(createSpecification(methodMetadata, mirror), id, methodMetadata, mirror, returnType, parameterTypes); 358 return parseImpl(createSpecification(methodMetadata, mirror), id, methodMetadata, mirror, returnType, parameterTypes);