ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/microscheme/scheme.c
(Generate patch)

Comparing microscheme/scheme.c (file contents):
Revision 1.33 by root, Sat Nov 28 10:59:14 2015 UTC vs.
Revision 1.34 by root, Sat Nov 28 22:14:49 2015 UTC

1079 return x; 1079 return x;
1080} 1080}
1081 1081
1082/* ========== oblist implementation ========== */ 1082/* ========== oblist implementation ========== */
1083 1083
1084static pointer
1085generate_symbol (SCHEME_P_ const char *name)
1086{
1087 pointer x = mk_string (SCHEME_A_ name);
1088 setimmutable (x);
1089 x = immutable_cons (x, NIL);
1090 set_typeflag (x, T_SYMBOL);
1091 return x;
1092}
1093
1084#ifndef USE_OBJECT_LIST 1094#ifndef USE_OBJECT_LIST
1085 1095
1086static int 1096static int
1087hash_fn (const char *key, int table_size) 1097hash_fn (const char *key, int table_size)
1088{ 1098{
1103 1113
1104/* returns the new symbol */ 1114/* returns the new symbol */
1105static pointer 1115static pointer
1106oblist_add_by_name (SCHEME_P_ const char *name) 1116oblist_add_by_name (SCHEME_P_ const char *name)
1107{ 1117{
1108 int location; 1118 pointer x = generate_symbol (SCHEME_A_ name);
1109
1110 pointer x = immutable_cons (mk_string (SCHEME_A_ name), NIL);
1111 set_typeflag (x, T_SYMBOL);
1112 setimmutable (car (x));
1113
1114 location = hash_fn (name, veclength (SCHEME_V->oblist)); 1119 int location = hash_fn (name, veclength (SCHEME_V->oblist));
1115 vector_set (SCHEME_V->oblist, location, immutable_cons (x, vector_get (SCHEME_V->oblist, location))); 1120 vector_set (SCHEME_V->oblist, location, immutable_cons (x, vector_get (SCHEME_V->oblist, location)));
1116 return x; 1121 return x;
1117} 1122}
1118 1123
1119ecb_inline pointer 1124ecb_inline pointer
1371 1376
1372INTERFACE pointer 1377INTERFACE pointer
1373gensym (SCHEME_P) 1378gensym (SCHEME_P)
1374{ 1379{
1375 pointer x; 1380 pointer x;
1376
1377 for (; SCHEME_V->gensym_cnt < LONG_MAX; SCHEME_V->gensym_cnt++)
1378 {
1379 char name[40] = "gensym-"; 1381 char name[40] = "gensym-";
1380 xnum (name + 7, SCHEME_V->gensym_cnt); 1382 xnum (name + 7, SCHEME_V->gensym_cnt);
1381 1383
1382 /* first check oblist */ 1384 return generate_symbol (SCHEME_A_ name);
1383 x = oblist_find_by_name (SCHEME_A_ name);
1384
1385 if (x == NIL)
1386 {
1387 x = oblist_add_by_name (SCHEME_A_ name);
1388 return x;
1389 }
1390 }
1391
1392 return NIL;
1393} 1385}
1394 1386
1395/* make symbol or number atom from string */ 1387/* make symbol or number atom from string */
1396static pointer 1388static pointer
1397mk_atom (SCHEME_P_ char *q) 1389mk_atom (SCHEME_P_ char *q)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines