guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core NEWS ice-9/ChangeLog ice-9/ses...


From: Dirk Herrmann
Subject: guile/guile-core NEWS ice-9/ChangeLog ice-9/ses...
Date: Tue, 12 Dec 2000 10:36:36 -0800

CVSROOT:        /cvs
Module name:    guile
Changes by:     Dirk Herrmann <address@hidden>  00/12/12 10:36:35

Modified files:
        guile-core     : NEWS 
        guile-core/ice-9: ChangeLog session.scm 
        guile-core/libguile: ChangeLog gc.c root.h stacks.c symbols.c 
                             symbols.h 

Log message:
        * The creation of symbols and bindings are two separate issues now.

CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/NEWS.diff?r1=1.227&r2=1.228
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/ice-9/ChangeLog.diff?r1=1.361&r2=1.362
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/ice-9/session.scm.diff?r1=1.21&r2=1.22
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ChangeLog.diff?r1=1.1205&r2=1.1206
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/gc.c.diff?r1=1.171&r2=1.172
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/root.h.diff?r1=1.30&r2=1.31
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/stacks.c.diff?r1=1.52&r2=1.53
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/symbols.c.diff?r1=1.72&r2=1.73
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/symbols.h.diff?r1=1.48&r2=1.49

Patches:
Index: guile/guile-core/NEWS
diff -u guile/guile-core/NEWS:1.227 guile/guile-core/NEWS:1.228
--- guile/guile-core/NEWS:1.227 Fri Dec  8 10:10:57 2000
+++ guile/guile-core/NEWS       Tue Dec 12 10:36:35 2000
@@ -207,6 +207,10 @@
 the child process from the current Scheme ports, instead of using the
 current values of file descriptors 0, 1, and 2 in the parent process.
 
+** Removed function:  builtin-weak-bindings
+
+There is no such concept as a weak binding any more.
+
 * Changes to the gh_ interface
 
 * Changes to the scm_ interface
Index: guile/guile-core/ice-9/ChangeLog
diff -u guile/guile-core/ice-9/ChangeLog:1.361 
guile/guile-core/ice-9/ChangeLog:1.362
--- guile/guile-core/ice-9/ChangeLog:1.361      Tue Dec 12 10:10:56 2000
+++ guile/guile-core/ice-9/ChangeLog    Tue Dec 12 10:36:35 2000
@@ -1,5 +1,10 @@
 2000-12-12  Dirk Herrmann  <address@hidden>
 
+       * session.scm (apropos, apropos-fold):  There are no weak bindings
+       any more.
+
+2000-12-12  Dirk Herrmann  <address@hidden>
+
        * boot-9.scm (top-repl):  Lookup 'use-emacs-interface in
        the-root-module.
 
