- index.html\r
- if a directory is requested and URL does not end with /, redirect\r
- minimize stage2 initialization code, just move it to source files\r
+_ push call/allot counts as ulong bignums\r
\r
+ bignums:\r
\r
IN: words
DEFER: <word>
+DEFER: word-hashcode
DEFER: word-primitive
DEFER: set-word-primitive
DEFER: word-parameter
fsqrt
word?
<word>
+ word-hashcode
word-primitive
set-word-primitive
word-parameter
USE: math
USE: namespaces
USE: prettyprint
+USE: random
USE: stack
USE: stdio
USE: streams
( Words )
: word, ( -- pointer )
- word-tag here-as word-tag >header emit 0 emit ;
+ word-tag here-as word-tag >header emit
+ 0 HEX: fffffff random-int emit ( hashcode )
+ 0 emit ;
! This is to handle mutually recursive words
! It is a hack. A recursive word in the cdr of a
r> ( parameter -- ) emit
( plist -- ) emit
0 emit ( padding )
- 0 emit
0 emit ;
: primitive, ( word primitive -- ) f (worddef,) ;
: hashcode ( obj -- hash )
#! If two objects are =, they must have equal hashcodes.
[
+ [ word? ] [ word-hashcode ]
[ cons? ] [ 4 cons-hashcode ]
[ string? ] [ str-hashcode ]
[ number? ] [ >fixnum ]
primitive_fsqrt,
primitive_wordp,
primitive_word,
+ primitive_word_hashcode,
primitive_word_primitive,
primitive_set_word_primitive,
primitive_word_parameter,
extern XT primitives[];
-#define PRIMITIVE_COUNT 144
+#define PRIMITIVE_COUNT 145
CELL primitive_to_xt(CELL primitive);
WORD* word(CELL primitive, CELL parameter, CELL plist)
{
WORD* word = allot_object(WORD_TYPE,sizeof(WORD));
+ word->hashcode = (CELL)word; /* initial address */
word->xt = primitive_to_xt(primitive);
word->primitive = primitive;
word->parameter = parameter;
word->plist = plist;
word->call_count = 0;
+ word->allot_count = 0;
return word;
}
dpush(tag_word(word(primitive,parameter,plist)));
}
+void primitive_word_hashcode(void)
+{
+ drepl(tag_fixnum(untag_word(dpeek())->hashcode));
+}
+
void primitive_word_primitive(void)
{
drepl(tag_fixnum(untag_word(dpeek())->primitive));
typedef struct {
/* TAGGED header */
CELL header;
+ /* untagged hashcode */
+ CELL hashcode;
/* untagged execution token: jump here to execute word */
CELL xt;
/* untagged on-disk primitive number */
CELL call_count;
/* UNTAGGED amount of memory allocated in word */
CELL allot_count;
- CELL padding;
} WORD;
INLINE WORD* untag_word(CELL tagged)
void update_xt(WORD* word);
void primitive_wordp(void);
void primitive_word(void);
+void primitive_word_hashcode(void);
void primitive_word_primitive(void);
void primitive_set_word_primitive(void);
void primitive_word_parameter(void);