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


Java IfNode.getFail方法代码示例

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


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

示例1: enterIfNode

import jdk.nashorn.internal.ir.IfNode; //导入方法依赖的package包/类
@Override
public boolean enterIfNode(final IfNode ifNode) {
    enterDefault(ifNode);

    type("IfStatement");
    comma();

    property("test");
    ifNode.getTest().accept(this);
    comma();

    property("consequent");
    ifNode.getPass().accept(this);
    final Node elsePart = ifNode.getFail();
    comma();

    property("alternate");
    if (elsePart != null) {
        elsePart.accept(this);
    } else {
        nullValue();
    }

    return leave();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:JSONWriter.java

示例2: leaveIfNode

import jdk.nashorn.internal.ir.IfNode; //导入方法依赖的package包/类
@Override
public Node leaveIfNode(final IfNode ifNode) {
    final Node test = ifNode.getTest();
    if (test instanceof LiteralNode.PrimitiveLiteralNode) {
        final boolean isTrue = ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue();
        final Block executed = isTrue ? ifNode.getPass() : ifNode.getFail();
        final Block dropped  = isTrue ? ifNode.getFail() : ifNode.getPass();
        final List<Statement> statements = new ArrayList<>();

        if (executed != null) {
            statements.addAll(executed.getStatements()); // Get statements form executed branch
        }
        if (dropped != null) {
            extractVarNodes(dropped, statements); // Get var-nodes from non-executed branch
        }
        if (statements.isEmpty()) {
            return new EmptyNode(ifNode);
        }
        return BlockStatement.createReplacement(ifNode, ifNode.getFinish(), statements);
    }
    return ifNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:FoldConstants.java

示例3: leaveIfNode

import jdk.nashorn.internal.ir.IfNode; //导入方法依赖的package包/类
@Override
public Node leaveIfNode(final IfNode ifNode) {
    final Node test = ifNode.getTest();
    if (test instanceof LiteralNode.PrimitiveLiteralNode) {
        final boolean isTrue = ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue();
        final Block executed = isTrue ? ifNode.getPass() : ifNode.getFail();
        final Block dropped  = isTrue ? ifNode.getFail() : ifNode.getPass();
        final List<Statement> statements = new ArrayList<>();

        if (executed != null) {
            statements.addAll(executed.getStatements()); // Get statements form executed branch
        }
        if (dropped != null) {
            extractVarNodesFromDeadCode(dropped, statements); // Get var-nodes from non-executed branch
        }
        if (statements.isEmpty()) {
            return new EmptyNode(ifNode);
        }
        return BlockStatement.createReplacement(ifNode, ifNode.getFinish(), statements);
    }
    return ifNode;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:FoldConstants.java

示例4: enterIfNode

import jdk.nashorn.internal.ir.IfNode; //导入方法依赖的package包/类
@Override
public boolean enterIfNode(final IfNode ifNode) {
    ifNode.toString(sb);
    ifNode.getPass().accept(this);

    final Block fail = ifNode.getFail();

    if (fail != null) {
        sb.append(" else ");
        fail.accept(this);
    }

    return false;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:15,代码来源:PrintVisitor.java

示例5: enterIfNode

import jdk.nashorn.internal.ir.IfNode; //导入方法依赖的package包/类
@Override
public boolean enterIfNode(final IfNode ifNode) {
    lineNumber(ifNode);

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

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

    new BranchOptimizer(this, method).execute(test, failLabel, false);

    boolean passTerminal = false;
    boolean failTerminal = false;

    pass.accept(this);
    if (!pass.hasTerminalFlags()) {
        method._goto(afterLabel); //don't fallthru to fail block
    } else {
        passTerminal = pass.isTerminal();
    }

    if (fail != null) {
        method.label(failLabel);
        fail.accept(this);
        failTerminal = fail.isTerminal();
    }

    //if if terminates, put the after label there
    if (!passTerminal || !failTerminal) {
        method.label(afterLabel);
    }

    return false;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:37,代码来源:CodeGenerator.java

示例6: leaveIfNode

import jdk.nashorn.internal.ir.IfNode; //导入方法依赖的package包/类
@Override
public Node leaveIfNode(final IfNode ifNode) {
    final Node test = ifNode.getTest();
    if (test instanceof LiteralNode) {
        final Block shortCut = ((LiteralNode<?>)test).isTrue() ? ifNode.getPass() : ifNode.getFail();
        if (shortCut != null) {
            return new BlockStatement(ifNode.getLineNumber(), shortCut);
        }
        return new EmptyNode(ifNode);
    }
    return ifNode;
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:13,代码来源:FoldConstants.java

示例7: enterIfNode

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

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

    test.accept(this);

    final Map<Symbol, LvarType> afterTestLvarTypes = localVariableTypes;
    if(!isAlwaysFalse(test)) {
        pass.accept(this);
    }
    final Map<Symbol, LvarType> passLvarTypes = localVariableTypes;
    final boolean reachableFromPass = reachable;

    reachable = true;
    localVariableTypes = afterTestLvarTypes;
    if(!isAlwaysTrue(test) && fail != null) {
        fail.accept(this);
        final boolean reachableFromFail = reachable;
        reachable |= reachableFromPass;
        if(!reachable) {
            return false;
        }

        if(reachableFromFail) {
            if(reachableFromPass) {
                final Map<Symbol, LvarType> failLvarTypes = localVariableTypes;
                localVariableTypes = getUnionTypes(passLvarTypes, failLvarTypes);
                setConversion(pass, passLvarTypes, localVariableTypes);
                setConversion(fail, failLvarTypes, localVariableTypes);
            }
            return false;
        }
    }

    if(reachableFromPass) {
        localVariableTypes = getUnionTypes(afterTestLvarTypes, passLvarTypes);
        // IfNode itself is associated with conversions that might need to be performed after the test if there's no
        // else branch. E.g.
        // if(x = 1, cond) { x = 1.0 } must widen "x = 1" to a double.
        setConversion(pass, passLvarTypes, localVariableTypes);
        setConversion(ifNode, afterTestLvarTypes, localVariableTypes);
    } else {
        localVariableTypes = afterTestLvarTypes;
    }

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

示例8: enterIfNode

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


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