Index: guile/guile-core/ice-9/session.scm
diff -u guile/guile-core/ice-9/session.scm:1.21 
guile/guile-core/ice-9/session.scm:1.22
--- guile/guile-core/ice-9/session.scm:1.21     Tue Oct 10 00:32:45 2000
+++ guile/guile-core/ice-9/session.scm  Tue Dec 12 10:36:35 2000
@@ -199,8 +199,7 @@
                               (eq? module the-root-module)))
                  (name (module-name module))
                  (obarrays (if builtin
-                               (list (builtin-weak-bindings)
-                                     (builtin-bindings))
+                               (list (builtin-bindings))
                                (list (module-obarray module))))
                  (get-refs (if builtin
                                (list id id)
@@ -278,10 +277,8 @@
               (cond ((or (eq? module the-scm-module)
                          (eq? module the-root-module))
                      (hash-fold obarray-filter
-                                (hash-fold obarray-filter
-                                           data
-                                           (builtin-bindings))
-                                (builtin-weak-bindings)))
+                                data
+                                (builtin-bindings)))
                     (module (hash-fold module-filter
                                        data
                                        (module-obarray module)))
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1205 
guile/guile-core/libguile/ChangeLog:1.1206
--- guile/guile-core/libguile/ChangeLog:1.1205  Tue Dec 12 06:07:06 2000
+++ guile/guile-core/libguile/ChangeLog Tue Dec 12 10:36:35 2000
@@ -1,5 +1,40 @@
 2000-12-12  Dirk Herrmann  <address@hidden>
 
+       * gc.c (scm_init_storage), root.h (scm_weak_symhash, scm_symbols):
+       Removed the former scm_weak_symhash hash table.  Added scm_symbols
+       hash table.
+
+       * stacks.c (get_applybody):  scm_sym2vcell may return #f.
+
+       * symbols.c (scm_mem2symbol):  This function is now responsible
+       for creating symbol objects and storing them in the global
+       scm_symbols hash table.
+
+       (scm_str2symbol):  Rewritten in terms of scm_mem2symbol.
+
+       (scm_sym2vcell):  For system bindings, there is now only one
+       obarray - scm_symhash.  If scm_sym2vcell is called to look up a
+       symbol that can't be found and shall not be created, #f is
+       returned.  Most callers of scm_sym2vcell have expected this
+       behaviour anyway.
+
+       (scm_intern_obarray_soft):  Removed reference to scm_weak_symhash
+       from comment.
+
+       (scm_intern_obarray_soft, scm_sysintern0_no_module_lookup):  These
+       functions are not responsible for symbol creation any more, only
+       for creation of bindings.
+
+       (scm_symbol_value0):  Don't use scm_intern_obarray_soft to create
+       a symbol object.
+
+       (scm_symbol_interned_p):  scm_weak_symhash is removed.
+
+       * symbols.[ch] (scm_builtin_weak_bindings):  Removed.  There are
+       no weak bindings any more.
+
+2000-12-12  Dirk Herrmann  <address@hidden>
+
        * hooks.c (scm_create_hook), script.c
        (scm_compile_shell_switches), snarf.h (SCM_VCELL,
        SCM_GLOBAL_VCELL, SCM_VCELL_INIT, SCM_GLOBAL_VCELL_INIT):  Create
Index: guile/guile-core/libguile/gc.c
diff -u guile/guile-core/libguile/gc.c:1.171 
guile/guile-core/libguile/gc.c:1.172
--- guile/guile-core/libguile/gc.c:1.171        Mon Dec 11 06:48:23 2000
+++ guile/guile-core/libguile/gc.c      Tue Dec 12 10:36:35 2000
@@ -2521,7 +2521,7 @@
 
 #define DEFAULT_SYMHASH_SIZE 277
   scm_symhash = scm_make_vector (SCM_MAKINUM (DEFAULT_SYMHASH_SIZE), SCM_EOL);
-  scm_weak_symhash = scm_make_weak_key_hash_table (SCM_MAKINUM 
(DEFAULT_SYMHASH_SIZE));
+  scm_symbols = scm_make_weak_key_hash_table (SCM_MAKINUM 
(DEFAULT_SYMHASH_SIZE));
   scm_symhash_vars = scm_make_vector (SCM_MAKINUM (DEFAULT_SYMHASH_SIZE), 
SCM_EOL);
 
   scm_stand_in_procs = SCM_EOL;
Index: guile/guile-core/libguile/root.h
diff -u guile/guile-core/libguile/root.h:1.30 
guile/guile-core/libguile/root.h:1.31
--- guile/guile-core/libguile/root.h:1.30       Fri Dec  8 09:32:56 2000
+++ guile/guile-core/libguile/root.h    Tue Dec 12 10:36:35 2000
@@ -61,8 +61,8 @@
 #define scm_undefineds scm_sys_protects[2]
 #define scm_nullvect scm_sys_protects[3]
 #define scm_nullstr scm_sys_protects[4]
-#define scm_symhash scm_sys_protects[5]
-#define scm_weak_symhash scm_sys_protects[6]
+#define scm_symbols scm_sys_protects[5]
+#define scm_symhash scm_sys_protects[6]
 #define scm_symhash_vars scm_sys_protects[7]
 #define scm_keyword_obarray scm_sys_protects[8]
 #define scm_stand_in_procs scm_sys_protects[9]
Index: guile/guile-core/libguile/stacks.c
diff -u guile/guile-core/libguile/stacks.c:1.52 
guile/guile-core/libguile/stacks.c:1.53
--- guile/guile-core/libguile/stacks.c:1.52     Fri Dec  8 09:08:34 2000
+++ guile/guile-core/libguile/stacks.c  Tue Dec 12 10:36:35 2000
@@ -222,9 +222,9 @@
 static SCM
 get_applybody ()
 {
-  SCM proc = SCM_CDR (scm_sym2vcell (scm_sym_apply, SCM_BOOL_F, SCM_BOOL_F));
-  if (SCM_CLOSUREP (proc))
-    return SCM_CADR (SCM_CODE (proc));
+  SCM cell = scm_sym2vcell (scm_sym_apply, SCM_BOOL_F, SCM_BOOL_F);
+  if (SCM_CONSP (cell) && SCM_CLOSUREP (SCM_CDR (cell)))
+    return SCM_CADR (SCM_CODE (SCM_CDR (cell)));
   else
     return SCM_UNDEFINED;
 }
Index: guile/guile-core/libguile/symbols.c
diff -u guile/guile-core/libguile/symbols.c:1.72 
guile/guile-core/libguile/symbols.c:1.73
--- guile/guile-core/libguile/symbols.c:1.72    Tue Dec 12 05:57:26 2000
+++ guile/guile-core/libguile/symbols.c Tue Dec 12 10:36:35 2000
@@ -82,6 +82,67 @@
  */
 
 
+SCM
+scm_mem2symbol (const char *name, scm_sizet len)
+{
+  scm_sizet raw_hash = scm_string_hash ((const unsigned char *) name, len);
+  scm_sizet hash = raw_hash % SCM_VECTOR_LENGTH (scm_symbols);
+
+  {
+    /* Try to find the symbol in the scm_symbols table */
+
+    SCM l;
+
+    for (l = SCM_VELTS (scm_symbols) [hash]; !SCM_NULLP (l); l = SCM_CDR (l))
+      {
+       SCM sym = SCM_CAAR (l);
+       if (SCM_SYMBOL_HASH (sym) == raw_hash && SCM_SYMBOL_LENGTH (sym) == len)
+         {
+           char *chrs = SCM_SYMBOL_CHARS (sym);
+           scm_sizet i = len;
+
+           while (i != 0)
+             {
+               --i;
+               if (name[i] != chrs[i])
+                 goto next_symbol;
+             }
+
+           return sym;
+         }
+      next_symbol:
+      }
+  }
+
+  {
+    /* The symbol was not found - create it. */
+
+    SCM symbol;
+    SCM cell;
+    SCM slot;
+
+    SCM_NEWCELL2 (symbol);
+    SCM_SET_SYMBOL_CHARS (symbol, duplicate_string (name, len));
+    SCM_SET_SYMBOL_HASH (symbol, raw_hash);
+    SCM_SET_PROP_SLOTS (symbol, scm_cons (SCM_BOOL_F, SCM_EOL));
+    SCM_SET_SYMBOL_LENGTH (symbol, (long) len);
+
+    cell = scm_cons (symbol, SCM_UNDEFINED);
+    slot = SCM_VELTS (scm_symbols) [hash];
+    SCM_VELTS (scm_symbols) [hash] = scm_cons (cell, slot);
+
+    return symbol;
+  }
+}
+
+
+SCM
+scm_str2symbol (const char *str)
+{
+  return scm_mem2symbol (str, strlen (str));
+}
+
+
 /* scm_sym2vcell
  * looks up the symbol in the symhash table. 
  */
@@ -109,13 +170,11 @@
   else
     {
       SCM lsym;
-      SCM * lsymp;
-      scm_sizet hash1;
-      scm_sizet hash2;
+      scm_sizet hash;
 
       SCM_DEFER_INTS;
-      hash1 = SCM_SYMBOL_HASH (sym) % SCM_VECTOR_LENGTH (scm_symhash);
-      for (lsym = SCM_VELTS (scm_symhash)[hash1]; SCM_NIMP (lsym); lsym = 
SCM_CDR (lsym))
+      hash = SCM_SYMBOL_HASH (sym) % SCM_VECTOR_LENGTH (scm_symhash);
+      for (lsym = SCM_VELTS (scm_symhash)[hash]; SCM_NIMP (lsym); lsym = 
SCM_CDR (lsym))
        {
          SCM z = SCM_CAR (lsym);
          if (SCM_EQ_P (SCM_CAR (z), sym))
@@ -125,27 +184,21 @@
            }
        }
 
-      hash2 = SCM_SYMBOL_HASH (sym) % SCM_VECTOR_LENGTH (scm_weak_symhash);
-      for (lsym = *(lsymp = &SCM_VELTS (scm_weak_symhash)[hash2]);
-          SCM_NIMP (lsym);
-          lsym = *(lsymp = SCM_CDRLOC (lsym)))
+      if (!SCM_FALSEP (definep))
        {
-         SCM z = SCM_CAR (lsym);
-         if (SCM_EQ_P (SCM_CAR (z), sym))
-           {
-             if (SCM_NFALSEP (definep))
-               {
-                 /* Move handle from scm_weak_symhash to scm_symhash. */
-                 *lsymp = SCM_CDR (lsym);
-                 SCM_SETCDR (lsym, SCM_VELTS(scm_symhash)[hash1]);
-                 SCM_VELTS(scm_symhash)[hash1] = lsym;
-               }
-             SCM_ALLOW_INTS;
-             return z;
-           }
+         SCM cell = scm_cons (sym, SCM_UNDEFINED);
+         SCM slot = SCM_VELTS (scm_symhash) [hash];
+
+         SCM_VELTS (scm_symhash) [hash] = scm_cons (cell, slot);
+
+         SCM_ALLOW_INTS;
+         return cell;
        }
-      SCM_ALLOW_INTS;
-      return scm_wta (sym, "uninterned symbol? ", "");
+      else
+       {
+         SCM_ALLOW_INTS;
+         return SCM_BOOL_F;
+       }
     }
 }
 
