• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UnaryNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



UnaryNode类属于jdk.nashorn.internal.ir包,在下文中一共展示了UnaryNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: leaveTYPEOF

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add((Expression)LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName()).accept(this)); //null
    } else {
        args.add(rhs);
        args.add((Expression)LiteralNode.newInstance(unaryNode).accept(this)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args).accept(this);

    end(unaryNode);

    return runtimeNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:AssignSymbols.java


示例2: branchOptimizer

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private void branchOptimizer(final UnaryNode unaryNode, final Label label, final boolean state) {
    final Expression rhs = unaryNode.getExpression();

    switch (unaryNode.tokenType()) {
    case NOT:
        branchOptimizer(rhs, label, !state);
        return;
    default:
        if (unaryNode.getType().isBoolean()) {
            branchOptimizer(rhs, label, state);
            return;
        }
        break;
    }

    loadTestAndJump(unaryNode, label, state);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:BranchOptimizer.java


示例3: loadNOT

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private void loadNOT(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    if(expr instanceof UnaryNode && expr.isTokenType(TokenType.NOT)) {
        // !!x is idiomatic boolean cast in JavaScript
        loadExpressionAsBoolean(((UnaryNode)expr).getExpression());
    } else {
        final Label trueLabel  = new Label("true");
        final Label afterLabel = new Label("after");

        emitBranch(expr, trueLabel, true);
        method.load(true);
        method._goto(afterLabel);
        method.label(trueLabel);
        method.load(false);
        method.label(afterLabel);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:CodeGenerator.java


示例4: loadSUB

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private void loadSUB(final UnaryNode unaryNode, final TypeBounds resultBounds) {
    final Type type = unaryNode.getType();
    assert type.isNumeric();
    final TypeBounds numericBounds = resultBounds.booleanToInt();
    new OptimisticOperation(unaryNode, numericBounds) {
        @Override
        void loadStack() {
            final Expression expr = unaryNode.getExpression();
            loadExpression(expr, numericBounds.notWiderThan(Type.NUMBER));
        }
        @Override
        void consumeStack() {
            // Must do an explicit conversion to the operation's type when it's double so that we correctly handle
            // negation of an int 0 to a double -0. With this, we get the correct negation of a local variable after
            // it deoptimized, e.g. "iload_2; i2d; dneg". Without this, we get "iload_2; ineg; i2d".
            if(type.isNumber()) {
                method.convert(type);
            }
            method.neg(getProgramPoint());
        }
    }.emit();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:CodeGenerator.java


示例5: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    if (unaryNode.isTokenType(TokenType.NEW)) {
        curExpr = new NewTreeImpl(unaryNode,
                translateExpr(unaryNode.getExpression()));
    } else if (unaryNode.isTokenType(TokenType.YIELD) ||
            unaryNode.isTokenType(TokenType.YIELD_STAR)) {
        curExpr = new YieldTreeImpl(unaryNode,
                translateExpr(unaryNode.getExpression()));
    } else if (unaryNode.isTokenType(TokenType.SPREAD_ARGUMENT) ||
            unaryNode.isTokenType(TokenType.SPREAD_ARRAY)) {
        curExpr = new SpreadTreeImpl(unaryNode,
                translateExpr(unaryNode.getExpression()));
    } else {
        curExpr = new UnaryTreeImpl(unaryNode,
                translateExpr(unaryNode.getExpression()));
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:IRTranslator.java


示例6: enterLiteralNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
    if (literalNode.isArray()) {
        if (((LiteralNode.ArrayLiteralNode)literalNode).hasSpread() && ((LiteralNode.ArrayLiteralNode)literalNode).hasTrailingComma()) {
            throw error("Rest element must be last", literalNode.getElementExpressions().get(literalNode.getElementExpressions().size() - 1).getToken());
        }
        boolean restElement = false;
        for (final Expression element : literalNode.getElementExpressions()) {
            if (element != null) {
                if (restElement) {
                    throw error("Unexpected element after rest element", element.getToken());
                }
                if (element.isTokenType(SPREAD_ARRAY)) {
                    restElement = true;
                    final Expression lvalue = ((UnaryNode) element).getExpression();
                    verifySpreadElement(lvalue);
                }
                element.accept(this);
            }
        }
        return false;
    } else {
        return enterDefault(literalNode);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Parser.java


示例7: leaveTYPEOF

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:AssignSymbols.java


示例8: newExpression

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的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


示例9: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public final boolean enterUnaryNode(final UnaryNode unaryNode) {
    switch (unaryNode.tokenType()) {
    case ADD:
        return enterADD(unaryNode);
    case BIT_NOT:
        return enterBIT_NOT(unaryNode);
    case DELETE:
        return enterDELETE(unaryNode);
    case NEW:
        return enterNEW(unaryNode);
    case NOT:
        return enterNOT(unaryNode);
    case SUB:
        return enterSUB(unaryNode);
    case TYPEOF:
        return enterTYPEOF(unaryNode);
    case VOID:
        return enterVOID(unaryNode);
    case DECPREFIX:
    case DECPOSTFIX:
    case INCPREFIX:
    case INCPOSTFIX:
        return enterDECINC(unaryNode);
    default:
        return super.enterUnaryNode(unaryNode);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:NodeOperatorVisitor.java


示例10: leaveUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public final Node leaveUnaryNode(final UnaryNode unaryNode) {
    switch (unaryNode.tokenType()) {
    case ADD:
        return leaveADD(unaryNode);
    case BIT_NOT:
        return leaveBIT_NOT(unaryNode);
    case DELETE:
        return leaveDELETE(unaryNode);
    case NEW:
        return leaveNEW(unaryNode);
    case NOT:
        return leaveNOT(unaryNode);
    case SUB:
        return leaveSUB(unaryNode);
    case TYPEOF:
        return leaveTYPEOF(unaryNode);
    case VOID:
        return leaveVOID(unaryNode);
    case DECPREFIX:
    case DECPOSTFIX:
    case INCPREFIX:
    case INCPOSTFIX:
        return leaveDECINC(unaryNode);
    default:
        return super.leaveUnaryNode(unaryNode);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:NodeOperatorVisitor.java


示例11: leaveUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public Node leaveUnaryNode(final UnaryNode unaryNode) {
    if (unaryNode.isAssignment() && unaryNode.getExpression() instanceof IdentNode) {
        checkConstAssignment((IdentNode) unaryNode.getExpression());
    }
    switch (unaryNode.tokenType()) {
    case DELETE:
        return leaveDELETE(unaryNode);
    case TYPEOF:
        return leaveTYPEOF(unaryNode);
    default:
        return super.leaveUnaryNode(unaryNode);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:AssignSymbols.java


示例12: leaveUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public Node leaveUnaryNode(final UnaryNode unaryNode) {
    final LiteralNode<?> literalNode = new UnaryNodeConstantEvaluator(unaryNode).eval();
    if (literalNode != null) {
        log.info("Unary constant folded ", unaryNode, " to ", literalNode);
        return literalNode;
    }
    return unaryNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:FoldConstants.java


示例13: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    if(unaryNode.isTokenType(TokenType.NOT) || unaryNode.isTokenType(TokenType.NEW)) {
        // Operand of boolean negation is never optimistic (always coerced to boolean).
        // Operand of "new" is never optimistic (always coerced to Object).
        tagNeverOptimistic(unaryNode.getExpression());
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:OptimisticTypesCalculator.java


示例14: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    expr.accept(this);

    if(unaryNode.isSelfModifying()) {
        if(expr instanceof IdentNode) {
            final IdentNode ident = (IdentNode)expr;
            onSelfAssignment(ident, unaryNode, getLocalVariableTypeIfBytecode(ident.getSymbol()));
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:LocalVariableTypesCalculator.java


示例15: loadADD

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private void loadADD(final UnaryNode unaryNode, final TypeBounds resultBounds) {
    loadExpression(unaryNode.getExpression(), resultBounds.booleanToInt().notWiderThan(Type.NUMBER));
    if(method.peekType() == Type.BOOLEAN) {
        // It's a no-op in bytecode, but we must make sure it is treated as an int for purposes of type signatures
        method.convert(Type.INT);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:CodeGenerator.java


示例16: loadNEW

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
private void loadNEW(final UnaryNode unaryNode) {
    final CallNode callNode = (CallNode)unaryNode.getExpression();
    final List<Expression> args   = callNode.getArgs();

    // Load function reference.
    loadExpressionAsObject(callNode.getFunction()); // must detect type error

    method.dynamicNew(1 + loadArgs(args), getCallSiteFlags());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:CodeGenerator.java


示例17: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    if (unaryNode.isTokenType(SPREAD_ARRAY)) {
        // rest element
        return true;
    } else {
        return enterDefault(unaryNode);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Parser.java


示例18: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    unaryNode.toString(sb, new Runnable() {
        @Override
        public void run() {
            unaryNode.getExpression().accept(PrintVisitor.this);
        }
    }, printTypes);
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:PrintVisitor.java


示例19: enterUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    switch (unaryNode.tokenType()) {
    case POS:
        return enterPOS(unaryNode);
    case BIT_NOT:
        return enterBIT_NOT(unaryNode);
    case DELETE:
        return enterDELETE(unaryNode);
    case NEW:
        return enterNEW(unaryNode);
    case NOT:
        return enterNOT(unaryNode);
    case NEG:
        return enterNEG(unaryNode);
    case TYPEOF:
        return enterTYPEOF(unaryNode);
    case VOID:
        return enterVOID(unaryNode);
    case DECPREFIX:
    case DECPOSTFIX:
    case INCPREFIX:
    case INCPOSTFIX:
        return enterDECINC(unaryNode);
    default:
        return super.enterUnaryNode(unaryNode);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:NodeOperatorVisitor.java


示例20: leaveUnaryNode

import jdk.nashorn.internal.ir.UnaryNode; //导入依赖的package包/类
@Override
public final Node leaveUnaryNode(final UnaryNode unaryNode) {
    switch (unaryNode.tokenType()) {
    case POS:
        return leavePOS(unaryNode);
    case BIT_NOT:
        return leaveBIT_NOT(unaryNode);
    case DELETE:
        return leaveDELETE(unaryNode);
    case NEW:
        return leaveNEW(unaryNode);
    case NOT:
        return leaveNOT(unaryNode);
    case NEG:
        return leaveNEG(unaryNode);
    case TYPEOF:
        return leaveTYPEOF(unaryNode);
    case VOID:
        return leaveVOID(unaryNode);
    case DECPREFIX:
    case DECPOSTFIX:
    case INCPREFIX:
    case INCPOSTFIX:
        return leaveDECINC(unaryNode);
    default:
        return super.leaveUnaryNode(unaryNode);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:NodeOperatorVisitor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IfNode类代码示例发布时间:2022-05-22
下一篇:
Java SampleQuantiles类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap