Beispiel #1
0
Datei: code.c Projekt: WeiY/ktap
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);
}
Beispiel #2
0
Datei: code.c Projekt: WeiY/ktap
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);
	}
}
Beispiel #3
0
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);
}
Beispiel #4
0
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));
		}
	}
}
Beispiel #5
0
static void error_expected(ktap_lexstate *ls, int token)
{
	lex_syntaxerror(ls,
		ktapc_sprintf("%s expected", lex_token2str(ls, token)));
}
Beispiel #6
0
/* 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);
}