comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/MethodParser.java @ 8237:6b74ffe38183

Implemented support for executing nodes in @Children fields.
author Christian Humer <christian.humer@gmail.com>
date Fri, 01 Mar 2013 17:03:57 +0100
parents 6ad077b60cb3
children 703c09f8640c
comparison
equal deleted inserted replaced
7860:dbbdc0a30a16 8237:6b74ffe38183
25 import java.util.*; 25 import java.util.*;
26 26
27 import javax.lang.model.element.*; 27 import javax.lang.model.element.*;
28 28
29 import com.oracle.truffle.codegen.processor.*; 29 import com.oracle.truffle.codegen.processor.*;
30 import com.oracle.truffle.codegen.processor.node.NodeFieldData.ExecutionKind; 30 import com.oracle.truffle.codegen.processor.node.NodeFieldData.*;
31 import com.oracle.truffle.codegen.processor.template.*; 31 import com.oracle.truffle.codegen.processor.template.*;
32 import com.oracle.truffle.codegen.processor.template.ParameterSpec.Cardinality; 32 import com.oracle.truffle.codegen.processor.template.ParameterSpec.Cardinality;
33 33
34 public abstract class MethodParser<E extends TemplateMethod> extends TemplateMethodParser<NodeData, E> { 34 public abstract class MethodParser<E extends TemplateMethod> extends TemplateMethodParser<NodeData, E> {
35 35
54 return Utils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; 54 return Utils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null;
55 } 55 }
56 56
57 protected final MethodSpec createDefaultMethodSpec(String shortCircuitName) { 57 protected final MethodSpec createDefaultMethodSpec(String shortCircuitName) {
58 List<ParameterSpec> defaultParameters = new ArrayList<>(); 58 List<ParameterSpec> defaultParameters = new ArrayList<>();
59 ParameterSpec frameSpec = new ParameterSpec("frame", getContext().getTruffleTypes().getFrame(), true); 59
60 defaultParameters.add(frameSpec); 60 if (getNode().supportsFrame()) {
61 ParameterSpec frameSpec = new ParameterSpec("frame", getContext().getTruffleTypes().getFrame(), true);
62 defaultParameters.add(frameSpec);
63 }
61 64
62 for (NodeFieldData field : getNode().getFields()) { 65 for (NodeFieldData field : getNode().getFields()) {
63 if (field.getExecutionKind() == ExecutionKind.IGNORE) { 66 if (field.getExecutionKind() == ExecutionKind.IGNORE) {
64 continue; 67 continue;
65 } 68 }
66 69
67 if (field.getExecutionKind() == ExecutionKind.DEFAULT) { 70 if (field.getExecutionKind() == ExecutionKind.DEFAULT) {
68 defaultParameters.add(createValueParameterSpec(field.getName(), field.getNodeData(), false)); 71 ParameterSpec spec = createValueParameterSpec(field.getName(), field.getNodeData(), false);
72 if (field.getKind() == FieldKind.CHILDREN) {
73 spec.setCardinality(Cardinality.MULTIPLE);
74 spec.setIndexed(true);
75 }
76 defaultParameters.add(spec);
69 } else if (field.getExecutionKind() == ExecutionKind.SHORT_CIRCUIT) { 77 } else if (field.getExecutionKind() == ExecutionKind.SHORT_CIRCUIT) {
70 String valueName = field.getName(); 78 String valueName = field.getName();
71 if (shortCircuitName != null && valueName.equals(shortCircuitName)) { 79 if (shortCircuitName != null && valueName.equals(shortCircuitName)) {
72 break; 80 break;
73 } 81 }