From b17c76817d008de0e0de460c5d0fac4741d0fe02 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 13 Oct 1995 12:16:25 -0300 Subject: [PATCH] new function "luaI_findconstantbyname". --- lex.c | 6 +++--- opcode.c | 4 ++-- table.c | 13 +++++++++---- table.h | 3 ++- 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 @@ -char *rcs_lex = "$Id: lex.c,v 2.17 1995/10/03 18:06:10 roberto Exp $"; +char *rcs_lex = "$Id: lex.c,v 2.18 1995/10/06 13:10:53 roberto Exp roberto $"; #include @@ -200,7 +200,7 @@ int yylex (void) return WRONGTOKEN; save_and_next(); /* pass the second ']' */ *(yytextLast-2) = 0; /* erases ']]' */ - yylval.vWord = luaI_findconstant(lua_constcreate(yytext+2)); + yylval.vWord = luaI_findconstantbyname(yytext+2); return STRING; } @@ -260,7 +260,7 @@ int yylex (void) } next(); /* skip the delimiter */ *yytextLast = 0; - yylval.vWord = luaI_findconstant(lua_constcreate(yytext)); + yylval.vWord = luaI_findconstantbyname(yytext); return STRING; } diff --git a/opcode.c b/opcode.c index edf8d4c4..97eb3ea5 100644 --- a/opcode.c +++ b/opcode.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_opcode="$Id: opcode.c,v 3.41 1995/10/09 13:10:20 roberto Exp roberto $"; +char *rcs_opcode="$Id: opcode.c,v 3.42 1995/10/09 18:45:59 roberto Exp roberto $"; #include #include @@ -678,7 +678,7 @@ void lua_pushstring (char *s) */ void lua_pushliteral (char *s) { - tsvalue(top) = lua_constant[luaI_findconstant(lua_constcreate(s))]; + tsvalue(top) = lua_constant[luaI_findconstantbyname(s)]; tag(top) = LUA_T_STRING; incr_top; } diff --git a/table.c b/table.c index 05f92c15..fc3d753c 100644 --- a/table.c +++ b/table.c @@ -3,7 +3,7 @@ ** Module to control static tables */ -char *rcs_table="$Id: table.c,v 2.32 1995/09/15 20:47:53 roberto Exp $"; +char *rcs_table="$Id: table.c,v 2.33 1995/10/04 14:20:26 roberto Exp roberto $"; #include @@ -119,9 +119,8 @@ Word luaI_findsymbolbyname (char *name) /* -** Given a name, search it at constant table and return its index. If not -** found, allocate it. -** On error, return -1. +** Given a tree node, check it is has a correspondent constant index. If not, +** allocate it. */ Word luaI_findconstant (TreeNode *t) { @@ -146,6 +145,12 @@ Word luaI_findconstant (TreeNode *t) } +Word luaI_findconstantbyname (char *name) +{ + return luaI_findconstant(lua_constcreate(name)); +} + + /* ** Traverse symbol table objects */ diff --git a/table.h b/table.h index f80f981e..3cab37ed 100644 --- a/table.h +++ b/table.h @@ -1,7 +1,7 @@ /* ** Module to control static tables ** TeCGraf - PUC-Rio -** $Id: table.h,v 2.9 1994/11/23 14:31:11 roberto Stab roberto $ +** $Id: table.h,v 2.10 1994/12/20 21:20:36 roberto Exp roberto $ */ #ifndef table_h @@ -21,6 +21,7 @@ void lua_initconstant (void); Word luaI_findsymbolbyname (char *name); Word luaI_findsymbol (TreeNode *t); Word luaI_findconstant (TreeNode *t); +Word luaI_findconstantbyname (char *name); void lua_travsymbol (void (*fn)(Object *)); void lua_markobject (Object *o); void lua_pack (void);