factor/library/compiler/compiler.factor

43 lines
1.2 KiB
Factor
Raw Normal View History

! Copyright (C) 2004, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: compiler
USING: errors hashtables inference io kernel lists math
namespaces optimizer prettyprint sequences test words ;
: (compile) ( word -- )
2006-04-28 18:38:48 -04:00
[
[ dup specialized-def dataflow optimize generate ] keep
] benchmark nip "compile-time" set-word-prop ;
2005-12-21 02:43:41 -05:00
: inform-compile ( word -- ) "Compiling " write . flush ;
2004-09-08 02:31:03 -04:00
2004-09-28 00:24:36 -04:00
: compile-postponed ( -- )
2005-12-21 02:43:41 -05:00
compile-words get dup empty? [
2006-04-28 18:38:48 -04:00
drop
] [
pop dup inform-compile (compile) compile-postponed
] if ;
2004-09-08 02:31:03 -04:00
: compile ( word -- )
2004-09-28 00:24:36 -04:00
[ postpone-word compile-postponed ] with-compiler ;
2006-03-25 01:06:52 -05:00
: compiled ( -- ) "compile" get [ word compile ] when ; parsing
2004-12-16 19:57:03 -05:00
: try-compile ( word -- )
2005-09-21 01:12:16 -04:00
[ compile ] [ error. drop ] recover ;
2004-12-16 19:57:03 -05:00
2006-02-09 20:34:49 -05:00
: compile-vocabs ( vocabs -- )
[ words ] map concat
dup [ f "no-effect" set-word-prop ] each
[ try-compile ] each ;
: compile-all ( -- ) vocabs compile-vocabs ;
2005-09-08 22:23:54 -04:00
: recompile ( word -- ) dup update-xt compile ;
2005-08-14 01:17:25 -04:00
2006-03-15 15:58:22 -05:00
: compile-quot ( quot -- word )
gensym [ swap define-compound ] keep
"compile" get [ dup compile ] when ;
: compile-1 ( quot -- ) compile-quot execute ;