Java Code Examples for jdk.nashorn.internal.ir.Expression#getToken()

The following examples show how to use jdk.nashorn.internal.ir.Expression#getToken() . 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: Parser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 2
Source File: Parser.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 3
Source File: Parser.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expresssion
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments));

    return new UnaryNode(newToken, callNode);
}
 
Example 4
Source File: Parser.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 5
Source File: Parser.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expression
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);

    return new UnaryNode(newToken, callNode);
}
 
Example 6
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 7
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expresssion
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments));

    return new UnaryNode(newToken, callNode);
}
 
Example 8
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 9
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expresssion
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments));

    return new UnaryNode(newToken, callNode);
}
 
Example 10
Source File: Parser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expression
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);

    return new UnaryNode(newToken, callNode);
}
 
Example 11
Source File: Parser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expression
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);

    return new UnaryNode(newToken, callNode);
}
 
Example 12
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 13
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expression
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);

    return new UnaryNode(newToken, callNode);
}
 
Example 14
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 15
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expression
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);

    return new UnaryNode(newToken, callNode);
}
 
Example 16
Source File: Parser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
 
Example 17
Source File: Parser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * NewExpression :
 *      MemberExpression
 *      new NewExpression
 *
 * See 11.2
 *
 * Parse new expression.
 * @return Expression node.
 */
private Expression newExpression() {
    final long newToken = token;
    // NEW is tested in caller.
    next();

    // Get function base.
    final int  callLine    = line;
    final Expression constructor = memberExpression();
    if (constructor == null) {
        return null;
    }
    // Get arguments.
    ArrayList<Expression> arguments;

    // Allow for missing arguments.
    if (type == LPAREN) {
        arguments = argumentList();
    } else {
        arguments = new ArrayList<>();
    }

    // Nashorn extension: This is to support the following interface implementation
    // syntax:
    //
    //     var r = new java.lang.Runnable() {
    //         run: function() { println("run"); }
    //     };
    //
    // The object literal following the "new Constructor()" expresssion
    // is passed as an additional (last) argument to the constructor.
    if (!env._no_syntax_extensions && type == LBRACE) {
        arguments.add(objectLiteral());
    }

    final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);

    return new UnaryNode(newToken, callNode);
}
 
Example 18
Source File: Parser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (earlyError) {
        throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
    }
    final ArrayList<Expression> args = new ArrayList<>();
    args.add(lhs);
    if (rhs == null) {
        args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
    } else {
        args.add(rhs);
    }
    args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
    return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}