@@ -203,109 +256,48 @@
    in OBARRAY; instead, just return #f.
 
    If OBARRAY is SCM_BOOL_F, create a symbol listed in no obarray and
-   return (SYMBOL . SCM_UNDEFINED).
-
-   If OBARRAY is scm_symhash, and that doesn't contain the symbol,
-   check scm_weak_symhash instead.  */
+   return (SYMBOL . SCM_UNDEFINED).  */
 
 
 SCM 
 scm_intern_obarray_soft (const char *name,scm_sizet len,SCM obarray,unsigned 
int softness)
 {
-  scm_sizet raw_hash = scm_string_hash ((unsigned char *) name, len);
+  SCM symbol = scm_mem2symbol (name, len);
+  scm_sizet raw_hash = SCM_SYMBOL_HASH (symbol);
   scm_sizet hash;
   SCM lsym;
 
-  SCM_REDEFER_INTS;
-
   if (SCM_FALSEP (obarray))
     {
-      hash = raw_hash % 1019;
-      goto uninterned_symbol;
+      if (softness)
+       return SCM_BOOL_F;
+      else
+       return scm_cons (symbol, SCM_UNDEFINED);
     }
 
   hash = raw_hash % SCM_VECTOR_LENGTH (obarray);
 
- retry_new_obarray:
   for (lsym = SCM_VELTS (obarray)[hash]; SCM_NIMP (lsym); lsym = SCM_CDR 
(lsym))
     {
-      scm_sizet i;
       SCM a = SCM_CAR (lsym);
       SCM z = SCM_CAR (a);
-      char *tmp = SCM_SYMBOL_CHARS (z);
-      if (SCM_SYMBOL_HASH (z) != raw_hash)
-       goto trynext;
-      if (SCM_SYMBOL_LENGTH (z) != len)
-       goto trynext;
-      for (i = len; i--;)
-       if (name[i] != tmp[i])
-         goto trynext;
-      {
-       SCM_REALLOW_INTS;
+      if (SCM_EQ_P (z, symbol))
        return a;
-      }
-    trynext:;
     }
-
-  if (SCM_EQ_P (obarray, scm_symhash))
-    {
-      obarray = scm_weak_symhash;
-      goto retry_new_obarray;
-    }
   
- uninterned_symbol:
   if (softness)
     {
-      SCM_REALLOW_INTS;
       return SCM_BOOL_F;
     }
-
-  SCM_NEWCELL2 (lsym);
-  SCM_SET_SYMBOL_CHARS (lsym, duplicate_string (name, len));
-  SCM_SET_SYMBOL_HASH (lsym, raw_hash);
-  SCM_SET_PROP_SLOTS (lsym, scm_cons (SCM_BOOL_F, SCM_EOL));
-  SCM_SET_SYMBOL_LENGTH (lsym, (long) len);
-
-  if (SCM_FALSEP (obarray))
-    {
-      SCM answer;
-      SCM_REALLOW_INTS;
-      SCM_NEWCELL (answer);
-      SCM_DEFER_INTS;
-      SCM_SETCAR (answer, lsym);
-      SCM_SETCDR (answer, SCM_UNDEFINED);
-      SCM_REALLOW_INTS;
-      return answer;
-    }
   else
     {
-      SCM a;
-      SCM b;
+      SCM cell = scm_cons (symbol, SCM_UNDEFINED);
+      SCM slot = SCM_VELTS (obarray) [hash];
 
-      SCM_NEWCELL (a);
-      SCM_NEWCELL (b);
-      SCM_SETCAR (a, lsym);
-      SCM_SETCDR (a, SCM_UNDEFINED);
-      SCM_SETCAR (b, a);
-      SCM_SETCDR (b, SCM_VELTS(obarray)[hash]);
-      SCM_VELTS(obarray)[hash] = b;
-      SCM_REALLOW_INTS;
-      return SCM_CAR (b);
-    }
-}
+      SCM_VELTS (obarray) [hash] = scm_cons (cell, slot);
 
