diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-05-16 14:23:58 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-05-16 14:23:58 -0300 |
commit | ec79f25286a4ac843280ae7377ec1e5b39a70cea (patch) | |
tree | 03872cdc5d5f18266021c1cc5d07b214daf59ff3 | |
parent | 18ea2eff80c720632cb6a89d560c5cce2377df06 (diff) | |
download | lua-ec79f25286a4ac843280ae7377ec1e5b39a70cea.tar.gz lua-ec79f25286a4ac843280ae7377ec1e5b39a70cea.tar.bz2 lua-ec79f25286a4ac843280ae7377ec1e5b39a70cea.zip |
new lua function "getstack"; new interface to function luaI_reportbug.
-rw-r--r-- | inout.c | 26 | ||||
-rw-r--r-- | inout.h | 8 | ||||
-rw-r--r-- | opcode.c | 8 | ||||
-rw-r--r-- | table.c | 4 |
4 files changed, 30 insertions, 16 deletions
@@ -5,7 +5,7 @@ | |||
5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.19 1995/05/02 18:43:03 roberto Exp roberto $"; |
9 | 9 | ||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
@@ -19,6 +19,14 @@ char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $"; | |||
19 | #include "tree.h" | 19 | #include "tree.h" |
20 | #include "lua.h" | 20 | #include "lua.h" |
21 | 21 | ||
22 | |||
23 | #ifndef MAXFUNCSTACK | ||
24 | #define MAXFUNCSTACK 100 | ||
25 | #endif | ||
26 | |||
27 | #define MAXMESSAGE MAXFUNCSTACK*80 | ||
28 | |||
29 | |||
22 | /* Exported variables */ | 30 | /* Exported variables */ |
23 | Word lua_linenumber; | 31 | Word lua_linenumber; |
24 | Bool lua_debug; | 32 | Bool lua_debug; |
@@ -145,10 +153,12 @@ void lua_popfunction (void) | |||
145 | } | 153 | } |
146 | 154 | ||
147 | /* | 155 | /* |
148 | ** Report bug building a message. | 156 | ** Report bug building a message and pushing it on the stack. |
149 | */ | 157 | */ |
150 | void luaI_reportbug (char *msg, int size) | 158 | void luaI_reportbug (char *s, int err) |
151 | { | 159 | { |
160 | char msg[MAXMESSAGE]; | ||
161 | strcpy (msg, s); | ||
152 | if (lua_debugline != 0) | 162 | if (lua_debugline != 0) |
153 | { | 163 | { |
154 | if (funcStack) | 164 | if (funcStack) |
@@ -163,7 +173,7 @@ void luaI_reportbug (char *msg, int size) | |||
163 | lua_constant[func->function]->str, func->file, line); | 173 | lua_constant[func->function]->str, func->file, line); |
164 | line = func->line; | 174 | line = func->line; |
165 | func = func->next; | 175 | func = func->next; |
166 | lua_popfunction(); | 176 | if (err) lua_popfunction(); |
167 | } while (func); | 177 | } while (func); |
168 | } | 178 | } |
169 | else | 179 | else |
@@ -173,6 +183,7 @@ void luaI_reportbug (char *msg, int size) | |||
173 | lua_debugline, lua_filename()); | 183 | lua_debugline, lua_filename()); |
174 | } | 184 | } |
175 | } | 185 | } |
186 | lua_pushstring(msg); | ||
176 | } | 187 | } |
177 | 188 | ||
178 | 189 | ||
@@ -288,3 +299,10 @@ void luaI_error (void) | |||
288 | lua_error(s); | 299 | lua_error(s); |
289 | } | 300 | } |
290 | 301 | ||
302 | void luaI_getstack (void) | ||
303 | { | ||
304 | char *s = lua_getstring(lua_getparam(1)); | ||
305 | if (s == NULL) s = ""; | ||
306 | luaI_reportbug(s, 0); | ||
307 | } | ||
308 | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: inout.h,v 1.7 1994/12/20 21:20:36 roberto Exp roberto $ | 2 | ** $Id: inout.h,v 1.8 1995/05/02 18:43:03 roberto Exp roberto $ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | 5 | ||
@@ -8,9 +8,6 @@ | |||
8 | 8 | ||
9 | #include "types.h" | 9 | #include "types.h" |
10 | 10 | ||
11 | #ifndef MAXFUNCSTACK | ||
12 | #define MAXFUNCSTACK 100 | ||
13 | #endif | ||
14 | 11 | ||
15 | extern Word lua_linenumber; | 12 | extern Word lua_linenumber; |
16 | extern Bool lua_debug; | 13 | extern Bool lua_debug; |
@@ -22,13 +19,14 @@ char *lua_openstring (char *s); | |||
22 | void lua_closestring (void); | 19 | void lua_closestring (void); |
23 | void lua_pushfunction (char *file, Word function); | 20 | void lua_pushfunction (char *file, Word function); |
24 | void lua_popfunction (void); | 21 | void lua_popfunction (void); |
25 | void luaI_reportbug (char *s, int size); | 22 | void luaI_reportbug (char *s, int err); |
26 | 23 | ||
27 | void lua_internaldofile (void); | 24 | void lua_internaldofile (void); |
28 | void lua_internaldostring (void); | 25 | void lua_internaldostring (void); |
29 | void lua_print (void); | 26 | void lua_print (void); |
30 | void luaI_type (void); | 27 | void luaI_type (void); |
31 | void lua_obj2number (void); | 28 | void lua_obj2number (void); |
29 | void luaI_getstack (void); | ||
32 | void luaI_error (void); | 30 | void luaI_error (void); |
33 | 31 | ||
34 | #endif | 32 | #endif |
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.36 1995/04/11 17:56:30 celes Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.37 1995/05/02 18:43:03 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -68,14 +68,10 @@ Object *luaI_Address (lua_Object o) | |||
68 | ** Error messages | 68 | ** Error messages |
69 | */ | 69 | */ |
70 | 70 | ||
71 | #define MAXMESSAGE MAXFUNCSTACK*80 | ||
72 | 71 | ||
73 | static void lua_message (char *s) | 72 | static void lua_message (char *s) |
74 | { | 73 | { |
75 | char msg[MAXMESSAGE]; | 74 | luaI_reportbug(s, 1); |
76 | strcpy (msg, s); | ||
77 | luaI_reportbug(msg, MAXMESSAGE-strlen(s)); | ||
78 | lua_pushstring(msg); | ||
79 | do_call(&luaI_fallBacks[FB_ERROR].function, (top-stack)-1, 0, (top-stack)-1); | 75 | do_call(&luaI_fallBacks[FB_ERROR].function, (top-stack)-1, 0, (top-stack)-1); |
80 | } | 76 | } |
81 | 77 | ||
@@ -3,7 +3,7 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: table.c,v 2.28 1995/01/18 20:15:54 celes Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.29 1995/05/02 18:43:03 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
@@ -68,6 +68,8 @@ static void lua_initsymbol (void) | |||
68 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_internaldostring; | 68 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_internaldostring; |
69 | n = luaI_findsymbolbyname("setfallback"); | 69 | n = luaI_findsymbolbyname("setfallback"); |
70 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_setfallback; | 70 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_setfallback; |
71 | n = luaI_findsymbolbyname("getstack"); | ||
72 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_getstack; | ||
71 | n = luaI_findsymbolbyname("error"); | 73 | n = luaI_findsymbolbyname("error"); |
72 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_error; | 74 | s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = luaI_error; |
73 | } | 75 | } |