diff options
Diffstat (limited to '')
| -rw-r--r-- | src/3rdParty/lua/Makefile | 25 | ||||
| -rw-r--r-- | src/3rdParty/lua/lua.c | 677 | ||||
| -rw-r--r-- | src/3rdParty/lua/luac.c | 724 |
3 files changed, 3 insertions, 1423 deletions
diff --git a/src/3rdParty/lua/Makefile b/src/3rdParty/lua/Makefile index 1907381..3988cb3 100644 --- a/src/3rdParty/lua/Makefile +++ b/src/3rdParty/lua/Makefile | |||
| @@ -37,14 +37,8 @@ CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem | |||
| 37 | LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o | 37 | LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o |
| 38 | BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) | 38 | BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) |
| 39 | 39 | ||
| 40 | LUA_T= lua | 40 | ALL_O= $(BASE_O) |
| 41 | LUA_O= lua.o | 41 | ALL_T= $(LUA_A) |
| 42 | |||
| 43 | LUAC_T= luac | ||
| 44 | LUAC_O= luac.o | ||
| 45 | |||
| 46 | ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) | ||
| 47 | ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) | ||
| 48 | ALL_A= $(LUA_A) | 42 | ALL_A= $(LUA_A) |
| 49 | 43 | ||
| 50 | # Targets start here. | 44 | # Targets start here. |
| @@ -60,15 +54,6 @@ $(LUA_A): $(BASE_O) | |||
| 60 | $(AR) $@ $(BASE_O) | 54 | $(AR) $@ $(BASE_O) |
| 61 | $(RANLIB) $@ | 55 | $(RANLIB) $@ |
| 62 | 56 | ||
| 63 | $(LUA_T): $(LUA_O) $(LUA_A) | ||
| 64 | $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) | ||
| 65 | |||
| 66 | $(LUAC_T): $(LUAC_O) $(LUA_A) | ||
| 67 | $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) | ||
| 68 | |||
| 69 | test: | ||
| 70 | ./$(LUA_T) -v | ||
| 71 | |||
| 72 | clean: | 57 | clean: |
| 73 | $(RM) $(ALL_T) $(ALL_O) | 58 | $(RM) $(ALL_T) $(ALL_O) |
| 74 | 59 | ||
| @@ -129,10 +114,9 @@ Darwin macos macosx: | |||
| 129 | $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline" | 114 | $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline" |
| 130 | 115 | ||
| 131 | mingw: | 116 | mingw: |
| 132 | $(MAKE) "LUA_A=lua54.dll" "LUA_T=lua.exe" \ | 117 | $(MAKE) "LUA_A=lua54.dll" \ |
| 133 | "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ | 118 | "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ |
| 134 | "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe | 119 | "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe |
| 135 | $(MAKE) "LUAC_T=luac.exe" luac.exe | ||
| 136 | 120 | ||
| 137 | posix: | 121 | posix: |
| 138 | $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX" | 122 | $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX" |
| @@ -206,9 +190,6 @@ ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ | |||
| 206 | ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h | 190 | ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h |
| 207 | ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ | 191 | ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ |
| 208 | llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h | 192 | llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h |
| 209 | lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h | ||
| 210 | luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h ldebug.h lstate.h \ | ||
| 211 | lobject.h llimits.h ltm.h lzio.h lmem.h lopcodes.h lopnames.h lundump.h | ||
| 212 | lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \ | 193 | lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \ |
| 213 | lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \ | 194 | lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \ |
| 214 | lundump.h | 195 | lundump.h |
diff --git a/src/3rdParty/lua/lua.c b/src/3rdParty/lua/lua.c deleted file mode 100644 index 7f7dc2b..0000000 --- a/src/3rdParty/lua/lua.c +++ /dev/null | |||
| @@ -1,677 +0,0 @@ | |||
| 1 | /* | ||
| 2 | ** $Id: lua.c $ | ||
| 3 | ** Lua stand-alone interpreter | ||
| 4 | ** See Copyright Notice in lua.h | ||
| 5 | */ | ||
| 6 | |||
| 7 | #define lua_c | ||
| 8 | |||
| 9 | #include "lprefix.h" | ||
| 10 | |||
| 11 | |||
| 12 | #include <stdio.h> | ||
| 13 | #include <stdlib.h> | ||
| 14 | #include <string.h> | ||
| 15 | |||
| 16 | #include <signal.h> | ||
| 17 | |||
| 18 | #include "lua.h" | ||
| 19 | |||
| 20 | #include "lauxlib.h" | ||
| 21 | #include "lualib.h" | ||
| 22 | |||
| 23 | |||
| 24 | #if !defined(LUA_PROGNAME) | ||
| 25 | #define LUA_PROGNAME "lua" | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #if !defined(LUA_INIT_VAR) | ||
| 29 | #define LUA_INIT_VAR "LUA_INIT" | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX | ||
| 33 | |||
| 34 | |||
| 35 | static lua_State *globalL = NULL; | ||
| 36 | |||
| 37 | static const char *progname = LUA_PROGNAME; | ||
| 38 | |||
| 39 | |||
| 40 | #if defined(LUA_USE_POSIX) /* { */ | ||
| 41 | |||
| 42 | /* | ||
| 43 | ** Use 'sigaction' when available. | ||
| 44 | */ | ||
| 45 | static void setsignal (int sig, void (*handler)(int)) { | ||
| 46 | struct sigaction sa; | ||
| 47 | sa.sa_handler = handler; | ||
| 48 | sa.sa_flags = 0; | ||
| 49 | sigemptyset(&sa.sa_mask); /* do not mask any signal */ | ||
| 50 | sigaction(sig, &sa, NULL); | ||
| 51 | } | ||
| 52 | |||
| 53 | #else /* }{ */ | ||
| 54 | |||
| 55 | #define setsignal signal | ||
| 56 | |||
| 57 | #endif /* } */ | ||
| 58 | |||
| 59 | |||
| 60 | /* | ||
| 61 | ** Hook set by signal function to stop the interpreter. | ||
| 62 | */ | ||
| 63 | static void lstop (lua_State *L, lua_Debug *ar) { | ||
| 64 | (void)ar; /* unused arg. */ | ||
| 65 | lua_sethook(L, NULL, 0, 0); /* reset hook */ | ||
| 66 | luaL_error(L, "interrupted!"); | ||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | /* | ||
| 71 | ** Function to be called at a C signal. Because a C signal cannot | ||
| 72 | ** just change a Lua state (as there is no proper synchronization), | ||
| 73 | ** this function only sets a hook that, when called, will stop the | ||
| 74 | ** interpreter. | ||
| 75 | */ | ||
| 76 | static void laction (int i) { | ||
| 77 | int flag = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT; | ||
| 78 | setsignal(i, SIG_DFL); /* if another SIGINT happens, terminate process */ | ||
| 79 | lua_sethook(globalL, lstop, flag, 1); | ||
| 80 | } | ||
| 81 | |||
| 82 | |||
| 83 | static void print_usage (const char *badoption) { | ||
| 84 | lua_writestringerror("%s: ", progname); | ||
| 85 | if (badoption[1] == 'e' || badoption[1] == 'l') | ||
| 86 | lua_writestringerror("'%s' needs argument\n", badoption); | ||
| 87 | else | ||
| 88 | lua_writestringerror("unrecognized option '%s'\n", badoption); | ||
| 89 | lua_writestringerror( | ||
| 90 | "usage: %s [options] [script [args]]\n" | ||
| 91 | "Available options are:\n" | ||
| 92 | " -e stat execute string 'stat'\n" | ||
| 93 | " -i enter interactive mode after executing 'script'\n" | ||
| 94 | " -l mod require library 'mod' into global 'mod'\n" | ||
| 95 | " -l g=mod require library 'mod' into global 'g'\n" | ||
| 96 | " -v show version information\n" | ||
| 97 | " -E ignore environment variables\n" | ||
| 98 | " -W turn warnings on\n" | ||
| 99 | " -- stop handling options\n" | ||
| 100 | " - stop handling options and execute stdin\n" | ||
| 101 | , | ||
| 102 | progname); | ||
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | /* | ||
| 107 | ** Prints an error message, adding the program name in front of it | ||
| 108 | ** (if present) | ||
| 109 | */ | ||
| 110 | static void l_message (const char *pname, const char *msg) { | ||
| 111 | if (pname) lua_writestringerror("%s: ", pname); | ||
| 112 | lua_writestringerror("%s\n", msg); | ||
| 113 | } | ||
| 114 | |||
| 115 | |||
| 116 | /* | ||
| 117 | ** Check whether 'status' is not OK and, if so, prints the error | ||
| 118 | ** message on the top of the stack. It assumes that the error object | ||
| 119 | ** is a string, as it was either generated by Lua or by 'msghandler'. | ||
| 120 | */ | ||
| 121 | static int report (lua_State *L, int status) { | ||
| 122 | if (status != LUA_OK) { | ||
| 123 | const char *msg = lua_tostring(L, -1); | ||
| 124 | l_message(progname, msg); | ||
| 125 | lua_pop(L, 1); /* remove message */ | ||
| 126 | } | ||
| 127 | return status; | ||
| 128 | } | ||
| 129 | |||
| 130 | |||
| 131 | /* | ||
| 132 | ** Message handler used to run all chunks | ||
| 133 | */ | ||
| 134 | static int msghandler (lua_State *L) { | ||
| 135 | const char *msg = lua_tostring(L, 1); | ||
| 136 | if (msg == NULL) { /* is error object not a string? */ | ||
| 137 | if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */ | ||
| 138 | lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */ | ||
| 139 | return 1; /* that is the message */ | ||
| 140 | else | ||
| 141 | msg = lua_pushfstring(L, "(error object is a %s value)", | ||
| 142 | luaL_typename(L, 1)); | ||
| 143 | } | ||
| 144 | luaL_traceback(L, L, msg, 1); /* append a standard traceback */ | ||
| 145 | return 1; /* return the traceback */ | ||
| 146 | } | ||
| 147 | |||
| 148 | |||
| 149 | /* | ||
| 150 | ** Interface to 'lua_pcall', which sets appropriate message function | ||
| 151 | ** and C-signal handler. Used to run all chunks. | ||
| 152 | */ | ||
| 153 | static int docall (lua_State *L, int narg, int nres) { | ||
| 154 | int status; | ||
| 155 | int base = lua_gettop(L) - narg; /* function index */ | ||
| 156 | lua_pushcfunction(L, msghandler); /* push message handler */ | ||
| 157 | lua_insert(L, base); /* put it under function and args */ | ||
| 158 | globalL = L; /* to be available to 'laction' */ | ||
| 159 | setsignal(SIGINT, laction); /* set C-signal handler */ | ||
| 160 | status = lua_pcall(L, narg, nres, base); | ||
| 161 | setsignal(SIGINT, SIG_DFL); /* reset C-signal handler */ | ||
| 162 | lua_remove(L, base); /* remove message handler from the stack */ | ||
| 163 | return status; | ||
| 164 | } | ||
| 165 | |||
| 166 | |||
| 167 | static void print_version (void) { | ||
| 168 | lua_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT)); | ||
| 169 | lua_writeline(); | ||
| 170 | } | ||
| 171 | |||
| 172 | |||
| 173 | /* | ||
| 174 | ** Create the 'arg' table, which stores all arguments from the | ||
| 175 | ** command line ('argv'). It should be aligned so that, at index 0, | ||
| 176 | ** it has 'argv[script]', which is the script name. The arguments | ||
| 177 | ** to the script (everything after 'script') go to positive indices; | ||
| 178 | ** other arguments (before the script name) go to negative indices. | ||
| 179 | ** If there is no script name, assume interpreter's name as base. | ||
| 180 | ** (If there is no interpreter's name either, 'script' is -1, so | ||
| 181 | ** table sizes are zero.) | ||
| 182 | */ | ||
| 183 | static void createargtable (lua_State *L, char **argv, int argc, int script) { | ||
| 184 | int i, narg; | ||
| 185 | narg = argc - (script + 1); /* number of positive indices */ | ||
| 186 | lua_createtable(L, narg, script + 1); | ||
| 187 | for (i = 0; i < argc; i++) { | ||
| 188 | lua_pushstring(L, argv[i]); | ||
| 189 | lua_rawseti(L, -2, i - script); | ||
| 190 | } | ||
| 191 | lua_setglobal(L, "arg"); | ||
| 192 | } | ||
| 193 | |||
| 194 | |||
| 195 | static int dochunk (lua_State *L, int status) { | ||
| 196 | if (status == LUA_OK) status = docall(L, 0, 0); | ||
| 197 | return report(L, status); | ||
| 198 | } | ||
| 199 | |||
| 200 | |||
| 201 | static int dofile (lua_State *L, const char *name) { | ||
| 202 | return dochunk(L, luaL_loadfile(L, name)); | ||
| 203 | } | ||
| 204 | |||
| 205 | |||
| 206 | static int dostring (lua_State *L, const char *s, const char *name) { | ||
| 207 | return dochunk(L, luaL_loadbuffer(L, s, strlen(s), name)); | ||
| 208 | } | ||
| 209 | |||
| 210 | |||
| 211 | /* | ||
| 212 | ** Receives 'globname[=modname]' and runs 'globname = require(modname)'. | ||
| 213 | */ | ||
| 214 | static int dolibrary (lua_State *L, char *globname) { | ||
| 215 | int status; | ||
| 216 | char *modname = strchr(globname, '='); | ||
| 217 | if (modname == NULL) /* no explicit name? */ | ||
| 218 | modname = globname; /* module name is equal to global name */ | ||
| 219 | else { | ||
| 220 | *modname = '\0'; /* global name ends here */ | ||
| 221 | modname++; /* module name starts after the '=' */ | ||
| 222 | } | ||
| 223 | lua_getglobal(L, "require"); | ||
| 224 | lua_pushstring(L, modname); | ||
| 225 | status = docall(L, 1, 1); /* call 'require(modname)' */ | ||
| 226 | if (status == LUA_OK) | ||
| 227 | lua_setglobal(L, globname); /* globname = require(modname) */ | ||
| 228 | return report(L, status); | ||
| 229 | } | ||
| 230 | |||
| 231 | |||
| 232 | /* | ||
| 233 | ** Push on the stack the contents of table 'arg' from 1 to #arg | ||
| 234 | */ | ||
| 235 | static int pushargs (lua_State *L) { | ||
| 236 | int i, n; | ||
| 237 | if (lua_getglobal(L, "arg") != LUA_TTABLE) | ||
| 238 | luaL_error(L, "'arg' is not a table"); | ||
| 239 | n = (int)luaL_len(L, -1); | ||
| 240 | luaL_checkstack(L, n + 3, "too many arguments to script"); | ||
| 241 | for (i = 1; i <= n; i++) | ||
| 242 | lua_rawgeti(L, -i, i); | ||
| 243 | lua_remove(L, -i); /* remove table from the stack */ | ||
| 244 | return n; | ||
| 245 | } | ||
| 246 | |||
| 247 | |||
| 248 | static int handle_script (lua_State *L, char **argv) { | ||
| 249 | int status; | ||
| 250 | const char *fname = argv[0]; | ||
| 251 | if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0) | ||
| 252 | fname = NULL; /* stdin */ | ||
| 253 | status = luaL_loadfile(L, fname); | ||
| 254 | if (status == LUA_OK) { | ||
| 255 | int n = pushargs(L); /* push arguments to script */ | ||
| 256 | status = docall(L, n, LUA_MULTRET); | ||
| 257 | } | ||
| 258 | return report(L, status); | ||
| 259 | } | ||
| 260 | |||
| 261 | |||
| 262 | /* bits of various argument indicators in 'args' */ | ||
| 263 | #define has_error 1 /* bad option */ | ||
| 264 | #define has_i 2 /* -i */ | ||
| 265 | #define has_v 4 /* -v */ | ||
| 266 | #define has_e 8 /* -e */ | ||
| 267 | #define has_E 16 /* -E */ | ||
| 268 | |||
| 269 | |||
| 270 | /* | ||
| 271 | ** Traverses all arguments from 'argv', returning a mask with those | ||
| 272 | ** needed before running any Lua code or an error code if it finds any | ||
| 273 | ** invalid argument. In case of error, 'first' is the index of the bad | ||
| 274 | ** argument. Otherwise, 'first' is -1 if there is no program name, | ||
| 275 | ** 0 if there is no script name, or the index of the script name. | ||
| 276 | */ | ||
| 277 | static int collectargs (char **argv, int *first) { | ||
| 278 | int args = 0; | ||
| 279 | int i; | ||
| 280 | if (argv[0] != NULL) { /* is there a program name? */ | ||
| 281 | if (argv[0][0]) /* not empty? */ | ||
| 282 | progname = argv[0]; /* save it */ | ||
| 283 | } | ||
| 284 | else { /* no program name */ | ||
| 285 | *first = -1; | ||
| 286 | return 0; | ||
| 287 | } | ||
| 288 | for (i = 1; argv[i] != NULL; i++) { /* handle arguments */ | ||
| 289 | *first = i; | ||
| 290 | if (argv[i][0] != '-') /* not an option? */ | ||
| 291 | return args; /* stop handling options */ | ||
| 292 | switch (argv[i][1]) { /* else check option */ | ||
| 293 | case '-': /* '--' */ | ||
| 294 | if (argv[i][2] != '\0') /* extra characters after '--'? */ | ||
| 295 | return has_error; /* invalid option */ | ||
| 296 | *first = i + 1; | ||
| 297 | return args; | ||
| 298 | case '\0': /* '-' */ | ||
| 299 | return args; /* script "name" is '-' */ | ||
| 300 | case 'E': | ||
| 301 | if (argv[i][2] != '\0') /* extra characters? */ | ||
| 302 | return has_error; /* invalid option */ | ||
| 303 | args |= has_E; | ||
| 304 | break; | ||
| 305 | case 'W': | ||
| 306 | if (argv[i][2] != '\0') /* extra characters? */ | ||
| 307 | return has_error; /* invalid option */ | ||
| 308 | break; | ||
| 309 | case 'i': | ||
| 310 | args |= has_i; /* (-i implies -v) *//* FALLTHROUGH */ | ||
| 311 | case 'v': | ||
| 312 | if (argv[i][2] != '\0') /* extra characters? */ | ||
| 313 | return has_error; /* invalid option */ | ||
| 314 | args |= has_v; | ||
| 315 | break; | ||
| 316 | case 'e': | ||
| 317 | args |= has_e; /* FALLTHROUGH */ | ||
| 318 | case 'l': /* both options need an argument */ | ||
| 319 | if (argv[i][2] == '\0') { /* no concatenated argument? */ | ||
| 320 | i++; /* try next 'argv' */ | ||
| 321 | if (argv[i] == NULL || argv[i][0] == '-') | ||
| 322 | return has_error; /* no next argument or it is another option */ | ||
| 323 | } | ||
| 324 | break; | ||
| 325 | default: /* invalid option */ | ||
| 326 | return has_error; | ||
| 327 | } | ||
| 328 | } | ||
| 329 | *first = 0; /* no script name */ | ||
| 330 | return args; | ||
| 331 | } | ||
| 332 | |||
| 333 | |||
| 334 | /* | ||
| 335 | ** Processes options 'e' and 'l', which involve running Lua code, and | ||
| 336 | ** 'W', which also affects the state. | ||
| 337 | ** Returns 0 if some code raises an error. | ||
| 338 | */ | ||
| 339 | static int runargs (lua_State *L, char **argv, int n) { | ||
| 340 | int i; | ||
| 341 | for (i = 1; i < n; i++) { | ||
| 342 | int option = argv[i][1]; | ||
| 343 | lua_assert(argv[i][0] == '-'); /* already checked */ | ||
| 344 | switch (option) { | ||
| 345 | case 'e': case 'l': { | ||
| 346 | int status; | ||
| 347 | char *extra = argv[i] + 2; /* both options need an argument */ | ||
| 348 | if (*extra == '\0') extra = argv[++i]; | ||
| 349 | lua_assert(extra != NULL); | ||
| 350 | status = (option == 'e') | ||
| 351 | ? dostring(L, extra, "=(command line)") | ||
| 352 | : dolibrary(L, extra); | ||
| 353 | if (status != LUA_OK) return 0; | ||
| 354 | break; | ||
| 355 | } | ||
| 356 | case 'W': | ||
| 357 | lua_warning(L, "@on", 0); /* warnings on */ | ||
| 358 | break; | ||
| 359 | } | ||
| 360 | } | ||
| 361 | return 1; | ||
| 362 | } | ||
| 363 | |||
| 364 | |||
| 365 | static int handle_luainit (lua_State *L) { | ||
| 366 | const char *name = "=" LUA_INITVARVERSION; | ||
| 367 | const char *init = getenv(name + 1); | ||
| 368 | if (init == NULL) { | ||
| 369 | name = "=" LUA_INIT_VAR; | ||
| 370 | init = getenv(name + 1); /* try alternative name */ | ||
| 371 | } | ||
| 372 | if (init == NULL) return LUA_OK; | ||
| 373 | else if (init[0] == '@') | ||
| 374 | return dofile(L, init+1); | ||
| 375 | else | ||
| 376 | return dostring(L, init, name); | ||
| 377 | } | ||
| 378 | |||
| 379 | |||
| 380 | /* | ||
| 381 | ** {================================================================== | ||
| 382 | ** Read-Eval-Print Loop (REPL) | ||
| 383 | ** =================================================================== | ||
| 384 | */ | ||
| 385 | |||
| 386 | #if !defined(LUA_PROMPT) | ||
| 387 | #define LUA_PROMPT "> " | ||
| 388 | #define LUA_PROMPT2 ">> " | ||
| 389 | #endif | ||
| 390 | |||
| 391 | #if !defined(LUA_MAXINPUT) | ||
| 392 | #define LUA_MAXINPUT 512 | ||
| 393 | #endif | ||
| 394 | |||
| 395 | |||
| 396 | /* | ||
| 397 | ** lua_stdin_is_tty detects whether the standard input is a 'tty' (that | ||
| 398 | ** is, whether we're running lua interactively). | ||
| 399 | */ | ||
| 400 | #if !defined(lua_stdin_is_tty) /* { */ | ||
| 401 | |||
| 402 | #if defined(LUA_USE_POSIX) /* { */ | ||
| 403 | |||
| 404 | #include <unistd.h> | ||
| 405 | #define lua_stdin_is_tty() isatty(0) | ||
| 406 | |||
| 407 | #elif defined(LUA_USE_WINDOWS) /* }{ */ | ||
| 408 | |||
| 409 | #include <io.h> | ||
| 410 | #include <windows.h> | ||
| 411 | |||
| 412 | #define lua_stdin_is_tty() _isatty(_fileno(stdin)) | ||
| 413 | |||
| 414 | #else /* }{ */ | ||
| 415 | |||
| 416 | /* ISO C definition */ | ||
| 417 | #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ | ||
| 418 | |||
| 419 | #endif /* } */ | ||
| 420 | |||
| 421 | #endif /* } */ | ||
| 422 | |||
| 423 | |||
| 424 | /* | ||
| 425 | ** lua_readline defines how to show a prompt and then read a line from | ||
| 426 | ** the standard input. | ||
| 427 | ** lua_saveline defines how to "save" a read line in a "history". | ||
| 428 | ** lua_freeline defines how to free a line read by lua_readline. | ||
| 429 | */ | ||
| 430 | #if !defined(lua_readline) /* { */ | ||
| 431 | |||
| 432 | #if defined(LUA_USE_READLINE) /* { */ | ||
| 433 | |||
| 434 | #include <readline/readline.h> | ||
| 435 | #include <readline/history.h> | ||
| 436 | #define lua_initreadline(L) ((void)L, rl_readline_name="lua") | ||
| 437 | #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) | ||
| 438 | #define lua_saveline(L,line) ((void)L, add_history(line)) | ||
| 439 | #define lua_freeline(L,b) ((void)L, free(b)) | ||
| 440 | |||
| 441 | #else /* }{ */ | ||
| 442 | |||
| 443 | #define lua_initreadline(L) ((void)L) | ||
| 444 | #define lua_readline(L,b,p) \ | ||
| 445 | ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ | ||
| 446 | fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ | ||
| 447 | #define lua_saveline(L,line) { (void)L; (void)line; } | ||
| 448 | #define lua_freeline(L,b) { (void)L; (void)b; } | ||
| 449 | |||
| 450 | #endif /* } */ | ||
| 451 | |||
| 452 | #endif /* } */ | ||
| 453 | |||
| 454 | |||
| 455 | /* | ||
| 456 | ** Return the string to be used as a prompt by the interpreter. Leave | ||
| 457 | ** the string (or nil, if using the default value) on the stack, to keep | ||
| 458 | ** it anchored. | ||
| 459 | */ | ||
| 460 | static const char *get_prompt (lua_State *L, int firstline) { | ||
| 461 | if (lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2") == LUA_TNIL) | ||
| 462 | return (firstline ? LUA_PROMPT : LUA_PROMPT2); /* use the default */ | ||
| 463 | else { /* apply 'tostring' over the value */ | ||
| 464 | const char *p = luaL_tolstring(L, -1, NULL); | ||
| 465 | lua_remove(L, -2); /* remove original value */ | ||
| 466 | return p; | ||
| 467 | } | ||
| 468 | } | ||
| 469 | |||
| 470 | /* mark in error messages for incomplete statements */ | ||
| 471 | #define EOFMARK "<eof>" | ||
| 472 | #define marklen (sizeof(EOFMARK)/sizeof(char) - 1) | ||
| 473 | |||
| 474 | |||
| 475 | /* | ||
| 476 | ** Check whether 'status' signals a syntax error and the error | ||
| 477 | ** message at the top of the stack ends with the above mark for | ||
| 478 | ** incomplete statements. | ||
| 479 | */ | ||
| 480 | static int incomplete (lua_State *L, int status) { | ||
| 481 | if (status == LUA_ERRSYNTAX) { | ||
| 482 | size_t lmsg; | ||
| 483 | const char *msg = lua_tolstring(L, -1, &lmsg); | ||
| 484 | if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) { | ||
| 485 | lua_pop(L, 1); | ||
| 486 | return 1; | ||
| 487 | } | ||
| 488 | } | ||
| 489 | return 0; /* else... */ | ||
| 490 | } | ||
| 491 | |||
| 492 | |||
| 493 | /* | ||
| 494 | ** Prompt the user, read a line, and push it into the Lua stack. | ||
| 495 | */ | ||
| 496 | static int pushline (lua_State *L, int firstline) { | ||
| 497 | char buffer[LUA_MAXINPUT]; | ||
| 498 | char *b = buffer; | ||
| 499 | size_t l; | ||
| 500 | const char *prmt = get_prompt(L, firstline); | ||
| 501 | int readstatus = lua_readline(L, b, prmt); | ||
| 502 | if (readstatus == 0) | ||
| 503 | return 0; /* no input (prompt will be popped by caller) */ | ||
| 504 | lua_pop(L, 1); /* remove prompt */ | ||
| 505 | l = strlen(b); | ||
| 506 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ | ||
| 507 | b[--l] = '\0'; /* remove it */ | ||
| 508 | if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */ | ||
| 509 | lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */ | ||
| 510 | else | ||
| 511 | lua_pushlstring(L, b, l); | ||
| 512 | lua_freeline(L, b); | ||
| 513 | return 1; | ||
| 514 | } | ||
| 515 | |||
| 516 | |||
| 517 | /* | ||
| 518 | ** Try to compile line on the stack as 'return <line>;'; on return, stack | ||
| 519 | ** has either compiled chunk or original line (if compilation failed). | ||
| 520 | */ | ||
| 521 | static int addreturn (lua_State *L) { | ||
| 522 | const char *line = lua_tostring(L, -1); /* original line */ | ||
| 523 | const char *retline = lua_pushfstring(L, "return %s;", line); | ||
| 524 | int status = luaL_loadbuffer(L, retline, strlen(retline), "=stdin"); | ||
| 525 | if (status == LUA_OK) { | ||
| 526 | lua_remove(L, -2); /* remove modified line */ | ||
| 527 | if (line[0] != '\0') /* non empty? */ | ||
| 528 | lua_saveline(L, line); /* keep history */ | ||
| 529 | } | ||
| 530 | else | ||
| 531 | lua_pop(L, 2); /* pop result from 'luaL_loadbuffer' and modified line */ | ||
| 532 | return status; | ||
| 533 | } | ||
| 534 | |||
| 535 | |||
| 536 | /* | ||
| 537 | ** Read multiple lines until a complete Lua statement | ||
| 538 | */ | ||
| 539 | static int multiline (lua_State *L) { | ||
| 540 | for (;;) { /* repeat until gets a complete statement */ | ||
| 541 | size_t len; | ||
| 542 | const char *line = lua_tolstring(L, 1, &len); /* get what it has */ | ||
| 543 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ | ||
| 544 | if (!incomplete(L, status) || !pushline(L, 0)) { | ||
| 545 | lua_saveline(L, line); /* keep history */ | ||
| 546 | return status; /* cannot or should not try to add continuation line */ | ||
| 547 | } | ||
| 548 | lua_pushliteral(L, "\n"); /* add newline... */ | ||
| 549 | lua_insert(L, -2); /* ...between the two lines */ | ||
| 550 | lua_concat(L, 3); /* join them */ | ||
| 551 | } | ||
| 552 | } | ||
| 553 | |||
| 554 | |||
| 555 | /* | ||
| 556 | ** Read a line and try to load (compile) it first as an expression (by | ||
| 557 | ** adding "return " in front of it) and second as a statement. Return | ||
| 558 | ** the final status of load/call with the resulting function (if any) | ||
| 559 | ** in the top of the stack. | ||
| 560 | */ | ||
| 561 | static int loadline (lua_State *L) { | ||
| 562 | int status; | ||
| 563 | lua_settop(L, 0); | ||
| 564 | if (!pushline(L, 1)) | ||
| 565 | return -1; /* no input */ | ||
| 566 | if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */ | ||
| 567 | status = multiline(L); /* try as command, maybe with continuation lines */ | ||
| 568 | lua_remove(L, 1); /* remove line from the stack */ | ||
| 569 | lua_assert(lua_gettop(L) == 1); | ||
| 570 | return status; | ||
| 571 | } | ||
| 572 | |||
| 573 | |||
| 574 | /* | ||
| 575 | ** Prints (calling the Lua 'print' function) any values on the stack | ||
| 576 | */ | ||
| 577 | static void l_print (lua_State *L) { | ||
| 578 | int n = lua_gettop(L); | ||
| 579 | if (n > 0) { /* any result to be printed? */ | ||
| 580 | luaL_checkstack(L, LUA_MINSTACK, "too many results to print"); | ||
| 581 | lua_getglobal(L, "print"); | ||
| 582 | lua_insert(L, 1); | ||
| 583 | if (lua_pcall(L, n, 0, 0) != LUA_OK) | ||
| 584 | l_message(progname, lua_pushfstring(L, "error calling 'print' (%s)", | ||
| 585 | lua_tostring(L, -1))); | ||
| 586 | } | ||
| 587 | } | ||
| 588 | |||
| 589 | |||
| 590 | /* | ||
| 591 | ** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and | ||
| 592 | ** print any results. | ||
| 593 | */ | ||
| 594 | static void doREPL (lua_State *L) { | ||
| 595 | int status; | ||
| 596 | const char *oldprogname = progname; | ||
| 597 | progname = NULL; /* no 'progname' on errors in interactive mode */ | ||
| 598 | lua_initreadline(L); | ||
| 599 | while ((status = loadline(L)) != -1) { | ||
| 600 | if (status == LUA_OK) | ||
| 601 | status = docall(L, 0, LUA_MULTRET); | ||
| 602 | if (status == LUA_OK) l_print(L); | ||
| 603 | else report(L, status); | ||
| 604 | } | ||
| 605 | lua_settop(L, 0); /* clear stack */ | ||
| 606 | lua_writeline(); | ||
| 607 | progname = oldprogname; | ||
| 608 | } | ||
| 609 | |||
| 610 | /* }================================================================== */ | ||
| 611 | |||
| 612 | |||
| 613 | /* | ||
| 614 | ** Main body of stand-alone interpreter (to be called in protected mode). | ||
| 615 | ** Reads the options and handles them all. | ||
| 616 | */ | ||
| 617 | static int pmain (lua_State *L) { | ||
| 618 | int argc = (int)lua_tointeger(L, 1); | ||
| 619 | char **argv = (char **)lua_touserdata(L, 2); | ||
| 620 | int script; | ||
| 621 | int args = collectargs(argv, &script); | ||
| 622 | int optlim = (script > 0) ? script : argc; /* first argv not an option */ | ||
| 623 | luaL_checkversion(L); /* check that interpreter has correct version */ | ||
| 624 | if (args == has_error) { /* bad arg? */ | ||
| 625 | print_usage(argv[script]); /* 'script' has index of bad arg. */ | ||
| 626 | return 0; | ||
| 627 | } | ||
| 628 | if (args & has_v) /* option '-v'? */ | ||
| 629 | print_version(); | ||
| 630 | if (args & has_E) { /* option '-E'? */ | ||
| 631 | lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */ | ||
| 632 | lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); | ||
| 633 | } | ||
| 634 | luaL_openlibs(L); /* open standard libraries */ | ||
| 635 | createargtable(L, argv, argc, script); /* create table 'arg' */ | ||
| 636 | lua_gc(L, LUA_GCGEN, 0, 0); /* GC in generational mode */ | ||
| 637 | if (!(args & has_E)) { /* no option '-E'? */ | ||
| 638 | if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */ | ||
| 639 | return 0; /* error running LUA_INIT */ | ||
| 640 | } | ||
| 641 | if (!runargs(L, argv, optlim)) /* execute arguments -e and -l */ | ||
| 642 | return 0; /* something failed */ | ||
| 643 | if (script > 0) { /* execute main script (if there is one) */ | ||
| 644 | if (handle_script(L, argv + script) != LUA_OK) | ||
| 645 | return 0; /* interrupt in case of error */ | ||
| 646 | } | ||
| 647 | if (args & has_i) /* -i option? */ | ||
| 648 | doREPL(L); /* do read-eval-print loop */ | ||
| 649 | else if (script < 1 && !(args & (has_e | has_v))) { /* no active option? */ | ||
| 650 | if (lua_stdin_is_tty()) { /* running in interactive mode? */ | ||
| 651 | print_version(); | ||
| 652 | doREPL(L); /* do read-eval-print loop */ | ||
| 653 | } | ||
| 654 | else dofile(L, NULL); /* executes stdin as a file */ | ||
| 655 | } | ||
| 656 | lua_pushboolean(L, 1); /* signal no errors */ | ||
| 657 | return 1; | ||
| 658 | } | ||
| 659 | |||
| 660 | |||
| 661 | int main (int argc, char **argv) { | ||
| 662 | int status, result; | ||
| 663 | lua_State *L = luaL_newstate(); /* create state */ | ||
| 664 | if (L == NULL) { | ||
| 665 | l_message(argv[0], "cannot create state: not enough memory"); | ||
| 666 | return EXIT_FAILURE; | ||
| 667 | } | ||
| 668 | lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ | ||
| 669 | lua_pushinteger(L, argc); /* 1st argument */ | ||
| 670 | lua_pushlightuserdata(L, argv); /* 2nd argument */ | ||
| 671 | status = lua_pcall(L, 2, 1, 0); /* do the call */ | ||
| 672 | result = lua_toboolean(L, -1); /* get result */ | ||
| 673 | report(L, status); | ||
| 674 | lua_close(L); | ||
| 675 | return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; | ||
| 676 | } | ||
| 677 | |||
diff --git a/src/3rdParty/lua/luac.c b/src/3rdParty/lua/luac.c deleted file mode 100644 index 56ddc41..0000000 --- a/src/3rdParty/lua/luac.c +++ /dev/null | |||
| @@ -1,724 +0,0 @@ | |||
| 1 | /* | ||
| 2 | ** $Id: luac.c $ | ||
| 3 | ** Lua compiler (saves bytecodes to files; also lists bytecodes) | ||
| 4 | ** See Copyright Notice in lua.h | ||
| 5 | */ | ||
| 6 | |||
| 7 | #define luac_c | ||
| 8 | #define LUA_CORE | ||
| 9 | |||
| 10 | #include "lprefix.h" | ||
| 11 | |||
| 12 | #include <ctype.h> | ||
| 13 | #include <errno.h> | ||
| 14 | #include <stdio.h> | ||
| 15 | #include <stdlib.h> | ||
| 16 | #include <string.h> | ||
| 17 | |||
| 18 | #include "lua.h" | ||
| 19 | #include "lauxlib.h" | ||
| 20 | |||
| 21 | #include "ldebug.h" | ||
| 22 | #include "lobject.h" | ||
| 23 | #include "lopcodes.h" | ||
| 24 | #include "lopnames.h" | ||
| 25 | #include "lstate.h" | ||
| 26 | #include "lundump.h" | ||
| 27 | |||
| 28 | static void PrintFunction(const Proto* f, int full); | ||
| 29 | #define luaU_print PrintFunction | ||
| 30 | |||
| 31 | #define PROGNAME "luac" /* default program name */ | ||
| 32 | #define OUTPUT PROGNAME ".out" /* default output file */ | ||
| 33 | |||
| 34 | static int listing=0; /* list bytecodes? */ | ||
| 35 | static int dumping=1; /* dump bytecodes? */ | ||
| 36 | static int stripping=0; /* strip debug information? */ | ||
| 37 | static char Output[]={ OUTPUT }; /* default output file name */ | ||
| 38 | static const char* output=Output; /* actual output file name */ | ||
| 39 | static const char* progname=PROGNAME; /* actual program name */ | ||
| 40 | static TString **tmname; | ||
| 41 | |||
| 42 | static void fatal(const char* message) | ||
| 43 | { | ||
| 44 | fprintf(stderr,"%s: %s\n",progname,message); | ||
| 45 | exit(EXIT_FAILURE); | ||
| 46 | } | ||
| 47 | |||
| 48 | static void cannot(const char* what) | ||
| 49 | { | ||
| 50 | fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); | ||
| 51 | exit(EXIT_FAILURE); | ||
| 52 | } | ||
| 53 | |||
| 54 | static void usage(const char* message) | ||
| 55 | { | ||
| 56 | if (*message=='-') | ||
| 57 | fprintf(stderr,"%s: unrecognized option '%s'\n",progname,message); | ||
| 58 | else | ||
| 59 | fprintf(stderr,"%s: %s\n",progname,message); | ||
| 60 | fprintf(stderr, | ||
| 61 | "usage: %s [options] [filenames]\n" | ||
| 62 | "Available options are:\n" | ||
| 63 | " -l list (use -l -l for full listing)\n" | ||
| 64 | " -o name output to file 'name' (default is \"%s\")\n" | ||
| 65 | " -p parse only\n" | ||
| 66 | " -s strip debug information\n" | ||
| 67 | " -v show version information\n" | ||
| 68 | " -- stop handling options\n" | ||
| 69 | " - stop handling options and process stdin\n" | ||
| 70 | ,progname,Output); | ||
| 71 | exit(EXIT_FAILURE); | ||
| 72 | } | ||
| 73 | |||
| 74 | #define IS(s) (strcmp(argv[i],s)==0) | ||
| 75 | |||
| 76 | static int doargs(int argc, char* argv[]) | ||
| 77 | { | ||
| 78 | int i; | ||
| 79 | int version=0; | ||
| 80 | if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; | ||
| 81 | for (i=1; i<argc; i++) | ||
| 82 | { | ||
| 83 | if (*argv[i]!='-') /* end of options; keep it */ | ||
| 84 | break; | ||
| 85 | else if (IS("--")) /* end of options; skip it */ | ||
| 86 | { | ||
| 87 | ++i; | ||
| 88 | if (version) ++version; | ||
| 89 | break; | ||
| 90 | } | ||
| 91 | else if (IS("-")) /* end of options; use stdin */ | ||
| 92 | break; | ||
| 93 | else if (IS("-l")) /* list */ | ||
| 94 | ++listing; | ||
| 95 | else if (IS("-o")) /* output file */ | ||
| 96 | { | ||
| 97 | output=argv[++i]; | ||
| 98 | if (output==NULL || *output==0 || (*output=='-' && output[1]!=0)) | ||
| 99 | usage("'-o' needs argument"); | ||
| 100 | if (IS("-")) output=NULL; | ||
| 101 | } | ||
| 102 | else if (IS("-p")) /* parse only */ | ||
| 103 | dumping=0; | ||
| 104 | else if (IS("-s")) /* strip debug information */ | ||
| 105 | stripping=1; | ||
| 106 | else if (IS("-v")) /* show version */ | ||
| 107 | ++version; | ||
| 108 | else /* unknown option */ | ||
| 109 | usage(argv[i]); | ||
| 110 | } | ||
| 111 | if (i==argc && (listing || !dumping)) | ||
| 112 | { | ||
| 113 | dumping=0; | ||
| 114 | argv[--i]=Output; | ||
| 115 | } | ||
| 116 | if (version) | ||
| 117 | { | ||
| 118 | printf("%s\n",LUA_COPYRIGHT); | ||
| 119 | if (version==argc-1) exit(EXIT_SUCCESS); | ||
| 120 | } | ||
| 121 | return i; | ||
| 122 | } | ||
| 123 | |||
| 124 | #define FUNCTION "(function()end)();" | ||
| 125 | |||
| 126 | static const char* reader(lua_State* L, void* ud, size_t* size) | ||
| 127 | { | ||
| 128 | UNUSED(L); | ||
| 129 | if ((*(int*)ud)--) | ||
| 130 | { | ||
| 131 | *size=sizeof(FUNCTION)-1; | ||
| 132 | return FUNCTION; | ||
| 133 | } | ||
| 134 | else | ||
| 135 | { | ||
| 136 | *size=0; | ||
| 137 | return NULL; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | #define toproto(L,i) getproto(s2v(L->top+(i))) | ||
| 142 | |||
| 143 | static const Proto* combine(lua_State* L, int n) | ||
| 144 | { | ||
| 145 | if (n==1) | ||
| 146 | return toproto(L,-1); | ||
| 147 | else | ||
| 148 | { | ||
| 149 | Proto* f; | ||
| 150 | int i=n; | ||
| 151 | if (lua_load(L,reader,&i,"=(" PROGNAME ")",NULL)!=LUA_OK) fatal(lua_tostring(L,-1)); | ||
| 152 | f=toproto(L,-1); | ||
| 153 | for (i=0; i<n; i++) | ||
| 154 | { | ||
| 155 | f->p[i]=toproto(L,i-n-1); | ||
| 156 | if (f->p[i]->sizeupvalues>0) f->p[i]->upvalues[0].instack=0; | ||
| 157 | } | ||
| 158 | f->sizelineinfo=0; | ||
| 159 | return f; | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 163 | static int writer(lua_State* L, const void* p, size_t size, void* u) | ||
| 164 | { | ||
| 165 | UNUSED(L); | ||
| 166 | return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); | ||
| 167 | } | ||
| 168 | |||
| 169 | static int pmain(lua_State* L) | ||
| 170 | { | ||
| 171 | int argc=(int)lua_tointeger(L,1); | ||
| 172 | char** argv=(char**)lua_touserdata(L,2); | ||
| 173 | const Proto* f; | ||
| 174 | int i; | ||
| 175 | tmname=G(L)->tmname; | ||
| 176 | if (!lua_checkstack(L,argc)) fatal("too many input files"); | ||
| 177 | for (i=0; i<argc; i++) | ||
| 178 | { | ||
| 179 | const char* filename=IS("-") ? NULL : argv[i]; | ||
| 180 | if (luaL_loadfile(L,filename)!=LUA_OK) fatal(lua_tostring(L,-1)); | ||
| 181 | } | ||
| 182 | f=combine(L,argc); | ||
| 183 | if (listing) luaU_print(f,listing>1); | ||
| 184 | if (dumping) | ||
| 185 | { | ||
| 186 | FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); | ||
| 187 | if (D==NULL) cannot("open"); | ||
| 188 | lua_lock(L); | ||
| 189 | luaU_dump(L,f,writer,D,stripping); | ||
| 190 | lua_unlock(L); | ||
| 191 | if (ferror(D)) cannot("write"); | ||
| 192 | if (fclose(D)) cannot("close"); | ||
| 193 | } | ||
| 194 | return 0; | ||
| 195 | } | ||
| 196 | |||
| 197 | int main(int argc, char* argv[]) | ||
| 198 | { | ||
| 199 | lua_State* L; | ||
| 200 | int i=doargs(argc,argv); | ||
| 201 | argc-=i; argv+=i; | ||
| 202 | if (argc<=0) usage("no input files given"); | ||
| 203 | L=luaL_newstate(); | ||
| 204 | if (L==NULL) fatal("cannot create state: not enough memory"); | ||
| 205 | lua_pushcfunction(L,&pmain); | ||
| 206 | lua_pushinteger(L,argc); | ||
| 207 | lua_pushlightuserdata(L,argv); | ||
| 208 | if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1)); | ||
| 209 | lua_close(L); | ||
| 210 | return EXIT_SUCCESS; | ||
| 211 | } | ||
| 212 | |||
| 213 | /* | ||
| 214 | ** print bytecodes | ||
| 215 | */ | ||
| 216 | |||
| 217 | #define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-") | ||
| 218 | #define VOID(p) ((const void*)(p)) | ||
| 219 | #define eventname(i) (getstr(tmname[i])) | ||
| 220 | |||
| 221 | static void PrintString(const TString* ts) | ||
| 222 | { | ||
| 223 | const char* s=getstr(ts); | ||
| 224 | size_t i,n=tsslen(ts); | ||
| 225 | printf("\""); | ||
| 226 | for (i=0; i<n; i++) | ||
| 227 | { | ||
| 228 | int c=(int)(unsigned char)s[i]; | ||
| 229 | switch (c) | ||
| 230 | { | ||
| 231 | case '"': | ||
| 232 | printf("\\\""); | ||
| 233 | break; | ||
| 234 | case '\\': | ||
| 235 | printf("\\\\"); | ||
| 236 | break; | ||
| 237 | case '\a': | ||
| 238 | printf("\\a"); | ||
| 239 | break; | ||
| 240 | case '\b': | ||
| 241 | printf("\\b"); | ||
| 242 | break; | ||
| 243 | case '\f': | ||
| 244 | printf("\\f"); | ||
| 245 | break; | ||
| 246 | case '\n': | ||
| 247 | printf("\\n"); | ||
| 248 | break; | ||
| 249 | case '\r': | ||
| 250 | printf("\\r"); | ||
| 251 | break; | ||
| 252 | case '\t': | ||
| 253 | printf("\\t"); | ||
| 254 | break; | ||
| 255 | case '\v': | ||
| 256 | printf("\\v"); | ||
| 257 | break; | ||
| 258 | default: | ||
| 259 | if (isprint(c)) printf("%c",c); else printf("\\%03d",c); | ||
| 260 | break; | ||
| 261 | } | ||
| 262 | } | ||
| 263 | printf("\""); | ||
| 264 | } | ||
| 265 | |||
| 266 | static void PrintType(const Proto* f, int i) | ||
| 267 | { | ||
| 268 | const TValue* o=&f->k[i]; | ||
| 269 | switch (ttypetag(o)) | ||
| 270 | { | ||
| 271 | case LUA_VNIL: | ||
| 272 | printf("N"); | ||
| 273 | break; | ||
| 274 | case LUA_VFALSE: | ||
| 275 | case LUA_VTRUE: | ||
| 276 | printf("B"); | ||
| 277 | break; | ||
| 278 | case LUA_VNUMFLT: | ||
| 279 | printf("F"); | ||
| 280 | break; | ||
| 281 | case LUA_VNUMINT: | ||
| 282 | printf("I"); | ||
| 283 | break; | ||
| 284 | case LUA_VSHRSTR: | ||
| 285 | case LUA_VLNGSTR: | ||
| 286 | printf("S"); | ||
| 287 | break; | ||
| 288 | default: /* cannot happen */ | ||
| 289 | printf("?%d",ttypetag(o)); | ||
| 290 | break; | ||
| 291 | } | ||
| 292 | printf("\t"); | ||
| 293 | } | ||
| 294 | |||
| 295 | static void PrintConstant(const Proto* f, int i) | ||
| 296 | { | ||
| 297 | const TValue* o=&f->k[i]; | ||
| 298 | switch (ttypetag(o)) | ||
| 299 | { | ||
| 300 | case LUA_VNIL: | ||
| 301 | printf("nil"); | ||
| 302 | break; | ||
| 303 | case LUA_VFALSE: | ||
| 304 | printf("false"); | ||
| 305 | break; | ||
| 306 | case LUA_VTRUE: | ||
| 307 | printf("true"); | ||
| 308 | break; | ||
| 309 | case LUA_VNUMFLT: | ||
| 310 | { | ||
| 311 | char buff[100]; | ||
| 312 | sprintf(buff,LUA_NUMBER_FMT,fltvalue(o)); | ||
| 313 | printf("%s",buff); | ||
| 314 | if (buff[strspn(buff,"-0123456789")]=='\0') printf(".0"); | ||
| 315 | break; | ||
| 316 | } | ||
| 317 | case LUA_VNUMINT: | ||
| 318 | printf(LUA_INTEGER_FMT,ivalue(o)); | ||
| 319 | break; | ||
| 320 | case LUA_VSHRSTR: | ||
| 321 | case LUA_VLNGSTR: | ||
| 322 | PrintString(tsvalue(o)); | ||
| 323 | break; | ||
| 324 | default: /* cannot happen */ | ||
| 325 | printf("?%d",ttypetag(o)); | ||
| 326 | break; | ||
| 327 | } | ||
| 328 | } | ||
| 329 | |||
| 330 | #define COMMENT "\t; " | ||
| 331 | #define EXTRAARG GETARG_Ax(code[pc+1]) | ||
| 332 | #define EXTRAARGC (EXTRAARG*(MAXARG_C+1)) | ||
| 333 | #define ISK (isk ? "k" : "") | ||
| 334 | |||
| 335 | static void PrintCode(const Proto* f) | ||
| 336 | { | ||
| 337 | const Instruction* code=f->code; | ||
| 338 | int pc,n=f->sizecode; | ||
| 339 | for (pc=0; pc<n; pc++) | ||
| 340 | { | ||
| 341 | Instruction i=code[pc]; | ||
| 342 | OpCode o=GET_OPCODE(i); | ||
| 343 | int a=GETARG_A(i); | ||
| 344 | int b=GETARG_B(i); | ||
| 345 | int c=GETARG_C(i); | ||
| 346 | int ax=GETARG_Ax(i); | ||
| 347 | int bx=GETARG_Bx(i); | ||
| 348 | int sb=GETARG_sB(i); | ||
| 349 | int sc=GETARG_sC(i); | ||
| 350 | int sbx=GETARG_sBx(i); | ||
| 351 | int isk=GETARG_k(i); | ||
| 352 | int line=luaG_getfuncline(f,pc); | ||
| 353 | printf("\t%d\t",pc+1); | ||
| 354 | if (line>0) printf("[%d]\t",line); else printf("[-]\t"); | ||
| 355 | printf("%-9s\t",opnames[o]); | ||
| 356 | switch (o) | ||
| 357 | { | ||
| 358 | case OP_MOVE: | ||
| 359 | printf("%d %d",a,b); | ||
| 360 | break; | ||
| 361 | case OP_LOADI: | ||
| 362 | printf("%d %d",a,sbx); | ||
| 363 | break; | ||
| 364 | case OP_LOADF: | ||
| 365 | printf("%d %d",a,sbx); | ||
| 366 | break; | ||
| 367 | case OP_LOADK: | ||
| 368 | printf("%d %d",a,bx); | ||
| 369 | printf(COMMENT); PrintConstant(f,bx); | ||
| 370 | break; | ||
| 371 | case OP_LOADKX: | ||
| 372 | printf("%d",a); | ||
| 373 | printf(COMMENT); PrintConstant(f,EXTRAARG); | ||
| 374 | break; | ||
| 375 | case OP_LOADFALSE: | ||
| 376 | printf("%d",a); | ||
| 377 | break; | ||
| 378 | case OP_LFALSESKIP: | ||
| 379 | printf("%d",a); | ||
| 380 | break; | ||
| 381 | case OP_LOADTRUE: | ||
| 382 | printf("%d",a); | ||
| 383 | break; | ||
| 384 | case OP_LOADNIL: | ||
| 385 | printf("%d %d",a,b); | ||
| 386 | printf(COMMENT "%d out",b+1); | ||
| 387 | break; | ||
| 388 | case OP_GETUPVAL: | ||
| 389 | printf("%d %d",a,b); | ||
| 390 | printf(COMMENT "%s",UPVALNAME(b)); | ||
| 391 | break; | ||
| 392 | case OP_SETUPVAL: | ||
| 393 | printf("%d %d",a,b); | ||
| 394 | printf(COMMENT "%s",UPVALNAME(b)); | ||
| 395 | break; | ||
| 396 | case OP_GETTABUP: | ||
| 397 | printf("%d %d %d",a,b,c); | ||
| 398 | printf(COMMENT "%s",UPVALNAME(b)); | ||
| 399 | printf(" "); PrintConstant(f,c); | ||
| 400 | break; | ||
| 401 | case OP_GETTABLE: | ||
| 402 | printf("%d %d %d",a,b,c); | ||
| 403 | break; | ||
| 404 | case OP_GETI: | ||
| 405 | printf("%d %d %d",a,b,c); | ||
| 406 | break; | ||
| 407 | case OP_GETFIELD: | ||
| 408 | printf("%d %d %d",a,b,c); | ||
| 409 | printf(COMMENT); PrintConstant(f,c); | ||
| 410 | break; | ||
| 411 | case OP_SETTABUP: | ||
| 412 | printf("%d %d %d%s",a,b,c,ISK); | ||
| 413 | printf(COMMENT "%s",UPVALNAME(a)); | ||
| 414 | printf(" "); PrintConstant(f,b); | ||
| 415 | if (isk) { printf(" "); PrintConstant(f,c); } | ||
| 416 | break; | ||
| 417 | case OP_SETTABLE: | ||
| 418 | printf("%d %d %d%s",a,b,c,ISK); | ||
| 419 | if (isk) { printf(COMMENT); PrintConstant(f,c); } | ||
| 420 | break; | ||
| 421 | case OP_SETI: | ||
| 422 | printf("%d %d %d%s",a,b,c,ISK); | ||
| 423 | if (isk) { printf(COMMENT); PrintConstant(f,c); } | ||
| 424 | break; | ||
| 425 | case OP_SETFIELD: | ||
| 426 | printf("%d %d %d%s",a,b,c,ISK); | ||
| 427 | printf(COMMENT); PrintConstant(f,b); | ||
| 428 | if (isk) { printf(" "); PrintConstant(f,c); } | ||
| 429 | break; | ||
| 430 | case OP_NEWTABLE: | ||
| 431 | printf("%d %d %d",a,b,c); | ||
| 432 | printf(COMMENT "%d",c+EXTRAARGC); | ||
| 433 | break; | ||
| 434 | case OP_SELF: | ||
| 435 | printf("%d %d %d%s",a,b,c,ISK); | ||
| 436 | if (isk) { printf(COMMENT); PrintConstant(f,c); } | ||
| 437 | break; | ||
| 438 | case OP_ADDI: | ||
| 439 | printf("%d %d %d",a,b,sc); | ||
| 440 | break; | ||
| 441 | case OP_ADDK: | ||
| 442 | printf("%d %d %d",a,b,c); | ||
| 443 | printf(COMMENT); PrintConstant(f,c); | ||
| 444 | break; | ||
| 445 | case OP_SUBK: | ||
| 446 | printf("%d %d %d",a,b,c); | ||
| 447 | printf(COMMENT); PrintConstant(f,c); | ||
| 448 | break; | ||
| 449 | case OP_MULK: | ||
| 450 | printf("%d %d %d",a,b,c); | ||
| 451 | printf(COMMENT); PrintConstant(f,c); | ||
| 452 | break; | ||
| 453 | case OP_MODK: | ||
| 454 | printf("%d %d %d",a,b,c); | ||
| 455 | printf(COMMENT); PrintConstant(f,c); | ||
| 456 | break; | ||
| 457 | case OP_POWK: | ||
| 458 | printf("%d %d %d",a,b,c); | ||
| 459 | printf(COMMENT); PrintConstant(f,c); | ||
| 460 | break; | ||
| 461 | case OP_DIVK: | ||
| 462 | printf("%d %d %d",a,b,c); | ||
| 463 | printf(COMMENT); PrintConstant(f,c); | ||
| 464 | break; | ||
| 465 | case OP_IDIVK: | ||
| 466 | printf("%d %d %d",a,b,c); | ||
| 467 | printf(COMMENT); PrintConstant(f,c); | ||
| 468 | break; | ||
| 469 | case OP_BANDK: | ||
| 470 | printf("%d %d %d",a,b,c); | ||
| 471 | printf(COMMENT); PrintConstant(f,c); | ||
| 472 | break; | ||
| 473 | case OP_BORK: | ||
| 474 | printf("%d %d %d",a,b,c); | ||
| 475 | printf(COMMENT); PrintConstant(f,c); | ||
| 476 | break; | ||
| 477 | case OP_BXORK: | ||
| 478 | printf("%d %d %d",a,b,c); | ||
| 479 | printf(COMMENT); PrintConstant(f,c); | ||
| 480 | break; | ||
| 481 | case OP_SHRI: | ||
| 482 | printf("%d %d %d",a,b,sc); | ||
| 483 | break; | ||
| 484 | case OP_SHLI: | ||
| 485 | printf("%d %d %d",a,b,sc); | ||
| 486 | break; | ||
| 487 | case OP_ADD: | ||
| 488 | printf("%d %d %d",a,b,c); | ||
| 489 | break; | ||
| 490 | case OP_SUB: | ||
| 491 | printf("%d %d %d",a,b,c); | ||
| 492 | break; | ||
| 493 | case OP_MUL: | ||
| 494 | printf("%d %d %d",a,b,c); | ||
| 495 | break; | ||
| 496 | case OP_MOD: | ||
| 497 | printf("%d %d %d",a,b,c); | ||
| 498 | break; | ||
| 499 | case OP_POW: | ||
| 500 | printf("%d %d %d",a,b,c); | ||
| 501 | break; | ||
| 502 | case OP_DIV: | ||
| 503 | printf("%d %d %d",a,b,c); | ||
| 504 | break; | ||
| 505 | case OP_IDIV: | ||
| 506 | printf("%d %d %d",a,b,c); | ||
| 507 | break; | ||
| 508 | case OP_BAND: | ||
| 509 | printf("%d %d %d",a,b,c); | ||
| 510 | break; | ||
| 511 | case OP_BOR: | ||
| 512 | printf("%d %d %d",a,b,c); | ||
| 513 | break; | ||
| 514 | case OP_BXOR: | ||
| 515 | printf("%d %d %d",a,b,c); | ||
| 516 | break; | ||
| 517 | case OP_SHL: | ||
| 518 | printf("%d %d %d",a,b,c); | ||
| 519 | break; | ||
| 520 | case OP_SHR: | ||
| 521 | printf("%d %d %d",a,b,c); | ||
| 522 | break; | ||
| 523 | case OP_MMBIN: | ||
| 524 | printf("%d %d %d",a,b,c); | ||
| 525 | printf(COMMENT "%s",eventname(c)); | ||
| 526 | break; | ||
| 527 | case OP_MMBINI: | ||
| 528 | printf("%d %d %d %d",a,sb,c,isk); | ||
| 529 | printf(COMMENT "%s",eventname(c)); | ||
| 530 | if (isk) printf(" flip"); | ||
| 531 | break; | ||
| 532 | case OP_MMBINK: | ||
| 533 | printf("%d %d %d %d",a,b,c,isk); | ||
| 534 | printf(COMMENT "%s ",eventname(c)); PrintConstant(f,b); | ||
| 535 | if (isk) printf(" flip"); | ||
| 536 | break; | ||
| 537 | case OP_UNM: | ||
| 538 | printf("%d %d",a,b); | ||
| 539 | break; | ||
| 540 | case OP_BNOT: | ||
| 541 | printf("%d %d",a,b); | ||
| 542 | break; | ||
| 543 | case OP_NOT: | ||
| 544 | printf("%d %d",a,b); | ||
| 545 | break; | ||
| 546 | case OP_LEN: | ||
| 547 | printf("%d %d",a,b); | ||
| 548 | break; | ||
| 549 | case OP_CONCAT: | ||
| 550 | printf("%d %d",a,b); | ||
| 551 | break; | ||
| 552 | case OP_CLOSE: | ||
| 553 | printf("%d",a); | ||
| 554 | break; | ||
| 555 | case OP_TBC: | ||
| 556 | printf("%d",a); | ||
| 557 | break; | ||
| 558 | case OP_JMP: | ||
| 559 | printf("%d",GETARG_sJ(i)); | ||
| 560 | printf(COMMENT "to %d",GETARG_sJ(i)+pc+2); | ||
| 561 | break; | ||
| 562 | case OP_EQ: | ||
| 563 | printf("%d %d %d",a,b,isk); | ||
| 564 | break; | ||
| 565 | case OP_LT: | ||
| 566 | printf("%d %d %d",a,b,isk); | ||
| 567 | break; | ||
| 568 | case OP_LE: | ||
| 569 | printf("%d %d %d",a,b,isk); | ||
| 570 | break; | ||
| 571 | case OP_EQK: | ||
| 572 | printf("%d %d %d",a,b,isk); | ||
| 573 | printf(COMMENT); PrintConstant(f,b); | ||
| 574 | break; | ||
| 575 | case OP_EQI: | ||
| 576 | printf("%d %d %d",a,sb,isk); | ||
| 577 | break; | ||
| 578 | case OP_LTI: | ||
| 579 | printf("%d %d %d",a,sb,isk); | ||
| 580 | break; | ||
| 581 | case OP_LEI: | ||
| 582 | printf("%d %d %d",a,sb,isk); | ||
| 583 | break; | ||
| 584 | case OP_GTI: | ||
| 585 | printf("%d %d %d",a,sb,isk); | ||
| 586 | break; | ||
| 587 | case OP_GEI: | ||
| 588 | printf("%d %d %d",a,sb,isk); | ||
| 589 | break; | ||
| 590 | case OP_TEST: | ||
| 591 | printf("%d %d",a,isk); | ||
| 592 | break; | ||
| 593 | case OP_TESTSET: | ||
| 594 | printf("%d %d %d",a,b,isk); | ||
| 595 | break; | ||
| 596 | case OP_CALL: | ||
| 597 | printf("%d %d %d",a,b,c); | ||
| 598 | printf(COMMENT); | ||
| 599 | if (b==0) printf("all in "); else printf("%d in ",b-1); | ||
| 600 | if (c==0) printf("all out"); else printf("%d out",c-1); | ||
| 601 | break; | ||
| 602 | case OP_TAILCALL: | ||
| 603 | printf("%d %d %d",a,b,c); | ||
| 604 | printf(COMMENT "%d in",b-1); | ||
| 605 | break; | ||
| 606 | case OP_RETURN: | ||
| 607 | printf("%d %d %d",a,b,c); | ||
| 608 | printf(COMMENT); | ||
| 609 | if (b==0) printf("all out"); else printf("%d out",b-1); | ||
| 610 | break; | ||
| 611 | case OP_RETURN0: | ||
| 612 | break; | ||
| 613 | case OP_RETURN1: | ||
| 614 | printf("%d",a); | ||
| 615 | break; | ||
| 616 | case OP_FORLOOP: | ||
| 617 | printf("%d %d",a,bx); | ||
| 618 | printf(COMMENT "to %d",pc-bx+2); | ||
| 619 | break; | ||
| 620 | case OP_FORPREP: | ||
| 621 | printf("%d %d",a,bx); | ||
| 622 | printf(COMMENT "to %d",pc+bx+2); | ||
| 623 | break; | ||
| 624 | case OP_TFORPREP: | ||
| 625 | printf("%d %d",a,bx); | ||
| 626 | printf(COMMENT "to %d",pc+bx+2); | ||
| 627 | break; | ||
| 628 | case OP_TFORCALL: | ||
| 629 | printf("%d %d",a,c); | ||
| 630 | break; | ||
| 631 | case OP_TFORLOOP: | ||
| 632 | printf("%d %d",a,bx); | ||
| 633 | printf(COMMENT "to %d",pc-bx+2); | ||
| 634 | break; | ||
| 635 | case OP_SETLIST: | ||
| 636 | printf("%d %d %d",a,b,c); | ||
| 637 | if (isk) printf(COMMENT "%d",c+EXTRAARGC); | ||
| 638 | break; | ||
| 639 | case OP_CLOSURE: | ||
| 640 | printf("%d %d",a,bx); | ||
| 641 | printf(COMMENT "%p",VOID(f->p[bx])); | ||
| 642 | break; | ||
| 643 | case OP_VARARG: | ||
| 644 | printf("%d %d",a,c); | ||
| 645 | printf(COMMENT); | ||
| 646 | if (c==0) printf("all out"); else printf("%d out",c-1); | ||
| 647 | break; | ||
| 648 | case OP_VARARGPREP: | ||
| 649 | printf("%d",a); | ||
| 650 | break; | ||
| 651 | case OP_EXTRAARG: | ||
| 652 | printf("%d",ax); | ||
| 653 | break; | ||
| 654 | #if 0 | ||
| 655 | default: | ||
| 656 | printf("%d %d %d",a,b,c); | ||
| 657 | printf(COMMENT "not handled"); | ||
| 658 | break; | ||
| 659 | #endif | ||
| 660 | } | ||
| 661 | printf("\n"); | ||
| 662 | } | ||
| 663 | } | ||
| 664 | |||
| 665 | |||
| 666 | #define SS(x) ((x==1)?"":"s") | ||
| 667 | #define S(x) (int)(x),SS(x) | ||
| 668 | |||
| 669 | static void PrintHeader(const Proto* f) | ||
| 670 | { | ||
| 671 | const char* s=f->source ? getstr(f->source) : "=?"; | ||
| 672 | if (*s=='@' || *s=='=') | ||
| 673 | s++; | ||
| 674 | else if (*s==LUA_SIGNATURE[0]) | ||
| 675 | s="(bstring)"; | ||
| 676 | else | ||
| 677 | s="(string)"; | ||
| 678 | printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n", | ||
| 679 | (f->linedefined==0)?"main":"function",s, | ||
| 680 | f->linedefined,f->lastlinedefined, | ||
| 681 | S(f->sizecode),VOID(f)); | ||
| 682 | printf("%d%s param%s, %d slot%s, %d upvalue%s, ", | ||
| 683 | (int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams), | ||
| 684 | S(f->maxstacksize),S(f->sizeupvalues)); | ||
| 685 | printf("%d local%s, %d constant%s, %d function%s\n", | ||
| 686 | S(f->sizelocvars),S(f->sizek),S(f->sizep)); | ||
| 687 | } | ||
| 688 | |||
| 689 | static void PrintDebug(const Proto* f) | ||
| 690 | { | ||
| 691 | int i,n; | ||
| 692 | n=f->sizek; | ||
| 693 | printf("constants (%d) for %p:\n",n,VOID(f)); | ||
| 694 | for (i=0; i<n; i++) | ||
| 695 | { | ||
| 696 | printf("\t%d\t",i); | ||
| 697 | PrintType(f,i); | ||
| 698 | PrintConstant(f,i); | ||
| 699 | printf("\n"); | ||
| 700 | } | ||
| 701 | n=f->sizelocvars; | ||
| 702 | printf("locals (%d) for %p:\n",n,VOID(f)); | ||
| 703 | for (i=0; i<n; i++) | ||
| 704 | { | ||
| 705 | printf("\t%d\t%s\t%d\t%d\n", | ||
| 706 | i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); | ||
| 707 | } | ||
| 708 | n=f->sizeupvalues; | ||
| 709 | printf("upvalues (%d) for %p:\n",n,VOID(f)); | ||
| 710 | for (i=0; i<n; i++) | ||
| 711 | { | ||
| 712 | printf("\t%d\t%s\t%d\t%d\n", | ||
| 713 | i,UPVALNAME(i),f->upvalues[i].instack,f->upvalues[i].idx); | ||
| 714 | } | ||
| 715 | } | ||
| 716 | |||
| 717 | static void PrintFunction(const Proto* f, int full) | ||
| 718 | { | ||
| 719 | int i,n=f->sizep; | ||
| 720 | PrintHeader(f); | ||
| 721 | PrintCode(f); | ||
| 722 | if (full) PrintDebug(f); | ||
| 723 | for (i=0; i<n; i++) PrintFunction(f->p[i],full); | ||
| 724 | } | ||
