@Override public void visitVariable(Variable variable) { if (variable.getReceiver() == null) { variables.add(variable.getResolvedVariable()); } }
@Override public void visitVariable(Variable variable) { if (variable.getReceiver() == null) { variables.add(variable.getResolvedVariable()); } }
if (variable.getResolvedVariable() == null) { throw new InvalidExpressionException(String.format("%s cannot be resolved.", variable.getName()));
Parameter resolvedParameter = specialization.findByVariable(variable.getResolvedVariable()); if (resolvedParameter != null) { LocalVariable localVariable;
if (variable.getResolvedVariable() == null) { throw new InvalidExpressionException(String.format("%s cannot be resolved.", variable.getName()));
public void visitVariable(Variable variable) { VariableElement resolvedVariable = variable.getResolvedVariable(); CodeTree tree; if (variable.getResolvedType().getKind() == TypeKind.NULL) { tree = CodeTreeBuilder.singleString("null"); } else if (variable.getReceiver() == null) { if (isStatic(resolvedVariable)) { tree = staticReference(resolvedVariable); } else { tree = bindings.get(variable); boolean bound = true; if (tree == null) { tree = string(resolvedVariable.getSimpleName().toString()); bound = false; } if (root != null && !bound) { tree = combine(root, string("."), tree); } } } else { if (isStatic(resolvedVariable)) { throw new AssertionError("Static variables cannot have receivers."); } tree = combine(pop(), string("."), string(resolvedVariable.getSimpleName().toString())); } push(tree); }
private static Map<Variable, LocalVariable> bindExpressionValues(DSLExpression expression, SpecializationData specialization, LocalContext currentValues) throws AssertionError { Map<Variable, LocalVariable> bindings = new HashMap<>(); Set<Variable> boundVariables = expression.findBoundVariables(); if (specialization == null && !boundVariables.isEmpty()) { throw new AssertionError("Cannot bind guard variable in non-specialization group. yet."); } // resolve bindings for local context for (Variable variable : boundVariables) { Parameter resolvedParameter = specialization.findByVariable(variable.getResolvedVariable()); if (resolvedParameter != null) { LocalVariable localVariable; if (resolvedParameter.getSpecification().isSignature()) { NodeExecutionData execution = resolvedParameter.getSpecification().getExecution(); localVariable = currentValues.getValue(execution); } else { localVariable = currentValues.get(resolvedParameter.getLocalName()); } if (localVariable != null) { bindings.put(variable, localVariable); } } } return bindings; }
public void visitVariable(Variable variable) { VariableElement resolvedVariable = variable.getResolvedVariable(); CodeTree tree; if (variable.getResolvedType().getKind() == TypeKind.NULL) { tree = CodeTreeBuilder.singleString("null"); } else if (variable.getReceiver() == null) { if (isStatic(resolvedVariable)) { tree = staticReference(resolvedVariable); } else { tree = bindings.get(variable); boolean bound = true; if (tree == null) { tree = string(resolvedVariable.getSimpleName().toString()); bound = false; } if (root != null && !bound) { tree = combine(root, string("."), tree); } } } else { if (isStatic(resolvedVariable)) { throw new AssertionError("Static variables cannot have receivers."); } tree = combine(pop(), string("."), string(resolvedVariable.getSimpleName().toString())); } push(tree); }
private boolean isVariableAccessMember(Variable variable) { if (variable.getName().equals("null") && variable.getReceiver() == null) { return false; } Parameter p = specialization.findByVariable(variable.getResolvedVariable()); if (p == null && !variable.getResolvedVariable().getModifiers().contains(STATIC)) { DSLExpression receiver = variable.getReceiver(); if (receiver instanceof Variable) { return isVariableAccessMember((Variable) receiver); } else if (receiver instanceof Call) { return isMethodAccessMember((Call) receiver); } return true; } else if (p != null && p.getSpecification().isCached()) { return true; } return false; }
@Override public DSLExpression visitVariable(Variable binary) { // on the slow path we can assume all cache expressions inlined. for (CacheExpression cache : source.getCaches()) { if (ElementUtils.variableEquals(cache.getParameter().getVariableElement(), binary.getResolvedVariable())) { return cache.getExpression(); } } return super.visitVariable(binary); }
@Override public DSLExpression reduce(DSLExpressionReducer reducer) { DSLExpression newReceiver = null; if (receiver != null) { newReceiver = receiver.reduceImpl(reducer); } Variable c = this; if (newReceiver != receiver) { c = new Variable(newReceiver, getName()); c.setResolvedTargetType(getResolvedTargetType()); c.setResolvedVariable(getResolvedVariable()); } return reducer.visitVariable(c); }