-
-SCM
-scm_mem2symbol (const char *mem, scm_sizet len)
-{
-  return SCM_CAR (scm_intern_obarray_soft (mem, len, scm_symhash, 0));
-}
-
-
-SCM
-scm_str2symbol (const char *str)
-{
-  return SCM_CAR (scm_intern_obarray_soft (str, strlen (str), scm_symhash, 0));
+      return cell;
+    }
 }
 
 
@@ -334,9 +326,10 @@
 SCM 
 scm_sysintern0_no_module_lookup (const char *name)
 {
+  scm_sizet len = strlen (name);
   SCM easy_answer;
   SCM_DEFER_INTS;
-  easy_answer = scm_intern_obarray_soft (name, strlen (name), scm_symhash, 1);
+  easy_answer = scm_intern_obarray_soft (name, len, scm_symhash, 1);
   if (SCM_NIMP (easy_answer))
     {
       SCM_ALLOW_INTS;
@@ -344,21 +337,15 @@
     }
   else
     {
-      SCM lsym;
-      scm_sizet len = strlen (name);
-      scm_sizet raw_hash = scm_string_hash ((unsigned char *) name, len);
+      SCM symbol = scm_mem2symbol (name, len);
+      scm_sizet raw_hash = SCM_SYMBOL_HASH (symbol);
       scm_sizet hash = raw_hash % SCM_VECTOR_LENGTH (scm_symhash);
-
-      SCM_NEWCELL2 (lsym);
-      SCM_SET_SYMBOL_CHARS (lsym, name);
-      SCM_SET_SYMBOL_HASH (lsym, raw_hash);
-      SCM_SET_PROP_SLOTS (lsym, scm_cons (SCM_BOOL_F, SCM_EOL));
-      SCM_SET_SYMBOL_LENGTH (lsym, (long) len);
+      SCM cell = scm_cons (symbol, SCM_UNDEFINED);
+      SCM slot = SCM_VELTS (scm_symhash) [hash];
 
-      lsym = scm_cons (lsym, SCM_UNDEFINED);
-      SCM_VELTS (scm_symhash)[hash] = scm_cons (lsym, SCM_VELTS 
(scm_symhash)[hash]);
+      SCM_VELTS (scm_symhash) [hash] = scm_cons (cell, slot);
       SCM_ALLOW_INTS;
-      return lsym;
+      return cell;
     }
 }
 
