فهرست منبع

Acrescentar o gerenciador de memoria "mm", corrigir bug reservando
o byte para a coleta de lixo nas constantes pre-definidas e
colocar um teste em tempo de execucao para evitar duplicidade de
valores na tabela de strings (teste ainda linear).

Waldemar Celes 31 سال پیش
والد
کامیت
540dc65bcd
1فایلهای تغییر یافته به همراه14 افزوده شده و 5 حذف شده
  1. 14 5
      table.c

+ 14 - 5
table.c

@@ -3,11 +3,13 @@
 ** Module to control static tables
 */
 
-char *rcs_table="$Id: table.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $";
+char *rcs_table="$Id: table.c,v 1.2 1993/12/22 21:15:16 roberto Exp celes $";
 
 #include <stdlib.h>
 #include <string.h>
 
+#include "mm.h"
+
 #include "opcode.h"
 #include "hash.h"
 #include "inout.h"
@@ -49,12 +51,14 @@ static struct List *searchlist=&o0;
 #ifndef MAXCONSTANT
 #define MAXCONSTANT	256
 #endif
-static char  	       *constantbuffer[MAXCONSTANT] = {"mark","nil","number",
-                                                       "string","table",
-                                                       "function","cfunction"
+/* pre-defined constants need garbage collection extra byte */ 
+static char  	       *constantbuffer[MAXCONSTANT] = {" mark"+1," nil"+1,
+						       " number"+1, " string"+1,
+						       " table"+1, " function"+1,
+						       " cfunction"+1, " userdata"+1
                                                       };
 char  	      	      **lua_constant = constantbuffer;
-Word    		lua_nconstant=T_CFUNCTION+1;
+Word    		lua_nconstant=T_USERDATA+1;
 
 #ifndef MAXSTRING
 #define MAXSTRING	512
@@ -215,8 +219,13 @@ static void lua_pack (void)
 */
 char *lua_createstring (char *s)
 {
+ int i;
  if (s == NULL) return NULL;
  
+ for (i=0; i<lua_nstring; i++)
+  if (streq(s,lua_string[i]))
+   return s;
+
  if (lua_nstring >= MAXSTRING-1)
  {
   lua_pack ();