factor/library/compiler/compiler.factor

61 lines
1.5 KiB
Factor
Raw Normal View History

2005-03-22 22:38:24 -05:00
! Copyright (C) 2004, 2005 Slava Pestov.
IN: compiler
2005-08-29 18:18:10 -04:00
USING: compiler-backend compiler-frontend errors inference io
2005-09-09 00:17:19 -04:00
kernel lists math namespaces optimizer prettyprint sequences
words ;
2004-12-17 21:46:19 -05:00
: supported-cpu? ( -- ? )
cpu "unknown" = not ;
2005-09-08 22:23:54 -04:00
: precompile ( quotation -- basic-blocks )
dataflow optimize linearize split-blocks simplify ;
2004-12-25 15:52:08 -05:00
2005-09-08 22:23:54 -04:00
: (compile) ( word -- )
2004-09-28 00:24:36 -04:00
#! Should be called inside the with-compiler scope.
2005-09-08 22:23:54 -04:00
"Compiling " write dup . dup word-def precompile generate ;
2004-09-08 02:31:03 -04:00
2004-09-28 00:24:36 -04:00
: compile-postponed ( -- )
2005-09-14 00:37:50 -04:00
compile-words get dup empty?
[ dup pop (compile) compile-postponed ] unless drop ;
2004-09-08 02:31:03 -04:00
: compile ( word -- )
2004-09-28 00:24:36 -04:00
[ postpone-word compile-postponed ] with-compiler ;
2004-12-04 23:45:41 -05:00
: compiled ( -- )
2004-11-21 21:16:16 -05:00
#! Compile the most recently defined word.
2004-12-17 21:46:19 -05:00
"compile" get [ word compile ] when ; parsing
2004-12-16 19:57:03 -05:00
: try-compile ( word -- )
[ compile ] catch [ error. drop ] when* ;
2004-12-16 19:57:03 -05:00
: compile-all ( -- ) [ try-compile ] each-word ;
2005-09-08 22:23:54 -04:00
: recompile ( word -- ) dup update-xt compile ;
2005-08-14 01:17:25 -04:00
2005-09-04 17:07:59 -04:00
: compile-1 ( quot -- )
#! Compute and call a quotation.
"compile" get [
gensym [ swap define-compound ] keep dup compile execute
] [
call
] ifte ;
2005-09-14 00:37:50 -04:00
\ dataflow profile
\ linearize profile
\ split-blocks profile
\ simplify profile
\ keep-optimizing profile
\ literals profile
2005-09-14 00:37:50 -04:00
\ kill-set profile
\ kill-node profile
\ infer-classes profile
\ solve-recursion profile
\ post-inline profile
\ compose-shuffle-nodes profile
\ static-branch profile
\ optimize-hooks profile
\ partial-eval? profile
\ partial-eval profile
\ flip-branches profile
\ apply-identities profile