1 USING: classes.private generic.standard.engines namespaces
2 arrays assocs sequences.private quotations kernel.private
3 math slots.private math.private kernel accessors words
5 IN: generic.standard.engines.tag
7 TUPLE: lo-tag-dispatch-engine methods ;
9 C: <lo-tag-dispatch-engine> lo-tag-dispatch-engine
11 : direct-dispatch-quot ( alist n -- quot )
13 [ <enum> swap update ] keep
14 [ dispatch ] curry >quotation ;
16 : lo-tag-number ( class -- n )
17 dup \ hi-tag bootstrap-word eq? [
18 drop \ hi-tag tag-number
23 M: lo-tag-dispatch-engine engine>quot
24 methods>> engines>quots* [ >r lo-tag-number r> ] assoc-map
29 num-tags get direct-dispatch-quot
33 TUPLE: hi-tag-dispatch-engine methods ;
35 C: <hi-tag-dispatch-engine> hi-tag-dispatch-engine
37 : convert-hi-tag-methods ( assoc -- assoc' )
38 \ hi-tag bootstrap-word
39 \ <hi-tag-dispatch-engine> convert-methods ;
41 : num-hi-tags ( -- n ) num-types get num-tags get - ;
43 : hi-tag-number ( class -- n )
44 "type" word-prop num-tags get - ;
46 : hi-tag-quot ( -- quot )
47 [ 0 slot ] num-tags get [ fixnum-fast ] curry compose ;
49 M: hi-tag-dispatch-engine engine>quot
50 methods>> engines>quots* [ >r hi-tag-number r> ] assoc-map
52 picker % hi-tag-quot % [
55 num-hi-tags direct-dispatch-quot