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


Java TernaryNode类代码示例

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


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

示例1: enterTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    enterDefault(ternaryNode);

    type("ConditionalExpression");
    comma();

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

    property("consequent");
    ternaryNode.getTrueExpression().accept(this);
    comma();

    property("alternate");
    ternaryNode.getFalseExpression().accept(this);

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

示例2: enterTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    test.accept(this);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    if(!isAlwaysFalse(test)) {
        trueExpr.accept(this);
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    if(!isAlwaysTrue(test)) {
        falseExpr.accept(this);
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:LocalVariableTypesCalculator.java

示例3: loadTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void loadTernaryNode(final TernaryNode ternaryNode, final TypeBounds resultBounds) {
    final Expression test = ternaryNode.getTest();
    final JoinPredecessorExpression trueExpr  = ternaryNode.getTrueExpression();
    final JoinPredecessorExpression falseExpr = ternaryNode.getFalseExpression();

    final Label falseLabel = new Label("ternary_false");
    final Label exitLabel  = new Label("ternary_exit");

    final Type outNarrowest = Type.narrowest(resultBounds.widest, Type.generic(Type.widestReturnType(trueExpr.getType(), falseExpr.getType())));
    final TypeBounds outBounds = resultBounds.notNarrowerThan(outNarrowest);

    emitBranch(test, falseLabel, false);

    loadExpression(trueExpr.getExpression(), outBounds);
    assert Type.generic(method.peekType()) == outBounds.narrowest;
    method.beforeJoinPoint(trueExpr);
    method._goto(exitLabel);
    method.label(falseLabel);
    loadExpression(falseExpr.getExpression(), outBounds);
    assert Type.generic(method.peekType()) == outBounds.narrowest;
    method.beforeJoinPoint(falseExpr);
    method.label(exitLabel);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:CodeGenerator.java

示例4: loadTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void loadTernaryNode(final TernaryNode ternaryNode, final TypeBounds resultBounds) {
    final Expression test = ternaryNode.getTest();
    final JoinPredecessorExpression trueExpr  = ternaryNode.getTrueExpression();
    final JoinPredecessorExpression falseExpr = ternaryNode.getFalseExpression();

    final Label falseLabel = new Label("ternary_false");
    final Label exitLabel  = new Label("ternary_exit");

    final Type outNarrowest = Type.narrowest(resultBounds.widest, Type.generic(Type.widestReturnType(trueExpr.getType(), falseExpr.getType())));
    final TypeBounds outBounds = resultBounds.notNarrowerThan(outNarrowest);

    emitBranch(test, falseLabel, false);

    final boolean isCurrentDiscard = lc.popDiscardIfCurrent(ternaryNode);
    loadMaybeDiscard(isCurrentDiscard, trueExpr.getExpression(), outBounds);
    assert isCurrentDiscard || Type.generic(method.peekType()) == outBounds.narrowest;
    method.beforeJoinPoint(trueExpr);
    method._goto(exitLabel);
    method.label(falseLabel);
    loadMaybeDiscard(isCurrentDiscard, falseExpr.getExpression(), outBounds);
    assert isCurrentDiscard || Type.generic(method.peekType()) == outBounds.narrowest;
    method.beforeJoinPoint(falseExpr);
    method.label(exitLabel);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:CodeGenerator.java

示例5: branchOptimizer

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void branchOptimizer(final Expression node, final Label label, final boolean state) {
    if (!(node instanceof TernaryNode)) {

        if (node instanceof BinaryNode) {
            branchOptimizer((BinaryNode)node, label, state);
            return;
        }

        if (node instanceof UnaryNode) {
            branchOptimizer((UnaryNode)node, label, state);
            return;
        }
    }

    codegen.load(node, Type.BOOLEAN);
    if (state) {
        method.ifne(label);
    } else {
        method.ifeq(label);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:22,代码来源:BranchOptimizer.java

示例6: branchOptimizer

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void branchOptimizer(final Expression node, final Label label, final boolean state) {
    if (!(node instanceof TernaryNode)) {

        if (node instanceof BinaryNode) {
            branchOptimizer((BinaryNode)node, label, state);
            return;
        }

        if (node instanceof UnaryNode) {
            branchOptimizer((UnaryNode)node, label, state);
            return;
        }
    }

    load(node);
    method.convert(Type.BOOLEAN);
    if (state) {
        method.ifne(label);
    } else {
        method.ifeq(label);
    }
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:23,代码来源:BranchOptimizer.java

示例7: leaveTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
    final Node test = ternaryNode.getTest();
    if (test instanceof LiteralNode.PrimitiveLiteralNode) {
        return (((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression()).getExpression();
    }
    return ternaryNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:FoldConstants.java

示例8: enterTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    curExpr = new ConditionalExpressionTreeImpl(ternaryNode,
            translateExpr(ternaryNode.getTest()),
            translateExpr(ternaryNode.getTrueExpression()),
            translateExpr(ternaryNode.getFalseExpression()));
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:IRTranslator.java

示例9: ConditionalExpressionTreeImpl

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
ConditionalExpressionTreeImpl(final TernaryNode node,
        final ExpressionTree condExpr, final ExpressionTree trueExpr,
        final ExpressionTree falseExpr) {
    super(node);
    this.condExpr = condExpr;
    this.trueExpr = trueExpr;
    this.falseExpr = falseExpr;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:ConditionalExpressionTreeImpl.java

示例10: enterTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
    final Expression test = ternaryNode.getTest();
    final Expression trueExpr = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    visitExpression(test);

    final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
    final LvarType trueType;
    if(!isAlwaysFalse(test)) {
        trueType = visitExpression(trueExpr);
    } else {
        trueType = null;
    }
    final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
    localVariableTypes = testExitLvarTypes;
    final LvarType falseType;
    if(!isAlwaysTrue(test)) {
        falseType = visitExpression(falseExpr);
    } else {
        falseType = null;
    }
    final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
    localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
    setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
    setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);

    typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:LocalVariableTypesCalculator.java

示例11: leaveTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
    final Expression trueExpr  = ternaryNode.getTrueExpression();
    final Expression falseExpr = ternaryNode.getFalseExpression();

    ensureTypeNotUnknown(trueExpr);
    ensureTypeNotUnknown(falseExpr);

    final Type type = widestReturnType(trueExpr.getType(), falseExpr.getType());
    return end(ensureSymbol(type, ternaryNode));
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:12,代码来源:Attr.java

示例12: leaveTernaryNode

import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
    final Node test = ternaryNode.getTest();
    if (test instanceof LiteralNode.PrimitiveLiteralNode) {
        return ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression();
    }
    return ternaryNode;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:9,代码来源:FoldConstants.java


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