diff options
Diffstat (limited to 'lua.stx')
-rw-r--r-- | lua.stx | 35 |
1 files changed, 13 insertions, 22 deletions
@@ -1,6 +1,6 @@ | |||
1 | %{ | 1 | %{ |
2 | 2 | ||
3 | char *rcs_luastx = "$Id: lua.stx,v 3.19 1995/06/08 19:47:28 roberto Exp $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.20 1995/10/04 14:20:26 roberto Exp roberto $"; |
4 | 4 | ||
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
@@ -244,17 +244,10 @@ static void init_function (TreeNode *func) | |||
244 | } | 244 | } |
245 | pc=0; basepc=funcCode; maxcurr=maxcode; | 245 | pc=0; basepc=funcCode; maxcurr=maxcode; |
246 | nlocalvar=0; | 246 | nlocalvar=0; |
247 | if (lua_debug) | ||
248 | { | ||
249 | code_byte(SETFUNCTION); | ||
250 | code_code((TFunc *)luaI_strdup(lua_file[lua_nfile-1])); | ||
251 | code_word(luaI_findconstant(func)); | ||
252 | } | ||
253 | } | 247 | } |
254 | 248 | ||
255 | static void codereturn (void) | 249 | static void codereturn (void) |
256 | { | 250 | { |
257 | if (lua_debug) code_byte(RESET); | ||
258 | if (nlocalvar == 0) | 251 | if (nlocalvar == 0) |
259 | code_byte(RETCODE0); | 252 | code_byte(RETCODE0); |
260 | else | 253 | else |
@@ -345,8 +338,8 @@ static void codeIf (Long thenAdd, Long elseAdd) | |||
345 | static void yyerror (char *s) | 338 | static void yyerror (char *s) |
346 | { | 339 | { |
347 | static char msg[256]; | 340 | static char msg[256]; |
348 | sprintf (msg,"%s near \"%s\" at line %d in file \"%s\"", | 341 | sprintf (msg,"%s near \"%s\" at line %d in file `%s'", |
349 | s, lua_lasttext (), lua_linenumber, lua_filename()); | 342 | s, lua_lasttext (), lua_linenumber, lua_parsedfile); |
350 | lua_error (msg); | 343 | lua_error (msg); |
351 | } | 344 | } |
352 | 345 | ||
@@ -435,6 +428,7 @@ functionlist : /* empty */ | |||
435 | function : FUNCTION NAME | 428 | function : FUNCTION NAME |
436 | { | 429 | { |
437 | init_function($2); | 430 | init_function($2); |
431 | $<vInt>$ = lua_linenumber; | ||
438 | } | 432 | } |
439 | body | 433 | body |
440 | { | 434 | { |
@@ -442,6 +436,10 @@ function : FUNCTION NAME | |||
442 | luaI_insertfunction($4); /* may take part in GC */ | 436 | luaI_insertfunction($4); /* may take part in GC */ |
443 | s_tag(func) = LUA_T_FUNCTION; | 437 | s_tag(func) = LUA_T_FUNCTION; |
444 | lua_table[func].object.value.tf = $4; | 438 | lua_table[func].object.value.tf = $4; |
439 | $4->lineDefined = $<vInt>3; | ||
440 | $4->name1 = $2->ts.str; | ||
441 | $4->name2 = NULL; | ||
442 | $4->fileName = lua_parsedfile; | ||
445 | } | 443 | } |
446 | ; | 444 | ; |
447 | 445 | ||
@@ -449,6 +447,7 @@ method : FUNCTION NAME ':' NAME | |||
449 | { | 447 | { |
450 | init_function($4); | 448 | init_function($4); |
451 | add_localvar(luaI_findsymbolbyname("self")); | 449 | add_localvar(luaI_findsymbolbyname("self")); |
450 | $<vInt>$ = lua_linenumber; | ||
452 | } | 451 | } |
453 | body | 452 | body |
454 | { | 453 | { |
@@ -462,6 +461,10 @@ method : FUNCTION NAME ':' NAME | |||
462 | code_code($6); | 461 | code_code($6); |
463 | code_byte(STOREINDEXED0); | 462 | code_byte(STOREINDEXED0); |
464 | maincode=pc; *initcode=basepc; maxmain=maxcurr; | 463 | maincode=pc; *initcode=basepc; maxmain=maxcurr; |
464 | $6->lineDefined = $<vInt>5; | ||
465 | $6->name1 = $4->ts.str; | ||
466 | $6->name2 = $2->ts.str; | ||
467 | $6->fileName = lua_parsedfile; | ||
465 | } | 468 | } |
466 | ; | 469 | ; |
467 | 470 | ||
@@ -966,17 +969,6 @@ static void PrintCode (Byte *code, Byte *end) | |||
966 | printf ("%d RETCODE %d\n", p-code, *(++p)); | 969 | printf ("%d RETCODE %d\n", p-code, *(++p)); |
967 | p++; | 970 | p++; |
968 | break; | 971 | break; |
969 | case SETFUNCTION: | ||
970 | { | ||
971 | CodeCode c1; | ||
972 | CodeWord c2; | ||
973 | int n = p-code; | ||
974 | p++; | ||
975 | get_code(c1,p); | ||
976 | get_word(c2,p); | ||
977 | printf ("%d SETFUNCTION %s %d\n", n, (char *)c1.tf, c2.w); | ||
978 | } | ||
979 | break; | ||
980 | case SETLINE: | 972 | case SETLINE: |
981 | { | 973 | { |
982 | CodeWord c; | 974 | CodeWord c; |
@@ -987,7 +979,6 @@ static void PrintCode (Byte *code, Byte *end) | |||
987 | } | 979 | } |
988 | break; | 980 | break; |
989 | 981 | ||
990 | case RESET: printf ("%d RESET\n", (p++)-code); break; | ||
991 | default: printf ("%d Cannot happen: code %d\n", (p++)-code, *(p-1)); break; | 982 | default: printf ("%d Cannot happen: code %d\n", (p++)-code, *(p-1)); break; |
992 | } | 983 | } |
993 | } | 984 | } |