fix forget memory leak
parent
a6b851354c
commit
77b3175cd9
|
@ -26,13 +26,11 @@
|
||||||
- test copy-into of a sequence into itself
|
- test copy-into of a sequence into itself
|
||||||
- vertical alignment of arrows -vs- outliner gadget
|
- vertical alignment of arrows -vs- outliner gadget
|
||||||
- slice: if sequence or seq start is changed, abstraction violation
|
- slice: if sequence or seq start is changed, abstraction violation
|
||||||
- find* should test for index below 0
|
|
||||||
|
|
||||||
+ ui:
|
+ ui:
|
||||||
|
|
||||||
- multi-part gradients
|
- multi-part gradients
|
||||||
- tabular output
|
- tabular output
|
||||||
- completion
|
|
||||||
- debugger should use outlining
|
- debugger should use outlining
|
||||||
- support nested incremental layouts more efficiently
|
- support nested incremental layouts more efficiently
|
||||||
- make-pane should not need world-theme
|
- make-pane should not need world-theme
|
||||||
|
|
|
@ -138,6 +138,7 @@ namespaces sequences words ;
|
||||||
: binary-jump ( node label op -- )
|
: binary-jump ( node label op -- )
|
||||||
pick binary-op-imm?
|
pick binary-op-imm?
|
||||||
[ binary-jump-imm ] [ binary-jump-reg ] if ;
|
[ binary-jump-imm ] [ binary-jump-reg ] if ;
|
||||||
|
|
||||||
{
|
{
|
||||||
{ fixnum<= %jump-fixnum<= }
|
{ fixnum<= %jump-fixnum<= }
|
||||||
{ fixnum< %jump-fixnum< }
|
{ fixnum< %jump-fixnum< }
|
||||||
|
|
|
@ -16,7 +16,7 @@ USING: kernel line-editor namespaces sequences strings test ;
|
||||||
[ 0 ] [ 0 0 10 10 (point-update) ] unit-test
|
[ 0 ] [ 0 0 10 10 (point-update) ] unit-test
|
||||||
|
|
||||||
[ "Hello world" ] [
|
[ "Hello world" ] [
|
||||||
"Hello world" 0 "editor" get [ line-insert ] bind
|
"Hello world" 0 0 "editor" get [ line-replace ] bind
|
||||||
"editor" get [ line-text get ] bind
|
"editor" get [ line-text get ] bind
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ USING: kernel line-editor namespaces sequences strings test ;
|
||||||
|
|
||||||
[ "Hello, crazy world" ] [
|
[ "Hello, crazy world" ] [
|
||||||
"editor" get [ 0 set-caret-pos ] bind
|
"editor" get [ 0 set-caret-pos ] bind
|
||||||
", crazy" 5 "editor" get [ line-insert ] bind
|
", crazy" 5 5 "editor" get [ line-replace ] bind
|
||||||
"editor" get [ line-text get ] bind
|
"editor" get [ line-text get ] bind
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ USING: kernel line-editor namespaces sequences strings test ;
|
||||||
|
|
||||||
[ "Hello, crazy world" ] [
|
[ "Hello, crazy world" ] [
|
||||||
"editor" get [ 5 set-caret-pos "Hello world" line-text set ] bind
|
"editor" get [ 5 set-caret-pos "Hello world" line-text set ] bind
|
||||||
", crazy" 5 "editor" get [ line-insert ] bind
|
", crazy" 5 5 "editor" get [ line-replace ] bind
|
||||||
"editor" get [ line-text get ] bind
|
"editor" get [ line-text get ] bind
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ TUPLE: another-one ;
|
||||||
[ << another-one f >> ] [ <another-one> empty-method-test ] unit-test
|
[ << another-one f >> ] [ <another-one> empty-method-test ] unit-test
|
||||||
|
|
||||||
! Test generic see and parsing
|
! Test generic see and parsing
|
||||||
[ "IN: temporary\nSYMBOL: bah\nUNION: bah fixnum alien ;\n" ]
|
[ "IN: temporary SYMBOL: bah\nUNION: bah fixnum alien ;\n" ]
|
||||||
[ [ \ bah see ] string-out ] unit-test
|
[ [ \ bah see ] string-out ] unit-test
|
||||||
|
|
||||||
! Weird bug
|
! Weird bug
|
||||||
|
|
|
@ -34,17 +34,17 @@ unit-test
|
||||||
|
|
||||||
: foo dup * ; inline
|
: foo dup * ; inline
|
||||||
|
|
||||||
[ "IN: temporary\n: foo dup * ; inline\n" ]
|
[ "IN: temporary : foo dup * ; inline\n" ]
|
||||||
[ [ \ foo see ] string-out ] unit-test
|
[ [ \ foo see ] string-out ] unit-test
|
||||||
|
|
||||||
: bar ( x -- y ) 2 + ;
|
: bar ( x -- y ) 2 + ;
|
||||||
|
|
||||||
[ "IN: temporary\n: bar ( x -- y ) 2 + ;\n" ] [ [ \ bar see ] string-out ] unit-test
|
[ "IN: temporary : bar ( x -- y ) 2 + ;\n" ] [ [ \ bar see ] string-out ] unit-test
|
||||||
|
|
||||||
: baz dup ;
|
: baz dup ;
|
||||||
|
|
||||||
[ ] [ [ baz ] infer drop ] unit-test
|
[ ] [ [ baz ] infer drop ] unit-test
|
||||||
[ "IN: temporary\n: baz ( object -- object object ) dup ;\n" ]
|
[ "IN: temporary : baz ( object -- object object ) dup ;\n" ]
|
||||||
[ [ \ baz see ] string-out ] unit-test
|
[ [ \ baz see ] string-out ] unit-test
|
||||||
|
|
||||||
[ ] [ \ fixnum see ] unit-test
|
[ ] [ \ fixnum see ] unit-test
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
IN: temporary
|
IN: temporary
|
||||||
USING: generic kernel lists math namespaces test words sequences ;
|
USING: generic hashtables kernel lists math namespaces sequences
|
||||||
|
test words ;
|
||||||
|
|
||||||
[ 4 ] [
|
[ 4 ] [
|
||||||
"poo" "scratchpad" create [ 2 2 + ] define-compound
|
"poo" "scratchpad" create [ 2 2 + ] define-compound
|
||||||
|
@ -74,6 +75,16 @@ FORGET: another-forgotten
|
||||||
|
|
||||||
[ t ] [ \ car interned? ] unit-test
|
[ t ] [ \ car interned? ] unit-test
|
||||||
|
|
||||||
|
! I forgot remove-crossref calls!
|
||||||
|
: fee ;
|
||||||
|
: foe fee ;
|
||||||
|
: fie foe ;
|
||||||
|
|
||||||
|
[ 0 ] [ \ fee crossref get hash hash-size ] unit-test
|
||||||
|
[ t ] [ \ foe crossref get hash not ] unit-test
|
||||||
|
|
||||||
|
FORGET: foe
|
||||||
|
|
||||||
! This has to be the last test in the file.
|
! This has to be the last test in the file.
|
||||||
: test-last ( -- ) ;
|
: test-last ( -- ) ;
|
||||||
word word-name "last-word-test" set
|
word word-name "last-word-test" set
|
||||||
|
|
|
@ -62,8 +62,7 @@ M: word summary ( word -- )
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: format-column ( list ? -- list )
|
: format-column ( list ? -- list )
|
||||||
>r [ unparse-short ] map
|
>r [ unparse-short ] map r> [
|
||||||
r> [
|
|
||||||
[ 0 [ length max ] reduce ] keep
|
[ 0 [ length max ] reduce ] keep
|
||||||
[ swap CHAR: \s pad-right ] map-with
|
[ swap CHAR: \s pad-right ] map-with
|
||||||
] unless ;
|
] unless ;
|
||||||
|
|
|
@ -72,6 +72,7 @@ SYMBOL: vocabularies
|
||||||
: forget ( word -- )
|
: forget ( word -- )
|
||||||
#! Remove a word definition.
|
#! Remove a word definition.
|
||||||
dup uncrossref
|
dup uncrossref
|
||||||
|
crossref get [ dupd remove-hash ] when*
|
||||||
dup word-name swap word-vocabulary vocab remove-hash ;
|
dup word-name swap word-vocabulary vocab remove-hash ;
|
||||||
|
|
||||||
: interned? ( word -- ? )
|
: interned? ( word -- ? )
|
||||||
|
|
|
@ -7,13 +7,16 @@ namespaces sequences strings vectors ;
|
||||||
! The basic word type. Words can be named and compared using
|
! The basic word type. Words can be named and compared using
|
||||||
! identity. They hold a property map.
|
! identity. They hold a property map.
|
||||||
|
|
||||||
: word-prop ( word name -- value ) swap word-props hash ;
|
: word-prop ( word name -- value )
|
||||||
|
swap word-props hash ;
|
||||||
|
|
||||||
: set-word-prop ( word value name -- )
|
: set-word-prop ( word value name -- )
|
||||||
rot word-props pick [ set-hash ] [ remove-hash drop ] if ;
|
rot word-props pick [ set-hash ] [ remove-hash drop ] if ;
|
||||||
|
|
||||||
! Pointer to executable native code
|
! Pointer to executable native code
|
||||||
GENERIC: word-xt
|
GENERIC: word-xt
|
||||||
M: word word-xt ( w -- xt ) 7 integer-slot ;
|
M: word word-xt ( w -- xt ) 7 integer-slot ;
|
||||||
|
|
||||||
GENERIC: set-word-xt
|
GENERIC: set-word-xt
|
||||||
M: word set-word-xt ( xt w -- ) 7 set-integer-slot ;
|
M: word set-word-xt ( xt w -- ) 7 set-integer-slot ;
|
||||||
|
|
||||||
|
@ -41,21 +44,8 @@ SYMBOL: crossref
|
||||||
#! Marks each word in the quotation as being a dependency
|
#! Marks each word in the quotation as being a dependency
|
||||||
#! of the word.
|
#! of the word.
|
||||||
crossref get [
|
crossref get [
|
||||||
dup uses [ (add-crossref) ] each-with
|
dup dup uses [ (add-crossref) ] each-with
|
||||||
] [
|
] when drop ;
|
||||||
drop
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: (remove-crossref) crossref get [ nest remove-hash ] bind ;
|
|
||||||
|
|
||||||
: remove-crossref ( word -- )
|
|
||||||
#! Marks each word in the quotation as not being a
|
|
||||||
#! dependency of the word.
|
|
||||||
crossref get [
|
|
||||||
dup uses [ (remove-crossref) ] each-with
|
|
||||||
] [
|
|
||||||
drop
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: usages ( word -- deps )
|
: usages ( word -- deps )
|
||||||
#! List all usages of a word. This is a transitive closure,
|
#! List all usages of a word. This is a transitive closure,
|
||||||
|
@ -67,10 +57,17 @@ SYMBOL: crossref
|
||||||
crossref get ?hash dup [ hash-keys ] when ;
|
crossref get ?hash dup [ hash-keys ] when ;
|
||||||
|
|
||||||
GENERIC: (uncrossref) ( word -- )
|
GENERIC: (uncrossref) ( word -- )
|
||||||
|
|
||||||
M: word (uncrossref) drop ;
|
M: word (uncrossref) drop ;
|
||||||
|
|
||||||
|
: remove-crossref ( usage user -- )
|
||||||
|
crossref get [ nest remove-hash ] bind ;
|
||||||
|
|
||||||
: uncrossref ( word -- )
|
: uncrossref ( word -- )
|
||||||
dup (uncrossref) usages [ (uncrossref) ] each ;
|
crossref get [
|
||||||
|
dup dup uses [ remove-crossref ] each-with
|
||||||
|
dup (uncrossref) dup usages [ (uncrossref) ] each
|
||||||
|
] when drop ;
|
||||||
|
|
||||||
! The word primitive combined with the word def specify what the
|
! The word primitive combined with the word def specify what the
|
||||||
! word does when invoked.
|
! word does when invoked.
|
||||||
|
@ -106,7 +103,7 @@ PREDICATE: word compound ( obj -- ? ) word-primitive 1 = ;
|
||||||
M: compound definer drop \ : ;
|
M: compound definer drop \ : ;
|
||||||
|
|
||||||
: define-compound ( word def -- )
|
: define-compound ( word def -- )
|
||||||
>r dup dup remove-crossref r> 1 swap define add-crossref ;
|
over >r 1 swap define r> add-crossref ;
|
||||||
|
|
||||||
: reset-props ( word seq -- )
|
: reset-props ( word seq -- )
|
||||||
[ f swap set-word-prop ] each-with ;
|
[ f swap set-word-prop ] each-with ;
|
||||||
|
|
Loading…
Reference in New Issue