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


Java Expression.isAlwaysFalse方法代码示例

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


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

示例1: enterDoWhile

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
private void enterDoWhile(final WhileNode whileNode) {
    final int liveLocalsOnContinueOrBreak = method.getUsedSlotsWithLiveTemporaries();
    method.beforeJoinPoint(whileNode);

    final Block body = whileNode.getBody();
    body.accept(this);

    emitContinueLabel(whileNode.getContinueLabel(), liveLocalsOnContinueOrBreak);
    if(method.isReachable()) {
        lineNumber(whileNode);
        final JoinPredecessorExpression test = whileNode.getTest();
        final Label bodyEntryLabel = body.getEntryLabel();
        final boolean testHasLiveConversion = LocalVariableConversion.hasLiveConversion(test);
        if(Expression.isAlwaysFalse(test)) {
            loadAndDiscard(test);
            if(testHasLiveConversion) {
                method.beforeJoinPoint(test);
            }
        } else if(testHasLiveConversion) {
            // If we have conversions after the test in do-while, they need to be effected on both branches.
            final Label beforeExit = new Label("do_while_preexit");
            emitBranch(test.getExpression(), beforeExit, false);
            method.beforeJoinPoint(test);
            method._goto(bodyEntryLabel);
            method.label(beforeExit);
            method.beforeJoinPoint(test);
        } else {
            emitBranch(test.getExpression(), bodyEntryLabel, true);
        }
    }
    method.breakLabel(whileNode.getBreakLabel(), liveLocalsOnContinueOrBreak);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:CodeGenerator.java

示例2: enterIfNode

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
@Override
public boolean enterIfNode(final IfNode ifNode) {
    if(!method.isReachable()) {
        return false;
    }
    enterStatement(ifNode);

    final Expression test = ifNode.getTest();
    final Block pass = ifNode.getPass();
    final Block fail = ifNode.getFail();

    if (Expression.isAlwaysTrue(test)) {
        loadAndDiscard(test);
        pass.accept(this);
        return false;
    } else if (Expression.isAlwaysFalse(test)) {
        loadAndDiscard(test);
        if (fail != null) {
            fail.accept(this);
        }
        return false;
    }

    final boolean hasFailConversion = LocalVariableConversion.hasLiveConversion(ifNode);

    final Label failLabel  = new Label("if_fail");
    final Label afterLabel = (fail == null && !hasFailConversion) ? null : new Label("if_done");

    emitBranch(test, failLabel, false);

    pass.accept(this);
    if(method.isReachable() && afterLabel != null) {
        method._goto(afterLabel); //don't fallthru to fail block
    }
    method.label(failLabel);

    if (fail != null) {
        fail.accept(this);
    } else if(hasFailConversion) {
        method.beforeJoinPoint(ifNode);
    }

    if(afterLabel != null && afterLabel.isReachable()) {
        method.label(afterLabel);
    }

    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:CodeGenerator.java

示例3: enterForOrWhile

import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
private void enterForOrWhile(final LoopNode loopNode, final JoinPredecessorExpression modify) {
    // NOTE: the usual pattern for compiling test-first loops is "GOTO test; body; test; IFNE body". We use the less
    // conventional "test; IFEQ break; body; GOTO test; break;". It has one extra unconditional GOTO in each repeat
    // of the loop, but it's not a problem for modern JIT compilers. We do this because our local variable type
    // tracking is unfortunately not really prepared for out-of-order execution, e.g. compiling the following
    // contrived but legal JavaScript code snippet would fail because the test changes the type of "i" from object
    // to double: var i = {valueOf: function() { return 1} }; while(--i >= 0) { ... }
    // Instead of adding more complexity to the local variable type tracking, we instead choose to emit this
    // different code shape.
    final int liveLocalsOnBreak = method.getUsedSlotsWithLiveTemporaries();
    final JoinPredecessorExpression test = loopNode.getTest();
    if(Expression.isAlwaysFalse(test)) {
        loadAndDiscard(test);
        return;
    }

    method.beforeJoinPoint(loopNode);

    final Label continueLabel = loopNode.getContinueLabel();
    final Label repeatLabel = modify != null ? new Label("for_repeat") : continueLabel;
    method.label(repeatLabel);
    final int liveLocalsOnContinue = method.getUsedSlotsWithLiveTemporaries();

    final Block   body                  = loopNode.getBody();
    final Label   breakLabel            = loopNode.getBreakLabel();
    final boolean testHasLiveConversion = test != null && LocalVariableConversion.hasLiveConversion(test);

    if(Expression.isAlwaysTrue(test)) {
        if(test != null) {
            loadAndDiscard(test);
            if(testHasLiveConversion) {
                method.beforeJoinPoint(test);
            }
        }
    } else if (test != null) {
        if (testHasLiveConversion) {
            emitBranch(test.getExpression(), body.getEntryLabel(), true);
            method.beforeJoinPoint(test);
            method._goto(breakLabel);
        } else {
            emitBranch(test.getExpression(), breakLabel, false);
        }
    }

    body.accept(this);
    if(repeatLabel != continueLabel) {
        emitContinueLabel(continueLabel, liveLocalsOnContinue);
    }

    if (loopNode.hasPerIterationScope() && lc.getCurrentBlock().needsScope()) {
        // ES6 for loops with LET init need a new scope for each iteration. We just create a shallow copy here.
        method.loadCompilerConstant(SCOPE);
        method.invoke(virtualCallNoLookup(ScriptObject.class, "copy", ScriptObject.class));
        method.storeCompilerConstant(SCOPE);
    }

    if(method.isReachable()) {
        if(modify != null) {
            lineNumber(loopNode);
            loadAndDiscard(modify);
            method.beforeJoinPoint(modify);
        }
        method._goto(repeatLabel);
    }

    method.breakLabel(breakLabel, liveLocalsOnBreak);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:CodeGenerator.java


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