… | |
… | |
1079 | return x; |
1079 | return x; |
1080 | } |
1080 | } |
1081 | |
1081 | |
1082 | /* ========== oblist implementation ========== */ |
1082 | /* ========== oblist implementation ========== */ |
1083 | |
1083 | |
|
|
1084 | static pointer |
|
|
1085 | generate_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 | |
1086 | static int |
1096 | static int |
1087 | hash_fn (const char *key, int table_size) |
1097 | hash_fn (const char *key, int table_size) |
1088 | { |
1098 | { |
… | |
… | |
1103 | |
1113 | |
1104 | /* returns the new symbol */ |
1114 | /* returns the new symbol */ |
1105 | static pointer |
1115 | static pointer |
1106 | oblist_add_by_name (SCHEME_P_ const char *name) |
1116 | oblist_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 | |
1119 | ecb_inline pointer |
1124 | ecb_inline pointer |
… | |
… | |
1371 | |
1376 | |
1372 | INTERFACE pointer |
1377 | INTERFACE pointer |
1373 | gensym (SCHEME_P) |
1378 | gensym (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 */ |
1396 | static pointer |
1388 | static pointer |
1397 | mk_atom (SCHEME_P_ char *q) |
1389 | mk_atom (SCHEME_P_ char *q) |