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));
}
Aggregations