Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeCastParser.java @ 11467:43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 29 Aug 2013 19:19:00 +0200 |
parents | 79041ab43660 |
children |
comparison
equal
deleted
inserted
replaced
11466:4830676526e3 | 11467:43eab069ca9b |
---|---|
46 spec.addRequired(new ParameterSpec("value", getTypeSystem().getPrimitiveTypeMirrors())); | 46 spec.addRequired(new ParameterSpec("value", getTypeSystem().getPrimitiveTypeMirrors())); |
47 return spec; | 47 return spec; |
48 } | 48 } |
49 | 49 |
50 @Override | 50 @Override |
51 public TypeCastData create(TemplateMethod method) { | 51 public TypeCastData create(TemplateMethod method, boolean invalid) { |
52 if (invalid) { | |
53 return new TypeCastData(method, null, null); | |
54 } | |
55 | |
52 TypeData targetType = findTypeByMethodName(method, "as"); | 56 TypeData targetType = findTypeByMethodName(method, "as"); |
53 ActualParameter parameter = method.findParameter("valueValue"); | 57 ActualParameter parameter = method.findParameter("valueValue"); |
54 return new TypeCastData(method, parameter.getTypeSystemType(), targetType); | 58 |
59 TypeData sourceType = null; | |
60 if (parameter != null) { | |
61 sourceType = getTypeSystem().findTypeData(parameter.getType()); | |
62 } | |
63 TypeCastData cast = new TypeCastData(method, sourceType, targetType); | |
64 | |
65 if (targetType != method.getReturnType().getTypeSystemType()) { | |
66 cast.addError("Cast type %s does not match to the returned type %s.", Utils.getSimpleName(targetType.getPrimitiveType()), | |
67 method.getReturnType() != null ? Utils.getSimpleName(method.getReturnType().getTypeSystemType().getPrimitiveType()) : null); | |
68 } | |
69 return cast; | |
55 } | 70 } |
56 | 71 |
57 @Override | 72 @Override |
58 public Class<? extends Annotation> getAnnotationType() { | 73 public Class<? extends Annotation> getAnnotationType() { |
59 return TypeCast.class; | 74 return TypeCast.class; |