aboutsummaryrefslogtreecommitdiff
path: root/lua.stx
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-02-07 16:10:27 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-02-07 16:10:27 -0200
commit5a3a1fe458a7eab402f5386e4dcb8282c94ff068 (patch)
treefc315159d0b00d3e726c0a538e40b6acdaa3e013 /lua.stx
parent56fb06b6f5eaea4f3dba32af1cc476a99b678497 (diff)
downloadlua-5a3a1fe458a7eab402f5386e4dcb8282c94ff068.tar.gz
lua-5a3a1fe458a7eab402f5386e4dcb8282c94ff068.tar.bz2
lua-5a3a1fe458a7eab402f5386e4dcb8282c94ff068.zip
debug interface functions to manipulated local variables:
"lua_getlocal" and "lua_setlocal".
Diffstat (limited to 'lua.stx')
-rw-r--r--lua.stx30
1 files changed, 19 insertions, 11 deletions
diff --git a/lua.stx b/lua.stx
index 5426b4c3..b48b7e76 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,11 +1,12 @@
1%{ 1%{
2 2
3char *rcs_luastx = "$Id: lua.stx,v 3.27 1996/01/23 17:50:29 roberto Exp $"; 3char *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 */
51static Word fields[MAXFIELDS]; /* fieldnames to be flushed */ 52static Word fields[MAXFIELDS]; /* fieldnames to be flushed */
52static int nfields=0; 53static int nfields=0;
53 54
55int 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
152static void add_localvar (TreeNode *name)
153{
154 if (nlocalvar < MAXLOCALS)
155 localvar[nlocalvar++] = name;
156 else
157 yyerror ("too many local variables");
158}
159
160static void store_localvar (TreeNode *name, int n) 154static 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
164static void add_localvar (TreeNode *name)
165{
166 store_localvar(name, 0);
167 nlocalvar++;
166} 168}
167 169
168static void add_varbuffer (Long var) 170static void add_varbuffer (Long var)
@@ -391,7 +393,6 @@ static void codeIf (Long thenAdd, Long elseAdd)
391*/ 393*/
392void lua_parse (TFunc *tf) 394void 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 }