Search in sources :

Example 1 with LabelStmtToken

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

the class GotoCompiler method write.

@Override
public void write(GotoStmtToken token) {
    LabelNode labelNode = method.getOrCreateGotoLabel(token.getLabel().getName());
    LabelStmtToken labelStmtToken = method.statement.findLabel(token.getLabel().getName());
    if (labelStmtToken == null) {
        compiler.getEnvironment().error(token.getLabel().toTraceInfo(compiler.getContext()), "'goto' to undefined label '%s'", token.getLabel().getName());
        return;
    }
    if (labelStmtToken.getLevel() > token.getLevel()) {
        compiler.getEnvironment().error(token.toTraceInfo(compiler.getContext()), "'goto' into loop, switch or finally statement is disallowed");
    }
    add(new JumpInsnNode(GOTO, labelNode));
}
Also used : LabelNode(org.objectweb.asm.tree.LabelNode) LabelStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.LabelStmtToken) JumpInsnNode(org.objectweb.asm.tree.JumpInsnNode)

Aggregations

LabelStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.LabelStmtToken)1 JumpInsnNode (org.objectweb.asm.tree.JumpInsnNode)1 LabelNode (org.objectweb.asm.tree.LabelNode)1