diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-26 18:00:27 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-26 18:00:27 -0300 |
commit | d6e4c29733b43130c5222c49b3c4b9dfcd8bb893 (patch) | |
tree | 379cb091e690a3680bf1f26f23658d5d9af4789c | |
parent | 3e429699792218af45a0f399542e14563c1a173b (diff) | |
download | lua-d6e4c29733b43130c5222c49b3c4b9dfcd8bb893.tar.gz lua-d6e4c29733b43130c5222c49b3c4b9dfcd8bb893.tar.bz2 lua-d6e4c29733b43130c5222c49b3c4b9dfcd8bb893.zip |
fixed strings (not collectable) don't need to be inserted in the constant table.
-rw-r--r-- | inout.c | 6 | ||||
-rw-r--r-- | lua.stx | 4 | ||||
-rw-r--r-- | table.c | 36 | ||||
-rw-r--r-- | table.h | 4 |
4 files changed, 24 insertions, 26 deletions
@@ -5,7 +5,7 @@ | |||
5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | char *rcs_inout="$Id: inout.c,v 2.31 1996/02/13 17:30:39 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.32 1996/02/14 18:25:04 roberto Exp roberto $"; |
9 | 9 | ||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
@@ -66,7 +66,7 @@ int lua_openfile (char *fn) | |||
66 | if (fp == NULL) | 66 | if (fp == NULL) |
67 | return 1; | 67 | return 1; |
68 | lua_linenumber = 1; | 68 | lua_linenumber = 1; |
69 | lua_parsedfile = lua_constcreate(fn)->str; | 69 | lua_parsedfile = luaI_createfixedstring(fn)->str; |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
@@ -90,7 +90,7 @@ void lua_openstring (char *s) | |||
90 | lua_setinput (stringinput); | 90 | lua_setinput (stringinput); |
91 | st = s; | 91 | st = s; |
92 | lua_linenumber = 1; | 92 | lua_linenumber = 1; |
93 | lua_parsedfile = lua_constcreate("(string)")->str; | 93 | lua_parsedfile = luaI_createfixedstring("(string)")->str; |
94 | } | 94 | } |
95 | 95 | ||
96 | /* | 96 | /* |
@@ -1,6 +1,6 @@ | |||
1 | %{ | 1 | %{ |
2 | 2 | ||
3 | char *rcs_luastx = "$Id: lua.stx,v 3.32 1996/02/14 18:25:04 roberto Exp roberto $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.33 1996/02/26 17:07:20 roberto Exp roberto $"; |
4 | 4 | ||
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
@@ -487,7 +487,7 @@ funcname : var { $$ =$1; init_func(); } | |||
487 | code_word(luaI_findconstant($3)); | 487 | code_word(luaI_findconstant($3)); |
488 | $$ = 0; /* indexed variable */ | 488 | $$ = 0; /* indexed variable */ |
489 | init_func(); | 489 | init_func(); |
490 | add_localvar(lua_constcreate("self")); | 490 | add_localvar(luaI_createfixedstring("self")); |
491 | } | 491 | } |
492 | ; | 492 | ; |
493 | 493 | ||
@@ -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.46 1996/02/14 13:35:51 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.47 1996/02/14 18:25:04 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include "mem.h" | 8 | #include "mem.h" |
9 | #include "opcode.h" | 9 | #include "opcode.h" |
@@ -39,19 +39,19 @@ static struct { | |||
39 | char *name; | 39 | char *name; |
40 | lua_CFunction func; | 40 | lua_CFunction func; |
41 | } int_funcs[] = { | 41 | } int_funcs[] = { |
42 | {"nextvar", lua_nextvar}, | 42 | {"assert", luaI_assert}, |
43 | {"dofile", lua_internaldofile}, | ||
44 | {"dostring", lua_internaldostring}, | ||
43 | {"error", luaI_error}, | 45 | {"error", luaI_error}, |
44 | {"tonumber", lua_obj2number}, | 46 | {"getglobal", luaI_getglobal}, |
45 | {"setfallback", luaI_setfallback}, | ||
46 | {"next", lua_next}, | 47 | {"next", lua_next}, |
47 | {"dofile", lua_internaldofile}, | 48 | {"nextvar", lua_nextvar}, |
49 | {"print", luaI_print}, | ||
50 | {"setfallback", luaI_setfallback}, | ||
48 | {"setglobal", luaI_setglobal}, | 51 | {"setglobal", luaI_setglobal}, |
49 | {"getglobal", luaI_getglobal}, | 52 | {"tonumber", lua_obj2number}, |
50 | {"type", luaI_type}, | ||
51 | {"tostring", luaI_tostring}, | 53 | {"tostring", luaI_tostring}, |
52 | {"print", luaI_print}, | 54 | {"type", luaI_type} |
53 | {"dostring", lua_internaldostring}, | ||
54 | {"assert", luaI_assert} | ||
55 | }; | 55 | }; |
56 | 56 | ||
57 | #define INTFUNCSIZE (sizeof(int_funcs)/sizeof(int_funcs[0])) | 57 | #define INTFUNCSIZE (sizeof(int_funcs)/sizeof(int_funcs[0])) |
@@ -100,8 +100,6 @@ Word luaI_findsymbol (TaggedString *t) | |||
100 | lua_table[lua_ntable].varname = t; | 100 | lua_table[lua_ntable].varname = t; |
101 | s_tag(lua_ntable) = LUA_T_NIL; | 101 | s_tag(lua_ntable) = LUA_T_NIL; |
102 | lua_ntable++; | 102 | lua_ntable++; |
103 | if (!t->marked) | ||
104 | t->marked = 2; /* avoid GC */ | ||
105 | } | 103 | } |
106 | return t->varindex; | 104 | return t->varindex; |
107 | } | 105 | } |
@@ -109,7 +107,7 @@ Word luaI_findsymbol (TaggedString *t) | |||
109 | 107 | ||
110 | Word luaI_findsymbolbyname (char *name) | 108 | Word luaI_findsymbolbyname (char *name) |
111 | { | 109 | { |
112 | return luaI_findsymbol(lua_createstring(name)); | 110 | return luaI_findsymbol(luaI_createfixedstring(name)); |
113 | } | 111 | } |
114 | 112 | ||
115 | 113 | ||
@@ -133,8 +131,6 @@ Word luaI_findconstant (TaggedString *t) | |||
133 | t->constindex = lua_nconstant; | 131 | t->constindex = lua_nconstant; |
134 | lua_constant[lua_nconstant] = t; | 132 | lua_constant[lua_nconstant] = t; |
135 | lua_nconstant++; | 133 | lua_nconstant++; |
136 | if (!t->marked) | ||
137 | t->marked = 2; /* avoid GC */ | ||
138 | } | 134 | } |
139 | return t->constindex; | 135 | return t->constindex; |
140 | } | 136 | } |
@@ -142,13 +138,15 @@ Word luaI_findconstant (TaggedString *t) | |||
142 | 138 | ||
143 | Word luaI_findconstantbyname (char *name) | 139 | Word luaI_findconstantbyname (char *name) |
144 | { | 140 | { |
145 | return luaI_findconstant(lua_createstring(name)); | 141 | return luaI_findconstant(luaI_createfixedstring(name)); |
146 | } | 142 | } |
147 | 143 | ||
148 | TaggedString *lua_constcreate(char *name) | 144 | TaggedString *luaI_createfixedstring (char *name) |
149 | { | 145 | { |
150 | int i = luaI_findconstantbyname(name); | 146 | TaggedString *ts = lua_createstring(name); |
151 | return lua_constant[i]; | 147 | if (!ts->marked) |
148 | ts->marked = 2; /* avoid GC */ | ||
149 | return ts; | ||
152 | } | 150 | } |
153 | 151 | ||
154 | 152 | ||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | ** Module to control static tables | 2 | ** Module to control static tables |
3 | ** TeCGraf - PUC-Rio | 3 | ** TeCGraf - PUC-Rio |
4 | ** $Id: table.h,v 2.17 1996/02/12 18:32:40 roberto Exp roberto $ | 4 | ** $Id: table.h,v 2.18 1996/02/14 13:35:51 roberto Exp roberto $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef table_h | 7 | #ifndef table_h |
@@ -26,7 +26,7 @@ Word luaI_findsymbolbyname (char *name); | |||
26 | Word luaI_findsymbol (TaggedString *t); | 26 | Word luaI_findsymbol (TaggedString *t); |
27 | Word luaI_findconstant (TaggedString *t); | 27 | Word luaI_findconstant (TaggedString *t); |
28 | Word luaI_findconstantbyname (char *name); | 28 | Word luaI_findconstantbyname (char *name); |
29 | TaggedString *lua_constcreate (char *str); | 29 | TaggedString *luaI_createfixedstring (char *str); |
30 | int lua_markobject (Object *o); | 30 | int lua_markobject (Object *o); |
31 | Long luaI_collectgarbage (void); | 31 | Long luaI_collectgarbage (void); |
32 | void lua_pack (void); | 32 | void lua_pack (void); |