diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-22 13:37:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-22 13:37:17 -0300 |
commit | 23e6bac8a0bbb9e5df43cbc0b7634b6d1395b0ff (patch) | |
tree | b8f01be3b195252ecb414092dce98299fc325a54 /onelua.c | |
parent | 682054920ddc434fd4a7f8cc78027dbb03f47f00 (diff) | |
download | lua-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 'onelua.c')
-rw-r--r-- | onelua.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/onelua.c b/onelua.c new file mode 100644 index 00000000..3c605981 --- /dev/null +++ b/onelua.c | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * one.c -- Lua core, libraries, and interpreter in a single file | ||
3 | */ | ||
4 | |||
5 | /* default is to build the full interpreter */ | ||
6 | #ifndef MAKE_LIB | ||
7 | #ifndef MAKE_LUAC | ||
8 | #ifndef MAKE_LUA | ||
9 | #define MAKE_LUA | ||
10 | #endif | ||
11 | #endif | ||
12 | #endif | ||
13 | |||
14 | /* choose suitable platform-specific features */ | ||
15 | /* some of these may need extra libraries such as -ldl -lreadline -lncurses */ | ||
16 | #if 0 | ||
17 | #define LUA_USE_LINUX | ||
18 | #define LUA_USE_MACOSX | ||
19 | #define LUA_USE_POSIX | ||
20 | #define LUA_ANSI | ||
21 | #endif | ||
22 | |||
23 | /* no need to change anything below this line ----------------------------- */ | ||
24 | |||
25 | #include "lprefix.h" | ||
26 | |||
27 | #include <assert.h> | ||
28 | #include <ctype.h> | ||
29 | #include <errno.h> | ||
30 | #include <float.h> | ||
31 | #include <limits.h> | ||
32 | #include <locale.h> | ||
33 | #include <math.h> | ||
34 | #include <setjmp.h> | ||
35 | #include <signal.h> | ||
36 | #include <stdarg.h> | ||
37 | #include <stddef.h> | ||
38 | #include <stdio.h> | ||
39 | #include <stdlib.h> | ||
40 | #include <string.h> | ||
41 | #include <time.h> | ||
42 | |||
43 | |||
44 | /* setup for luaconf.h */ | ||
45 | #define LUA_CORE | ||
46 | #define LUA_LIB | ||
47 | #define ltable_c | ||
48 | #define lvm_c | ||
49 | #include "luaconf.h" | ||
50 | |||
51 | /* do not export internal symbols */ | ||
52 | #undef LUAI_FUNC | ||
53 | #undef LUAI_DDEC | ||
54 | #undef LUAI_DDEF | ||
55 | #define LUAI_FUNC static | ||
56 | #define LUAI_DDEC(def) /* empty */ | ||
57 | #define LUAI_DDEF static | ||
58 | |||
59 | /* core -- used by all */ | ||
60 | #include "lzio.c" | ||
61 | #include "lctype.c" | ||
62 | #include "lopcodes.c" | ||
63 | #include "lmem.c" | ||
64 | #include "lundump.c" | ||
65 | #include "ldump.c" | ||
66 | #include "lstate.c" | ||
67 | #include "lgc.c" | ||
68 | #include "llex.c" | ||
69 | #include "lcode.c" | ||
70 | #include "lparser.c" | ||
71 | #include "ldebug.c" | ||
72 | #include "lfunc.c" | ||
73 | #include "lobject.c" | ||
74 | #include "ltm.c" | ||
75 | #include "lstring.c" | ||
76 | #include "ltable.c" | ||
77 | #include "ldo.c" | ||
78 | #include "lvm.c" | ||
79 | #include "lapi.c" | ||
80 | |||
81 | /* auxiliary library -- used by all */ | ||
82 | #include "lauxlib.c" | ||
83 | |||
84 | /* standard library -- not used by luac */ | ||
85 | #ifndef MAKE_LUAC | ||
86 | #include "lbaselib.c" | ||
87 | #include "lcorolib.c" | ||
88 | #include "ldblib.c" | ||
89 | #include "liolib.c" | ||
90 | #include "lmathlib.c" | ||
91 | #include "loadlib.c" | ||
92 | #include "loslib.c" | ||
93 | #include "lstrlib.c" | ||
94 | #include "ltablib.c" | ||
95 | #include "lutf8lib.c" | ||
96 | #include "linit.c" | ||
97 | #endif | ||
98 | |||
99 | /* lua */ | ||
100 | #ifdef MAKE_LUA | ||
101 | #include "lua.c" | ||
102 | #endif | ||
103 | |||
104 | /* luac */ | ||
105 | #ifdef MAKE_LUAC | ||
106 | #include "luac.c" | ||
107 | #endif | ||