issue #169 fix wrong error message - found due to travis build failure

asmvm
Dibyendu Majumdar 4 years ago
parent bf94ff65e8
commit 29d7bff586

@ -573,6 +573,7 @@ static const char Lua_header[] =
"extern void raviV_op_setupvalaf(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raviV_op_setupvalt(lua_State *L, LClosure *cl, TValue *ra, int b);\n"
"extern void raise_error(lua_State *L, int errorcode);\n"
"extern void raise_error_with_info(lua_State *L, int errorcode, const char *info);\n"
"extern void luaD_call (lua_State *L, StkId func, int nResults);\n"
"extern void raviH_set_int(lua_State *L, Table *t, lua_Unsigned key, lua_Integer value);\n"
"extern void raviH_set_float(lua_State *L, Table *t, lua_Unsigned key, lua_Number value);\n"
@ -1540,11 +1541,11 @@ static void emit_op_totype(struct function *fn, int A, int Bx, int pc) {
membuff_add_string(&fn->body, "if (!ttisnil(ra)) {\n");
membuff_add_fstring(&fn->body, " rb = K(%d);\n", Bx);
membuff_add_string(&fn->body, " if (!ttisshrstring(rb) || !raviV_check_usertype(L, tsvalue(rb), ra)) {\n");
#if GOTO_ON_ERROR
#if 0 // GOTO_ON_ERROR
membuff_add_fstring(&fn->body, " error_code = %d;\n", Error_type_mismatch);
membuff_add_string(&fn->body, " goto Lraise_error;\n");
#else
membuff_add_fstring(&fn->body, " raise_error(L, %d);\n", Error_type_mismatch);
membuff_add_fstring(&fn->body, " raise_error_with_info(L, %d, tsvalue(rb));\n", Error_type_mismatch);
#endif
membuff_add_string(&fn->body, " }\n");
membuff_add_string(&fn->body, "}\n");

@ -53,10 +53,15 @@ static const char *errortext[] = {"integer expected",
NULL};
static void raise_error(lua_State *L, int errorcode) {
assert(errorcode >= 0 && errorcode <= Error_type_mismatch);
assert(errorcode >= 0 && errorcode < Error_type_mismatch);
luaG_runerror(L, errortext[errorcode]);
}
static void raise_error_with_info(lua_State *L, int errorcode, const char *info) {
assert(errorcode == Error_type_mismatch);
luaG_runerror(L, "type mismatch: expected %s", info);
}
#if !RAVI_TARGET_X64
#error MIRJIT is currently only supported on X64 architecture
#endif
@ -69,6 +74,7 @@ typedef struct LuaFunc {
static LuaFunc Lua_functions[] = {
{ "luaF_close", luaF_close },
{ "raise_error", raise_error },
{ "raise_error_with_info", raise_error_with_info },
{ "luaV_tonumber_", luaV_tonumber_ },
{ "luaV_tointeger", luaV_tointeger },
{ "luaV_shiftl", luaV_shiftl },

@ -53,10 +53,15 @@ static const char *errortext[] = {"integer expected",
NULL};
static void raise_error(lua_State *L, int errorcode) {
assert(errorcode >= 0 && errorcode <= Error_type_mismatch);
assert(errorcode >= 0 && errorcode < Error_type_mismatch);
luaG_runerror(L, errortext[errorcode]);
}
static void raise_error_with_info(lua_State *L, int errorcode, const char *info) {
assert(errorcode == Error_type_mismatch);
luaG_runerror(L, "type mismatch: expected %s", info);
}
static void register_builtin_arg1(JIT_ContextRef module, const char *name,
void *fp, JIT_Type return_type,
JIT_Type arg1) {
@ -138,6 +143,7 @@ int raviV_initjit(struct lua_State *L) {
//extern void luaF_close (lua_State *L, StkId level);
register_builtin_arg2(jit->jit, "luaF_close", luaF_close, JIT_NoType, JIT_Address, JIT_Address);
register_builtin_arg2(jit->jit, "raise_error", raise_error, JIT_NoType, JIT_Address, JIT_Int32);
register_builtin_arg3(jit->jit, "raise_error_with_info", raise_error_with_info, JIT_NoType, JIT_Address, JIT_Int32, JIT_Address);
//extern int luaV_tonumber_(const TValue *obj, lua_Number *n);
register_builtin_arg2(jit->jit, "luaV_tonumber_", luaV_tonumber_, JIT_Int32, JIT_Address, JIT_Address);
//extern int luaV_tointeger(const TValue *obj, lua_Integer *p, int mode);

Loading…
Cancel
Save