Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java @ 8242:ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 04 Mar 2013 15:14:11 +0100 |
parents | 6b74ffe38183 |
children | 703c09f8640c |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java Mon Mar 04 15:13:25 2013 +0100 +++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java Mon Mar 04 15:14:11 2013 +0100 @@ -35,18 +35,18 @@ public class NodeData extends Template { - private NodeData parent; + private NodeData declaringNode; private List<NodeData> declaredChildren; private final TypeSystemData typeSystem; + private List<NodeFieldData> fields; + private TypeMirror nodeType; - private NodeFieldData[] fields; - private SpecializationData[] specializations; - private TemplateMethod[] specializationListeners; - private GuardData[] guards; - private ExecutableTypeData[] executableTypes; - - private TypeMirror nodeType; + private List<SpecializationData> specializations; + private List<SpecializationListenerData> specializationListeners; + private List<GuardData> guards; + private List<ExecutableTypeData> executableTypes; + private List<ShortCircuitData> shortCircuits; public NodeData(TypeElement type, TypeSystemData typeSystem) { super(type, null); @@ -95,12 +95,12 @@ this.declaredChildren = declaredChildren; for (NodeData child : declaredChildren) { - child.parent = this; + child.declaringNode = this; } } public NodeData getParent() { - return parent; + return declaringNode; } public List<NodeData> getDeclaredChildren() { @@ -121,17 +121,14 @@ } } - methods.addAll(Arrays.asList(getSpecializationListeners())); - methods.addAll(Arrays.asList(getExecutableTypes())); - methods.addAll(Arrays.asList(getGuards())); + methods.addAll(getSpecializationListeners()); + methods.addAll(getExecutableTypes()); + methods.addAll(getGuards()); + methods.addAll(getShortCircuits()); return methods; } - public TemplateMethod[] getSpecializationListeners() { - return specializationListeners; - } - public List<GuardData> findGuards(String name) { List<GuardData> foundGuards = new ArrayList<>(); for (GuardData guardData : getGuards()) { @@ -142,10 +139,6 @@ return foundGuards; } - public ExecutableTypeData[] getExecutableTypes() { - return executableTypes; - } - public ExecutableTypeData findGenericExecutableType(ProcessorContext context, TypeData type) { List<ExecutableTypeData> types = findGenericExecutableTypes(context); for (ExecutableTypeData availableType : types) { @@ -189,47 +182,20 @@ return result; } - public TypeMirror[] getExecutablePrimitiveTypeMirrors() { - TypeMirror[] typeMirrors = new TypeMirror[executableTypes.length]; - for (int i = 0; i < executableTypes.length; i++) { - typeMirrors[i] = executableTypes[i].getType().getPrimitiveType(); + public List<TypeMirror> getExecutablePrimitiveTypeMirrors() { + List<TypeMirror> typeMirrors = new ArrayList<>(); + for (ExecutableTypeData executableType : executableTypes) { + typeMirrors.add(executableType.getType().getPrimitiveType()); } return typeMirrors; } - void setExecutableTypes(ExecutableTypeData[] declaredExecuableTypes) { - this.executableTypes = declaredExecuableTypes; - } - - void setFields(NodeFieldData[] fields) { - this.fields = fields; - } - - void setSpecializations(SpecializationData[] specializations) { - this.specializations = specializations; - } - - void setSpecializationListeners(TemplateMethod[] specializationListeners) { - this.specializationListeners = specializationListeners; - } - - void setGuards(GuardData[] guards) { - this.guards = guards; - } - - public GuardData[] getGuards() { - return guards; - } - public NodeFieldData[] filterFields(FieldKind fieldKind, ExecutionKind usage) { List<NodeFieldData> filteredFields = new ArrayList<>(); - NodeFieldData[] resolvedFields = getFields(); - if (fields != null) { - for (NodeFieldData field : resolvedFields) { - if (usage == null || field.getExecutionKind() == usage) { - if (fieldKind == null || field.getKind() == fieldKind) { - filteredFields.add(field); - } + for (NodeFieldData field : getFields()) { + if (usage == null || field.getExecutionKind() == usage) { + if (fieldKind == null || field.getKind() == fieldKind) { + filteredFields.add(field); } } } @@ -258,7 +224,7 @@ } } - needsRewrites &= specializations.length >= 2; + needsRewrites &= specializations.size() >= 2; return needsRewrites; } @@ -279,18 +245,6 @@ } } - public NodeFieldData[] getFields() { - return fields; - } - - public NodeFieldData[] getDeclaredFields() { - return fields; - } - - public SpecializationData[] getSpecializations() { - return specializations; - } - public String dump() { StringBuilder b = new StringBuilder(); b.append(String.format("[name = %s\n" + " typeSystem = %s\n" + " fields = %s\n" + " types = %s\n" + " specializations = %s\n" + " guards = %s\n" + "]", @@ -298,7 +252,7 @@ return b.toString(); } - private static String dumpList(Object[] array) { + private static String dumpList(List<?> array) { if (array == null) { return "null"; } @@ -324,4 +278,55 @@ return null; } + public List<NodeFieldData> getFields() { + return fields; + } + + void setFields(List<NodeFieldData> fields) { + this.fields = fields; + } + + public List<SpecializationData> getSpecializations() { + return specializations; + } + + public List<SpecializationListenerData> getSpecializationListeners() { + return specializationListeners; + } + + public List<GuardData> getGuards() { + return guards; + } + + public List<ExecutableTypeData> getExecutableTypes() { + return executableTypes; + } + + public List<ShortCircuitData> getShortCircuits() { + return shortCircuits; + } + + void setSpecializations(List<SpecializationData> specializations) { + this.specializations = specializations; + for (SpecializationData specialization : specializations) { + specialization.setNode(this); + } + } + + void setSpecializationListeners(List<SpecializationListenerData> specializationListeners) { + this.specializationListeners = specializationListeners; + } + + void setGuards(List<GuardData> guards) { + this.guards = guards; + } + + void setExecutableTypes(List<ExecutableTypeData> executableTypes) { + this.executableTypes = executableTypes; + } + + void setShortCircuits(List<ShortCircuitData> shortCircuits) { + this.shortCircuits = shortCircuits; + } + }