Search in sources :

Example 1 with CodeTreeKind

use of com.oracle.truffle.dsl.processor.java.model.CodeTreeKind in project graal by oracle.

the class AbstractCodeWriter method visitTree.

@Override
public void visitTree(CodeTree e, Void p, Element enclosingElement) {
    CodeTreeKind kind = e.getCodeKind();
    switch(kind) {
        case COMMA_GROUP:
            List<CodeTree> children = e.getEnclosedElements();
            if (children != null) {
                for (int i = 0; i < children.size(); i++) {
                    visitTree(children.get(i), p, enclosingElement);
                    if (i < e.getEnclosedElements().size() - 1) {
                        write(", ");
                    }
                }
            }
            break;
        case GROUP:
            super.visitTree(e, p, enclosingElement);
            break;
        case INDENT:
            indent(1);
            super.visitTree(e, p, enclosingElement);
            dedent(1);
            break;
        case NEW_LINE:
            writeLn();
            break;
        case STRING:
            if (e.getString() != null) {
                write(e.getString());
            } else {
                write("null");
            }
            break;
        case STATIC_FIELD_REFERENCE:
            if (e.getString() != null) {
                write(imports.createStaticFieldReference(enclosingElement, e.getType(), e.getString()));
            } else {
                write("null");
            }
            break;
        case STATIC_METHOD_REFERENCE:
            if (e.getString() != null) {
                write(imports.createStaticMethodReference(enclosingElement, e.getType(), e.getString()));
            } else {
                write("null");
            }
            break;
        case TYPE:
            write(useImport(enclosingElement, e.getType()));
            break;
        default:
            assert false;
            return;
    }
}
Also used : CodeTreeKind(com.oracle.truffle.dsl.processor.java.model.CodeTreeKind) CodeTree(com.oracle.truffle.dsl.processor.java.model.CodeTree)

Aggregations

CodeTree (com.oracle.truffle.dsl.processor.java.model.CodeTree)1 CodeTreeKind (com.oracle.truffle.dsl.processor.java.model.CodeTreeKind)1