static void fixjump(FuncState *fs, int pc, int dest) { Instruction *jmp = &fs->f->code[pc]; int offset = dest-(pc+1); ktap_assert(dest != NO_JUMP); if (abs(offset) > MAXARG_sBx) lex_syntaxerror(fs->ls, "control structure too long"); SETARG_sBx(*jmp, offset); }
void codegen_checkstack(FuncState *fs, int n) { int newstack = fs->freereg + n; if (newstack > fs->f->maxstacksize) { if (newstack >= MAXSTACK) lex_syntaxerror(fs->ls, "function or expression too complex"); fs->f->maxstacksize = (u8)(newstack); } }
static void errorlimit(ktap_funcstate *fs, int limit, const char *what) { const char *msg; int line = fs->f->linedefined; const char *where = (line == 0) ? "main function" : ktapc_sprintf("function at line %d", line); msg = ktapc_sprintf("too many %s (limit is %d) in %s", what, limit, where); lex_syntaxerror(fs->ls, msg); }
static void check_match(ktap_lexstate *ls, int what, int who, int where) { if (!testnext(ls, what)) { if (where == ls->linenumber) error_expected(ls, what); else { lex_syntaxerror(ls, ktapc_sprintf( "%s expected (to close %s at line %d)", lex_token2str(ls, what), lex_token2str(ls, who), where)); } } }
static void error_expected(ktap_lexstate *ls, int token) { lex_syntaxerror(ls, ktapc_sprintf("%s expected", lex_token2str(ls, token))); }
/* semantic error */ static void semerror(ktap_lexstate *ls, const char *msg) { ls->t.token = 0; /* remove 'near to' from final message */ lex_syntaxerror(ls, msg); }