@@ -399,10 +386,8 @@
   /* This looks silly - we look up the symbol twice.  But it is in
      fact necessary given the current module system because the module
      lookup closures are written in scheme which needs real symbols. */
-  SCM symbol = scm_intern_obarray_soft (name, strlen (name), scm_symhash, 0);
-  SCM vcell = scm_sym2vcell (SCM_CAR (symbol),
-                            SCM_TOP_LEVEL_LOOKUP_CLOSURE,
-                            SCM_BOOL_F);
+  SCM symbol = scm_str2symbol (name);
+  SCM vcell = scm_sym2vcell (symbol, SCM_TOP_LEVEL_LOOKUP_CLOSURE, SCM_BOOL_F);
   if (SCM_FALSEP (vcell))
     return SCM_UNDEFINED;
   return SCM_CDR (vcell);
@@ -632,8 +617,6 @@
     o = scm_symhash;
   SCM_VALIDATE_VECTOR (1,o);
   vcell = scm_sym2ovcell_soft (s, o);
-  if (SCM_IMP (vcell) && SCM_EQ_P (o, scm_symhash))
-    vcell = scm_sym2ovcell_soft (s, scm_weak_symhash);
   return (SCM_NIMP(vcell)
          ? SCM_BOOL_T
          : SCM_BOOL_F);
