aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-13 12:16:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-13 12:16:25 -0300
commitb17c76817d008de0e0de460c5d0fac4741d0fe02 (patch)
tree02b5b942ab01853a5be4f385dceb8ec567c13008
parentb074306267b70015d770cb33c78dcf6cfe53fb45 (diff)
downloadlua-b17c76817d008de0e0de460c5d0fac4741d0fe02.tar.gz
lua-b17c76817d008de0e0de460c5d0fac4741d0fe02.tar.bz2
lua-b17c76817d008de0e0de460c5d0fac4741d0fe02.zip
new function "luaI_findconstantbyname".
-rw-r--r--lex.c6
-rw-r--r--opcode.c4
-rw-r--r--table.c13
-rw-r--r--table.h3
4 files changed, 16 insertions, 10 deletions
diff --git a/lex.c b/lex.c
index 221a4b4b..3b24857d 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
1char *rcs_lex = "$Id: lex.c,v 2.17 1995/10/03 18:06:10 roberto Exp $"; 1char *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
diff --git a/opcode.c b/opcode.c
index edf8d4c4..97eb3ea5 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.41 1995/10/09 13:10:20 roberto Exp roberto $"; 6char *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*/
679void lua_pushliteral (char *s) 679void 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}
diff --git a/table.c b/table.c
index 05f92c15..fc3d753c 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.32 1995/09/15 20:47:53 roberto Exp $"; 6char *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*/
126Word luaI_findconstant (TreeNode *t) 125Word luaI_findconstant (TreeNode *t)
127{ 126{
@@ -146,6 +145,12 @@ Word luaI_findconstant (TreeNode *t)
146} 145}
147 146
148 147
148Word 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*/
diff --git a/table.h b/table.h
index f80f981e..3cab37ed 100644
--- a/table.h
+++ b/table.h
@@ -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);
21Word luaI_findsymbolbyname (char *name); 21Word luaI_findsymbolbyname (char *name);
22Word luaI_findsymbol (TreeNode *t); 22Word luaI_findsymbol (TreeNode *t);
23Word luaI_findconstant (TreeNode *t); 23Word luaI_findconstant (TreeNode *t);
24Word luaI_findconstantbyname (char *name);
24void lua_travsymbol (void (*fn)(Object *)); 25void lua_travsymbol (void (*fn)(Object *));
25void lua_markobject (Object *o); 26void lua_markobject (Object *o);
26void lua_pack (void); 27void lua_pack (void);