Java 类jdk.nashorn.internal.ir.SwitchNode 实例源码

项目:openjdk-jdk10    文件:IRTranslator.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    final List<CaseNode> caseNodes = switchNode.getCases();
    final List<CaseTreeImpl> caseTrees = new ArrayList<>(caseNodes.size());
    for (final CaseNode caseNode : caseNodes) {
        final Block body = caseNode.getBody();
        caseTrees.add(
                new CaseTreeImpl(caseNode,
                        translateExpr(caseNode.getTest()),
                        translateStats(body != null? body.getStatements() : null)));
    }

    curStat = new SwitchTreeImpl(switchNode,
            translateExpr(switchNode.getExpression()),
            caseTrees);
    return false;
}
项目:openjdk9    文件:IRTranslator.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    final List<CaseNode> caseNodes = switchNode.getCases();
    final List<CaseTreeImpl> caseTrees = new ArrayList<>(caseNodes.size());
    for (final CaseNode caseNode : caseNodes) {
        final Block body = caseNode.getBody();
        caseTrees.add(
                new CaseTreeImpl(caseNode,
                        translateExpr(caseNode.getTest()),
                        translateStats(body != null? body.getStatements() : null)));
    }

    curStat = new SwitchTreeImpl(switchNode,
            translateExpr(switchNode.getExpression()),
            caseTrees);
    return false;
}
项目:OLD-OpenJDK8    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }

    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:nashorn-backport    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }

    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:nashorn-backport    文件:FinalizeTypes.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    final boolean allInteger = switchNode.getTag().getSymbolType().isInteger();

    if (allInteger) {
        return switchNode;
    }

    final Expression     expression  = switchNode.getExpression();
    final List<CaseNode> cases       = switchNode.getCases();
    final List<CaseNode> newCases    = new ArrayList<>();

    for (final CaseNode caseNode : cases) {
        final Expression test = caseNode.getTest();
        newCases.add(test != null ? caseNode.setTest(convert(test, Type.OBJECT)) : caseNode);
    }

    return switchNode.
        setExpression(lc, convert(expression, Type.OBJECT)).
        setCases(lc, newCases);
}
项目:nashorn    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }

    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:nashorn    文件:FinalizeTypes.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    final boolean allInteger = switchNode.getTag().getSymbolType().isInteger();

    if (allInteger) {
        return switchNode;
    }

    final Expression     expression  = switchNode.getExpression();
    final List<CaseNode> cases       = switchNode.getCases();
    final List<CaseNode> newCases    = new ArrayList<>();

    for (final CaseNode caseNode : cases) {
        final Expression test = caseNode.getTest();
        newCases.add(test != null ? caseNode.setTest(convert(test, Type.OBJECT)) : caseNode);
    }

    return switchNode.
        setExpression(lc, convert(expression, Type.OBJECT)).
        setCases(lc, newCases);
}
项目:OpenJSharp    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}
项目:OpenJSharp    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb, printTypes);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb, printTypes);
        printLocalVariableConversion(caseNode);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }
    if(switchNode.getLocalVariableConversion() != null) {
        sb.append(EOLN);
        indent();
        sb.append("default: ");
        printLocalVariableConversion(switchNode);
        sb.append("{}");
    }
    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:OpenJSharp    文件:AssignSymbols.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    // We only need a symbol for the tag if it's not an integer switch node
    if(!switchNode.isUniqueInteger()) {
        switchNode.setTag(newObjectInternal(SWITCH_TAG_PREFIX));
    }
    return switchNode;
}
项目:OpenJSharp    文件:FoldConstants.java   
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
    final Set<Integer> alreadySeen = new HashSet<>();
    for (final CaseNode caseNode : switchNode.getCases()) {
        final Expression test = caseNode.getTest();
        if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
            return false;
        }
    }
    return true;
}
项目:OpenJSharp    文件:Lower.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    if(!switchNode.isUniqueInteger()) {
        // Wrap it in a block so its internally created tag is restricted in scope
        addStatementEnclosedInBlock(switchNode);
    } else {
        addStatement(switchNode);
    }
    return switchNode;
}
项目:openjdk-jdk10    文件:SwitchTreeImpl.java   
SwitchTreeImpl(final SwitchNode node,
        final ExpressionTree expr,
        final List<? extends CaseTree> cases) {
    super(node);
    this.expr = expr;
    this.cases = cases;
}
项目:openjdk-jdk10    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}
项目:openjdk-jdk10    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb, printTypes);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb, printTypes);
        printLocalVariableConversion(caseNode);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }
    if(switchNode.getLocalVariableConversion() != null) {
        sb.append(EOLN);
        indent();
        sb.append("default: ");
        printLocalVariableConversion(switchNode);
        sb.append("{}");
    }
    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:openjdk-jdk10    文件:AssignSymbols.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    // We only need a symbol for the tag if it's not an integer switch node
    if(!switchNode.isUniqueInteger()) {
        return switchNode.setTag(lc, newObjectInternal(SWITCH_TAG_PREFIX));
    }
    return switchNode;
}
项目:openjdk-jdk10    文件:FoldConstants.java   
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
    final Set<Integer> alreadySeen = new HashSet<>();
    for (final CaseNode caseNode : switchNode.getCases()) {
        final Expression test = caseNode.getTest();
        if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
            return false;
        }
    }
    return true;
}
项目:openjdk-jdk10    文件:Lower.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    if(!switchNode.isUniqueInteger()) {
        // Wrap it in a block so its internally created tag is restricted in scope
        addStatementEnclosedInBlock(switchNode);
    } else {
        addStatement(switchNode);
    }
    return switchNode;
}
项目:openjdk9    文件:SwitchTreeImpl.java   
SwitchTreeImpl(final SwitchNode node,
        final ExpressionTree expr,
        List<? extends CaseTree> cases) {
    super(node);
    this.expr = expr;
    this.cases = cases;
}
项目:openjdk9    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}
项目:openjdk9    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb, printTypes);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb, printTypes);
        printLocalVariableConversion(caseNode);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }
    if(switchNode.getLocalVariableConversion() != null) {
        sb.append(EOLN);
        indent();
        sb.append("default: ");
        printLocalVariableConversion(switchNode);
        sb.append("{}");
    }
    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:openjdk9    文件:AssignSymbols.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    // We only need a symbol for the tag if it's not an integer switch node
    if(!switchNode.isUniqueInteger()) {
        return switchNode.setTag(lc, newObjectInternal(SWITCH_TAG_PREFIX));
    }
    return switchNode;
}
项目:openjdk9    文件:FoldConstants.java   
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
    final Set<Integer> alreadySeen = new HashSet<>();
    for (final CaseNode caseNode : switchNode.getCases()) {
        final Expression test = caseNode.getTest();
        if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
            return false;
        }
    }
    return true;
}
项目:openjdk9    文件:Lower.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    if(!switchNode.isUniqueInteger()) {
        // Wrap it in a block so its internally created tag is restricted in scope
        addStatementEnclosedInBlock(switchNode);
    } else {
        addStatement(switchNode);
    }
    return switchNode;
}
项目:kaziranga    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}
项目:kaziranga    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb, printTypes);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb, printTypes);
        printLocalVariableConversion(caseNode);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }
    if(switchNode.getLocalVariableConversion() != null) {
        sb.append(EOLN);
        indent();
        sb.append("default: ");
        printLocalVariableConversion(switchNode);
        sb.append("{}");
    }
    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:kaziranga    文件:AssignSymbols.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    // We only need a symbol for the tag if it's not an integer switch node
    if(!switchNode.isUniqueInteger()) {
        switchNode.setTag(newObjectInternal(SWITCH_TAG_PREFIX));
    }
    return switchNode;
}
项目:kaziranga    文件:FoldConstants.java   
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
    final Set<Integer> alreadySeen = new HashSet<>();
    for (final CaseNode caseNode : switchNode.getCases()) {
        final Expression test = caseNode.getTest();
        if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
            return false;
        }
    }
    return true;
}
项目:kaziranga    文件:Lower.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    if(!switchNode.isUniqueInteger()) {
        // Wrap it in a block so its internally created tag is restricted in scope
        addStatementEnclosedInBlock(switchNode);
    } else {
        addStatement(switchNode);
    }
    return switchNode;
}
项目:lookaside_java-1.8.0-openjdk    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}
项目:lookaside_java-1.8.0-openjdk    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb, printTypes);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb, printTypes);
        printLocalVariableConversion(caseNode);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }
    if(switchNode.getLocalVariableConversion() != null) {
        sb.append(EOLN);
        indent();
        sb.append("default: ");
        printLocalVariableConversion(switchNode);
        sb.append("{}");
    }
    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:AssignSymbols.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    // We only need a symbol for the tag if it's not an integer switch node
    if(!switchNode.isUniqueInteger()) {
        return switchNode.setTag(lc, newObjectInternal(SWITCH_TAG_PREFIX));
    }
    return switchNode;
}
项目:lookaside_java-1.8.0-openjdk    文件:FoldConstants.java   
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
    final Set<Integer> alreadySeen = new HashSet<>();
    for (final CaseNode caseNode : switchNode.getCases()) {
        final Expression test = caseNode.getTest();
        if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
            return false;
        }
    }
    return true;
}
项目:lookaside_java-1.8.0-openjdk    文件:Lower.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    if(!switchNode.isUniqueInteger()) {
        // Wrap it in a block so its internally created tag is restricted in scope
        addStatementEnclosedInBlock(switchNode);
    } else {
        addStatement(switchNode);
    }
    return switchNode;
}
项目:jdk8u_nashorn    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}
项目:jdk8u_nashorn    文件:PrintVisitor.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    switchNode.toString(sb, printTypes);
    sb.append(" {");

    final List<CaseNode> cases = switchNode.getCases();

    for (final CaseNode caseNode : cases) {
        sb.append(EOLN);
        indent();
        caseNode.toString(sb, printTypes);
        printLocalVariableConversion(caseNode);
        indent += TABWIDTH;
        caseNode.getBody().accept(this);
        indent -= TABWIDTH;
        sb.append(EOLN);
    }
    if(switchNode.getLocalVariableConversion() != null) {
        sb.append(EOLN);
        indent();
        sb.append("default: ");
        printLocalVariableConversion(switchNode);
        sb.append("{}");
    }
    sb.append(EOLN);
    indent();
    sb.append("}");

    return false;
}
项目:jdk8u_nashorn    文件:AssignSymbols.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    // We only need a symbol for the tag if it's not an integer switch node
    if(!switchNode.isUniqueInteger()) {
        return switchNode.setTag(lc, newObjectInternal(SWITCH_TAG_PREFIX));
    }
    return switchNode;
}
项目:jdk8u_nashorn    文件:FoldConstants.java   
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
    final Set<Integer> alreadySeen = new HashSet<>();
    for (final CaseNode caseNode : switchNode.getCases()) {
        final Expression test = caseNode.getTest();
        if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
            return false;
        }
    }
    return true;
}
项目:jdk8u_nashorn    文件:Lower.java   
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
    if(!switchNode.isUniqueInteger()) {
        // Wrap it in a block so its internally created tag is restricted in scope
        addStatementEnclosedInBlock(switchNode);
    } else {
        addStatement(switchNode);
    }
    return switchNode;
}
项目:infobip-open-jdk-8    文件:JSONWriter.java   
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
    enterDefault(switchNode);

    type("SwitchStatement");
    comma();

    property("discriminant");
    switchNode.getExpression().accept(this);
    comma();

    array("cases", switchNode.getCases());

    return leave();
}