diff options
| -rw-r--r-- | func.c | 20 | ||||
| -rw-r--r-- | func.h | 4 | ||||
| -rw-r--r-- | iolib.c | 39 | ||||
| -rw-r--r-- | lua.stx | 124 | ||||
| -rw-r--r-- | luadebug.h | 7 | ||||
| -rw-r--r-- | opcode.c | 11 | ||||
| -rw-r--r-- | table.c | 52 | ||||
| -rw-r--r-- | table.h | 4 |
8 files changed, 137 insertions, 124 deletions
| @@ -1,7 +1,10 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | |||
| 3 | #include "luadebug.h" | ||
| 2 | #include "table.h" | 4 | #include "table.h" |
| 3 | #include "mem.h" | 5 | #include "mem.h" |
| 4 | #include "func.h" | 6 | #include "func.h" |
| 7 | #include "opcode.h" | ||
| 5 | 8 | ||
| 6 | static TFunc *function_root = NULL; | 9 | static TFunc *function_root = NULL; |
| 7 | 10 | ||
| @@ -57,3 +60,20 @@ Long luaI_funccollector (void) | |||
| 57 | } | 60 | } |
| 58 | return counter; | 61 | return counter; |
| 59 | } | 62 | } |
| 63 | |||
| 64 | |||
| 65 | void lua_funcinfo (lua_Object func, char **filename, int *linedefined) | ||
| 66 | { | ||
| 67 | Object *f = luaI_Address(func); | ||
| 68 | if (f->tag == LUA_T_MARK || f->tag == LUA_T_FUNCTION) | ||
| 69 | { | ||
| 70 | *filename = f->value.tf->fileName; | ||
| 71 | *linedefined = f->value.tf->lineDefined; | ||
| 72 | } | ||
| 73 | else if (f->tag == LUA_T_CMARK || f->tag == LUA_T_CFUNCTION) | ||
| 74 | { | ||
| 75 | *filename = "(C)"; | ||
| 76 | *linedefined = -1; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define func_h | 2 | #define func_h |
| 3 | 3 | ||
| 4 | #include "types.h" | 4 | #include "types.h" |
| 5 | #include "lua.h" | ||
| 5 | 6 | ||
| 6 | /* | 7 | /* |
| 7 | ** Header para funcoes. | 8 | ** Header para funcoes. |
| @@ -13,12 +14,11 @@ typedef struct TFunc | |||
| 13 | int size; | 14 | int size; |
| 14 | Byte *code; | 15 | Byte *code; |
| 15 | int lineDefined; | 16 | int lineDefined; |
| 16 | char *name1; /* function or method name (or null if main) */ | ||
| 17 | char *name2; /* object name (or null if not method) */ | ||
| 18 | char *fileName; | 17 | char *fileName; |
| 19 | } TFunc; | 18 | } TFunc; |
| 20 | 19 | ||
| 21 | Long luaI_funccollector (void); | 20 | Long luaI_funccollector (void); |
| 22 | void luaI_insertfunction (TFunc *f); | 21 | void luaI_insertfunction (TFunc *f); |
| 23 | 22 | ||
| 23 | |||
| 24 | #endif | 24 | #endif |
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Input/output library to LUA | 3 | ** Input/output library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_iolib="$Id: iolib.c,v 1.24 1995/10/17 14:12:45 roberto Exp roberto $"; | 6 | char *rcs_iolib="$Id: iolib.c,v 1.25 1995/10/23 13:53:48 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <ctype.h> | 9 | #include <ctype.h> |
| @@ -612,20 +612,33 @@ static void print_message (void) | |||
| 612 | fprintf(stderr, "Active Stack:\n"); | 612 | fprintf(stderr, "Active Stack:\n"); |
| 613 | while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) | 613 | while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) |
| 614 | { | 614 | { |
| 615 | char *filename; char *funcname; | 615 | char *name; |
| 616 | char *objname; int linedefined; | 616 | int currentline; |
| 617 | lua_funcinfo(func, &filename, &funcname, &objname, &linedefined); | 617 | fprintf(stderr, "\t"); |
| 618 | if (objname == NULL) | 618 | switch (*getobjname(func, &name)) |
| 619 | if (funcname) | 619 | { |
| 620 | fprintf(stderr, "\t%s", funcname); | 620 | case 'g': |
| 621 | else | 621 | fprintf(stderr, "function %s", name); |
| 622 | break; | ||
| 623 | case 'f': | ||
| 624 | fprintf(stderr, "fallback %s", name); | ||
| 625 | break; | ||
| 626 | default: | ||
| 622 | { | 627 | { |
| 623 | fprintf(stderr, "\tmain of %s\n", filename); | 628 | char *filename; |
| 624 | continue; | 629 | int linedefined; |
| 630 | lua_funcinfo(func, &filename, &linedefined); | ||
| 631 | if (linedefined == 0) | ||
| 632 | fprintf(stderr, "main of %s", filename); | ||
| 633 | else if (linedefined < 0) | ||
| 634 | fprintf(stderr, "%s", filename); | ||
| 635 | else | ||
| 636 | fprintf(stderr, "function (%s:%d)", filename, linedefined); | ||
| 625 | } | 637 | } |
| 626 | else | 638 | } |
| 627 | fprintf(stderr, "\t%s:%s", objname, funcname); | 639 | if ((currentline = lua_currentline(func)) > 0) |
| 628 | fprintf(stderr, "\t(defined in %s)\n", filename); | 640 | fprintf(stderr, " at line %d", currentline); |
| 641 | fprintf(stderr, "\n"); | ||
| 629 | } | 642 | } |
| 630 | } | 643 | } |
| 631 | 644 | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | 2 | ||
| 3 | char *rcs_luastx = "$Id: lua.stx,v 3.22 1995/10/25 13:05:51 roberto Exp roberto $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.23 1995/10/25 14:33:25 roberto Exp roberto $"; |
| 4 | 4 | ||
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| @@ -54,6 +54,14 @@ static int nfields=0; | |||
| 54 | 54 | ||
| 55 | /* Internal functions */ | 55 | /* Internal functions */ |
| 56 | 56 | ||
| 57 | static void yyerror (char *s) | ||
| 58 | { | ||
| 59 | static char msg[256]; | ||
| 60 | sprintf (msg,"%s near \"%s\" at line %d in file `%s'", | ||
| 61 | s, lua_lasttext (), lua_linenumber, lua_parsedfile); | ||
| 62 | lua_error (msg); | ||
| 63 | } | ||
| 64 | |||
| 57 | static void code_byte (Byte c) | 65 | static void code_byte (Byte c) |
| 58 | { | 66 | { |
| 59 | if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ | 67 | if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ |
| @@ -148,6 +156,8 @@ static void add_localvar (Word name) | |||
| 148 | 156 | ||
| 149 | static void store_localvar (Word name, int n) | 157 | static void store_localvar (Word name, int n) |
| 150 | { | 158 | { |
| 159 | if (*initcode == basepc) | ||
| 160 | yyerror("local variable outside function body"); | ||
| 151 | if (nlocalvar+n < MAXLOCALS) | 161 | if (nlocalvar+n < MAXLOCALS) |
| 152 | localvar[nlocalvar+n] = name; | 162 | localvar[nlocalvar+n] = name; |
| 153 | else | 163 | else |
| @@ -249,6 +259,20 @@ static void savemain (void) | |||
| 249 | maincode=pc; *initcode=basepc; maxmain=maxcurr; | 259 | maincode=pc; *initcode=basepc; maxmain=maxcurr; |
| 250 | } | 260 | } |
| 251 | 261 | ||
| 262 | static void init_func (void) | ||
| 263 | { | ||
| 264 | if (funcCode == NULL) /* first function */ | ||
| 265 | { | ||
| 266 | funcCode = newvector(CODE_BLOCK, Byte); | ||
| 267 | maxcode = CODE_BLOCK; | ||
| 268 | } | ||
| 269 | savemain(); /* save main values */ | ||
| 270 | /* set func values */ | ||
| 271 | pc=0; basepc=funcCode; maxcurr=maxcode; | ||
| 272 | nlocalvar = 0; | ||
| 273 | luaI_codedebugline(lua_linenumber); | ||
| 274 | } | ||
| 275 | |||
| 252 | static void codereturn (void) | 276 | static void codereturn (void) |
| 253 | { | 277 | { |
| 254 | if (nlocalvar == 0) | 278 | if (nlocalvar == 0) |
| @@ -300,23 +324,31 @@ static void adjust_mult_assign (int vars, Long exps, int temps) | |||
| 300 | lua_codeadjust(temps); | 324 | lua_codeadjust(temps); |
| 301 | } | 325 | } |
| 302 | 326 | ||
| 303 | static void lua_codestore (int i) | 327 | static void storesinglevar (Long v) |
| 304 | { | 328 | { |
| 305 | if (varbuffer[i] > 0) /* global var */ | 329 | if (v > 0) /* global var */ |
| 306 | { | 330 | { |
| 307 | code_byte(STOREGLOBAL); | 331 | code_byte(STOREGLOBAL); |
| 308 | code_word(varbuffer[i]-1); | 332 | code_word(v-1); |
| 309 | } | 333 | } |
| 310 | else if (varbuffer[i] < 0) /* local var */ | 334 | else if (v < 0) /* local var */ |
| 311 | { | 335 | { |
| 312 | int number = (-varbuffer[i]) - 1; | 336 | int number = (-v) - 1; |
| 313 | if (number < 10) code_byte(STORELOCAL0 + number); | 337 | if (number < 10) code_byte(STORELOCAL0 + number); |
| 314 | else | 338 | else |
| 315 | { | 339 | { |
| 316 | code_byte(STORELOCAL); | 340 | code_byte(STORELOCAL); |
| 317 | code_byte(number); | 341 | code_byte(number); |
| 318 | } | 342 | } |
| 319 | } | 343 | } |
| 344 | else | ||
| 345 | code_byte(STOREINDEXED0); | ||
| 346 | } | ||
| 347 | |||
| 348 | static void lua_codestore (int i) | ||
| 349 | { | ||
| 350 | if (varbuffer[i] != 0) /* global or local var */ | ||
| 351 | storesinglevar(varbuffer[i]); | ||
| 320 | else /* indexed var */ | 352 | else /* indexed var */ |
| 321 | { | 353 | { |
| 322 | int j; | 354 | int j; |
| @@ -352,14 +384,6 @@ static void codeIf (Long thenAdd, Long elseAdd) | |||
| 352 | code_word_at(basepc+thenAdd+1,elseinit-(thenAdd+sizeof(Word)+1)); | 384 | code_word_at(basepc+thenAdd+1,elseinit-(thenAdd+sizeof(Word)+1)); |
| 353 | } | 385 | } |
| 354 | 386 | ||
| 355 | static void yyerror (char *s) | ||
| 356 | { | ||
| 357 | static char msg[256]; | ||
| 358 | sprintf (msg,"%s near \"%s\" at line %d in file `%s'", | ||
| 359 | s, lua_lasttext (), lua_linenumber, lua_parsedfile); | ||
| 360 | lua_error (msg); | ||
| 361 | } | ||
| 362 | |||
| 363 | 387 | ||
| 364 | /* | 388 | /* |
| 365 | ** Parse LUA code. | 389 | ** Parse LUA code. |
| @@ -419,8 +443,8 @@ void lua_parse (TFunc *tf) | |||
| 419 | %type <vInt> fieldlist, localdeclist, decinit | 443 | %type <vInt> fieldlist, localdeclist, decinit |
| 420 | %type <vInt> ffieldlist, ffieldlist1, semicolonpart | 444 | %type <vInt> ffieldlist, ffieldlist1, semicolonpart |
| 421 | %type <vInt> lfieldlist, lfieldlist1 | 445 | %type <vInt> lfieldlist, lfieldlist1 |
| 422 | %type <vInt> functiontoken | 446 | %type <vInt> parlist |
| 423 | %type <vLong> var, singlevar | 447 | %type <vLong> var, singlevar, funcname |
| 424 | %type <pFunc> body | 448 | %type <pFunc> body |
| 425 | 449 | ||
| 426 | %left AND OR | 450 | %left AND OR |
| @@ -438,59 +462,29 @@ void lua_parse (TFunc *tf) | |||
| 438 | functionlist : /* empty */ | 462 | functionlist : /* empty */ |
| 439 | | functionlist globalstat | 463 | | functionlist globalstat |
| 440 | | functionlist function | 464 | | functionlist function |
| 441 | | functionlist method | ||
| 442 | ; | 465 | ; |
| 443 | 466 | ||
| 444 | globalstat : stat sc | 467 | globalstat : stat sc |
| 445 | | setdebug | 468 | | setdebug |
| 446 | ; | 469 | ; |
| 447 | 470 | ||
| 448 | function : functiontoken NAME body | 471 | function : FUNCTION funcname body |
| 449 | { | 472 | { |
| 450 | code_byte(PUSHFUNCTION); | 473 | code_byte(PUSHFUNCTION); |
| 451 | code_code($3); | 474 | code_code($3); |
| 452 | code_byte(STOREGLOBAL); | 475 | storesinglevar($2); |
| 453 | code_word(luaI_findsymbol($2)); | ||
| 454 | $3->lineDefined = $1; | ||
| 455 | $3->name1 = $2->ts.str; | ||
| 456 | $3->name2 = NULL; | ||
| 457 | $3->fileName = lua_parsedfile; | ||
| 458 | } | 476 | } |
| 459 | ; | 477 | ; |
| 460 | 478 | ||
| 461 | method : functiontoken NAME methkind NAME body | 479 | funcname : var { $$ =$1; init_func(); } |
| 462 | { | 480 | | varexp ':' NAME |
| 463 | /* assign function to table field */ | ||
| 464 | lua_pushvar(luaI_findsymbol($2)+1); | ||
| 465 | code_byte(PUSHSTRING); | ||
| 466 | code_word(luaI_findconstant($4)); | ||
| 467 | code_byte(PUSHFUNCTION); | ||
| 468 | code_code($5); | ||
| 469 | code_byte(STOREINDEXED0); | ||
| 470 | $5->lineDefined = $1; | ||
| 471 | $5->name1 = $4->ts.str; | ||
| 472 | $5->name2 = $2->ts.str; | ||
| 473 | $5->fileName = lua_parsedfile; | ||
| 474 | } | ||
| 475 | ; | ||
| 476 | |||
| 477 | functiontoken : FUNCTION | ||
| 478 | { | 481 | { |
| 479 | if (funcCode == NULL) /* first function */ | 482 | code_byte(PUSHSTRING); |
| 480 | { | 483 | code_word(luaI_findconstant($3)); |
| 481 | funcCode = newvector(CODE_BLOCK, Byte); | 484 | $$ = 0; /* indexed variable */ |
| 482 | maxcode = CODE_BLOCK; | 485 | init_func(); |
| 483 | } | 486 | add_localvar(luaI_findsymbolbyname("self")); |
| 484 | savemain(); /* save main values */ | ||
| 485 | /* set func values */ | ||
| 486 | pc=0; basepc=funcCode; maxcurr=maxcode; | ||
| 487 | nlocalvar=0; | ||
| 488 | $$ = lua_linenumber; | ||
| 489 | } | 487 | } |
| 490 | ; | ||
| 491 | |||
| 492 | methkind : ':' { add_localvar(luaI_findsymbolbyname("self")); } | ||
| 493 | | '.' /* no self */ | ||
| 494 | ; | 488 | ; |
| 495 | 489 | ||
| 496 | body : '(' parlist ')' block END | 490 | body : '(' parlist ')' block END |
| @@ -499,6 +493,8 @@ body : '(' parlist ')' block END | |||
| 499 | $$ = new(TFunc); | 493 | $$ = new(TFunc); |
| 500 | $$->size = pc; | 494 | $$->size = pc; |
| 501 | $$->code = newvector(pc, Byte); | 495 | $$->code = newvector(pc, Byte); |
| 496 | $$->fileName = lua_parsedfile; | ||
| 497 | $$->lineDefined = $2; | ||
| 502 | memcpy($$->code, basepc, pc*sizeof(Byte)); | 498 | memcpy($$->code, basepc, pc*sizeof(Byte)); |
| 503 | /* save func values */ | 499 | /* save func values */ |
| 504 | funcCode = basepc; maxcode=maxcurr; | 500 | funcCode = basepc; maxcode=maxcurr; |
| @@ -674,8 +670,8 @@ exprlist1 : expr { if ($1 != 0) $$ = $1; else $$ = -1; } | |||
| 674 | } | 670 | } |
| 675 | ; | 671 | ; |
| 676 | 672 | ||
| 677 | parlist : /* empty */ { lua_codeadjust(0); } | 673 | parlist : /* empty */ { lua_codeadjust(0); $$ = lua_linenumber; } |
| 678 | | parlist1 { lua_codeadjust(0); } | 674 | | parlist1 { lua_codeadjust(0); $$ = lua_linenumber; } |
| 679 | ; | 675 | ; |
| 680 | 676 | ||
| 681 | parlist1 : NAME | 677 | parlist1 : NAME |
| @@ -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: $ | 5 | ** $Id: luadebug.h,v 1.1 1995/10/17 14:12:45 roberto Exp roberto $ |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | 8 | ||
| @@ -12,8 +12,9 @@ | |||
| 12 | #include "lua.h" | 12 | #include "lua.h" |
| 13 | 13 | ||
| 14 | lua_Object lua_stackedfunction(int level); | 14 | lua_Object lua_stackedfunction(int level); |
| 15 | void lua_funcinfo (lua_Object func, char **filename, char **funcname, | 15 | void lua_funcinfo (lua_Object func, char **filename, int *linedefined); |
| 16 | char **objname, int *linedefined); | 16 | int lua_currentline (lua_Object func); |
| 17 | char *getobjname (lua_Object o, char **name); | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | #endif | 20 | #endif |
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 3.46 1995/10/17 14:30:05 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.47 1995/10/25 13:05:51 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| @@ -355,17 +355,13 @@ lua_Object lua_stackedfunction (int level) | |||
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | 357 | ||
| 358 | void lua_funcinfo (lua_Object func, char **filename, char **funcname, | 358 | int lua_currentline (lua_Object func) |
| 359 | char **objname, int *line) | ||
| 360 | { | 359 | { |
| 361 | Object *f = Address(func); | 360 | Object *f = Address(func); |
| 362 | luaI_funcInfo(f, filename, funcname, objname, line); | 361 | return (f+1 < top && (f+1)->tag == LUA_T_LINE) ? (f+1)->value.i : -1; |
| 363 | *line = (f+1 < top && (f+1)->tag == LUA_T_LINE) ? | ||
| 364 | (f+1)->value.i : -1; | ||
| 365 | } | 362 | } |
| 366 | 363 | ||
| 367 | 364 | ||
| 368 | |||
| 369 | /* | 365 | /* |
| 370 | ** Execute a protected call. Assumes that function is at CBase and | 366 | ** Execute a protected call. Assumes that function is at CBase and |
| 371 | ** parameters are on top of it. Leave nResults on the stack. | 367 | ** parameters are on top of it. Leave nResults on the stack. |
| @@ -406,7 +402,6 @@ static int do_protectedmain (void) | |||
| 406 | stack[CBase].tag = LUA_T_FUNCTION; | 402 | stack[CBase].tag = LUA_T_FUNCTION; |
| 407 | stack[CBase].value.tf = &tf; | 403 | stack[CBase].value.tf = &tf; |
| 408 | tf.lineDefined = 0; | 404 | tf.lineDefined = 0; |
| 409 | tf.name1 = tf.name2 = NULL; | ||
| 410 | tf.fileName = lua_parsedfile; | 405 | tf.fileName = lua_parsedfile; |
| 411 | tf.code = NULL; | 406 | tf.code = NULL; |
| 412 | if (setjmp(myErrorJmp) == 0) | 407 | if (setjmp(myErrorJmp) == 0) |
| @@ -3,9 +3,9 @@ | |||
| 3 | ** Module to control static tables | 3 | ** Module to control static tables |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_table="$Id: table.c,v 2.35 1995/10/17 11:58:41 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.36 1995/10/23 13:53:48 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | /*#include <string.h>*/ |
| 9 | 9 | ||
| 10 | #include "mem.h" | 10 | #include "mem.h" |
| 11 | #include "opcode.h" | 11 | #include "opcode.h" |
| @@ -15,6 +15,7 @@ char *rcs_table="$Id: table.c,v 2.35 1995/10/17 11:58:41 roberto Exp roberto $"; | |||
| 15 | #include "inout.h" | 15 | #include "inout.h" |
| 16 | #include "lua.h" | 16 | #include "lua.h" |
| 17 | #include "fallback.h" | 17 | #include "fallback.h" |
| 18 | #include "luadebug.h" | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | #define BUFFER_BLOCK 256 | 21 | #define BUFFER_BLOCK 256 |
| @@ -254,39 +255,28 @@ static void getglobal (void) | |||
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | 257 | ||
| 257 | static lua_CFunction cfunc = NULL; | 258 | static Object *functofind; |
| 258 | static int checkfunc (Object *o) | 259 | static int checkfunc (Object *o) |
| 259 | { | 260 | { |
| 260 | return ((o->tag == LUA_T_CMARK || o->tag == LUA_T_CFUNCTION) && | 261 | if (o->tag == LUA_T_FUNCTION) |
| 261 | o->value.f == cfunc); | 262 | return |
| 263 | ((functofind->tag == LUA_T_FUNCTION || functofind->tag == LUA_T_MARK) | ||
| 264 | && (functofind->value.tf == o->value.tf)); | ||
| 265 | if (o->tag == LUA_T_CFUNCTION) | ||
| 266 | return | ||
| 267 | ((functofind->tag == LUA_T_CFUNCTION || functofind->tag == LUA_T_CMARK) | ||
| 268 | && (functofind->value.f == o->value.f)); | ||
| 269 | return 0; | ||
| 262 | } | 270 | } |
| 263 | 271 | ||
| 264 | 272 | ||
| 265 | void luaI_funcInfo (struct Object *func, char **filename, char **funcname, | 273 | char *getobjname (lua_Object o, char **name) |
| 266 | char **objname, int *linedefined) | 274 | { /* try to find a name for given function */ |
| 267 | { | 275 | functofind = luaI_Address(o); |
| 268 | if (func->tag == LUA_T_MARK || func->tag == LUA_T_FUNCTION) | 276 | if ((*name = lua_travsymbol(checkfunc)) != NULL) |
| 269 | { | 277 | return "global"; |
| 270 | TFunc *f = func->value.tf; | 278 | else if ((*name = luaI_travfallbacks(checkfunc)) != NULL) |
| 271 | *filename = f->fileName; | 279 | return "fallback"; |
| 272 | *funcname = f->name1; | 280 | else return ""; |
| 273 | *objname = f->name2; | ||
| 274 | *linedefined = f->lineDefined; | ||
| 275 | } | ||
| 276 | else if (func->tag == LUA_T_CMARK || func->tag == LUA_T_CFUNCTION) | ||
| 277 | { | ||
| 278 | /* temporario: */ | ||
| 279 | cfunc = func->value.f; | ||
| 280 | *filename = "(C)"; | ||
| 281 | *linedefined = 0; | ||
| 282 | *funcname = lua_travsymbol(checkfunc); | ||
| 283 | if (*funcname) | ||
| 284 | *objname = 0; | ||
| 285 | else | ||
| 286 | { | ||
| 287 | *funcname = luaI_travfallbacks(checkfunc); | ||
| 288 | *objname = "(FB)"; | ||
| 289 | } | ||
| 290 | } | ||
| 291 | } | 281 | } |
| 292 | 282 | ||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** Module to control static tables | 2 | ** Module to control static tables |
| 3 | ** TeCGraf - PUC-Rio | 3 | ** TeCGraf - PUC-Rio |
| 4 | ** $Id: table.h,v 2.11 1995/10/13 15:16:25 roberto Exp roberto $ | 4 | ** $Id: table.h,v 2.12 1995/10/17 11:58:41 roberto Exp roberto $ |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifndef table_h | 7 | #ifndef table_h |
| @@ -25,7 +25,5 @@ Word luaI_findconstantbyname (char *name); | |||
| 25 | int lua_markobject (Object *o); | 25 | int lua_markobject (Object *o); |
| 26 | void lua_pack (void); | 26 | void lua_pack (void); |
| 27 | 27 | ||
| 28 | void luaI_funcInfo (Object *func, char **filename, char **funcname, | ||
| 29 | char **objname, int *linedefined); | ||
| 30 | 28 | ||
| 31 | #endif | 29 | #endif |
