use a simple counter instead of gensym
parent
2c212f334c
commit
406f7a71d4
|
@ -1,3 +1,4 @@
|
|||
- fix fixnum<< vop on x86 and ppc
|
||||
- need line and paragraph spacing
|
||||
- update HTML stream
|
||||
- help cross-referencing
|
||||
|
|
|
@ -25,6 +25,8 @@ library, but is useful enough to ship with the Factor distribution.
|
|||
|
||||
- contrib/postgresql/ -- PostgreSQL binding (Doug Coleman)
|
||||
|
||||
- contrib/random-tester/ -- Random compiler tester (Doug Coleman)
|
||||
|
||||
- contrib/space-invaders/ -- Intel 8080-based Space Invaders arcade
|
||||
machine emulator (Chris Double)
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ sequences strings vectors words ;
|
|||
|
||||
: inc ( var -- ) [ 1+ ] change ; inline
|
||||
|
||||
: counter ( var -- n )
|
||||
global [ [ [ 0 ] unless* dup 1+ >fixnum ] change ] bind ;
|
||||
|
||||
: dec ( var -- ) [ 1- ] change ; inline
|
||||
|
||||
: bind ( namespace quot -- ) swap >n call n> drop ; inline
|
||||
|
|
|
@ -10,12 +10,12 @@ SYMBOL: recursive-state
|
|||
TUPLE: value recursion uid ;
|
||||
|
||||
C: value ( -- value )
|
||||
gensym over set-value-uid
|
||||
\ value counter over set-value-uid
|
||||
recursive-state get over set-value-recursion ;
|
||||
|
||||
M: value = eq? ;
|
||||
|
||||
M: value hashcode value-uid hashcode ;
|
||||
M: value hashcode value-uid ;
|
||||
|
||||
TUPLE: literal value ;
|
||||
|
||||
|
|
|
@ -19,8 +19,11 @@ M: comment pprint* ( ann -- )
|
|||
: values% ( prefix values -- )
|
||||
[
|
||||
swap %
|
||||
dup literal? [ literal-value ] [ value-uid ] if
|
||||
unparse %
|
||||
dup literal? [
|
||||
literal-value unparse %
|
||||
] [
|
||||
"@" % value-uid #
|
||||
] if
|
||||
] each-with ;
|
||||
|
||||
: effect-str ( node -- str )
|
||||
|
|
|
@ -98,8 +98,7 @@ M: word (uncrossref) drop ;
|
|||
M: word literalize <wrapper> ;
|
||||
|
||||
: gensym ( -- word )
|
||||
"G:"
|
||||
global [ \ gensym dup inc get ] bind
|
||||
number>string append f <word> dup init-word ;
|
||||
[ "G:" % \ gensym counter # ] "" make
|
||||
f <word> dup init-word ;
|
||||
|
||||
0 \ gensym set-global
|
||||
|
|
Loading…
Reference in New Issue