diff options
Diffstat (limited to 'table.c')
-rw-r--r-- | table.c | 29 |
1 files changed, 11 insertions, 18 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: table.c,v 2.48 1996/02/26 21:00:27 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.49 1996/03/14 15:57:19 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include "mem.h" | 8 | #include "mem.h" |
9 | #include "opcode.h" | 9 | #include "opcode.h" |
@@ -33,7 +33,7 @@ static Long lua_maxconstant = 0; | |||
33 | static void lua_nextvar (void); | 33 | static void lua_nextvar (void); |
34 | 34 | ||
35 | /* | 35 | /* |
36 | ** Initialise symbol table with internal functions | 36 | ** Internal functions |
37 | */ | 37 | */ |
38 | static struct { | 38 | static struct { |
39 | char *name; | 39 | char *name; |
@@ -56,6 +56,7 @@ static struct { | |||
56 | 56 | ||
57 | #define INTFUNCSIZE (sizeof(int_funcs)/sizeof(int_funcs[0])) | 57 | #define INTFUNCSIZE (sizeof(int_funcs)/sizeof(int_funcs[0])) |
58 | 58 | ||
59 | |||
59 | void luaI_initsymbol (void) | 60 | void luaI_initsymbol (void) |
60 | { | 61 | { |
61 | int i; | 62 | int i; |
@@ -74,8 +75,12 @@ void luaI_initsymbol (void) | |||
74 | */ | 75 | */ |
75 | void luaI_initconstant (void) | 76 | void luaI_initconstant (void) |
76 | { | 77 | { |
78 | int i; | ||
77 | lua_maxconstant = BUFFER_BLOCK; | 79 | lua_maxconstant = BUFFER_BLOCK; |
78 | lua_constant = newvector(lua_maxconstant, TaggedString *); | 80 | lua_constant = newvector(lua_maxconstant, TaggedString *); |
81 | /* pre-register mem error messages, to avoid loop when error arises */ | ||
82 | for (i=0; i<NUMERRMSG; i++) | ||
83 | luaI_findconstantbyname(luaI_memerrormsg[i]); | ||
79 | } | 84 | } |
80 | 85 | ||
81 | 86 | ||
@@ -88,14 +93,8 @@ Word luaI_findsymbol (TaggedString *t) | |||
88 | if (t->varindex == NOT_USED) | 93 | if (t->varindex == NOT_USED) |
89 | { | 94 | { |
90 | if (lua_ntable == lua_maxsymbol) | 95 | if (lua_ntable == lua_maxsymbol) |
91 | { | 96 | lua_maxsymbol = growvector(&lua_table, lua_maxsymbol, Symbol, |
92 | if (lua_maxsymbol >= MAX_WORD) | 97 | symbolEM, MAX_WORD); |
93 | lua_error("symbol table overflow"); | ||
94 | lua_maxsymbol *= 2; | ||
95 | if (lua_maxsymbol >= MAX_WORD) | ||
96 | lua_maxsymbol = MAX_WORD; | ||
97 | lua_table = growvector(lua_table, lua_maxsymbol, Symbol); | ||
98 | } | ||
99 | t->varindex = lua_ntable; | 98 | t->varindex = lua_ntable; |
100 | lua_table[lua_ntable].varname = t; | 99 | lua_table[lua_ntable].varname = t; |
101 | s_tag(lua_ntable) = LUA_T_NIL; | 100 | s_tag(lua_ntable) = LUA_T_NIL; |
@@ -120,14 +119,8 @@ Word luaI_findconstant (TaggedString *t) | |||
120 | if (t->constindex == NOT_USED) | 119 | if (t->constindex == NOT_USED) |
121 | { | 120 | { |
122 | if (lua_nconstant == lua_maxconstant) | 121 | if (lua_nconstant == lua_maxconstant) |
123 | { | 122 | lua_maxconstant = growvector(&lua_constant, lua_maxconstant, TaggedString *, |
124 | if (lua_maxconstant >= MAX_WORD) | 123 | constantEM, MAX_WORD); |
125 | lua_error("constant table overflow"); | ||
126 | lua_maxconstant *= 2; | ||
127 | if (lua_maxconstant >= MAX_WORD) | ||
128 | lua_maxconstant = MAX_WORD; | ||
129 | lua_constant = growvector(lua_constant, lua_maxconstant, TaggedString *); | ||
130 | } | ||
131 | t->constindex = lua_nconstant; | 124 | t->constindex = lua_nconstant; |
132 | lua_constant[lua_nconstant] = t; | 125 | lua_constant[lua_nconstant] = t; |
133 | lua_nconstant++; | 126 | lua_nconstant++; |