mirror of
https://github.com/lua/lua
synced 2024-11-25 06:09:36 +03:00
lua_table now has references to global variable names (TreeNode's).
This commit is contained in:
parent
19290a8e92
commit
0d50b87aa4
6
opcode.h
6
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)
|
||||
|
7
table.c
7
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);
|
||||
|
9
table.h
9
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;
|
||||
|
||||
|
20
tree.c
20
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);
|
||||
}
|
||||
|
||||
|
3
tree.h
3
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
|
||||
|
Loading…
Reference in New Issue
Block a user