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
This commit is contained in:
Roberto Ierusalimschy
2019-03-22 13:37:17 -03:00
parent 682054920d
commit 23e6bac8a0
13 changed files with 237 additions and 134 deletions

View File

@@ -294,7 +294,7 @@ OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
OP_VARARG,/* A C R(A), R(A+1), ..., R(A+C-2) = vararg */
OP_PREPVARARG,/*A (adjust vararg parameters) */
OP_VARARGPREP,/*A (adjust vararg parameters) */
OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
} OpCode;
@@ -331,6 +331,9 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
C > 0 means the function is vararg and (C - 1) is its number of
fixed parameters.
(*) In comparisons with an immediate operand, C signals whether the
original operand was a float.
===========================================================================*/