当前位置: 首页>>代码示例>>Java>>正文


Java Expression.getToken方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.ir.Expression.getToken方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.getToken方法的具体用法?Java Expression.getToken怎么用?Java Expression.getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.ir.Expression的用法示例。


在下文中一共展示了Expression.getToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newExpression

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:Parser.java

示例2: referenceError

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Parser.java

示例3: referenceError

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
    if (env._parse_only || 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Parser.java

示例4: newExpression

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
/**
 * 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();

    if (type == PERIOD && isES6()) {
        next();
        if (type == IDENT && "target".equals(getValue())) {
            if (lc.getCurrentFunction().isProgram()) {
                throw error(AbstractParser.message("new.target.in.function"), token);
            }
            next();
            markNewTarget(lc);
            return new IdentNode(newToken, finish, "new.target");
        } else {
            throw error(AbstractParser.message("expected.target"), token);
        }
    }

    // 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:Parser.java


注:本文中的jdk.nashorn.internal.ir.Expression.getToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。