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


Java Jump类代码示例

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


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

示例1: addSwitchCase

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
/**
 * If caseExpression argument is null it indicates a default label.
 */
private void addSwitchCase(Node switchBlock, Node caseExpression,
                           Node statements)
{
    if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
    Jump switchNode = (Jump)switchBlock.getFirstChild();
    if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();

    Node gotoTarget = Node.newTarget();
    if (caseExpression != null) {
        Jump caseNode = new Jump(Token.CASE, caseExpression);
        caseNode.target = gotoTarget;
        switchNode.addChildToBack(caseNode);
    } else {
        switchNode.setDefault(gotoTarget);
    }
    switchBlock.addChildToBack(gotoTarget);
    switchBlock.addChildToBack(statements);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:22,代码来源:IRFactory.java

示例2: closeSwitch

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private void closeSwitch(Node switchBlock)
{
    if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
    Jump switchNode = (Jump)switchBlock.getFirstChild();
    if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();

    Node switchBreakTarget = Node.newTarget();
    // switchNode.target is only used by NodeTransformer
    // to detect switch end
    switchNode.target = switchBreakTarget;

    Node defaultTarget = switchNode.getDefault();
    if (defaultTarget == null) {
        defaultTarget = switchBreakTarget;
    }

    switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
                              switchNode);
    switchBlock.addChildToBack(switchBreakTarget);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:21,代码来源:IRFactory.java

示例3: enterLoop

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private void enterLoop(Loop loop) {
    if (loopSet == null)
        loopSet = new ArrayList<Loop>();
    loopSet.add(loop);
    if (loopAndSwitchSet == null)
        loopAndSwitchSet = new ArrayList<Jump>();
    loopAndSwitchSet.add(loop);
    pushScope(loop);
    if (currentLabel != null) {
        currentLabel.setStatement(loop);
        currentLabel.getFirstLabel().setLoop(loop);
        // This is the only time during parsing that we set a node's parent
        // before parsing the children.  In order for the child node offsets
        // to be correct, we adjust the loop's reported position back to an
        // absolute source offset, and restore it when we call exitLoop().
        loop.setRelative(-currentLabel.getPosition());
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:19,代码来源:Parser.java

示例4: endCheckIf

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
/**
 * Returns in the then and else blocks must be consistent with each other.
 * If there is no else block, then the return statement can fall through.
 * @return logical OR of END_* flags
 */
private int endCheckIf()
{
    Node th, el;
    int rv = END_UNREACHED;

    th = next;
    el = ((Jump)this).target;

    rv = th.endCheck();

    if (el != null)
        rv |= el.endCheck();
    else
        rv |= END_DROPS_OFF;

    return rv;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:23,代码来源:Node.java

示例5: visitGoto

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private void visitGoto(Jump node, int type, Node child)
{
    Node target = node.target;
    if (type == Token.IFEQ || type == Token.IFNE) {
        if (child == null) throw Codegen.badTree();
        int targetLabel = getTargetLabel(target);
        int fallThruLabel = cfw.acquireLabel();
        if (type == Token.IFEQ)
            generateIfJump(child, node, targetLabel, fallThruLabel);
        else
            generateIfJump(child, node, fallThruLabel, targetLabel);
        cfw.markLabel(fallThruLabel);
    } else {
        if (type == Token.JSR) {
            if (isGenerator) {
                addGotoWithReturn(target);
            } else {
                // This assumes that JSR is only ever used for finally
                inlineFinally(target);
            }
        } else {
            addGoto(target, ByteCode.GOTO);
        }
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:26,代码来源:Codegen.java

示例6: visitGoto

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private void visitGoto(Jump node, int type, Node child)
{
    Node target = node.target;
    if (type == Token.IFEQ || type == Token.IFNE) {
        if (child == null) throw Codegen.badTree();
        int targetLabel = getTargetLabel(target);
        int fallThruLabel = cfw.acquireLabel();
        if (type == Token.IFEQ)
            generateIfJump(child, node, targetLabel, fallThruLabel);
        else
            generateIfJump(child, node, fallThruLabel, targetLabel);
        cfw.markLabel(fallThruLabel);
    } else {
        if (type == Token.JSR) {
            if (isGenerator) {
                addGotoWithReturn(target);
            } else {
                addGoto(target, ByteCode.JSR);
            }
        } else {
            addGoto(target, ByteCode.GOTO);
        }
    }
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:25,代码来源:Codegen.java

示例7: createLoopNode

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
/**
 * Create loop node. The code generator will later call
 * createWhile|createDoWhile|createFor|createForIn
 * to finish loop generation.
 */
private Scope createLoopNode(Node loopLabel, int lineno) {
    Scope result = createScopeNode(Token.LOOP, lineno);
    if (loopLabel != null) {
        ((Jump)loopLabel).setLoop(result);
    }
    return result;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:13,代码来源:IRFactory.java

示例8: createIf

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
{
    int condStatus = isAlwaysDefinedBoolean(cond);
    if (condStatus == ALWAYS_TRUE_BOOLEAN) {
        return ifTrue;
    } else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
        if (ifFalse != null) {
            return ifFalse;
        }
        // Replace if (false) xxx by empty block
        return new Node(Token.BLOCK, lineno);
    }

    Node result = new Node(Token.BLOCK, lineno);
    Node ifNotTarget = Node.newTarget();
    Jump IFNE = new Jump(Token.IFNE, cond);
    IFNE.target = ifNotTarget;

    result.addChildToBack(IFNE);
    result.addChildrenToBack(ifTrue);

    if (ifFalse != null) {
        Node endTarget = Node.newTarget();
        result.addChildToBack(makeJump(Token.GOTO, endTarget));
        result.addChildToBack(ifNotTarget);
        result.addChildrenToBack(ifFalse);
        result.addChildToBack(endTarget);
    } else {
        result.addChildToBack(ifNotTarget);
    }

    return result;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:34,代码来源:IRFactory.java

示例9: breakStatement

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private BreakStatement breakStatement()
    throws IOException
{
    if (currentToken != Token.BREAK) codeBug();
    consumeToken();
    int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd;
    Name breakLabel = null;
    if (peekTokenOrEOL() == Token.NAME) {
        breakLabel = createNameNode();
        end = getNodeEnd(breakLabel);
    }

    // matchJumpLabelName only matches if there is one
    LabeledStatement labels = matchJumpLabelName();
    // always use first label as target
    Jump breakTarget = labels == null ? null : labels.getFirstLabel();

    if (breakTarget == null && breakLabel == null) {
        if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
            if (breakLabel == null) {
                reportError("msg.bad.break", pos, end - pos);
            }
        } else {
            breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1);
        }
    }

    BreakStatement pn = new BreakStatement(pos, end - pos);
    pn.setBreakLabel(breakLabel);
    // can be null if it's a bad break in error-recovery mode
    if (breakTarget != null)
        pn.setBreakTarget(breakTarget);
    pn.setLineno(lineno);
    return pn;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:36,代码来源:Parser.java

示例10: endCheckLoop

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
/**
 * Return statement in the loop body must be consistent. The default
 * assumption for any kind of a loop is that it will eventually terminate.
 * The only exception is a loop with a constant true condition. Code that
 * follows such a loop is examined only if one can statically determine
 * that there is a break out of the loop.
 * <pre>
 *  for(&lt;&gt; ; &lt;&gt;; &lt;&gt;) {}
 *  for(&lt;&gt; in &lt;&gt; ) {}
 *  while(&lt;&gt;) { }
 *  do { } while(&lt;&gt;)
 * </pre>
 * @return logical OR of END_* flags
 */
private int endCheckLoop()
{
    Node n;
    int rv = END_UNREACHED;

    // To find the loop body, we look at the second to last node of the
    // loop node, which should be the predicate that the loop should
    // satisfy.
    // The target of the predicate is the loop-body for all 4 kinds of
    // loops.
    for (n = first; n.next != last; n = n.next) {
        /* skip */
    }
    if (n.type != Token.IFEQ)
        return END_DROPS_OFF;

    // The target's next is the loop body block
    rv = ((Jump)n).target.next.endCheck();

    // check to see if the loop condition is true
    if (n.first.type == Token.TRUE)
        rv &= ~END_DROPS_OFF;

    // look for effect of breaks
    rv |= getIntProp(CONTROL_BLOCK_PROP, END_UNREACHED);

    return rv;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:43,代码来源:Node.java

示例11: endCheckBreak

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
/**
 * When a break is encountered annotate the statement being broken
 * out of by setting its CONTROL_BLOCK_PROP property.
 * @return logical OR of END_* flags
 */
private int endCheckBreak()
{
    Node n = ((Jump) this).getJumpStatement();
    n.putIntProp(CONTROL_BLOCK_PROP, END_DROPS_OFF);
    return END_UNREACHED;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:12,代码来源:Node.java

示例12: pushExceptionInfo

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
/**
 * Push a new try block onto the exception information stack.
 *
 * @param node an exception handling node (node.getType() ==
 *             Token.TRY)
 */
void pushExceptionInfo(Jump node)
{
    Node fBlock = getFinallyAtTarget(node.getFinally());
    ExceptionInfo ei = new ExceptionInfo(node, fBlock);
    exceptionInfo.add(ei);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:13,代码来源:Codegen.java

示例13: ExceptionInfo

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
ExceptionInfo(Jump node, Node finallyBlock)
{
    this.node = node;
    this.finallyBlock = finallyBlock;
    handlerLabels = new int[EXCEPTION_MAX];
    exceptionStarts = new int[EXCEPTION_MAX];
    currentFinally = null;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:9,代码来源:Codegen.java

示例14: visitSwitch

import org.mozilla.javascript.ast.Jump; //导入依赖的package包/类
private void visitSwitch(Jump switchNode, Node child)
{
    // See comments in IRFactory.createSwitch() for description
    // of SWITCH node

    generateExpression(child, switchNode);
    // save selector value
    short selector = getNewWordLocal();
    cfw.addAStore(selector);

    for (Jump caseNode = (Jump)child.getNext();
         caseNode != null;
         caseNode = (Jump)caseNode.getNext())
    {
        if (caseNode.getType() != Token.CASE)
            throw Codegen.badTree();
        Node test = caseNode.getFirstChild();
        generateExpression(test, caseNode);
        cfw.addALoad(selector);
        addScriptRuntimeInvoke("shallowEq",
                               "(Ljava/lang/Object;"
                               +"Ljava/lang/Object;"
                               +")Z");
        addGoto(caseNode.target, ByteCode.IFNE);
    }
    releaseWordLocal(selector);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:28,代码来源:Codegen.java


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