Browse Source

fixed strings (not collectable) don't need to be inserted in the constant table.

Roberto Ierusalimschy 29 years ago
parent
commit
d6e4c29733
4 changed files with 24 additions and 26 deletions
  1. 3 3
      inout.c
  2. 2 2
      lua.stx
  3. 17 19
      table.c
  4. 2 2
      table.h

+ 3 - 3
inout.c

@@ -5,7 +5,7 @@
 ** Also provides some predefined lua functions.
 */
 
-char *rcs_inout="$Id: inout.c,v 2.31 1996/02/13 17:30:39 roberto Exp roberto $";
+char *rcs_inout="$Id: inout.c,v 2.32 1996/02/14 18:25:04 roberto Exp roberto $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -66,7 +66,7 @@ int lua_openfile (char *fn)
  if (fp == NULL)
    return 1;
  lua_linenumber = 1;
- lua_parsedfile = lua_constcreate(fn)->str;
+ lua_parsedfile = luaI_createfixedstring(fn)->str;
  return 0;
 }
 
@@ -90,7 +90,7 @@ void lua_openstring (char *s)
  lua_setinput (stringinput);
  st = s;
  lua_linenumber = 1;
- lua_parsedfile = lua_constcreate("(string)")->str;
+ lua_parsedfile = luaI_createfixedstring("(string)")->str;
 }
 
 /*

+ 2 - 2
lua.stx

@@ -1,6 +1,6 @@
 %{
 
-char *rcs_luastx = "$Id: lua.stx,v 3.32 1996/02/14 18:25:04 roberto Exp roberto $";
+char *rcs_luastx = "$Id: lua.stx,v 3.33 1996/02/26 17:07:20 roberto Exp roberto $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -487,7 +487,7 @@ funcname	: var { $$ =$1; init_func(); }
 	  code_word(luaI_findconstant($3));
 	  $$ = 0;  /* indexed variable */
 	  init_func();
-	  add_localvar(lua_constcreate("self"));
+	  add_localvar(luaI_createfixedstring("self"));
 	}
 		;
 

+ 17 - 19
table.c

@@ -3,7 +3,7 @@
 ** Module to control static tables
 */
 
-char *rcs_table="$Id: table.c,v 2.46 1996/02/14 13:35:51 roberto Exp roberto $";
+char *rcs_table="$Id: table.c,v 2.47 1996/02/14 18:25:04 roberto Exp roberto $";
 
 #include "mem.h"
 #include "opcode.h"
@@ -39,19 +39,19 @@ static struct {
   char *name;
   lua_CFunction func;
 } int_funcs[] = {
-  {"nextvar", lua_nextvar},
+  {"assert", luaI_assert},
+  {"dofile", lua_internaldofile},
+  {"dostring", lua_internaldostring},
   {"error", luaI_error},
-  {"tonumber", lua_obj2number},
-  {"setfallback", luaI_setfallback},
+  {"getglobal", luaI_getglobal},
   {"next", lua_next},
-  {"dofile", lua_internaldofile},
+  {"nextvar", lua_nextvar},
+  {"print", luaI_print},
+  {"setfallback", luaI_setfallback},
   {"setglobal", luaI_setglobal},
-  {"getglobal", luaI_getglobal},
-  {"type", luaI_type},
+  {"tonumber", lua_obj2number},
   {"tostring", luaI_tostring},
-  {"print", luaI_print},
-  {"dostring", lua_internaldostring},
-  {"assert", luaI_assert}
+  {"type", luaI_type}
 };
 
 #define INTFUNCSIZE (sizeof(int_funcs)/sizeof(int_funcs[0]))
@@ -100,8 +100,6 @@ Word luaI_findsymbol (TaggedString *t)
   lua_table[lua_ntable].varname = t;
   s_tag(lua_ntable) = LUA_T_NIL;
   lua_ntable++;
-  if (!t->marked)
-    t->marked = 2;  /* avoid GC */
  }
  return t->varindex;
 }
@@ -109,7 +107,7 @@ Word luaI_findsymbol (TaggedString *t)
 
 Word luaI_findsymbolbyname (char *name)
 {
-  return luaI_findsymbol(lua_createstring(name));
+  return luaI_findsymbol(luaI_createfixedstring(name));
 }
 
 
@@ -133,8 +131,6 @@ Word luaI_findconstant (TaggedString *t)
   t->constindex = lua_nconstant;
   lua_constant[lua_nconstant] = t;
   lua_nconstant++;
-  if (!t->marked)
-    t->marked = 2;  /* avoid GC */
  }
  return t->constindex;
 }
@@ -142,13 +138,15 @@ Word luaI_findconstant (TaggedString *t)
 
 Word  luaI_findconstantbyname (char *name)
 {
-  return luaI_findconstant(lua_createstring(name));
+  return luaI_findconstant(luaI_createfixedstring(name));
 }
 
-TaggedString *lua_constcreate(char *name)
+TaggedString *luaI_createfixedstring (char *name)
 {
-  int i = luaI_findconstantbyname(name);
-  return lua_constant[i];
+  TaggedString *ts = lua_createstring(name);
+  if (!ts->marked)
+    ts->marked = 2;  /* avoid GC */
+  return ts;
 }
 
 

+ 2 - 2
table.h

@@ -1,7 +1,7 @@
 /*
 ** Module to control static tables
 ** TeCGraf - PUC-Rio
-** $Id: table.h,v 2.17 1996/02/12 18:32:40 roberto Exp roberto $
+** $Id: table.h,v 2.18 1996/02/14 13:35:51 roberto Exp roberto $
 */
 
 #ifndef table_h
@@ -26,7 +26,7 @@ Word  luaI_findsymbolbyname (char *name);
 Word  luaI_findsymbol      (TaggedString *t);
 Word  luaI_findconstant    (TaggedString *t);
 Word  luaI_findconstantbyname (char *name);
-TaggedString *lua_constcreate  (char *str);
+TaggedString *luaI_createfixedstring  (char *str);
 int   lua_markobject      (Object *o);
 Long luaI_collectgarbage (void);
 void  lua_pack            (void);