Java Code Examples for jdk.nashorn.internal.ir.ForNode#getTest()

The following examples show how to use jdk.nashorn.internal.ir.ForNode#getTest() . 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: Lower.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForIn() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(newForNode.isForIn()) {
        // Wrap it in a block so its internally created iterator is restricted in scope
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 2
Source File: Lower.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForIn() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(newForNode.isForIn()) {
        // Wrap it in a block so its internally created iterator is restricted in scope
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 3
Source File: Lower.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForIn() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(newForNode.isForIn()) {
        // Wrap it in a block so its internally created iterator is restricted in scope
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 4
Source File: Lower.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForIn() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(newForNode.isForIn()) {
        // Wrap it in a block so its internally created iterator is restricted in scope
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 5
Source File: Lower.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForInOrOf() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(!es6 && newForNode.isForInOrOf()) {
        // Wrap it in a block so its internally created iterator is restricted in scope, unless we are running
        // in ES6 mode, in which case the parser already created a block to capture let/const declarations.
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 6
Source File: Lower.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForIn() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(newForNode.isForIn()) {
        // Wrap it in a block so its internally created iterator is restricted in scope
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 7
Source File: Lower.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Expression test = forNode.getTest();
    if (!forNode.isForIn() && isAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    newForNode = checkEscape(newForNode);
    if(newForNode.isForIn()) {
        // Wrap it in a block so its internally created iterator is restricted in scope
        addStatementEnclosedInBlock(newForNode);
    } else {
        addStatement(newForNode);
    }
    return newForNode;
}
 
Example 8
Source File: Lower.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Node  test = forNode.getTest();
    if (!forNode.isForIn() && conservativeAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    return addStatement(checkEscape(newForNode));
}
 
Example 9
Source File: CodeGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void enterFor(final ForNode forNode) {
    final Expression init   = forNode.getInit();
    final Expression test   = forNode.getTest();
    final Block      body   = forNode.getBody();
    final Expression modify = forNode.getModify();

    if (init != null) {
        init.accept(this);
    }

    final Label loopLabel = new Label("loop");
    final Label testLabel = new Label("test");

    method._goto(testLabel);
    method.label(loopLabel);
    body.accept(this);
    method.label(forNode.getContinueLabel());

    if (!body.isTerminal() && modify != null) {
        load(modify);
    }

    method.label(testLabel);
    if (test != null) {
        new BranchOptimizer(this, method).execute(test, loopLabel, true);
    } else {
        method._goto(loopLabel);
    }

    method.label(forNode.getBreakLabel());
}
 
Example 10
Source File: Lower.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Node  test = forNode.getTest();
    if (!forNode.isForIn() && conservativeAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    return addStatement(checkEscape(newForNode));
}
 
Example 11
Source File: CodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void enterFor(final ForNode forNode) {
    final Expression init   = forNode.getInit();
    final Expression test   = forNode.getTest();
    final Block      body   = forNode.getBody();
    final Expression modify = forNode.getModify();

    if (init != null) {
        init.accept(this);
    }

    final Label loopLabel = new Label("loop");
    final Label testLabel = new Label("test");

    method._goto(testLabel);
    method.label(loopLabel);
    body.accept(this);
    method.label(forNode.getContinueLabel());

    if (!body.isTerminal() && modify != null) {
        load(modify);
    }

    method.label(testLabel);
    if (test != null) {
        new BranchOptimizer(this, method).execute(test, loopLabel, true);
    } else {
        method._goto(loopLabel);
    }

    method.label(forNode.getBreakLabel());
}
 
Example 12
Source File: Lower.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Node leaveForNode(final ForNode forNode) {
    ForNode newForNode = forNode;

    final Node  test = forNode.getTest();
    if (!forNode.isForIn() && conservativeAlwaysTrue(test)) {
        newForNode = forNode.setTest(lc, null);
    }

    return addStatement(checkEscape(newForNode));
}
 
Example 13
Source File: CodeGenerator.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void enterFor(final ForNode forNode) {
    final Expression init   = forNode.getInit();
    final Expression test   = forNode.getTest();
    final Block      body   = forNode.getBody();
    final Expression modify = forNode.getModify();

    if (init != null) {
        init.accept(this);
    }

    final Label loopLabel = new Label("loop");
    final Label testLabel = new Label("test");

    method._goto(testLabel);
    method.label(loopLabel);
    body.accept(this);
    method.label(forNode.getContinueLabel());

    if (!body.isTerminal() && modify != null) {
        load(modify);
    }

    method.label(testLabel);
    if (test != null) {
        new BranchOptimizer(this, method).execute(test, loopLabel, true);
    } else {
        method._goto(loopLabel);
    }

    method.label(forNode.getBreakLabel());
}