Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethodParser.java @ 9217:61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 15 Apr 2013 18:50:19 +0200 |
parents | 8a1115c92271 |
children | 97ad6d3e7557 |
comparison
equal
deleted
inserted
replaced
9216:8b9ea2f5c36e | 9217:61ba6fc21ba4 |
---|---|
32 import javax.lang.model.util.*; | 32 import javax.lang.model.util.*; |
33 | 33 |
34 import com.oracle.truffle.api.codegen.*; | 34 import com.oracle.truffle.api.codegen.*; |
35 import com.oracle.truffle.codegen.processor.*; | 35 import com.oracle.truffle.codegen.processor.*; |
36 import com.oracle.truffle.codegen.processor.template.ParameterSpec.Cardinality; | 36 import com.oracle.truffle.codegen.processor.template.ParameterSpec.Cardinality; |
37 import com.oracle.truffle.codegen.processor.typesystem.*; | |
37 | 38 |
38 public abstract class TemplateMethodParser<T extends Template, E extends TemplateMethod> { | 39 public abstract class TemplateMethodParser<T extends Template, E extends TemplateMethod> { |
39 | 40 |
40 private final ProcessorContext context; | 41 private final ProcessorContext context; |
41 | 42 |
65 this.emitErrors = emitErrors; | 66 this.emitErrors = emitErrors; |
66 } | 67 } |
67 | 68 |
68 public ProcessorContext getContext() { | 69 public ProcessorContext getContext() { |
69 return context; | 70 return context; |
71 } | |
72 | |
73 public TypeSystemData getTypeSystem() { | |
74 return template.getTypeSystem(); | |
70 } | 75 } |
71 | 76 |
72 public abstract MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror); | 77 public abstract MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror); |
73 | 78 |
74 public abstract E create(TemplateMethod method); | 79 public abstract E create(TemplateMethod method); |
261 | 266 |
262 // success! | 267 // success! |
263 return parsedParams; | 268 return parsedParams; |
264 } | 269 } |
265 | 270 |
266 private ActualParameter matchParameter(ParameterSpec specification, TypeMirror mirror, Template typeSystem, int index, boolean implicit) { | 271 private ActualParameter matchParameter(ParameterSpec specification, TypeMirror mirror, Template originalTemplate, int index, boolean implicit) { |
267 TypeMirror resolvedType = mirror; | 272 TypeMirror resolvedType = mirror; |
268 if (hasError(resolvedType)) { | 273 if (hasError(resolvedType)) { |
269 resolvedType = context.resolveNotYetCompiledType(mirror, typeSystem); | 274 resolvedType = context.resolveNotYetCompiledType(mirror, originalTemplate); |
270 } | 275 } |
271 | 276 |
272 if (!specification.matches(resolvedType)) { | 277 if (!specification.matches(resolvedType)) { |
273 return null; | 278 return null; |
274 } | 279 } |
275 return new ActualParameter(specification, resolvedType, index, implicit); | 280 |
281 TypeData resolvedTypeData = getTypeSystem().findTypeData(resolvedType); | |
282 if (resolvedTypeData != null) { | |
283 return new ActualParameter(specification, resolvedTypeData, index, implicit); | |
284 } else { | |
285 return new ActualParameter(specification, resolvedType, index, implicit); | |
286 } | |
276 } | 287 } |
277 | 288 |
278 /* Helper class for parsing. */ | 289 /* Helper class for parsing. */ |
279 private static class ConsumableListIterator<E> implements Iterable<E> { | 290 private static class ConsumableListIterator<E> implements Iterable<E> { |
280 | 291 |