Search in sources :

Example 1 with ContinueStmtToken

use of org.develnext.jphp.core.tokenizer.token.stmt.ContinueStmtToken in project jphp by jphp-compiler.

the class JumpCompiler method write.

@Override
public void write(JumpStmtToken token) {
    int level = token.getLevel();
    JumpItem jump = method.getJump(level);
    if (jump == null) {
        env.error(token.toTraceInfo(compiler.getContext()), ErrorType.E_COMPILE_ERROR, level == 1 ? Messages.ERR_CANNOT_JUMP.fetch() : Messages.ERR_CANNOT_JUMP_TO_LEVEL.fetch(level));
        return;
    }
    if (token instanceof ContinueStmtToken) {
        add(new JumpInsnNode(GOTO, jump.continueLabel));
    } else if (token instanceof BreakStmtToken) {
        add(new JumpInsnNode(GOTO, jump.breakLabel));
    }
}
Also used : ContinueStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ContinueStmtToken) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode) JumpItem(org.develnext.jphp.core.compiler.jvm.misc.JumpItem) BreakStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.BreakStmtToken)

Aggregations

JumpItem (org.develnext.jphp.core.compiler.jvm.misc.JumpItem)1 BreakStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.BreakStmtToken)1 ContinueStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.ContinueStmtToken)1 JumpInsnNode (org.objectweb.asm.tree.JumpInsnNode)1