commit 0d50b87aa47d3cb64730bf5c8646e5e6ff02c268
parent 19290a8e92a9b22f448b82c2bcb67ea635dee6ad
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 26 Jan 1996 16:02:59 -0200
lua_table now has references to global variable names (TreeNode's).
Diffstat:
5 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/opcode.h b/opcode.h
@@ -1,6 +1,6 @@
/*
** TeCGraf - PUC-Rio
-** $Id: opcode.h,v 3.14 1995/10/25 13:05:51 roberto Exp roberto $
+** $Id: opcode.h,v 3.15 1995/12/21 16:14:04 roberto Exp roberto $
*/
#ifndef opcode_h
@@ -94,10 +94,6 @@ typedef struct Object
Value value;
} Object;
-typedef struct
-{
- Object object;
-} Symbol;
/* Macros to access structure members */
#define tag(o) ((o)->tag)
diff --git a/table.c b/table.c
@@ -3,7 +3,7 @@
** Module to control static tables
*/
-char *rcs_table="$Id: table.c,v 2.42 1996/01/23 18:39:45 roberto Exp roberto $";
+char *rcs_table="$Id: table.c,v 2.43 1996/01/26 14:04:32 roberto Exp roberto $";
/*#include <string.h>*/
@@ -101,6 +101,7 @@ Word luaI_findsymbol (TreeNode *t)
lua_table = growvector(lua_table, lua_maxsymbol, Symbol);
}
t->varindex = lua_ntable;
+ lua_table[lua_ntable].varname = t;
s_tag(lua_ntable) = LUA_T_NIL;
lua_ntable++;
}
@@ -155,7 +156,7 @@ static char *lua_travsymbol (int (*fn)(Object *))
Word i;
for (i=0; i<lua_ntable; i++)
if (fn(&s_object(i)))
- return luaI_nodebysymbol(i)->ts.str;
+ return lua_table[i].varname->ts.str;
return NULL;
}
@@ -234,7 +235,7 @@ static void lua_nextvar (void)
}
else
{
- TreeNode *t = luaI_nodebysymbol(next);
+ TreeNode *t = lua_table[next].varname;
Object name;
tag(&name) = LUA_T_STRING;
tsvalue(&name) = &(t->ts);
diff --git a/table.h b/table.h
@@ -1,7 +1,7 @@
/*
** Module to control static tables
** TeCGraf - PUC-Rio
-** $Id: table.h,v 2.13 1995/10/26 14:21:56 roberto Exp roberto $
+** $Id: table.h,v 2.14 1996/01/22 14:15:13 roberto Exp roberto $
*/
#ifndef table_h
@@ -10,6 +10,13 @@
#include "tree.h"
#include "opcode.h"
+typedef struct
+{
+ Object object;
+ TreeNode *varname;
+} Symbol;
+
+
extern Symbol *lua_table;
extern TaggedString **lua_constant;
diff --git a/tree.c b/tree.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_tree="$Id: tree.c,v 1.13 1995/01/12 14:19:04 roberto Exp roberto $";
+char *rcs_tree="$Id: tree.c,v 1.14 1995/10/17 11:53:53 roberto Exp roberto $";
#include <string.h>
@@ -103,21 +103,3 @@ Long lua_strcollector (void)
}
-/*
-** Traverse the constant tree looking for a specific symbol number
-*/
-static TreeNode *nodebysymbol (TreeNode *root, Word symbol)
-{
- TreeNode *t;
- if (root == NULL) return NULL;
- if (root->varindex == symbol) return root;
- t = nodebysymbol(root->left, symbol);
- if (t) return t;
- return nodebysymbol(root->right, symbol);
-}
-
-TreeNode *luaI_nodebysymbol (Word symbol)
-{
- return nodebysymbol(constant_root, symbol);
-}
-
diff --git a/tree.h b/tree.h
@@ -1,7 +1,7 @@
/*
** tree.h
** TecCGraf - PUC-Rio
-** $Id: tree.h,v 1.9 1995/01/12 14:19:04 roberto Exp roberto $
+** $Id: tree.h,v 1.10 1995/10/17 11:53:53 roberto Exp roberto $
*/
#ifndef tree_h
@@ -32,6 +32,5 @@ typedef struct TreeNode
TaggedString *lua_createstring (char *str);
TreeNode *lua_constcreate (char *str);
Long lua_strcollector (void);
-TreeNode *luaI_nodebysymbol (Word symbol);
#endif