use of com.oracle.truffle.dsl.processor.expression.DSLExpression.DSLExpressionVisitor in project graal by oracle.
the class FlatNodeGenFactory method accessesCachedState.
private static boolean accessesCachedState(List<SpecializationData> specializations) {
final AtomicBoolean needsState = new AtomicBoolean(false);
for (final SpecializationData specialization : specializations) {
if (!specialization.getAssumptionExpressions().isEmpty()) {
needsState.set(true);
break;
}
for (GuardExpression expression : specialization.getGuards()) {
expression.getExpression().accept(new DSLExpressionVisitor() {
public void visitVariable(Variable binary) {
if (!needsState.get() && isVariableAccessMember(binary)) {
needsState.set(true);
}
}
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;
}
public void visitBooleanLiteral(BooleanLiteral binary) {
}
public void visitNegate(Negate negate) {
}
public void visitIntLiteral(IntLiteral binary) {
}
private boolean isMethodAccessMember(Call call) {
if (!call.getResolvedMethod().getModifiers().contains(STATIC)) {
DSLExpression receiver = call.getReceiver();
if (receiver instanceof Variable) {
return isVariableAccessMember((Variable) receiver);
} else if (receiver instanceof Call) {
return isMethodAccessMember((Call) receiver);
}
return true;
}
return false;
}
public void visitCall(Call call) {
if (!needsState.get() && isMethodAccessMember(call)) {
needsState.set(true);
}
}
public void visitBinary(Binary binary) {
}
});
}
}
boolean needsStat = needsState.get();
return needsStat;
}
Aggregations