Java Code Examples for jdk.nashorn.internal.parser.TokenType#NEW

The following examples show how to use jdk.nashorn.internal.parser.TokenType#NEW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSONWriter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 2
Source File: JSONWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 3
Source File: JSONWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 4
Source File: JSONWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 5
Source File: JSONWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 6
Source File: JSONWriter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 7
Source File: JSONWriter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.rhs();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.rhs().accept(this);
    }

    return leave();
}
 
Example 8
Source File: JSONWriter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.rhs();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.rhs().accept(this);
    }

    return leave();
}
 
Example 9
Source File: JSONWriter.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 10
Source File: JSONWriter.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.rhs();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.rhs().accept(this);
    }

    return leave();
}