use of com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder in project graal by oracle.
the class NodeFactoryFactory method createCreateGetExecutionSignature.
private CodeExecutableElement createCreateGetExecutionSignature() {
TypeMirror returnValue = ElementUtils.getDeclaredType(ElementUtils.fromTypeMirror(context.getType(List.class)));
CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), returnValue, "getExecutionSignature");
CodeTreeBuilder builder = method.createBuilder();
builder.startReturn();
builder.startStaticCall(context.getType(Arrays.class), "asList");
for (NodeExecutionData execution : node.getChildExecutions()) {
builder.typeLiteral(execution.getNodeType());
}
builder.end();
builder.end();
return method;
}
use of com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder in project graal by oracle.
the class NodeFactoryFactory method createCreateMethod.
private CodeExecutableElement createCreateMethod(ExecutableElement constructor) {
CodeExecutableElement method = CodeExecutableElement.clone(context.getEnvironment(), constructor);
method.setSimpleName(CodeNames.of("create"));
method.getModifiers().clear();
method.getModifiers().add(Modifier.PUBLIC);
method.getModifiers().add(Modifier.STATIC);
method.setReturnType(node.getNodeType());
CodeTreeBuilder body = method.createBuilder();
body.startReturn();
if (node.getSpecializations().isEmpty()) {
body.nullLiteral();
} else {
body.startNew(NodeCodeGenerator.nodeType(node));
for (VariableElement var : method.getParameters()) {
body.string(var.getSimpleName().toString());
}
body.end();
}
body.end();
return method;
}
use of com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder in project graal by oracle.
the class TypeSystemCodeGenerator method check.
static CodeTree check(TypeSystemData typeSystem, TypeMirror type, CodeTree content) {
if (ElementUtils.isObject(type)) {
return content;
}
CodeTreeBuilder builder = CodeTreeBuilder.createBuilder();
TypeCheckData check = typeSystem.getCheck(type);
if (check == null) {
builder.instanceOf(content, ElementUtils.boxType(typeSystem.getContext(), type));
} else {
builder.startStaticCall(typeSystem.getTemplateType().asType(), check.getMethodName()).tree(content).end();
}
return builder.build();
}
use of com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder in project graal by oracle.
the class TypeSystemCodeGenerator method callImplictMethodFlat.
private static CodeTree callImplictMethodFlat(TypeSystemData typeSystem, TypeMirror type, String methodName, CodeTree value, CodeTree state) {
if (ElementUtils.isObject(type)) {
return value;
}
CodeTreeBuilder builder = CodeTreeBuilder.createBuilder();
builder.startStaticCall(createTypeSystemGen(typeSystem), methodName);
if (state != null) {
builder.tree(state);
}
builder.tree(value);
builder.end();
return builder.build();
}
use of com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder in project graal by oracle.
the class TypeSystemCodeGenerator method invokeImplicitCast.
static CodeTree invokeImplicitCast(TypeSystemData typeSystem, ImplicitCastData cast, CodeTree expression) {
CodeTreeBuilder builder = CodeTreeBuilder.createBuilder();
builder.startStaticCall(createTypeSystemGen(typeSystem), cast.getMethodName()).tree(expression);
builder.end();
return builder.build();
}
Aggregations