2005-08-04 00:48:07 -04:00
|
|
|
IN: temporary
|
2005-09-06 14:52:06 -04:00
|
|
|
USING: assembler compiler compiler-backend generic inference
|
|
|
|
kernel kernel-internals lists math prettyprint sequences strings
|
|
|
|
test vectors words ;
|
2004-12-05 21:17:09 -05:00
|
|
|
|
2005-09-08 00:37:17 -04:00
|
|
|
: kill-1
|
|
|
|
[ 1 2 3 ] [ + ] over drop drop ; compiled
|
|
|
|
|
|
|
|
[ [ 1 2 3 ] ] [ kill-1 ] unit-test
|
|
|
|
|
|
|
|
: kill-2
|
|
|
|
[ + ] [ 1 2 3 ] over drop nip ; compiled
|
|
|
|
|
|
|
|
[ [ 1 2 3 ] ] [ kill-2 ] unit-test
|
|
|
|
|
|
|
|
: kill-3
|
|
|
|
[ + ] dup over 3drop ;
|
|
|
|
|
|
|
|
[ ] [ kill-3 ] unit-test
|
|
|
|
|
|
|
|
: kill-4
|
|
|
|
[ 1 2 3 ] [ + ] [ - ] pick >r 2drop r> ; compiled
|
|
|
|
|
|
|
|
[ [ 1 2 3 ] [ 1 2 3 ] ] [ kill-4 ] unit-test
|
|
|
|
|
|
|
|
: kill-5
|
|
|
|
[ + ] [ - ] [ 1 2 3 ] pick pick 2drop >r 2drop r> ; compiled
|
|
|
|
|
|
|
|
[ [ 1 2 3 ] ] [ kill-5 ] unit-test
|
|
|
|
|
|
|
|
: kill-6
|
|
|
|
[ 1 2 3 ] [ 4 5 6 ] [ + ] pick >r drop r> ; compiled
|
|
|
|
|
|
|
|
[ [ 1 2 3 ] [ 4 5 6 ] [ 1 2 3 ] ] [ kill-6 ] unit-test
|
|
|
|
|
2005-05-22 21:07:24 -04:00
|
|
|
: kill-set*
|
2005-09-08 22:23:54 -04:00
|
|
|
dataflow dup solve-recursion dup split-node
|
|
|
|
kill-set [ literal-value ] map ;
|
2005-05-22 21:07:24 -04:00
|
|
|
|
2004-12-05 21:17:09 -05:00
|
|
|
: foo 1 2 3 ;
|
|
|
|
|
2005-08-07 00:00:57 -04:00
|
|
|
[ { } ] [ \ foo word-def dataflow kill-set ] unit-test
|
2005-01-14 12:01:48 -05:00
|
|
|
|
2005-08-07 00:00:57 -04:00
|
|
|
[ { [ 1 ] [ 2 ] } ] [ [ [ 1 ] [ 2 ] ifte ] kill-set* ] unit-test
|
2005-01-14 12:01:48 -05:00
|
|
|
|
2005-08-07 00:00:57 -04:00
|
|
|
[ { [ 1 ] [ 2 ] } ] [ [ [ 1 ] [ 2 ] ifte ] kill-set* ] unit-test
|
2005-01-14 12:01:48 -05:00
|
|
|
|
2005-05-15 21:17:56 -04:00
|
|
|
: literal-kill-test-1 4 compiled-offset cell 2 * - ; compiled
|
|
|
|
|
|
|
|
[ 4 ] [ literal-kill-test-1 drop ] unit-test
|
|
|
|
|
|
|
|
: literal-kill-test-2 3 compiled-offset cell 2 * - ; compiled
|
|
|
|
|
|
|
|
[ 3 ] [ literal-kill-test-2 drop ] unit-test
|
|
|
|
|
|
|
|
: literal-kill-test-3 10 3 /mod drop ; compiled
|
|
|
|
|
|
|
|
[ 3 ] [ literal-kill-test-3 ] unit-test
|
2005-05-22 21:07:24 -04:00
|
|
|
|
2005-08-13 04:01:21 -04:00
|
|
|
[ { [ 3 ] [ dup ] 3 } ] [ [ [ 3 ] [ dup ] ifte drop ] kill-set* ] unit-test
|
2005-05-22 21:07:24 -04:00
|
|
|
|
|
|
|
: literal-kill-test-4
|
|
|
|
5 swap [ 3 ] [ dup ] ifte 2drop ; compiled
|
|
|
|
|
|
|
|
[ ] [ t literal-kill-test-4 ] unit-test
|
|
|
|
[ ] [ f literal-kill-test-4 ] unit-test
|
|
|
|
|
2005-08-13 04:01:21 -04:00
|
|
|
[ { 5 [ 3 ] [ dup ] 3 } ] [ \ literal-kill-test-4 word-def kill-set* ] unit-test
|
2005-05-22 21:07:24 -04:00
|
|
|
|
|
|
|
: literal-kill-test-5
|
|
|
|
5 swap [ 5 ] [ dup ] ifte 2drop ; compiled
|
|
|
|
|
|
|
|
[ ] [ t literal-kill-test-5 ] unit-test
|
|
|
|
[ ] [ f literal-kill-test-5 ] unit-test
|
|
|
|
|
2005-08-13 04:01:21 -04:00
|
|
|
[ { 5 [ 5 ] [ dup ] 5 } ] [ \ literal-kill-test-5 word-def kill-set* ] unit-test
|
2005-05-22 21:07:24 -04:00
|
|
|
|
|
|
|
: literal-kill-test-6
|
|
|
|
5 swap [ dup ] [ dup ] ifte 2drop ; compiled
|
|
|
|
|
|
|
|
[ ] [ t literal-kill-test-6 ] unit-test
|
|
|
|
[ ] [ f literal-kill-test-6 ] unit-test
|
|
|
|
|
2005-08-07 00:00:57 -04:00
|
|
|
[ { 5 [ dup ] [ dup ] } ] [ \ literal-kill-test-6 word-def kill-set* ] unit-test
|
2005-05-22 21:07:24 -04:00
|
|
|
|
2005-07-25 01:04:33 -04:00
|
|
|
: literal-kill-test-7
|
|
|
|
[ 1 2 3 ] >r + r> drop ; compiled
|
|
|
|
|
|
|
|
[ 4 ] [ 2 2 literal-kill-test-7 ] unit-test
|
2005-08-01 16:22:53 -04:00
|
|
|
|
2005-08-06 02:44:25 -04:00
|
|
|
! Test method inlining
|
2005-08-04 00:48:07 -04:00
|
|
|
[ string ] [
|
2005-08-01 16:22:53 -04:00
|
|
|
\ string
|
2005-08-14 23:26:40 -04:00
|
|
|
[ repeated integer string mirror array reversed sbuf
|
2005-08-01 16:22:53 -04:00
|
|
|
slice vector diagonal general-list ]
|
2005-08-04 00:48:07 -04:00
|
|
|
min-class
|
2005-08-01 16:22:53 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ f ] [
|
|
|
|
\ fixnum
|
|
|
|
[ fixnum integer letter ]
|
2005-08-02 06:32:48 -04:00
|
|
|
min-class
|
2005-08-01 16:22:53 -04:00
|
|
|
] unit-test
|
|
|
|
|
2005-08-02 06:32:48 -04:00
|
|
|
[ fixnum ] [
|
2005-08-01 16:22:53 -04:00
|
|
|
\ fixnum
|
|
|
|
[ fixnum integer object ]
|
2005-08-02 06:32:48 -04:00
|
|
|
min-class
|
2005-08-01 16:22:53 -04:00
|
|
|
] unit-test
|
|
|
|
|
2005-08-02 06:32:48 -04:00
|
|
|
[ integer ] [
|
2005-08-01 16:22:53 -04:00
|
|
|
\ fixnum
|
2005-08-02 06:32:48 -04:00
|
|
|
[ integer float object ]
|
|
|
|
min-class
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ object ] [
|
|
|
|
\ word
|
|
|
|
[ integer float object ]
|
|
|
|
min-class
|
2005-08-01 16:22:53 -04:00
|
|
|
] unit-test
|
2005-08-02 22:40:12 -04:00
|
|
|
|
|
|
|
GENERIC: xyz
|
|
|
|
M: cons xyz xyz ;
|
|
|
|
|
|
|
|
[ ] [ \ xyz compile ] unit-test
|
2005-08-03 18:47:32 -04:00
|
|
|
|
|
|
|
! Test predicate inlining
|
|
|
|
: pred-test-1
|
|
|
|
dup cons? [
|
|
|
|
dup general-list? [ "general-list" ] [ "nope" ] ifte
|
|
|
|
] [
|
|
|
|
"not a cons"
|
|
|
|
] ifte ; compiled
|
|
|
|
|
|
|
|
[ [[ 1 2 ]] "general-list" ] [ [[ 1 2 ]] pred-test-1 ] unit-test
|
|
|
|
|
|
|
|
: pred-test-2
|
|
|
|
dup fixnum? [
|
|
|
|
dup integer? [ "integer" ] [ "nope" ] ifte
|
|
|
|
] [
|
|
|
|
"not a fixnum"
|
|
|
|
] ifte ; compiled
|
|
|
|
|
|
|
|
[ 1 "integer" ] [ 1 pred-test-2 ] unit-test
|
|
|
|
|
|
|
|
TUPLE: pred-test ;
|
|
|
|
|
|
|
|
: pred-test-3
|
|
|
|
dup tuple? [
|
|
|
|
dup pred-test? [ "pred-test" ] [ "nope" ] ifte
|
|
|
|
] [
|
|
|
|
"not a tuple"
|
|
|
|
] ifte ; compiled
|
|
|
|
|
2005-08-04 00:48:07 -04:00
|
|
|
[ << pred-test >> "pred-test" ] [ << pred-test >> pred-test-3 ] unit-test
|
2005-08-03 18:47:32 -04:00
|
|
|
|
|
|
|
: pred-test-4
|
|
|
|
dup pred-test? [
|
|
|
|
dup tuple? [ "pred-test" ] [ "nope" ] ifte
|
|
|
|
] [
|
|
|
|
"not a tuple"
|
|
|
|
] ifte ; compiled
|
|
|
|
|
|
|
|
[ << pred-test >> "pred-test" ] [ << pred-test >> pred-test-4 ] unit-test
|
2005-08-12 23:54:29 -04:00
|
|
|
|
|
|
|
: inline-test
|
|
|
|
"nom" = ; compiled
|
|
|
|
|
|
|
|
[ t ] [ "nom" inline-test ] unit-test
|
2005-08-13 04:01:21 -04:00
|
|
|
[ f ] [ "shayin" inline-test ] unit-test
|
2005-08-12 23:54:29 -04:00
|
|
|
[ f ] [ 3 inline-test ] unit-test
|
2005-08-13 23:39:46 -04:00
|
|
|
|
|
|
|
: fixnum-declarations >fixnum 24 shift 1234 bitxor ; compiled
|
|
|
|
|
|
|
|
[ ] [ 1000000 fixnum-declarations . ] unit-test
|
2005-09-03 22:28:46 -04:00
|
|
|
|
|
|
|
! regression
|
|
|
|
|
|
|
|
: literal-not-branch 0 not [ ] [ ] ifte ; compiled
|
|
|
|
|
|
|
|
[ ] [ literal-not-branch ] unit-test
|
2005-09-07 17:21:11 -04:00
|
|
|
|
|
|
|
! regression
|
|
|
|
|
|
|
|
: bad-kill-1 [ 3 f ] [ dup bad-kill-1 ] ifte ; inline
|
|
|
|
: bad-kill-2 bad-kill-1 drop ; compiled
|
|
|
|
|
|
|
|
[ 3 ] [ t bad-kill-2 ] unit-test
|