aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-17 12:12:45 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-17 12:12:45 -0200
commitd80659759bcbcabf8b964356e5c9c867cd55effd (patch)
tree0b5df11f98eda46d3d2517402659f0863ef1dcab
parentd24253d92f1579032c7a6a30e50bba75ca56d4fe (diff)
downloadlua-d80659759bcbcabf8b964356e5c9c867cd55effd.tar.gz
lua-d80659759bcbcabf8b964356e5c9c867cd55effd.tar.bz2
lua-d80659759bcbcabf8b964356e5c9c867cd55effd.zip
new module luadebug.h.
-rw-r--r--iolib.c33
-rw-r--r--lua.h4
-rw-r--r--makefile8
-rw-r--r--opcode.c7
4 files changed, 42 insertions, 10 deletions
diff --git a/iolib.c b/iolib.c
index 618afb4d..31eba5c5 100644
--- a/iolib.c
+++ b/iolib.c
@@ -3,7 +3,7 @@
3** Input/output library to LUA 3** Input/output library to LUA
4*/ 4*/
5 5
6char *rcs_iolib="$Id: iolib.c,v 1.22 1995/10/04 13:53:10 roberto Exp roberto $"; 6char *rcs_iolib="$Id: iolib.c,v 1.23 1995/10/11 20:50:56 roberto Exp roberto $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <ctype.h> 9#include <ctype.h>
@@ -14,6 +14,7 @@ char *rcs_iolib="$Id: iolib.c,v 1.22 1995/10/04 13:53:10 roberto Exp roberto $";
14#include <stdlib.h> 14#include <stdlib.h>
15 15
16#include "lua.h" 16#include "lua.h"
17#include "luadebug.h"
17#include "lualib.h" 18#include "lualib.h"
18 19
19static FILE *in=stdin, *out=stdout; 20static FILE *in=stdin, *out=stdout;
@@ -580,7 +581,7 @@ static void io_exit (void)
580{ 581{
581 lua_Object o = lua_getparam(1); 582 lua_Object o = lua_getparam(1);
582 if (lua_isstring(o)) 583 if (lua_isstring(o))
583 printf("%s\n", lua_getstring(o)); 584 fprintf(stderr, "%s\n", lua_getstring(o));
584 exit(1); 585 exit(1);
585} 586}
586 587
@@ -600,6 +601,33 @@ static void io_debug (void)
600 } 601 }
601} 602}
602 603
604
605static void print_message (void)
606{
607 lua_Object o = lua_getparam(1);
608 char *s = lua_isstring(o) ? lua_getstring(o) : "(no messsage)";
609 int level = 0;
610 lua_Object func;
611 fprintf(stderr, "lua: %s\n", s);
612 fprintf(stderr, "Active Stack:\n");
613 while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT)
614 {
615 char *filename; char *funcname;
616 char *objname; int linedefined;
617 lua_funcinfo(func, &filename, &funcname, &objname, &linedefined);
618 if (objname == NULL)
619 if (funcname)
620 fprintf(stderr, "\t%s\n", funcname);
621 else
622 {
623 fprintf(stderr, "\tmain of %s\n", filename);
624 }
625 else
626 fprintf(stderr, "\t%s:%s\n", objname, funcname);
627/* fprintf(stderr, "\t(in file: %s)\n", filename); */
628 }
629}
630
603/* 631/*
604** Open io library 632** Open io library
605*/ 633*/
@@ -619,4 +647,5 @@ void iolib_open (void)
619 lua_register ("beep", io_beep); 647 lua_register ("beep", io_beep);
620 lua_register ("exit", io_exit); 648 lua_register ("exit", io_exit);
621 lua_register ("debug", io_debug); 649 lua_register ("debug", io_debug);
650 lua_setfallback("error", print_message);
622} 651}
diff --git a/lua.h b/lua.h
index 33620bde..80c50e4c 100644
--- a/lua.h
+++ b/lua.h
@@ -2,7 +2,7 @@
2** LUA - Linguagem para Usuarios de Aplicacao 2** LUA - Linguagem para Usuarios de Aplicacao
3** Grupo de Tecnologia em Computacao Grafica 3** Grupo de Tecnologia em Computacao Grafica
4** TeCGraf - PUC-Rio 4** TeCGraf - PUC-Rio
5** $Id: lua.h,v 3.16 1995/01/27 17:19:06 celes Exp roberto $ 5** $Id: lua.h,v 3.17 1995/10/06 14:11:10 roberto Exp roberto $
6*/ 6*/
7 7
8 8
@@ -24,6 +24,8 @@ typedef enum
24 LUA_T_ARRAY = -4, 24 LUA_T_ARRAY = -4,
25 LUA_T_FUNCTION = -5, 25 LUA_T_FUNCTION = -5,
26 LUA_T_CFUNCTION= -6, 26 LUA_T_CFUNCTION= -6,
27 LUA_T_MARK = -7,
28 LUA_T_CMARK = -8,
27 LUA_T_USERDATA = 0 29 LUA_T_USERDATA = 0
28} lua_Type; 30} lua_Type;
29 31
diff --git a/makefile b/makefile
index bda6afb1..6898891e 100644
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
1# $Id: makefile,v 1.13 1995/10/04 19:19:46 roberto Exp roberto $ 1# $Id: makefile,v 1.13 1995/10/09 18:51:49 roberto Exp roberto $
2 2
3#configuration 3#configuration
4 4
@@ -61,7 +61,7 @@ clear :
61 rcsclean 61 rcsclean
62 rm -f *.o 62 rm -f *.o
63 rm -f parser.c parser.h 63 rm -f parser.c parser.h
64 co lua.h lualib.h 64 co lua.h lualib.h luadebug.h
65 65
66% : RCS/%,v 66% : RCS/%,v
67 co $@ 67 co $@
@@ -72,14 +72,14 @@ func.o : func.c table.h tree.h types.h opcode.h lua.h func.h mem.h
72hash.o : hash.c mem.h opcode.h lua.h types.h tree.h func.h hash.h table.h 72hash.o : hash.c mem.h opcode.h lua.h types.h tree.h func.h hash.h table.h
73inout.o : inout.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \ 73inout.o : inout.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
74 table.h 74 table.h
75iolib.o : iolib.c lua.h lualib.h 75iolib.o : iolib.c lua.h lualib.h luadebug.h
76lex.o : lex.c mem.h tree.h types.h table.h opcode.h lua.h func.h inout.h parser.h \ 76lex.o : lex.c mem.h tree.h types.h table.h opcode.h lua.h func.h inout.h parser.h \
77 ugly.h 77 ugly.h
78lua.o : lua.c lua.h lualib.h 78lua.o : lua.c lua.h lualib.h
79mathlib.o : mathlib.c lualib.h lua.h 79mathlib.o : mathlib.c lualib.h lua.h
80mem.o : mem.c mem.h lua.h 80mem.o : mem.c mem.h lua.h
81opcode.o : opcode.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \ 81opcode.o : opcode.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
82 table.h fallback.h 82 table.h fallback.h luadebug.h
83parser.o : parser.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \ 83parser.o : parser.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
84 table.h 84 table.h
85strlib.o : strlib.c lua.h lualib.h 85strlib.o : strlib.c lua.h lualib.h
diff --git a/opcode.c b/opcode.c
index 5b5d7601..fce78f72 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.43 1995/10/13 15:16:25 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 3.44 1995/10/17 11:58:41 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdlib.h> 9#include <stdlib.h>
@@ -11,6 +11,7 @@ char *rcs_opcode="$Id: opcode.c,v 3.43 1995/10/13 15:16:25 roberto Exp roberto $
11#include <string.h> 11#include <string.h>
12#include <math.h> 12#include <math.h>
13 13
14#include "luadebug.h"
14#include "mem.h" 15#include "mem.h"
15#include "opcode.h" 16#include "opcode.h"
16#include "hash.h" 17#include "hash.h"
@@ -353,7 +354,7 @@ void lua_error (char *s)
353} 354}
354 355
355 356
356lua_Object luaD_stackedfunction (int level) 357lua_Object lua_stackedfunction (int level)
357{ 358{
358 Object *p = top; 359 Object *p = top;
359 while (--p >= stack) 360 while (--p >= stack)
@@ -364,7 +365,7 @@ lua_Object luaD_stackedfunction (int level)
364} 365}
365 366
366 367
367void luaD_funcInfo (lua_Object func, char **filename, char **funcname, 368void lua_funcinfo (lua_Object func, char **filename, char **funcname,
368 char **objname, int *linedefined) 369 char **objname, int *linedefined)
369{ 370{
370 return luaI_funcInfo(Address(func), filename, funcname, objname, linedefined); 371 return luaI_funcInfo(Address(func), filename, funcname, objname, linedefined);