diff options
Diffstat (limited to 'c-api')
| -rw-r--r-- | c-api/compat-5.3.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index 4cf7e25..b8110a8 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c | |||
| @@ -39,32 +39,16 @@ static void compat53_call_lua (lua_State *L, char const code[], size_t len, | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | static const char compat53_arith_code[] = { | 42 | static const char compat53_arith_code[] = |
| 43 | 'l', 'o', 'c', 'a', 'l', ' ', 'o', 'p', ',', 'a', ',', 'b', | 43 | "local op,a,b=...\n" |
| 44 | '=', '.', '.', '.', '\n', | 44 | "if op==0 then return a+b\n" |
| 45 | 'i', 'f', ' ', 'o', 'p', '=', '=', '0', ' ', | 45 | "elseif op==1 then return a-b\n" |
| 46 | 't', 'h', 'e', 'n', '\n', | 46 | "elseif op==2 then return a*b\n" |
| 47 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '+', 'b', '\n', | 47 | "elseif op==3 then return a/b\n" |
| 48 | 'e', 'l', 's', 'e', 'i', 'f', ' ', 'o', 'p', '=', '=', '1', ' ', | 48 | "elseif op==4 then return a%b\n" |
| 49 | 't', 'h', 'e', 'n', '\n', | 49 | "elseif op==5 then return a^b\n" |
| 50 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '-', 'b', '\n', | 50 | "elseif op==6 then return -a\n" |
| 51 | 'e', 'l', 's', 'e', 'i', 'f', ' ', 'o', 'p', '=', '=', '2', ' ', | 51 | "end\n"; |
| 52 | 't', 'h', 'e', 'n', '\n', | ||
| 53 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '*', 'b', '\n', | ||
| 54 | 'e', 'l', 's', 'e', 'i', 'f', ' ', 'o', 'p', '=', '=', '3', ' ', | ||
| 55 | 't', 'h', 'e', 'n', '\n', | ||
| 56 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '/', 'b', '\n', | ||
| 57 | 'e', 'l', 's', 'e', 'i', 'f', ' ', 'o', 'p', '=', '=', '4', ' ', | ||
| 58 | 't', 'h', 'e', 'n', '\n', | ||
| 59 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '%', 'b', '\n', | ||
| 60 | 'e', 'l', 's', 'e', 'i', 'f', ' ', 'o', 'p', '=', '=', '5', ' ', | ||
| 61 | 't', 'h', 'e', 'n', '\n', | ||
| 62 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '^', 'b', '\n', | ||
| 63 | 'e', 'l', 's', 'e', 'i', 'f', ' ', 'o', 'p', '=', '=', '6', ' ', | ||
| 64 | 't', 'h', 'e', 'n', '\n', | ||
| 65 | 'r', 'e', 't', 'u', 'r', 'n', ' ', '-', 'a', '\n', | ||
| 66 | 'e', 'n', 'd', '\n', '\0' | ||
| 67 | }; | ||
| 68 | 52 | ||
| 69 | COMPAT53_API void lua_arith (lua_State *L, int op) { | 53 | COMPAT53_API void lua_arith (lua_State *L, int op) { |
| 70 | if (op < LUA_OPADD && op > LUA_OPUNM) | 54 | if (op < LUA_OPADD && op > LUA_OPUNM) |
| @@ -79,10 +63,9 @@ COMPAT53_API void lua_arith (lua_State *L, int op) { | |||
| 79 | } | 63 | } |
| 80 | 64 | ||
| 81 | 65 | ||
| 82 | static const char compat53_compare_code[] = { | 66 | static const char compat53_compare_code[] = |
| 83 | 'l', 'o', 'c', 'a', 'l', ' ', 'a', ',', 'b', '=', '.', '.', '.', '\n', | 67 | "local a,b=...\n" |
| 84 | 'r', 'e', 't', 'u', 'r', 'n', ' ', 'a', '<', '=', 'b', '\n', '\0' | 68 | "return a<=b\n"; |
| 85 | }; | ||
| 86 | 69 | ||
| 87 | COMPAT53_API int lua_compare (lua_State *L, int idx1, int idx2, int op) { | 70 | COMPAT53_API int lua_compare (lua_State *L, int idx1, int idx2, int op) { |
| 88 | int result = 0; | 71 | int result = 0; |
