Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/CreateCastParser.java @ 16755:bd28da642eea
Truffle-DSL: Several new features implemented:
Implementation of a new code generation layout which shares code between generated nodes.
Declaration order of specializations is now used as specialization order.
Specializations do no longer perform fallthrough on respecialization, they now always respecialize from the first specialization.
Implemented support for contains relations between specializations.
Improved reachability error messages.
Preliminary support for @Implies.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:53:05 +0200 |
parents | b466199f19e1 |
children |
comparison
equal
deleted
inserted
replaced
16754:55fd5be68a52 | 16755:bd28da642eea |
---|---|
56 TypeMirror baseType = getContext().getTruffleTypes().getNode(); | 56 TypeMirror baseType = getContext().getTruffleTypes().getNode(); |
57 if (foundChild != null) { | 57 if (foundChild != null) { |
58 baseType = foundChild.getOriginalType(); | 58 baseType = foundChild.getOriginalType(); |
59 } | 59 } |
60 | 60 |
61 MethodSpec spec = new MethodSpec(new InheritsParameterSpec(getContext(), "child", baseType)); | 61 MethodSpec spec = new MethodSpec(new InheritsParameterSpec("child", baseType)); |
62 addDefaultFieldMethodSpec(spec); | 62 addDefaultFieldMethodSpec(spec); |
63 ParameterSpec childSpec = new ParameterSpec("castedChild", baseType); | 63 ParameterSpec childSpec = new ParameterSpec("castedChild", baseType); |
64 childSpec.setSignature(true); | 64 childSpec.setSignature(true); |
65 spec.addRequired(childSpec); | 65 spec.addRequired(childSpec); |
66 return spec; | 66 return spec; |
95 return cast; | 95 return cast; |
96 } | 96 } |
97 | 97 |
98 private static class InheritsParameterSpec extends ParameterSpec { | 98 private static class InheritsParameterSpec extends ParameterSpec { |
99 | 99 |
100 private final ProcessorContext context; | 100 public InheritsParameterSpec(String name, TypeMirror... allowedTypes) { |
101 | |
102 public InheritsParameterSpec(ProcessorContext context, String name, TypeMirror... allowedTypes) { | |
103 super(name, Arrays.asList(allowedTypes)); | 101 super(name, Arrays.asList(allowedTypes)); |
104 this.context = context; | |
105 } | 102 } |
106 | 103 |
107 @Override | 104 @Override |
108 public boolean matches(TypeMirror actualType) { | 105 public boolean matches(TypeMirror actualType) { |
109 boolean found = false; | 106 boolean found = false; |
110 for (TypeMirror specType : getAllowedTypes()) { | 107 for (TypeMirror specType : getAllowedTypes()) { |
111 if (Utils.isAssignable(context, actualType, specType)) { | 108 if (Utils.isAssignable(actualType, specType)) { |
112 found = true; | 109 found = true; |
113 break; | 110 break; |
114 } | 111 } |
115 } | 112 } |
116 return found; | 113 return found; |