Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java @ 19289:62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 03 Feb 2015 15:07:07 +0100 |
parents | 08aa0372dad4 |
children | b31b2f289e7d |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java Mon Dec 29 18:32:03 2014 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java Tue Feb 03 15:07:07 2015 +0100 @@ -36,8 +36,23 @@ return Parser.parse(input); } - public final List<Variable> findBoundVariables() { - final List<Variable> variables = new ArrayList<>(); + public final Set<VariableElement> findBoundVariableElements() { + final Set<VariableElement> variables = new HashSet<>(); + this.accept(new AbstractDSLExpressionVisitor() { + + @Override + public void visitVariable(Variable variable) { + if (variable.getReceiver() == null) { + variables.add(variable.getResolvedVariable()); + } + } + + }); + return variables; + } + + public final Set<Variable> findBoundVariables() { + final Set<Variable> variables = new HashSet<>(); this.accept(new AbstractDSLExpressionVisitor() { @Override @@ -52,12 +67,7 @@ } public final boolean isVariableBound(VariableElement variableElement) { - for (Variable variable : findBoundVariables()) { - if (variable.getResolvedVariable() == variableElement) { - return true; - } - } - return false; + return findBoundVariableElements().contains(variableElement); } public abstract TypeMirror getResolvedType(); @@ -217,7 +227,11 @@ @Override public TypeMirror getResolvedType() { - return resolvedMethod != null ? resolvedMethod.getReturnType() : null; + if (resolvedMethod.getKind() == ElementKind.CONSTRUCTOR) { + return resolvedMethod.getEnclosingElement().asType(); + } else { + return resolvedMethod != null ? resolvedMethod.getReturnType() : null; + } } public ExecutableElement getResolvedMethod() {