mirror of https://github.com/rusefi/lua.git
storing chunk "sources" instead of "filenames".
This commit is contained in:
parent
677188de8a
commit
5a8bb00df4
9
lapi.c
9
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.39 1999/02/25 19:13:56 roberto Exp roberto $
|
** $Id: lapi.c,v 1.40 1999/03/01 17:49:04 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -594,18 +594,17 @@ int lua_setlocal (lua_Function func, int local_number)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lua_funcinfo (lua_Object func, char **filename, int *linedefined)
|
void lua_funcinfo (lua_Object func, char **source, int *linedefined) {
|
||||||
{
|
|
||||||
if (!lua_isfunction(func))
|
if (!lua_isfunction(func))
|
||||||
lua_error("API - `funcinfo' called with a non-function value");
|
lua_error("API - `funcinfo' called with a non-function value");
|
||||||
else {
|
else {
|
||||||
TObject *f = luaA_protovalue(Address(func));
|
TObject *f = luaA_protovalue(Address(func));
|
||||||
if (normalized_type(f) == LUA_T_PROTO) {
|
if (normalized_type(f) == LUA_T_PROTO) {
|
||||||
*filename = tfvalue(f)->fileName->str;
|
*source = tfvalue(f)->source->str;
|
||||||
*linedefined = tfvalue(f)->lineDefined;
|
*linedefined = tfvalue(f)->lineDefined;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*filename = "(C)";
|
*source = "(C)";
|
||||||
*linedefined = -1;
|
*linedefined = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
lauxlib.c
19
lauxlib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.13 1998/09/07 18:59:59 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.14 1999/02/25 19:13:56 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +34,7 @@ void luaL_argerror (int numarg, char *extramsg) {
|
||||||
lua_getobjname(f, &funcname);
|
lua_getobjname(f, &funcname);
|
||||||
numarg -= lua_nups(f);
|
numarg -= lua_nups(f);
|
||||||
if (funcname == NULL)
|
if (funcname == NULL)
|
||||||
funcname = "(unknown)";
|
funcname = "?";
|
||||||
if (extramsg == NULL)
|
if (extramsg == NULL)
|
||||||
luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
|
luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
|
||||||
else
|
else
|
||||||
|
@ -111,3 +111,18 @@ void luaL_verror (char *fmt, ...)
|
||||||
lua_error(buff);
|
lua_error(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void luaL_chunkid (char *out, char *source, int len) {
|
||||||
|
len -= 13; /* 13 = strlen("string ''...\0") */
|
||||||
|
if (*source == '@')
|
||||||
|
sprintf(out, "file `%.*s'", len, source+1);
|
||||||
|
else if (*source == '(')
|
||||||
|
strcpy(out, "(C code)");
|
||||||
|
else {
|
||||||
|
char *b = strchr(source , '\n'); /* stop string at first new line */
|
||||||
|
int lim = (b && (b-source)<len) ? b-source : len;
|
||||||
|
sprintf(out, "string `%.*s'", lim, source);
|
||||||
|
strcpy(out+lim+(13-5), "...'"); /* 5 = strlen("...'\0") */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.10 1998/12/28 13:44:54 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,6 @@ int luaL_newbuffer (int size);
|
||||||
void luaL_oldbuffer (int old);
|
void luaL_oldbuffer (int old);
|
||||||
char *luaL_buffer (void);
|
char *luaL_buffer (void);
|
||||||
int luaL_findstring (char *name, char *list[]);
|
int luaL_findstring (char *name, char *list[]);
|
||||||
|
void luaL_chunkid (char *out, char *source, int len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbuiltin.c,v 1.54 1999/02/23 14:57:28 roberto Exp roberto $
|
** $Id: lbuiltin.c,v 1.55 1999/03/01 20:22:16 roberto Exp roberto $
|
||||||
** Built-in functions
|
** Built-in functions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -250,7 +250,7 @@ static void luaB_dostring (void) {
|
||||||
char *s = luaL_check_lstr(1, &l);
|
char *s = luaL_check_lstr(1, &l);
|
||||||
if (*s == ID_CHUNK)
|
if (*s == ID_CHUNK)
|
||||||
lua_error("`dostring' cannot run pre-compiled code");
|
lua_error("`dostring' cannot run pre-compiled code");
|
||||||
if (lua_dobuffer(s, l, luaL_opt_string(2, NULL)) == 0)
|
if (lua_dobuffer(s, l, luaL_opt_string(2, s)) == 0)
|
||||||
if (luaA_passresults() == 0)
|
if (luaA_passresults() == 0)
|
||||||
lua_pushuserdata(NULL); /* at least one result to signal no errors */
|
lua_pushuserdata(NULL); /* at least one result to signal no errors */
|
||||||
}
|
}
|
||||||
|
|
14
ldblib.c
14
ldblib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldblib.c,v 1.3 1999/01/15 11:36:28 roberto Exp roberto $
|
** $Id: ldblib.c,v 1.4 1999/02/04 17:47:59 roberto Exp roberto $
|
||||||
** Interface from Lua to its debug API
|
** Interface from Lua to its debug API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -33,24 +33,24 @@ static void settabsi (lua_Object t, char *i, int v) {
|
||||||
|
|
||||||
static lua_Object getfuncinfo (lua_Object func) {
|
static lua_Object getfuncinfo (lua_Object func) {
|
||||||
lua_Object result = lua_createtable();
|
lua_Object result = lua_createtable();
|
||||||
char *name;
|
char *str;
|
||||||
int line;
|
int line;
|
||||||
lua_funcinfo(func, &name, &line);
|
lua_funcinfo(func, &str, &line);
|
||||||
if (line == -1) /* C function? */
|
if (line == -1) /* C function? */
|
||||||
settabss(result, "kind", "C");
|
settabss(result, "kind", "C");
|
||||||
else if (line == 0) { /* "main"? */
|
else if (line == 0) { /* "main"? */
|
||||||
settabss(result, "kind", "chunk");
|
settabss(result, "kind", "chunk");
|
||||||
settabss(result, "name", name);
|
settabss(result, "source", str);
|
||||||
}
|
}
|
||||||
else { /* Lua function */
|
else { /* Lua function */
|
||||||
settabss(result, "kind", "Lua");
|
settabss(result, "kind", "Lua");
|
||||||
settabsi(result, "def_line", line);
|
settabsi(result, "def_line", line);
|
||||||
settabss(result, "def_chunk", name);
|
settabss(result, "source", str);
|
||||||
}
|
}
|
||||||
if (line != 0) { /* is it not a "main"? */
|
if (line != 0) { /* is it not a "main"? */
|
||||||
char *kind = lua_getobjname(func, &name);
|
char *kind = lua_getobjname(func, &str);
|
||||||
if (*kind) {
|
if (*kind) {
|
||||||
settabss(result, "name", name);
|
settabss(result, "name", str);
|
||||||
settabss(result, "where", kind);
|
settabss(result, "where", kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
47
ldo.c
47
ldo.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.35 1999/02/22 19:23:36 roberto Exp roberto $
|
** $Id: ldo.c,v 1.36 1999/02/26 15:48:55 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -108,7 +108,7 @@ void luaD_callHook (StkId base, TProtoFunc *tf, int isreturn)
|
||||||
else {
|
else {
|
||||||
TObject *f = L->stack.stack+base-1;
|
TObject *f = L->stack.stack+base-1;
|
||||||
if (tf)
|
if (tf)
|
||||||
(*L->callhook)(Ref(f), tf->fileName->str, tf->lineDefined);
|
(*L->callhook)(Ref(f), tf->source->str, tf->lineDefined);
|
||||||
else
|
else
|
||||||
(*L->callhook)(Ref(f), "(C)", -1);
|
(*L->callhook)(Ref(f), "(C)", -1);
|
||||||
}
|
}
|
||||||
|
@ -355,23 +355,27 @@ void luaD_gcIM (TObject *o)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int lua_dofile (char *filename)
|
#define MAXFILENAME 200 /* maximum part of a file name kept */
|
||||||
{
|
|
||||||
|
int lua_dofile (char *filename) {
|
||||||
ZIO z;
|
ZIO z;
|
||||||
int status;
|
int status;
|
||||||
int c;
|
int c;
|
||||||
int bin;
|
int bin;
|
||||||
|
char name[MAXFILENAME+2]; /* +2 for '@' and '\0' */
|
||||||
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
|
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return 2;
|
return 2;
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = "(stdin)";
|
strcpy(name, "@stdin");
|
||||||
|
else
|
||||||
|
sprintf(name, "@%.*s", MAXFILENAME, filename);
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
ungetc(c, f);
|
ungetc(c, f);
|
||||||
bin = (c == ID_CHUNK);
|
bin = (c == ID_CHUNK);
|
||||||
if (bin)
|
if (bin)
|
||||||
f = freopen(filename, "rb", f); /* set binary mode */
|
f = freopen(filename, "rb", f); /* set binary mode */
|
||||||
luaZ_Fopen(&z, f, filename);
|
luaZ_Fopen(&z, f, name);
|
||||||
status = do_main(&z, bin);
|
status = do_main(&z, bin);
|
||||||
if (f != stdin)
|
if (f != stdin)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -379,40 +383,15 @@ int lua_dofile (char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define SIZE_PREF 20 /* size of string prefix to appear in error messages */
|
|
||||||
#define SSIZE_PREF "20"
|
|
||||||
|
|
||||||
|
|
||||||
static void build_name (char *str, char *name) {
|
|
||||||
if (str == NULL || *str == ID_CHUNK)
|
|
||||||
strcpy(name, "(buffer)");
|
|
||||||
else {
|
|
||||||
char *temp;
|
|
||||||
sprintf(name, "(dostring) >> \"%." SSIZE_PREF "s\"", str);
|
|
||||||
temp = strchr(name, '\n');
|
|
||||||
if (temp) { /* end string after first line */
|
|
||||||
*temp = '"';
|
|
||||||
*(temp+1) = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int lua_dostring (char *str) {
|
int lua_dostring (char *str) {
|
||||||
return lua_dobuffer(str, strlen(str), NULL);
|
return lua_dobuffer(str, strlen(str), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int lua_dobuffer (char *buff, int size, char *name) {
|
int lua_dobuffer (char *buff, int size, char *name) {
|
||||||
char newname[SIZE_PREF+25];
|
|
||||||
ZIO z;
|
ZIO z;
|
||||||
int status;
|
if (!name) name = "?";
|
||||||
if (name==NULL) {
|
|
||||||
build_name(buff, newname);
|
|
||||||
name = newname;
|
|
||||||
}
|
|
||||||
luaZ_mopen(&z, buff, size, name);
|
luaZ_mopen(&z, buff, size, name);
|
||||||
status = do_main(&z, buff[0]==ID_CHUNK);
|
return do_main(&z, buff[0]==ID_CHUNK);
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
lfunc.c
4
lfunc.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lfunc.c,v 1.8 1997/12/15 16:17:20 roberto Exp roberto $
|
** $Id: lfunc.c,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $
|
||||||
** Auxiliary functions to manipulate prototypes and closures
|
** Auxiliary functions to manipulate prototypes and closures
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +31,7 @@ TProtoFunc *luaF_newproto (void)
|
||||||
TProtoFunc *f = luaM_new(TProtoFunc);
|
TProtoFunc *f = luaM_new(TProtoFunc);
|
||||||
f->code = NULL;
|
f->code = NULL;
|
||||||
f->lineDefined = 0;
|
f->lineDefined = 0;
|
||||||
f->fileName = NULL;
|
f->source = NULL;
|
||||||
f->consts = NULL;
|
f->consts = NULL;
|
||||||
f->nconsts = 0;
|
f->nconsts = 0;
|
||||||
f->locvars = NULL;
|
f->locvars = NULL;
|
||||||
|
|
4
lgc.c
4
lgc.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 1.21 1999/02/25 15:16:26 roberto Exp roberto $
|
** $Id: lgc.c,v 1.22 1999/02/26 15:48:55 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -162,7 +162,7 @@ static void protomark (TProtoFunc *f) {
|
||||||
if (!f->head.marked) {
|
if (!f->head.marked) {
|
||||||
int i;
|
int i;
|
||||||
f->head.marked = 1;
|
f->head.marked = 1;
|
||||||
strmark(f->fileName);
|
strmark(f->source);
|
||||||
for (i=0; i<f->nconsts; i++)
|
for (i=0; i<f->nconsts; i++)
|
||||||
markobject(&f->consts[i]);
|
markobject(&f->consts[i]);
|
||||||
}
|
}
|
||||||
|
|
22
liolib.c
22
liolib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 1.30 1999/02/05 15:22:43 roberto Exp roberto $
|
** $Id: liolib.c,v 1.31 1999/02/22 14:17:24 roberto Exp roberto $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -455,6 +455,10 @@ static void io_debug (void) {
|
||||||
#define MESSAGESIZE 150
|
#define MESSAGESIZE 150
|
||||||
#define MAXMESSAGE (MESSAGESIZE*10)
|
#define MAXMESSAGE (MESSAGESIZE*10)
|
||||||
|
|
||||||
|
|
||||||
|
#define MAXSRC 40
|
||||||
|
|
||||||
|
|
||||||
static void errorfb (void) {
|
static void errorfb (void) {
|
||||||
char buff[MAXMESSAGE];
|
char buff[MAXMESSAGE];
|
||||||
int level = 1; /* skip level 0 (it's this function) */
|
int level = 1; /* skip level 0 (it's this function) */
|
||||||
|
@ -464,8 +468,10 @@ static void errorfb (void) {
|
||||||
char *name;
|
char *name;
|
||||||
int currentline;
|
int currentline;
|
||||||
char *chunkname;
|
char *chunkname;
|
||||||
|
char buffchunk[MAXSRC];
|
||||||
int linedefined;
|
int linedefined;
|
||||||
lua_funcinfo(func, &chunkname, &linedefined);
|
lua_funcinfo(func, &chunkname, &linedefined);
|
||||||
|
luaL_chunkid(buffchunk, chunkname, MAXSRC);
|
||||||
if (level == 2) strcat(buff, "Active Stack:\n");
|
if (level == 2) strcat(buff, "Active Stack:\n");
|
||||||
strcat(buff, "\t");
|
strcat(buff, "\t");
|
||||||
if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) {
|
if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) {
|
||||||
|
@ -474,26 +480,24 @@ static void errorfb (void) {
|
||||||
}
|
}
|
||||||
switch (*lua_getobjname(func, &name)) {
|
switch (*lua_getobjname(func, &name)) {
|
||||||
case 'g':
|
case 'g':
|
||||||
sprintf(buff+strlen(buff), "function %.50s", name);
|
sprintf(buff+strlen(buff), "function `%.50s'", name);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
sprintf(buff+strlen(buff), "`%.50s' tag method", name);
|
sprintf(buff+strlen(buff), "`%.50s' tag method", name);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
if (linedefined == 0)
|
if (linedefined == 0)
|
||||||
sprintf(buff+strlen(buff), "main of %.50s", chunkname);
|
sprintf(buff+strlen(buff), "main of %.50s", buffchunk);
|
||||||
else if (linedefined < 0)
|
else if (linedefined > 0)
|
||||||
sprintf(buff+strlen(buff), "%.50s", chunkname);
|
sprintf(buff+strlen(buff), "function <%d:%.50s>",
|
||||||
else
|
linedefined, buffchunk);
|
||||||
sprintf(buff+strlen(buff), "function (%.50s:%d)",
|
|
||||||
chunkname, linedefined);
|
|
||||||
chunkname = NULL;
|
chunkname = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((currentline = lua_currentline(func)) > 0)
|
if ((currentline = lua_currentline(func)) > 0)
|
||||||
sprintf(buff+strlen(buff), " at line %d", currentline);
|
sprintf(buff+strlen(buff), " at line %d", currentline);
|
||||||
if (chunkname)
|
if (chunkname)
|
||||||
sprintf(buff+strlen(buff), " [in chunk %.50s]", chunkname);
|
sprintf(buff+strlen(buff), " [in %.50s]", buffchunk);
|
||||||
strcat(buff, "\n");
|
strcat(buff, "\n");
|
||||||
}
|
}
|
||||||
func = lua_rawgetglobal("_ALERT");
|
func = lua_rawgetglobal("_ALERT");
|
||||||
|
|
14
llex.c
14
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.29 1999/02/25 15:17:01 roberto Exp roberto $
|
** $Id: llex.c,v 1.30 1999/02/25 19:13:56 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -32,8 +32,7 @@ char *reserved [] = {"and", "do", "else", "elseif", "end", "function",
|
||||||
"until", "while"};
|
"until", "while"};
|
||||||
|
|
||||||
|
|
||||||
void luaX_init (void)
|
void luaX_init (void) {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
|
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
|
||||||
TaggedString *ts = luaS_new(reserved[i]);
|
TaggedString *ts = luaS_new(reserved[i]);
|
||||||
|
@ -42,11 +41,16 @@ void luaX_init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define MAXSRC 40
|
||||||
|
|
||||||
void luaX_syntaxerror (LexState *ls, char *s, char *token) {
|
void luaX_syntaxerror (LexState *ls, char *s, char *token) {
|
||||||
|
char buff[MAXSRC];
|
||||||
|
luaL_chunkid(buff, zname(ls->lex_z), MAXSRC);
|
||||||
if (token[0] == '\0')
|
if (token[0] == '\0')
|
||||||
token = "<eof>";
|
token = "<eof>";
|
||||||
luaL_verror("%.100s;\n last token read: `%.50s' at line %d in chunk `%.50s'",
|
luaL_verror("%.100s;\n last token read: `%.50s' "
|
||||||
s, token, ls->linenumber, zname(ls->lex_z));
|
"at line %d from %.50s",
|
||||||
|
s, token, ls->linenumber, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 1.25 1999/01/04 13:37:07 roberto Exp roberto $
|
** $Id: lobject.h,v 1.26 1999/02/03 13:53:48 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -128,7 +128,7 @@ typedef struct TProtoFunc {
|
||||||
int nconsts;
|
int nconsts;
|
||||||
Byte *code; /* ends with opcode ENDCODE */
|
Byte *code; /* ends with opcode ENDCODE */
|
||||||
int lineDefined;
|
int lineDefined;
|
||||||
TaggedString *fileName;
|
TaggedString *source;
|
||||||
struct LocVar *locvars; /* ends with line = -1 */
|
struct LocVar *locvars; /* ends with line = -1 */
|
||||||
} TProtoFunc;
|
} TProtoFunc;
|
||||||
|
|
||||||
|
|
10
lparser.c
10
lparser.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.24 1999/02/25 19:13:56 roberto Exp roberto $
|
** $Id: lparser.c,v 1.25 1999/02/26 15:48:55 roberto Exp roberto $
|
||||||
** LL(1) Parser and code generator for Lua
|
** LL(1) Parser and code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -534,7 +534,7 @@ static void func_onstack (LexState *ls, FuncState *func) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) {
|
static void init_state (LexState *ls, FuncState *fs, TaggedString *source) {
|
||||||
TProtoFunc *f = luaF_newproto();
|
TProtoFunc *f = luaF_newproto();
|
||||||
fs->prev = ls->fs; /* linked list of funcstates */
|
fs->prev = ls->fs; /* linked list of funcstates */
|
||||||
ls->fs = fs;
|
ls->fs = fs;
|
||||||
|
@ -544,7 +544,7 @@ static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) {
|
||||||
fs->nupvalues = 0;
|
fs->nupvalues = 0;
|
||||||
fs->lastsetline = 0;
|
fs->lastsetline = 0;
|
||||||
fs->f = f;
|
fs->f = f;
|
||||||
f->fileName = filename;
|
f->source = source;
|
||||||
fs->pc = 0;
|
fs->pc = 0;
|
||||||
f->code = NULL;
|
f->code = NULL;
|
||||||
fs->nvars = (L->debug) ? 0 : -1; /* flag no debug information? */
|
fs->nvars = (L->debug) ? 0 : -1; /* flag no debug information? */
|
||||||
|
@ -828,7 +828,7 @@ static int funcname (LexState *ls, vardesc *v) {
|
||||||
static void body (LexState *ls, int needself, int line) {
|
static void body (LexState *ls, int needself, int line) {
|
||||||
/* body -> '(' parlist ')' chunk END */
|
/* body -> '(' parlist ')' chunk END */
|
||||||
FuncState newfs;
|
FuncState newfs;
|
||||||
init_state(ls, &newfs, ls->fs->f->fileName);
|
init_state(ls, &newfs, ls->fs->f->source);
|
||||||
newfs.f->lineDefined = line;
|
newfs.f->lineDefined = line;
|
||||||
check(ls, '(');
|
check(ls, '(');
|
||||||
if (needself)
|
if (needself)
|
||||||
|
@ -1140,7 +1140,7 @@ static int funcparams (LexState *ls, int slf) {
|
||||||
luaX_error(ls, "function arguments expected");
|
luaX_error(ls, "function arguments expected");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
code_byte(fs, CALLFUNC);
|
code_byte(fs, CALL);
|
||||||
code_byte(fs, 0); /* save space for nresult */
|
code_byte(fs, 0); /* save space for nresult */
|
||||||
code_byte(fs, (Byte)(nparams+slf));
|
code_byte(fs, (Byte)(nparams+slf));
|
||||||
return fs->pc-1;
|
return fs->pc-1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: luadebug.h,v 1.4 1999/01/15 13:11:22 roberto Exp roberto $
|
** $Id: luadebug.h,v 1.5 1999/02/04 17:47:59 roberto Exp roberto $
|
||||||
** Debugging API
|
** Debugging API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@ typedef void (*lua_LHFunction) (int line);
|
||||||
typedef void (*lua_CHFunction) (lua_Function func, char *file, int line);
|
typedef void (*lua_CHFunction) (lua_Function func, char *file, int line);
|
||||||
|
|
||||||
lua_Function lua_stackedfunction (int level);
|
lua_Function lua_stackedfunction (int level);
|
||||||
void lua_funcinfo (lua_Object func, char **filename, int *linedefined);
|
void lua_funcinfo (lua_Object func, char **source, int *linedefined);
|
||||||
int lua_currentline (lua_Function func);
|
int lua_currentline (lua_Function func);
|
||||||
char *lua_getobjname (lua_Object o, char **name);
|
char *lua_getobjname (lua_Object o, char **name);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lundump.c,v 1.5 1998/12/15 14:59:43 roberto Exp $
|
** $Id: lundump.c,v 1.6 1998/12/27 20:23:22 roberto Exp roberto $
|
||||||
** load bytecodes from files
|
** load bytecodes from files
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -161,7 +161,7 @@ static TProtoFunc* LoadFunction (ZIO* Z)
|
||||||
{
|
{
|
||||||
TProtoFunc* tf=luaF_newproto();
|
TProtoFunc* tf=luaF_newproto();
|
||||||
tf->lineDefined=LoadWord(Z);
|
tf->lineDefined=LoadWord(Z);
|
||||||
tf->fileName=LoadTString(Z);
|
tf->source=LoadTString(Z);
|
||||||
tf->code=LoadCode(Z);
|
tf->code=LoadCode(Z);
|
||||||
LoadLocals(tf,Z);
|
LoadLocals(tf,Z);
|
||||||
LoadConstants(tf,Z);
|
LoadConstants(tf,Z);
|
||||||
|
|
14
manual.tex
14
manual.tex
|
@ -1,4 +1,4 @@
|
||||||
% $Id: manual.tex,v 1.23 1999/02/12 19:23:02 roberto Exp roberto $
|
% $Id: manual.tex,v 1.24 1999/02/25 19:13:56 roberto Exp roberto $
|
||||||
|
|
||||||
\documentclass[11pt]{article}
|
\documentclass[11pt]{article}
|
||||||
\usepackage{fullpage,bnf}
|
\usepackage{fullpage,bnf}
|
||||||
|
@ -41,7 +41,7 @@ Waldemar Celes
|
||||||
\tecgraf\ --- Computer Science Department --- PUC-Rio
|
\tecgraf\ --- Computer Science Department --- PUC-Rio
|
||||||
}
|
}
|
||||||
|
|
||||||
%\date{\small \verb$Date: 1999/02/12 19:23:02 $}
|
%\date{\small \verb$Date: 1999/02/25 19:13:56 $}
|
||||||
|
|
||||||
\maketitle
|
\maketitle
|
||||||
|
|
||||||
|
@ -2926,12 +2926,16 @@ it accepts only a handle returned by
|
||||||
|
|
||||||
Three other functions produce extra information about a function:
|
Three other functions produce extra information about a function:
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
void lua_funcinfo (lua_Object func, char **filename, int *linedefined);
|
void lua_funcinfo (lua_Object func, char **source, int *linedefined);
|
||||||
int lua_currentline (lua_Function func);
|
int lua_currentline (lua_Function func);
|
||||||
char *lua_getobjname (lua_Object o, char **name);
|
char *lua_getobjname (lua_Object o, char **name);
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\verb|lua_funcinfo| gives the file name and the line where the
|
\verb|lua_funcinfo| gives the source and the line where the
|
||||||
given function has been defined.
|
given function has been defined:
|
||||||
|
If the function was defined in a string,
|
||||||
|
\verb|source| is that string;
|
||||||
|
If the function was defined in a file,
|
||||||
|
\verb|source| starts with a \verb|@| followed by the file name.
|
||||||
If the ``function'' is in fact the main code of a chunk,
|
If the ``function'' is in fact the main code of a chunk,
|
||||||
then \verb|linedefined| is 0.
|
then \verb|linedefined| is 0.
|
||||||
If the function is a C function,
|
If the function is a C function,
|
||||||
|
|
Loading…
Reference in New Issue