@@ -777,18 +760,6 @@
 }
 #undef FUNC_NAME
 
-
-SCM_DEFINE (scm_builtin_weak_bindings, "builtin-weak-bindings", 0, 0, 0, 
-            (),
-           "")
-#define FUNC_NAME s_scm_builtin_weak_bindings
-{
-  int length = SCM_VECTOR_LENGTH (scm_weak_symhash);
-  SCM obarray = scm_make_doubly_weak_hash_table (SCM_MAKINUM (length));
-  copy_and_prune_obarray (scm_weak_symhash, obarray);
-  return obarray;
-}
-#undef FUNC_NAME
 
 #define MAX_PREFIX_LENGTH 30
 
Index: guile/guile-core/libguile/symbols.h
diff -u guile/guile-core/libguile/symbols.h:1.48 
guile/guile-core/libguile/symbols.h:1.49
--- guile/guile-core/libguile/symbols.h:1.48    Tue Dec 12 05:57:26 2000
+++ guile/guile-core/libguile/symbols.h Tue Dec 12 10:36:35 2000
@@ -101,7 +101,6 @@
 extern SCM scm_symbol_pset_x (SCM s, SCM val);
 extern SCM scm_symbol_hash (SCM s);
 extern SCM scm_builtin_bindings (void);
-extern SCM scm_builtin_weak_bindings (void);
 extern SCM scm_gensym (SCM prefix);
 extern SCM scm_gentemp (SCM prefix, SCM obarray);
 extern void scm_init_symbols (void);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]