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


Java Statement类代码示例

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


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

示例1: emitProgram

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private boolean emitProgram(final FunctionNode functionNode) {
    enterDefault(functionNode);
    type("Program");
    comma();

    // body consists of nested functions and statements
    final List<Statement> stats = functionNode.getBody().getStatements();
    final int size = stats.size();
    int idx = 0;
    arrayStart("body");

    for (final Node stat : stats) {
        stat.accept(this);
        if (idx != (size - 1)) {
            comma();
        }
        idx++;
    }
    arrayEnd();

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

示例2: leaveIfNode

import jdk.nashorn.internal.ir.Statement; //导入依赖的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: handleBlock

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private boolean handleBlock(final Block block, final boolean sortStats) {
    // FIXME: revisit this!
    if (block.isSynthetic()) {
        final int statCount = block.getStatementCount();
        switch (statCount) {
            case 0: {
                final EmptyNode emptyNode = new EmptyNode(-1, block.getToken(), block.getFinish());
                curStat = new EmptyStatementTreeImpl(emptyNode);
                return false;
            }
            case 1: {
                curStat = translateStat(block.getStatements().get(0));
                return false;
            }
            default: {
                // fall through
                break;
            }
        }
    }

    final List<? extends Statement> stats = block.getStatements();
    curStat = new BlockTreeImpl(block,
        translateStats(sortStats? getOrderedStatements(stats) : stats));
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:IRTranslator.java

示例4: markEvalInArrowParameterList

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private void markEvalInArrowParameterList(final ParserContextBlockNode parameterBlock) {
    final Iterator<ParserContextFunctionNode> iter = lc.getFunctions();
    final ParserContextFunctionNode current = iter.next();
    final ParserContextFunctionNode parent = iter.next();

    if (parent.getFlag(FunctionNode.HAS_EVAL) != 0) {
        // we might have flagged has-eval in the parent function during parsing the parameter list,
        // if the parameter list contains eval; must tag arrow function as has-eval.
        for (final Statement st : parameterBlock.getStatements()) {
            st.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
                @Override
                public boolean enterCallNode(final CallNode callNode) {
                    if (callNode.getFunction() instanceof IdentNode && ((IdentNode) callNode.getFunction()).getName().equals("eval")) {
                        current.setFlag(FunctionNode.HAS_EVAL);
                    }
                    return true;
                }
            });
        }
        // TODO: function containing the arrow function should not be flagged has-eval
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Parser.java

示例5: leaveIfNode

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

示例6: extractVarNodesFromDeadCode

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
/**
 * When we eliminate dead code, we must preserve var declarations as they are scoped to the whole
 * function. This method gathers var nodes from code passed to it, removing their initializers.
 *
 * @param deadCodeRoot the root node of eliminated dead code
 * @param statements a list that will be receiving the var nodes from the dead code, with their
 * initializers removed.
 */
static void extractVarNodesFromDeadCode(final Node deadCodeRoot, final List<Statement> statements) {
    deadCodeRoot.accept(new SimpleNodeVisitor() {
        @Override
        public boolean enterVarNode(final VarNode varNode) {
            statements.add(varNode.setInit(null));
            return false;
        }

        @Override
        public boolean enterFunctionNode(final FunctionNode functionNode) {
            // Don't descend into nested functions
            return false;
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:FoldConstants.java

示例7: insert

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
public final void insert(String table, String[] parameters){
  try {
       Statement select = ds.createStatement();
       select.executeUpdate(" ");
  } catch (SQLException sqle) { 
   System.out.println("Erreur : "+sqle.getMessage());
  }
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:9,代码来源:DatabaseRequest.java

示例8: remove

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
public void remove(String table, String idName, String idValue){
   try {
       Statement select = ds.createStatement();
       select.executeUpdate("delete from "+table+" where id_name = "+idName+" and id_value = "+idValue);
   } catch (SQLException sqle) { 
   	System.out.println("Erreur : "+sqle.getMessage());
   }
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:9,代码来源:DatabaseRequest.java

示例9: update

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
public void update(String table, HashMap<Integer, Integer> parameters){
   try {
       Statement select = ds.createStatement();
       select.executeUpdate(" ");
   } catch (SQLException sqle) {  
   	System.out.println("Erreur : "+sqle.getMessage());
   }
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:9,代码来源:DatabaseRequest.java

示例10: addFunctionDeclarations

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private void addFunctionDeclarations(final FunctionNode functionNode) {
    VarNode lastDecl = null;
    for (int i = functionDeclarations.size() - 1; i >= 0; i--) {
        Statement decl = functionDeclarations.get(i);
        if (lastDecl == null && decl instanceof VarNode) {
            decl = lastDecl = ((VarNode)decl).setFlag(VarNode.IS_LAST_FUNCTION_DECLARATION);
            lc.setFlag(functionNode, FunctionNode.HAS_FUNCTION_DECLARATIONS);
        }
        prependStatement(decl);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:Parser.java

示例11: createSyntheticInitializers

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) {
    final List<VarNode> syntheticInitializers = new ArrayList<>(2);

    // Must visit the new var nodes in the context of the body. We could also just set the new statements into the
    // block and then revisit the entire block, but that seems to be too much double work.
    final Block body = functionNode.getBody();
    lc.push(body);
    try {
        if (functionNode.usesSelfSymbol()) {
            // "var fn = :callee"
            syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode));
        }

        if (functionNode.needsArguments()) {
            // "var arguments = :arguments"
            syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()),
                    ARGUMENTS, functionNode));
        }

        if (syntheticInitializers.isEmpty()) {
            return functionNode;
        }

        for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) {
            it.set((VarNode)it.next().accept(this));
        }
    } finally {
        lc.pop(body);
    }

    final List<Statement> stmts = body.getStatements();
    final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size());
    newStatements.addAll(syntheticInitializers);
    newStatements.addAll(stmts);
    return functionNode.setBody(lc, body.setStatements(lc, newStatements));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:AssignSymbols.java

示例12: extractVarNodes

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private static void extractVarNodes(final Block block, final List<Statement> statements) {
    final LexicalContext lc = new LexicalContext();
    block.accept(lc, new NodeVisitor<LexicalContext>(lc) {
        @Override
        public boolean enterVarNode(final VarNode varNode) {
            statements.add(varNode.setInit(null));
            return false;
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:FoldConstants.java

示例13: copyFinally

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private static List<Statement> copyFinally(final Block finallyBody) {
    final List<Statement> newStatements = new ArrayList<>();
    for (final Statement statement : finallyBody.getStatements()) {
        newStatements.add((Statement)ensureUniqueNamesIn(statement));
        if (statement.hasTerminalFlags()) {
            return newStatements;
        }
    }
    return newStatements;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Lower.java

示例14: addStatementEnclosedInBlock

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private void addStatementEnclosedInBlock(final Statement stmt) {
    BlockStatement b = BlockStatement.createReplacement(stmt, Collections.<Statement>singletonList(stmt));
    if(stmt.isTerminal()) {
        b = b.setBlock(b.getBlock().setIsTerminal(null, true));
    }
    addStatement(b);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:Lower.java

示例15: removeInnerFunctionBodies

import jdk.nashorn.internal.ir.Statement; //导入依赖的package包/类
private static FunctionNode removeInnerFunctionBodies(final FunctionNode fn) {
    return (FunctionNode)fn.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
        @Override
        public Node leaveBlock(final Block block) {
            if (lc.isFunctionBody() && lc.getFunction(block) != lc.getOutermostFunction()) {
                return block.setStatements(lc, Collections.<Statement>emptyList());
            }
            return super.leaveBlock(block);
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:AstSerializer.java


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