diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-10-13 12:16:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-10-13 12:16:25 -0300 |
commit | b17c76817d008de0e0de460c5d0fac4741d0fe02 (patch) | |
tree | 02b5b942ab01853a5be4f385dceb8ec567c13008 | |
parent | b074306267b70015d770cb33c78dcf6cfe53fb45 (diff) | |
download | lua-b17c76817d008de0e0de460c5d0fac4741d0fe02.tar.gz lua-b17c76817d008de0e0de460c5d0fac4741d0fe02.tar.bz2 lua-b17c76817d008de0e0de460c5d0fac4741d0fe02.zip |
new function "luaI_findconstantbyname".
-rw-r--r-- | lex.c | 6 | ||||
-rw-r--r-- | opcode.c | 4 | ||||
-rw-r--r-- | table.c | 13 | ||||
-rw-r--r-- | table.h | 3 |
4 files changed, 16 insertions, 10 deletions
@@ -1,4 +1,4 @@ | |||
1 | char *rcs_lex = "$Id: lex.c,v 2.17 1995/10/03 18:06:10 roberto Exp $"; | 1 | char *rcs_lex = "$Id: lex.c,v 2.18 1995/10/06 13:10:53 roberto Exp roberto $"; |
2 | 2 | ||
3 | 3 | ||
4 | #include <ctype.h> | 4 | #include <ctype.h> |
@@ -200,7 +200,7 @@ int yylex (void) | |||
200 | return WRONGTOKEN; | 200 | return WRONGTOKEN; |
201 | save_and_next(); /* pass the second ']' */ | 201 | save_and_next(); /* pass the second ']' */ |
202 | *(yytextLast-2) = 0; /* erases ']]' */ | 202 | *(yytextLast-2) = 0; /* erases ']]' */ |
203 | yylval.vWord = luaI_findconstant(lua_constcreate(yytext+2)); | 203 | yylval.vWord = luaI_findconstantbyname(yytext+2); |
204 | return STRING; | 204 | return STRING; |
205 | } | 205 | } |
206 | 206 | ||
@@ -260,7 +260,7 @@ int yylex (void) | |||
260 | } | 260 | } |
261 | next(); /* skip the delimiter */ | 261 | next(); /* skip the delimiter */ |
262 | *yytextLast = 0; | 262 | *yytextLast = 0; |
263 | yylval.vWord = luaI_findconstant(lua_constcreate(yytext)); | 263 | yylval.vWord = luaI_findconstantbyname(yytext); |
264 | return STRING; | 264 | return STRING; |
265 | } | 265 | } |
266 | 266 | ||
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.41 1995/10/09 13:10:20 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.42 1995/10/09 18:45:59 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -678,7 +678,7 @@ void lua_pushstring (char *s) | |||
678 | */ | 678 | */ |
679 | void lua_pushliteral (char *s) | 679 | void lua_pushliteral (char *s) |
680 | { | 680 | { |
681 | tsvalue(top) = lua_constant[luaI_findconstant(lua_constcreate(s))]; | 681 | tsvalue(top) = lua_constant[luaI_findconstantbyname(s)]; |
682 | tag(top) = LUA_T_STRING; | 682 | tag(top) = LUA_T_STRING; |
683 | incr_top; | 683 | incr_top; |
684 | } | 684 | } |
@@ -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.32 1995/09/15 20:47:53 roberto Exp $"; | 6 | char *rcs_table="$Id: table.c,v 2.33 1995/10/04 14:20:26 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
@@ -119,9 +119,8 @@ Word luaI_findsymbolbyname (char *name) | |||
119 | 119 | ||
120 | 120 | ||
121 | /* | 121 | /* |
122 | ** Given a name, search it at constant table and return its index. If not | 122 | ** Given a tree node, check it is has a correspondent constant index. If not, |
123 | ** found, allocate it. | 123 | ** allocate it. |
124 | ** On error, return -1. | ||
125 | */ | 124 | */ |
126 | Word luaI_findconstant (TreeNode *t) | 125 | Word luaI_findconstant (TreeNode *t) |
127 | { | 126 | { |
@@ -146,6 +145,12 @@ Word luaI_findconstant (TreeNode *t) | |||
146 | } | 145 | } |
147 | 146 | ||
148 | 147 | ||
148 | Word luaI_findconstantbyname (char *name) | ||
149 | { | ||
150 | return luaI_findconstant(lua_constcreate(name)); | ||
151 | } | ||
152 | |||
153 | |||
149 | /* | 154 | /* |
150 | ** Traverse symbol table objects | 155 | ** Traverse symbol table objects |
151 | */ | 156 | */ |
@@ -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.9 1994/11/23 14:31:11 roberto Stab roberto $ | 4 | ** $Id: table.h,v 2.10 1994/12/20 21:20:36 roberto Exp roberto $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef table_h | 7 | #ifndef table_h |
@@ -21,6 +21,7 @@ void lua_initconstant (void); | |||
21 | Word luaI_findsymbolbyname (char *name); | 21 | Word luaI_findsymbolbyname (char *name); |
22 | Word luaI_findsymbol (TreeNode *t); | 22 | Word luaI_findsymbol (TreeNode *t); |
23 | Word luaI_findconstant (TreeNode *t); | 23 | Word luaI_findconstant (TreeNode *t); |
24 | Word luaI_findconstantbyname (char *name); | ||
24 | void lua_travsymbol (void (*fn)(Object *)); | 25 | void lua_travsymbol (void (*fn)(Object *)); |
25 | void lua_markobject (Object *o); | 26 | void lua_markobject (Object *o); |
26 | void lua_pack (void); | 27 | void lua_pack (void); |