aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-04 18:23:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-04 18:23:39 -0300
commit5a8bb00df443dfdb5708689f32c64e90f2557bf8 (patch)
treef0328ef79978ce9bd8ceb63fdef2299b74c87490
parent677188de8aa0c4ed49a3db570f0c9ee7cd641ddc (diff)
downloadlua-5a8bb00df443dfdb5708689f32c64e90f2557bf8.tar.gz
lua-5a8bb00df443dfdb5708689f32c64e90f2557bf8.tar.bz2
lua-5a8bb00df443dfdb5708689f32c64e90f2557bf8.zip
storing chunk "sources" instead of "filenames".
-rw-r--r--lapi.c9
-rw-r--r--lauxlib.c19
-rw-r--r--lauxlib.h4
-rw-r--r--lbuiltin.c4
-rw-r--r--ldblib.c14
-rw-r--r--ldo.c47
-rw-r--r--lfunc.c4
-rw-r--r--lgc.c4
-rw-r--r--liolib.c22
-rw-r--r--llex.c14
-rw-r--r--lobject.h4
-rw-r--r--lparser.c10
-rw-r--r--luadebug.h4
-rw-r--r--lundump.c4
-rw-r--r--manual.tex14
15 files changed, 91 insertions, 86 deletions
diff --git a/lapi.c b/lapi.c
index aea8462d..98b6e213 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.39 1999/02/25 19:13:56 roberto Exp roberto $ 2** $Id: lapi.c,v 1.40 1999/03/01 17:49:04 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -594,18 +594,17 @@ int lua_setlocal (lua_Function func, int local_number)
594} 594}
595 595
596 596
597void lua_funcinfo (lua_Object func, char **filename, int *linedefined) 597void lua_funcinfo (lua_Object func, char **source, int *linedefined) {
598{
599 if (!lua_isfunction(func)) 598 if (!lua_isfunction(func))
600 lua_error("API - `funcinfo' called with a non-function value"); 599 lua_error("API - `funcinfo' called with a non-function value");
601 else { 600 else {
602 TObject *f = luaA_protovalue(Address(func)); 601 TObject *f = luaA_protovalue(Address(func));
603 if (normalized_type(f) == LUA_T_PROTO) { 602 if (normalized_type(f) == LUA_T_PROTO) {
604 *filename = tfvalue(f)->fileName->str; 603 *source = tfvalue(f)->source->str;
605 *linedefined = tfvalue(f)->lineDefined; 604 *linedefined = tfvalue(f)->lineDefined;
606 } 605 }
607 else { 606 else {
608 *filename = "(C)"; 607 *source = "(C)";
609 *linedefined = -1; 608 *linedefined = -1;
610 } 609 }
611 } 610 }
diff --git a/lauxlib.c b/lauxlib.c
index 37931dc6..090ded3c 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.13 1998/09/07 18:59:59 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.14 1999/02/25 19:13:56 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -34,7 +34,7 @@ void luaL_argerror (int numarg, char *extramsg) {
34 lua_getobjname(f, &funcname); 34 lua_getobjname(f, &funcname);
35 numarg -= lua_nups(f); 35 numarg -= lua_nups(f);
36 if (funcname == NULL) 36 if (funcname == NULL)
37 funcname = "(unknown)"; 37 funcname = "?";
38 if (extramsg == NULL) 38 if (extramsg == NULL)
39 luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); 39 luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
40 else 40 else
@@ -111,3 +111,18 @@ void luaL_verror (char *fmt, ...)
111 lua_error(buff); 111 lua_error(buff);
112} 112}
113 113
114
115void luaL_chunkid (char *out, char *source, int len) {
116 len -= 13; /* 13 = strlen("string ''...\0") */
117 if (*source == '@')
118 sprintf(out, "file `%.*s'", len, source+1);
119 else if (*source == '(')
120 strcpy(out, "(C code)");
121 else {
122 char *b = strchr(source , '\n'); /* stop string at first new line */
123 int lim = (b && (b-source)<len) ? b-source : len;
124 sprintf(out, "string `%.*s'", lim, source);
125 strcpy(out+lim+(13-5), "...'"); /* 5 = strlen("...'\0") */
126 }
127}
128
diff --git a/lauxlib.h b/lauxlib.h
index 508b1cd0..81a26817 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.10 1998/12/28 13:44:54 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -46,6 +46,6 @@ int luaL_newbuffer (int size);
46void luaL_oldbuffer (int old); 46void luaL_oldbuffer (int old);
47char *luaL_buffer (void); 47char *luaL_buffer (void);
48int luaL_findstring (char *name, char *list[]); 48int luaL_findstring (char *name, char *list[]);
49 49void luaL_chunkid (char *out, char *source, int len);
50 50
51#endif 51#endif
diff --git a/lbuiltin.c b/lbuiltin.c
index 32f07ec6..82d0b246 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.54 1999/02/23 14:57:28 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.55 1999/03/01 20:22:16 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -250,7 +250,7 @@ static void luaB_dostring (void) {
250 char *s = luaL_check_lstr(1, &l); 250 char *s = luaL_check_lstr(1, &l);
251 if (*s == ID_CHUNK) 251 if (*s == ID_CHUNK)
252 lua_error("`dostring' cannot run pre-compiled code"); 252 lua_error("`dostring' cannot run pre-compiled code");
253 if (lua_dobuffer(s, l, luaL_opt_string(2, NULL)) == 0) 253 if (lua_dobuffer(s, l, luaL_opt_string(2, s)) == 0)
254 if (luaA_passresults() == 0) 254 if (luaA_passresults() == 0)
255 lua_pushuserdata(NULL); /* at least one result to signal no errors */ 255 lua_pushuserdata(NULL); /* at least one result to signal no errors */
256} 256}
diff --git a/ldblib.c b/ldblib.c
index 6e8cc5b7..18951e3c 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.3 1999/01/15 11:36:28 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.4 1999/02/04 17:47:59 roberto Exp roberto $
3** Interface from Lua to its debug API 3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -33,24 +33,24 @@ static void settabsi (lua_Object t, char *i, int v) {
33 33
34static lua_Object getfuncinfo (lua_Object func) { 34static lua_Object getfuncinfo (lua_Object func) {
35 lua_Object result = lua_createtable(); 35 lua_Object result = lua_createtable();
36 char *name; 36 char *str;
37 int line; 37 int line;
38 lua_funcinfo(func, &name, &line); 38 lua_funcinfo(func, &str, &line);
39 if (line == -1) /* C function? */ 39 if (line == -1) /* C function? */
40 settabss(result, "kind", "C"); 40 settabss(result, "kind", "C");
41 else if (line == 0) { /* "main"? */ 41 else if (line == 0) { /* "main"? */
42 settabss(result, "kind", "chunk"); 42 settabss(result, "kind", "chunk");
43 settabss(result, "name", name); 43 settabss(result, "source", str);
44 } 44 }
45 else { /* Lua function */ 45 else { /* Lua function */
46 settabss(result, "kind", "Lua"); 46 settabss(result, "kind", "Lua");
47 settabsi(result, "def_line", line); 47 settabsi(result, "def_line", line);
48 settabss(result, "def_chunk", name); 48 settabss(result, "source", str);
49 } 49 }
50 if (line != 0) { /* is it not a "main"? */ 50 if (line != 0) { /* is it not a "main"? */
51 char *kind = lua_getobjname(func, &name); 51 char *kind = lua_getobjname(func, &str);
52 if (*kind) { 52 if (*kind) {
53 settabss(result, "name", name); 53 settabss(result, "name", str);
54 settabss(result, "where", kind); 54 settabss(result, "where", kind);
55 } 55 }
56 } 56 }
diff --git a/ldo.c b/ldo.c
index 9f3b7af1..19b36613 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.35 1999/02/22 19:23:36 roberto Exp roberto $ 2** $Id: ldo.c,v 1.36 1999/02/26 15:48:55 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -108,7 +108,7 @@ void luaD_callHook (StkId base, TProtoFunc *tf, int isreturn)
108 else { 108 else {
109 TObject *f = L->stack.stack+base-1; 109 TObject *f = L->stack.stack+base-1;
110 if (tf) 110 if (tf)
111 (*L->callhook)(Ref(f), tf->fileName->str, tf->lineDefined); 111 (*L->callhook)(Ref(f), tf->source->str, tf->lineDefined);
112 else 112 else
113 (*L->callhook)(Ref(f), "(C)", -1); 113 (*L->callhook)(Ref(f), "(C)", -1);
114 } 114 }
@@ -355,23 +355,27 @@ void luaD_gcIM (TObject *o)
355} 355}
356 356
357 357
358int lua_dofile (char *filename) 358#define MAXFILENAME 200 /* maximum part of a file name kept */
359{ 359
360int lua_dofile (char *filename) {
360 ZIO z; 361 ZIO z;
361 int status; 362 int status;
362 int c; 363 int c;
363 int bin; 364 int bin;
365 char name[MAXFILENAME+2]; /* +2 for '@' and '\0' */
364 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); 366 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
365 if (f == NULL) 367 if (f == NULL)
366 return 2; 368 return 2;
367 if (filename == NULL) 369 if (filename == NULL)
368 filename = "(stdin)"; 370 strcpy(name, "@stdin");
371 else
372 sprintf(name, "@%.*s", MAXFILENAME, filename);
369 c = fgetc(f); 373 c = fgetc(f);
370 ungetc(c, f); 374 ungetc(c, f);
371 bin = (c == ID_CHUNK); 375 bin = (c == ID_CHUNK);
372 if (bin) 376 if (bin)
373 f = freopen(filename, "rb", f); /* set binary mode */ 377 f = freopen(filename, "rb", f); /* set binary mode */
374 luaZ_Fopen(&z, f, filename); 378 luaZ_Fopen(&z, f, name);
375 status = do_main(&z, bin); 379 status = do_main(&z, bin);
376 if (f != stdin) 380 if (f != stdin)
377 fclose(f); 381 fclose(f);
@@ -379,40 +383,15 @@ int lua_dofile (char *filename)
379} 383}
380 384
381 385
382#define SIZE_PREF 20 /* size of string prefix to appear in error messages */
383#define SSIZE_PREF "20"
384
385
386static void build_name (char *str, char *name) {
387 if (str == NULL || *str == ID_CHUNK)
388 strcpy(name, "(buffer)");
389 else {
390 char *temp;
391 sprintf(name, "(dostring) >> \"%." SSIZE_PREF "s\"", str);
392 temp = strchr(name, '\n');
393 if (temp) { /* end string after first line */
394 *temp = '"';
395 *(temp+1) = 0;
396 }
397 }
398}
399
400
401int lua_dostring (char *str) { 386int lua_dostring (char *str) {
402 return lua_dobuffer(str, strlen(str), NULL); 387 return lua_dobuffer(str, strlen(str), str);
403} 388}
404 389
405 390
406int lua_dobuffer (char *buff, int size, char *name) { 391int lua_dobuffer (char *buff, int size, char *name) {
407 char newname[SIZE_PREF+25];
408 ZIO z; 392 ZIO z;
409 int status; 393 if (!name) name = "?";
410 if (name==NULL) {
411 build_name(buff, newname);
412 name = newname;
413 }
414 luaZ_mopen(&z, buff, size, name); 394 luaZ_mopen(&z, buff, size, name);
415 status = do_main(&z, buff[0]==ID_CHUNK); 395 return do_main(&z, buff[0]==ID_CHUNK);
416 return status;
417} 396}
418 397
diff --git a/lfunc.c b/lfunc.c
index efabfa3f..e1bdd2bd 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.8 1997/12/15 16:17:20 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -31,7 +31,7 @@ TProtoFunc *luaF_newproto (void)
31 TProtoFunc *f = luaM_new(TProtoFunc); 31 TProtoFunc *f = luaM_new(TProtoFunc);
32 f->code = NULL; 32 f->code = NULL;
33 f->lineDefined = 0; 33 f->lineDefined = 0;
34 f->fileName = NULL; 34 f->source = NULL;
35 f->consts = NULL; 35 f->consts = NULL;
36 f->nconsts = 0; 36 f->nconsts = 0;
37 f->locvars = NULL; 37 f->locvars = NULL;
diff --git a/lgc.c b/lgc.c
index b321e76c..5686a296 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.21 1999/02/25 15:16:26 roberto Exp roberto $ 2** $Id: lgc.c,v 1.22 1999/02/26 15:48:55 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -162,7 +162,7 @@ static void protomark (TProtoFunc *f) {
162 if (!f->head.marked) { 162 if (!f->head.marked) {
163 int i; 163 int i;
164 f->head.marked = 1; 164 f->head.marked = 1;
165 strmark(f->fileName); 165 strmark(f->source);
166 for (i=0; i<f->nconsts; i++) 166 for (i=0; i<f->nconsts; i++)
167 markobject(&f->consts[i]); 167 markobject(&f->consts[i]);
168 } 168 }
diff --git a/liolib.c b/liolib.c
index ed40b1ac..7b3eb9ea 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.30 1999/02/05 15:22:43 roberto Exp roberto $ 2** $Id: liolib.c,v 1.31 1999/02/22 14:17:24 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -455,6 +455,10 @@ static void io_debug (void) {
455#define MESSAGESIZE 150 455#define MESSAGESIZE 150
456#define MAXMESSAGE (MESSAGESIZE*10) 456#define MAXMESSAGE (MESSAGESIZE*10)
457 457
458
459#define MAXSRC 40
460
461
458static void errorfb (void) { 462static void errorfb (void) {
459 char buff[MAXMESSAGE]; 463 char buff[MAXMESSAGE];
460 int level = 1; /* skip level 0 (it's this function) */ 464 int level = 1; /* skip level 0 (it's this function) */
@@ -464,8 +468,10 @@ static void errorfb (void) {
464 char *name; 468 char *name;
465 int currentline; 469 int currentline;
466 char *chunkname; 470 char *chunkname;
471 char buffchunk[MAXSRC];
467 int linedefined; 472 int linedefined;
468 lua_funcinfo(func, &chunkname, &linedefined); 473 lua_funcinfo(func, &chunkname, &linedefined);
474 luaL_chunkid(buffchunk, chunkname, MAXSRC);
469 if (level == 2) strcat(buff, "Active Stack:\n"); 475 if (level == 2) strcat(buff, "Active Stack:\n");
470 strcat(buff, "\t"); 476 strcat(buff, "\t");
471 if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) { 477 if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) {
@@ -474,26 +480,24 @@ static void errorfb (void) {
474 } 480 }
475 switch (*lua_getobjname(func, &name)) { 481 switch (*lua_getobjname(func, &name)) {
476 case 'g': 482 case 'g':
477 sprintf(buff+strlen(buff), "function %.50s", name); 483 sprintf(buff+strlen(buff), "function `%.50s'", name);
478 break; 484 break;
479 case 't': 485 case 't':
480 sprintf(buff+strlen(buff), "`%.50s' tag method", name); 486 sprintf(buff+strlen(buff), "`%.50s' tag method", name);
481 break; 487 break;
482 default: { 488 default: {
483 if (linedefined == 0) 489 if (linedefined == 0)
484 sprintf(buff+strlen(buff), "main of %.50s", chunkname); 490 sprintf(buff+strlen(buff), "main of %.50s", buffchunk);
485 else if (linedefined < 0) 491 else if (linedefined > 0)
486 sprintf(buff+strlen(buff), "%.50s", chunkname); 492 sprintf(buff+strlen(buff), "function <%d:%.50s>",
487 else 493 linedefined, buffchunk);
488 sprintf(buff+strlen(buff), "function (%.50s:%d)",
489 chunkname, linedefined);
490 chunkname = NULL; 494 chunkname = NULL;
491 } 495 }
492 } 496 }
493 if ((currentline = lua_currentline(func)) > 0) 497 if ((currentline = lua_currentline(func)) > 0)
494 sprintf(buff+strlen(buff), " at line %d", currentline); 498 sprintf(buff+strlen(buff), " at line %d", currentline);
495 if (chunkname) 499 if (chunkname)
496 sprintf(buff+strlen(buff), " [in chunk %.50s]", chunkname); 500 sprintf(buff+strlen(buff), " [in %.50s]", buffchunk);
497 strcat(buff, "\n"); 501 strcat(buff, "\n");
498 } 502 }
499 func = lua_rawgetglobal("_ALERT"); 503 func = lua_rawgetglobal("_ALERT");
diff --git a/llex.c b/llex.c
index 88a57d97..0addaf47 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.29 1999/02/25 15:17:01 roberto Exp roberto $ 2** $Id: llex.c,v 1.30 1999/02/25 19:13:56 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -32,8 +32,7 @@ char *reserved [] = {"and", "do", "else", "elseif", "end", "function",
32 "until", "while"}; 32 "until", "while"};
33 33
34 34
35void luaX_init (void) 35void luaX_init (void) {
36{
37 int i; 36 int i;
38 for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) { 37 for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
39 TaggedString *ts = luaS_new(reserved[i]); 38 TaggedString *ts = luaS_new(reserved[i]);
@@ -42,11 +41,16 @@ void luaX_init (void)
42} 41}
43 42
44 43
44#define MAXSRC 40
45
45void luaX_syntaxerror (LexState *ls, char *s, char *token) { 46void luaX_syntaxerror (LexState *ls, char *s, char *token) {
47 char buff[MAXSRC];
48 luaL_chunkid(buff, zname(ls->lex_z), MAXSRC);
46 if (token[0] == '\0') 49 if (token[0] == '\0')
47 token = "<eof>"; 50 token = "<eof>";
48 luaL_verror("%.100s;\n last token read: `%.50s' at line %d in chunk `%.50s'", 51 luaL_verror("%.100s;\n last token read: `%.50s' "
49 s, token, ls->linenumber, zname(ls->lex_z)); 52 "at line %d from %.50s",
53 s, token, ls->linenumber, buff);
50} 54}
51 55
52 56
diff --git a/lobject.h b/lobject.h
index 4c5d0c12..b1221f0e 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.25 1999/01/04 13:37:07 roberto Exp roberto $ 2** $Id: lobject.h,v 1.26 1999/02/03 13:53:48 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -128,7 +128,7 @@ typedef struct TProtoFunc {
128 int nconsts; 128 int nconsts;
129 Byte *code; /* ends with opcode ENDCODE */ 129 Byte *code; /* ends with opcode ENDCODE */
130 int lineDefined; 130 int lineDefined;
131 TaggedString *fileName; 131 TaggedString *source;
132 struct LocVar *locvars; /* ends with line = -1 */ 132 struct LocVar *locvars; /* ends with line = -1 */
133} TProtoFunc; 133} TProtoFunc;
134 134
diff --git a/lparser.c b/lparser.c
index e967ad88..a30c3777 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.24 1999/02/25 19:13:56 roberto Exp roberto $ 2** $Id: lparser.c,v 1.25 1999/02/26 15:48:55 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -534,7 +534,7 @@ static void func_onstack (LexState *ls, FuncState *func) {
534} 534}
535 535
536 536
537static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) { 537static void init_state (LexState *ls, FuncState *fs, TaggedString *source) {
538 TProtoFunc *f = luaF_newproto(); 538 TProtoFunc *f = luaF_newproto();
539 fs->prev = ls->fs; /* linked list of funcstates */ 539 fs->prev = ls->fs; /* linked list of funcstates */
540 ls->fs = fs; 540 ls->fs = fs;
@@ -544,7 +544,7 @@ static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) {
544 fs->nupvalues = 0; 544 fs->nupvalues = 0;
545 fs->lastsetline = 0; 545 fs->lastsetline = 0;
546 fs->f = f; 546 fs->f = f;
547 f->fileName = filename; 547 f->source = source;
548 fs->pc = 0; 548 fs->pc = 0;
549 f->code = NULL; 549 f->code = NULL;
550 fs->nvars = (L->debug) ? 0 : -1; /* flag no debug information? */ 550 fs->nvars = (L->debug) ? 0 : -1; /* flag no debug information? */
@@ -828,7 +828,7 @@ static int funcname (LexState *ls, vardesc *v) {
828static void body (LexState *ls, int needself, int line) { 828static void body (LexState *ls, int needself, int line) {
829 /* body -> '(' parlist ')' chunk END */ 829 /* body -> '(' parlist ')' chunk END */
830 FuncState newfs; 830 FuncState newfs;
831 init_state(ls, &newfs, ls->fs->f->fileName); 831 init_state(ls, &newfs, ls->fs->f->source);
832 newfs.f->lineDefined = line; 832 newfs.f->lineDefined = line;
833 check(ls, '('); 833 check(ls, '(');
834 if (needself) 834 if (needself)
@@ -1140,7 +1140,7 @@ static int funcparams (LexState *ls, int slf) {
1140 luaX_error(ls, "function arguments expected"); 1140 luaX_error(ls, "function arguments expected");
1141 break; 1141 break;
1142 } 1142 }
1143 code_byte(fs, CALLFUNC); 1143 code_byte(fs, CALL);
1144 code_byte(fs, 0); /* save space for nresult */ 1144 code_byte(fs, 0); /* save space for nresult */
1145 code_byte(fs, (Byte)(nparams+slf)); 1145 code_byte(fs, (Byte)(nparams+slf));
1146 return fs->pc-1; 1146 return fs->pc-1;
diff --git a/luadebug.h b/luadebug.h
index d2e3c862..f7727119 100644
--- a/luadebug.h
+++ b/luadebug.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luadebug.h,v 1.4 1999/01/15 13:11:22 roberto Exp roberto $ 2** $Id: luadebug.h,v 1.5 1999/02/04 17:47:59 roberto Exp roberto $
3** Debugging API 3** Debugging API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -17,7 +17,7 @@ typedef void (*lua_LHFunction) (int line);
17typedef void (*lua_CHFunction) (lua_Function func, char *file, int line); 17typedef void (*lua_CHFunction) (lua_Function func, char *file, int line);
18 18
19lua_Function lua_stackedfunction (int level); 19lua_Function lua_stackedfunction (int level);
20void lua_funcinfo (lua_Object func, char **filename, int *linedefined); 20void lua_funcinfo (lua_Object func, char **source, int *linedefined);
21int lua_currentline (lua_Function func); 21int lua_currentline (lua_Function func);
22char *lua_getobjname (lua_Object o, char **name); 22char *lua_getobjname (lua_Object o, char **name);
23 23
diff --git a/lundump.c b/lundump.c
index 55860284..941f8ae8 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.5 1998/12/15 14:59:43 roberto Exp $ 2** $Id: lundump.c,v 1.6 1998/12/27 20:23:22 roberto Exp roberto $
3** load bytecodes from files 3** load bytecodes from files
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -161,7 +161,7 @@ static TProtoFunc* LoadFunction (ZIO* Z)
161{ 161{
162 TProtoFunc* tf=luaF_newproto(); 162 TProtoFunc* tf=luaF_newproto();
163 tf->lineDefined=LoadWord(Z); 163 tf->lineDefined=LoadWord(Z);
164 tf->fileName=LoadTString(Z); 164 tf->source=LoadTString(Z);
165 tf->code=LoadCode(Z); 165 tf->code=LoadCode(Z);
166 LoadLocals(tf,Z); 166 LoadLocals(tf,Z);
167 LoadConstants(tf,Z); 167 LoadConstants(tf,Z);
diff --git a/manual.tex b/manual.tex
index cbde48e0..7979064d 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.23 1999/02/12 19:23:02 roberto Exp roberto $ 1% $Id: manual.tex,v 1.24 1999/02/25 19:13:56 roberto Exp roberto $
2 2
3\documentclass[11pt]{article} 3\documentclass[11pt]{article}
4\usepackage{fullpage,bnf} 4\usepackage{fullpage,bnf}
@@ -41,7 +41,7 @@ Waldemar Celes
41\tecgraf\ --- Computer Science Department --- PUC-Rio 41\tecgraf\ --- Computer Science Department --- PUC-Rio
42} 42}
43 43
44%\date{\small \verb$Date: 1999/02/12 19:23:02 $} 44%\date{\small \verb$Date: 1999/02/25 19:13:56 $}
45 45
46\maketitle 46\maketitle
47 47
@@ -2926,12 +2926,16 @@ it accepts only a handle returned by
2926 2926
2927Three other functions produce extra information about a function: 2927Three other functions produce extra information about a function:
2928\begin{verbatim} 2928\begin{verbatim}
2929void lua_funcinfo (lua_Object func, char **filename, int *linedefined); 2929void lua_funcinfo (lua_Object func, char **source, int *linedefined);
2930int lua_currentline (lua_Function func); 2930int lua_currentline (lua_Function func);
2931char *lua_getobjname (lua_Object o, char **name); 2931char *lua_getobjname (lua_Object o, char **name);
2932\end{verbatim} 2932\end{verbatim}
2933\verb|lua_funcinfo| gives the file name and the line where the 2933\verb|lua_funcinfo| gives the source and the line where the
2934given function has been defined. 2934given function has been defined:
2935If the function was defined in a string,
2936\verb|source| is that string;
2937If the function was defined in a file,
2938\verb|source| starts with a \verb|@| followed by the file name.
2935If the ``function'' is in fact the main code of a chunk, 2939If the ``function'' is in fact the main code of a chunk,
2936then \verb|linedefined| is 0. 2940then \verb|linedefined| is 0.
2937If the function is a C function, 2941If the function is a C function,