aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-05-16 14:23:58 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-05-16 14:23:58 -0300
commitec79f25286a4ac843280ae7377ec1e5b39a70cea (patch)
tree03872cdc5d5f18266021c1cc5d07b214daf59ff3
parent18ea2eff80c720632cb6a89d560c5cce2377df06 (diff)
downloadlua-ec79f25286a4ac843280ae7377ec1e5b39a70cea.tar.gz
lua-ec79f25286a4ac843280ae7377ec1e5b39a70cea.tar.bz2
lua-ec79f25286a4ac843280ae7377ec1e5b39a70cea.zip
new lua function "getstack"; new interface to function luaI_reportbug.
-rw-r--r--inout.c26
-rw-r--r--inout.h8
-rw-r--r--opcode.c8
-rw-r--r--table.c4
4 files changed, 30 insertions, 16 deletions
diff --git a/inout.c b/inout.c
index 9ea0fd82..afb0ee52 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.18 1995/03/17 20:42:20 roberto Exp roberto $"; 8char *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 */
23Word lua_linenumber; 31Word lua_linenumber;
24Bool lua_debug; 32Bool 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*/
150void luaI_reportbug (char *msg, int size) 158void 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
302void luaI_getstack (void)
303{
304 char *s = lua_getstring(lua_getparam(1));
305 if (s == NULL) s = "";
306 luaI_reportbug(s, 0);
307}
308
diff --git a/inout.h b/inout.h
index ae84f133..fee22d15 100644
--- a/inout.h
+++ b/inout.h
@@ -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
15extern Word lua_linenumber; 12extern Word lua_linenumber;
16extern Bool lua_debug; 13extern Bool lua_debug;
@@ -22,13 +19,14 @@ char *lua_openstring (char *s);
22void lua_closestring (void); 19void lua_closestring (void);
23void lua_pushfunction (char *file, Word function); 20void lua_pushfunction (char *file, Word function);
24void lua_popfunction (void); 21void lua_popfunction (void);
25void luaI_reportbug (char *s, int size); 22void luaI_reportbug (char *s, int err);
26 23
27void lua_internaldofile (void); 24void lua_internaldofile (void);
28void lua_internaldostring (void); 25void lua_internaldostring (void);
29void lua_print (void); 26void lua_print (void);
30void luaI_type (void); 27void luaI_type (void);
31void lua_obj2number (void); 28void lua_obj2number (void);
29void luaI_getstack (void);
32void luaI_error (void); 30void luaI_error (void);
33 31
34#endif 32#endif
diff --git a/opcode.c b/opcode.c
index 152970aa..fe5c6dfc 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.36 1995/04/11 17:56:30 celes Exp roberto $"; 6char *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
73static void lua_message (char *s) 72static 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
diff --git a/table.c b/table.c
index 75fa21f2..d3fb89c3 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.28 1995/01/18 20:15:54 celes Exp roberto $"; 6char *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}