diff options
Diffstat (limited to 'lua.stx')
| -rw-r--r-- | lua.stx | 30 |
1 files changed, 19 insertions, 11 deletions
| @@ -1,11 +1,12 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | 2 | ||
| 3 | char *rcs_luastx = "$Id: lua.stx,v 3.27 1996/01/23 17:50:29 roberto Exp $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.28 1996/02/05 13:26:01 roberto Exp roberto $"; |
| 4 | 4 | ||
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | 8 | ||
| 9 | #include "luadebug.h" | ||
| 9 | #include "mem.h" | 10 | #include "mem.h" |
| 10 | #include "opcode.h" | 11 | #include "opcode.h" |
| 11 | #include "hash.h" | 12 | #include "hash.h" |
| @@ -51,6 +52,7 @@ static int nlocalvar=0; /* number of local variables */ | |||
| 51 | static Word fields[MAXFIELDS]; /* fieldnames to be flushed */ | 52 | static Word fields[MAXFIELDS]; /* fieldnames to be flushed */ |
| 52 | static int nfields=0; | 53 | static int nfields=0; |
| 53 | 54 | ||
| 55 | int lua_debug = 0; | ||
| 54 | 56 | ||
| 55 | /* Internal functions */ | 57 | /* Internal functions */ |
| 56 | 58 | ||
| @@ -149,20 +151,20 @@ static void flush_list (int m, int n) | |||
| 149 | code_byte(n); | 151 | code_byte(n); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | static void add_localvar (TreeNode *name) | ||
| 153 | { | ||
| 154 | if (nlocalvar < MAXLOCALS) | ||
| 155 | localvar[nlocalvar++] = name; | ||
| 156 | else | ||
| 157 | yyerror ("too many local variables"); | ||
| 158 | } | ||
| 159 | |||
| 160 | static void store_localvar (TreeNode *name, int n) | 154 | static void store_localvar (TreeNode *name, int n) |
| 161 | { | 155 | { |
| 162 | if (nlocalvar+n < MAXLOCALS) | 156 | if (nlocalvar+n < MAXLOCALS) |
| 163 | localvar[nlocalvar+n] = name; | 157 | localvar[nlocalvar+n] = name; |
| 164 | else | 158 | else |
| 165 | yyerror ("too many local variables"); | 159 | yyerror ("too many local variables"); |
| 160 | if (lua_debug) | ||
| 161 | luaI_registerlocalvar(name, lua_linenumber); | ||
| 162 | } | ||
| 163 | |||
| 164 | static void add_localvar (TreeNode *name) | ||
| 165 | { | ||
| 166 | store_localvar(name, 0); | ||
| 167 | nlocalvar++; | ||
| 166 | } | 168 | } |
| 167 | 169 | ||
| 168 | static void add_varbuffer (Long var) | 170 | static void add_varbuffer (Long var) |
| @@ -391,7 +393,6 @@ static void codeIf (Long thenAdd, Long elseAdd) | |||
| 391 | */ | 393 | */ |
| 392 | void lua_parse (TFunc *tf) | 394 | void lua_parse (TFunc *tf) |
| 393 | { | 395 | { |
| 394 | lua_debug = 0; | ||
| 395 | initcode = &(tf->code); | 396 | initcode = &(tf->code); |
| 396 | *initcode = newvector(CODE_BLOCK, Byte); | 397 | *initcode = newvector(CODE_BLOCK, Byte); |
| 397 | maincode = 0; | 398 | maincode = 0; |
| @@ -492,11 +493,14 @@ body : '(' parlist ')' block END | |||
| 492 | { | 493 | { |
| 493 | codereturn(); | 494 | codereturn(); |
| 494 | $$ = new(TFunc); | 495 | $$ = new(TFunc); |
| 496 | luaI_initTFunc($$); | ||
| 495 | $$->size = pc; | 497 | $$->size = pc; |
| 496 | $$->code = newvector(pc, Byte); | 498 | $$->code = newvector(pc, Byte); |
| 497 | $$->fileName = lua_parsedfile; | 499 | $$->fileName = lua_parsedfile; |
| 498 | $$->lineDefined = $2; | 500 | $$->lineDefined = $2; |
| 499 | memcpy($$->code, basepc, pc*sizeof(Byte)); | 501 | memcpy($$->code, basepc, pc*sizeof(Byte)); |
| 502 | if (lua_debug) | ||
| 503 | luaI_closelocalvars($$); | ||
| 500 | /* save func values */ | 504 | /* save func values */ |
| 501 | funcCode = basepc; maxcode=maxcurr; | 505 | funcCode = basepc; maxcode=maxcurr; |
| 502 | #if LISTING | 506 | #if LISTING |
| @@ -557,7 +561,11 @@ block : {$<vInt>$ = nlocalvar;} statlist ret | |||
| 557 | { | 561 | { |
| 558 | if (nlocalvar != $<vInt>1) | 562 | if (nlocalvar != $<vInt>1) |
| 559 | { | 563 | { |
| 560 | nlocalvar = $<vInt>1; | 564 | if (lua_debug) |
| 565 | for (; nlocalvar > $<vInt>1; nlocalvar--) | ||
| 566 | luaI_unregisterlocalvar(lua_linenumber); | ||
| 567 | else | ||
| 568 | nlocalvar = $<vInt>1; | ||
| 561 | lua_codeadjust (0); | 569 | lua_codeadjust (0); |
| 562 | } | 570 | } |
| 563 | } | 571 | } |
