aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-22 13:37:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-22 13:37:17 -0300
commit23e6bac8a0bbb9e5df43cbc0b7634b6d1395b0ff (patch)
treeb8f01be3b195252ecb414092dce98299fc325a54 /ltm.c
parent682054920ddc434fd4a7f8cc78027dbb03f47f00 (diff)
downloadlua-23e6bac8a0bbb9e5df43cbc0b7634b6d1395b0ff.tar.gz
lua-23e6bac8a0bbb9e5df43cbc0b7634b6d1395b0ff.tar.bz2
lua-23e6bac8a0bbb9e5df43cbc0b7634b6d1395b0ff.zip
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
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c8
1 files changed, 6 insertions, 2 deletions
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,
205 205
206 206
207int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, 207int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
208 int inv, TMS event) { 208 int inv, int isfloat, TMS event) {
209 TValue aux; const TValue *p2; 209 TValue aux; const TValue *p2;
210 setivalue(&aux, v2); 210 if (isfloat) {
211 setfltvalue(&aux, cast_num(v2));
212 }
213 else
214 setivalue(&aux, v2);
211 if (inv) { /* arguments were exchanged? */ 215 if (inv) { /* arguments were exchanged? */
212 p2 = p1; p1 = &aux; /* correct them */ 216 p2 = p1; p1 = &aux; /* correct them */
213 } 217 }