comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @ 16907:09d99d3c0c95

Truffle-DSL: made guard parsing more robust.
author Christian Humer <christian.humer@gmail.com>
date Sat, 23 Aug 2014 19:31:09 +0200
parents 2db61eddcb97
children 59bf50cc5a32
comparison
equal deleted inserted replaced
16906:8eca9a00aaba 16907:09d99d3c0c95
947 expression.setResolvedChildren(resolvedExecutions); 947 expression.setResolvedChildren(resolvedExecutions);
948 } 948 }
949 949
950 GuardParser parser = new GuardParser(context, node, source, expression); 950 GuardParser parser = new GuardParser(context, node, source, expression);
951 List<GuardData> matchingGuards = parser.parse(availableGuards); 951 List<GuardData> matchingGuards = parser.parse(availableGuards);
952 if (!matchingGuards.isEmpty()) { 952 if (!matchingGuards.isEmpty() && matchingGuards.get(0) != null) {
953 GuardData guard = matchingGuards.get(0); 953 expression.setResolvedGuard(matchingGuards.get(0));
954 // use the shared instance of the guard data
955 expression.setResolvedGuard(guard);
956 } else { 954 } else {
957 MethodSpec spec = parser.createSpecification(source.getMethod(), source.getMarkerAnnotation()); 955 MethodSpec spec = parser.createSpecification(source.getMethod(), source.getMarkerAnnotation());
958 spec.applyTypeDefinitions("types"); 956 spec.applyTypeDefinitions("types");
959 source.addError("No guard with name '%s' matched the required signature. Expected signature: %n%s", expression.getGuardName(), spec.toSignatureString("guard")); 957 source.addError("No guard with name '%s' matched the required signature. Expected signature: %n%s", expression.getGuardName(), spec.toSignatureString("guard"));
960 } 958 }