2008-08-08 14:14:36 -04:00
|
|
|
IN: compiler.tree.tuple-unboxing.tests
|
|
|
|
USING: tools.test compiler.tree.tuple-unboxing
|
|
|
|
compiler.tree compiler.tree.builder compiler.tree.normalization
|
|
|
|
compiler.tree.propagation compiler.tree.cleanup
|
|
|
|
compiler.tree.escape-analysis compiler.tree.tuple-unboxing
|
2008-08-08 17:04:33 -04:00
|
|
|
compiler.tree.def-use kernel accessors sequences math
|
|
|
|
sorting math.order binary-search ;
|
2008-08-08 14:14:36 -04:00
|
|
|
|
|
|
|
\ unbox-tuples must-infer
|
|
|
|
|
|
|
|
: test-unboxing ( quot -- )
|
|
|
|
#! Just make sure it doesn't throw errors; compute def use
|
|
|
|
#! for kicks.
|
|
|
|
build-tree
|
|
|
|
normalize
|
|
|
|
propagate
|
|
|
|
cleanup
|
|
|
|
escape-analysis
|
|
|
|
unbox-tuples
|
|
|
|
compute-def-use
|
|
|
|
drop ;
|
|
|
|
|
|
|
|
TUPLE: cons { car read-only } { cdr read-only } ;
|
|
|
|
|
|
|
|
TUPLE: empty-tuple ;
|
|
|
|
|
|
|
|
{
|
2008-08-08 17:04:33 -04:00
|
|
|
[ 1 2 cons boa [ car>> ] [ cdr>> ] bi ]
|
2008-08-08 14:14:36 -04:00
|
|
|
[ empty-tuple boa drop ]
|
|
|
|
[ cons boa [ car>> ] [ cdr>> ] bi ]
|
|
|
|
[ [ 1 cons boa ] [ 2 cons boa ] if car>> ]
|
|
|
|
[ dup cons boa 10 [ nip dup cons boa ] each-integer car>> ]
|
2008-08-08 17:04:33 -04:00
|
|
|
[ [ <=> ] sort ]
|
|
|
|
[ [ <=> ] with search ]
|
2008-08-08 14:14:36 -04:00
|
|
|
} [ [ ] swap [ test-unboxing ] curry unit-test ] each
|