lua

A copy of the Lua development repository
Log | Files | Refs | README

commit b17c76817d008de0e0de460c5d0fac4741d0fe02
parent b074306267b70015d770cb33c78dcf6cfe53fb45
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri, 13 Oct 1995 12:16:06 -0300

new function "luaI_findconstantbyname".

Diffstat:
Mlex.c | 6+++---
Mopcode.c | 4++--
Mtable.c | 13+++++++++----
Mtable.h | 3++-
4 files changed, 16 insertions(+), 10 deletions(-)

diff --git 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 <ctype.h> @@ -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 @@ -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 <setjmp.h> #include <stdlib.h> @@ -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 @@ -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 <string.h> @@ -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 @@ -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);