Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/typesystem/GuardParser.java @ 8592:a80bf36c6a1e
Refactor to shared template method signature comparison.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 01 Apr 2013 11:52:38 +0200 |
parents | 703c09f8640c |
children | 54e227b2e199 |
comparison
equal
deleted
inserted
replaced
8591:5c58da5b8233 | 8592:a80bf36c6a1e |
---|---|
27 | 27 |
28 import javax.lang.model.element.*; | 28 import javax.lang.model.element.*; |
29 import javax.lang.model.type.*; | 29 import javax.lang.model.type.*; |
30 | 30 |
31 import com.oracle.truffle.codegen.processor.*; | 31 import com.oracle.truffle.codegen.processor.*; |
32 import com.oracle.truffle.codegen.processor.node.*; | |
32 import com.oracle.truffle.codegen.processor.template.*; | 33 import com.oracle.truffle.codegen.processor.template.*; |
33 import com.oracle.truffle.codegen.processor.template.ParameterSpec.Cardinality; | |
34 | 34 |
35 public class GuardParser extends TemplateMethodParser<Template, GuardData> { | 35 public class GuardParser extends TemplateMethodParser<Template, GuardData> { |
36 | 36 |
37 private final TypeSystemData typeSystem; | 37 private final SpecializationData specialization; |
38 private final String guardName; | |
38 | 39 |
39 public GuardParser(ProcessorContext context, Template template, TypeSystemData typeSystem) { | 40 public GuardParser(ProcessorContext context, SpecializationData specialization, String guardName) { |
40 super(context, template); | 41 super(context, specialization.getNode()); |
41 this.typeSystem = typeSystem; | 42 this.specialization = specialization; |
43 this.guardName = guardName; | |
42 setEmitErrors(false); | 44 setEmitErrors(false); |
43 setParseNullOnError(false); | 45 setParseNullOnError(false); |
44 } | 46 } |
45 | 47 |
46 @Override | 48 @Override |
47 public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { | 49 public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { |
48 List<ParameterSpec> specs = new ArrayList<>(); | 50 List<ParameterSpec> specs = new ArrayList<>(); |
49 specs.add(new ParameterSpec("valueN", typeSystem, false, Cardinality.MULTIPLE)); | 51 for (ActualParameter parameter : specialization.getParameters()) { |
50 ParameterSpec returnTypeSpec = new ParameterSpec("returnType", getContext().getType(boolean.class), false); | 52 specs.add(new ParameterSpec(parameter.getSpecification().getName(), parameter.getActualType(), true, true)); |
53 } | |
54 ParameterSpec returnTypeSpec = new ParameterSpec("returnType", getContext().getType(boolean.class), false, false); | |
51 return new MethodSpec(Collections.<TypeMirror> emptyList(), returnTypeSpec, specs); | 55 return new MethodSpec(Collections.<TypeMirror> emptyList(), returnTypeSpec, specs); |
52 } | 56 } |
53 | 57 |
54 @Override | 58 @Override |
55 public boolean isParsable(ExecutableElement method) { | 59 public boolean isParsable(ExecutableElement method) { |
56 return true; | 60 return method.getSimpleName().toString().equals(guardName); |
57 } | 61 } |
58 | 62 |
59 @Override | 63 @Override |
60 public GuardData create(TemplateMethod method) { | 64 public GuardData create(TemplateMethod method) { |
61 return new GuardData(method); | 65 return new GuardData(method); |