From 23e6bac8a0bbb9e5df43cbc0b7634b6d1395b0ff Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 22 Mar 2019 13:37:17 -0300 Subject: Keep correct type for immediate operands in comparisons When calling metamethods for things like 'a < 3.0', which generates the opcode OP_LTI, the C register tells that the operand was converted to an integer, so that it can be corrected to float when calling a metamethod. This commit also includes some other stuff: - file 'onelua.c' added to the project - opcode OP_PREPVARARG renamed to OP_VARARGPREP - comparison opcodes rewritten through macros --- ltm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ltm.c') diff --git a/ltm.c b/ltm.c index 23a97a62..c4fd762b 100644 --- a/ltm.c +++ b/ltm.c @@ -205,9 +205,13 @@ int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, - int inv, TMS event) { + int inv, int isfloat, TMS event) { TValue aux; const TValue *p2; - setivalue(&aux, v2); + if (isfloat) { + setfltvalue(&aux, cast_num(v2)); + } + else + setivalue(&aux, v2); if (inv) { /* arguments were exchanged? */ p2 = p1; p1 = &aux; /* correct them */ } -- cgit v1.2.3-55-g6feb