use of com.oracle.truffle.dsl.processor.expression.DSLExpression.DSLExpressionReducer in project graal by oracle.
the class CacheExpression method getMergedLibraryIdentifier.
public String getMergedLibraryIdentifier() {
DSLExpression identifierExpression = getDefaultExpression().reduce(new DSLExpressionReducer() {
public DSLExpression visitVariable(Variable binary) {
if (binary.getReceiver() == null) {
Variable var = new Variable(binary.getReceiver(), "receiver");
var.setResolvedTargetType(binary.getResolvedTargetType());
var.setResolvedVariable(new CodeVariableElement(binary.getResolvedType(), "receiver"));
return var;
} else {
return binary;
}
}
public DSLExpression visitNegate(Negate negate) {
return negate;
}
public DSLExpression visitCall(Call binary) {
return binary;
}
public DSLExpression visitBinary(Binary binary) {
return binary;
}
});
String expressionText = identifierExpression.asString();
StringBuilder b = new StringBuilder(expressionText);
boolean nextUpperCase = false;
int i = 0;
while (i < b.length()) {
char charAt = b.charAt(i);
if (!Character.isJavaIdentifierPart(charAt)) {
b.deleteCharAt(i);
nextUpperCase = true;
} else if (nextUpperCase) {
nextUpperCase = false;
if (i != 0) {
b.setCharAt(i, Character.toUpperCase(b.charAt(i)));
}
i++;
} else {
i++;
}
}
String libraryName = ElementUtils.getSimpleName(getParameter().getType());
return b.toString() + libraryName + "_";
}
Aggregations