new module luadebug.h.
This commit is contained in:
33
iolib.c
33
iolib.c
@@ -3,7 +3,7 @@
|
|||||||
** Input/output library to LUA
|
** Input/output library to LUA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_iolib="$Id: iolib.c,v 1.22 1995/10/04 13:53:10 roberto Exp roberto $";
|
char *rcs_iolib="$Id: iolib.c,v 1.23 1995/10/11 20:50:56 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#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 $";
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
#include "luadebug.h"
|
||||||
#include "lualib.h"
|
#include "lualib.h"
|
||||||
|
|
||||||
static FILE *in=stdin, *out=stdout;
|
static FILE *in=stdin, *out=stdout;
|
||||||
@@ -580,7 +581,7 @@ static void io_exit (void)
|
|||||||
{
|
{
|
||||||
lua_Object o = lua_getparam(1);
|
lua_Object o = lua_getparam(1);
|
||||||
if (lua_isstring(o))
|
if (lua_isstring(o))
|
||||||
printf("%s\n", lua_getstring(o));
|
fprintf(stderr, "%s\n", lua_getstring(o));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,6 +601,33 @@ static void io_debug (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void print_message (void)
|
||||||
|
{
|
||||||
|
lua_Object o = lua_getparam(1);
|
||||||
|
char *s = lua_isstring(o) ? lua_getstring(o) : "(no messsage)";
|
||||||
|
int level = 0;
|
||||||
|
lua_Object func;
|
||||||
|
fprintf(stderr, "lua: %s\n", s);
|
||||||
|
fprintf(stderr, "Active Stack:\n");
|
||||||
|
while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT)
|
||||||
|
{
|
||||||
|
char *filename; char *funcname;
|
||||||
|
char *objname; int linedefined;
|
||||||
|
lua_funcinfo(func, &filename, &funcname, &objname, &linedefined);
|
||||||
|
if (objname == NULL)
|
||||||
|
if (funcname)
|
||||||
|
fprintf(stderr, "\t%s\n", funcname);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\tmain of %s\n", filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf(stderr, "\t%s:%s\n", objname, funcname);
|
||||||
|
/* fprintf(stderr, "\t(in file: %s)\n", filename); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Open io library
|
** Open io library
|
||||||
*/
|
*/
|
||||||
@@ -619,4 +647,5 @@ void iolib_open (void)
|
|||||||
lua_register ("beep", io_beep);
|
lua_register ("beep", io_beep);
|
||||||
lua_register ("exit", io_exit);
|
lua_register ("exit", io_exit);
|
||||||
lua_register ("debug", io_debug);
|
lua_register ("debug", io_debug);
|
||||||
|
lua_setfallback("error", print_message);
|
||||||
}
|
}
|
||||||
|
|||||||
4
lua.h
4
lua.h
@@ -2,7 +2,7 @@
|
|||||||
** LUA - Linguagem para Usuarios de Aplicacao
|
** LUA - Linguagem para Usuarios de Aplicacao
|
||||||
** Grupo de Tecnologia em Computacao Grafica
|
** Grupo de Tecnologia em Computacao Grafica
|
||||||
** TeCGraf - PUC-Rio
|
** TeCGraf - PUC-Rio
|
||||||
** $Id: lua.h,v 3.16 1995/01/27 17:19:06 celes Exp roberto $
|
** $Id: lua.h,v 3.17 1995/10/06 14:11:10 roberto Exp roberto $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -24,6 +24,8 @@ typedef enum
|
|||||||
LUA_T_ARRAY = -4,
|
LUA_T_ARRAY = -4,
|
||||||
LUA_T_FUNCTION = -5,
|
LUA_T_FUNCTION = -5,
|
||||||
LUA_T_CFUNCTION= -6,
|
LUA_T_CFUNCTION= -6,
|
||||||
|
LUA_T_MARK = -7,
|
||||||
|
LUA_T_CMARK = -8,
|
||||||
LUA_T_USERDATA = 0
|
LUA_T_USERDATA = 0
|
||||||
} lua_Type;
|
} lua_Type;
|
||||||
|
|
||||||
|
|||||||
8
makefile
8
makefile
@@ -1,4 +1,4 @@
|
|||||||
# $Id: makefile,v 1.13 1995/10/04 19:19:46 roberto Exp roberto $
|
# $Id: makefile,v 1.13 1995/10/09 18:51:49 roberto Exp roberto $
|
||||||
|
|
||||||
#configuration
|
#configuration
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ clear :
|
|||||||
rcsclean
|
rcsclean
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
rm -f parser.c parser.h
|
rm -f parser.c parser.h
|
||||||
co lua.h lualib.h
|
co lua.h lualib.h luadebug.h
|
||||||
|
|
||||||
% : RCS/%,v
|
% : RCS/%,v
|
||||||
co $@
|
co $@
|
||||||
@@ -72,14 +72,14 @@ func.o : func.c table.h tree.h types.h opcode.h lua.h func.h mem.h
|
|||||||
hash.o : hash.c mem.h opcode.h lua.h types.h tree.h func.h hash.h table.h
|
hash.o : hash.c mem.h opcode.h lua.h types.h tree.h func.h hash.h table.h
|
||||||
inout.o : inout.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
|
inout.o : inout.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
|
||||||
table.h
|
table.h
|
||||||
iolib.o : iolib.c lua.h lualib.h
|
iolib.o : iolib.c lua.h lualib.h luadebug.h
|
||||||
lex.o : lex.c mem.h tree.h types.h table.h opcode.h lua.h func.h inout.h parser.h \
|
lex.o : lex.c mem.h tree.h types.h table.h opcode.h lua.h func.h inout.h parser.h \
|
||||||
ugly.h
|
ugly.h
|
||||||
lua.o : lua.c lua.h lualib.h
|
lua.o : lua.c lua.h lualib.h
|
||||||
mathlib.o : mathlib.c lualib.h lua.h
|
mathlib.o : mathlib.c lualib.h lua.h
|
||||||
mem.o : mem.c mem.h lua.h
|
mem.o : mem.c mem.h lua.h
|
||||||
opcode.o : opcode.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
|
opcode.o : opcode.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
|
||||||
table.h fallback.h
|
table.h fallback.h luadebug.h
|
||||||
parser.o : parser.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
|
parser.o : parser.c mem.h opcode.h lua.h types.h tree.h func.h hash.h inout.h \
|
||||||
table.h
|
table.h
|
||||||
strlib.o : strlib.c lua.h lualib.h
|
strlib.o : strlib.c lua.h lualib.h
|
||||||
|
|||||||
7
opcode.c
7
opcode.c
@@ -3,7 +3,7 @@
|
|||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_opcode="$Id: opcode.c,v 3.43 1995/10/13 15:16:25 roberto Exp roberto $";
|
char *rcs_opcode="$Id: opcode.c,v 3.44 1995/10/17 11:58:41 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdlib.h>
|
#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 $
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "luadebug.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "opcode.h"
|
#include "opcode.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
@@ -353,7 +354,7 @@ void lua_error (char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lua_Object luaD_stackedfunction (int level)
|
lua_Object lua_stackedfunction (int level)
|
||||||
{
|
{
|
||||||
Object *p = top;
|
Object *p = top;
|
||||||
while (--p >= stack)
|
while (--p >= stack)
|
||||||
@@ -364,7 +365,7 @@ lua_Object luaD_stackedfunction (int level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaD_funcInfo (lua_Object func, char **filename, char **funcname,
|
void lua_funcinfo (lua_Object func, char **filename, char **funcname,
|
||||||
char **objname, int *linedefined)
|
char **objname, int *linedefined)
|
||||||
{
|
{
|
||||||
return luaI_funcInfo(Address(func), filename, funcname, objname, linedefined);
|
return luaI_funcInfo(Address(func), filename, funcname, objname, linedefined);
|
||||||
|
|||||||
Reference in New Issue
Block a user