diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index e261e35039..6b0ba8a611 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -18,7 +18,6 @@ - on win64: to_cell will break - .h .b .o for ratios and floats is broken - amd64 to do: - - fixnum<< overflow check - alien calls - relocation problem - compiling sheet runs out of memory diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index c30d524754..5b78f878d6 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -1,20 +1,23 @@ ! Copyright (C) 2004, 2005 Slava Pestov. IN: compiler -USING: compiler-backend compiler-frontend errors inference io -kernel lists math namespaces optimizer prettyprint sequences -words ; +USING: compiler-backend compiler-frontend errors hashtables +inference io kernel lists math namespaces optimizer prettyprint +sequences words ; -: precompile ( quotation -- basic-blocks ) - dataflow optimize linearize split-blocks simplify ; - -: (compile) ( word -- ) +: (compile) ( word -- basic-blocks ) #! Should be called inside the with-compiler scope. - "Compiling " write dup . flush - dup word-def precompile generate ; + dup word-def dataflow optimize linearize + [ split-blocks simplify generate ] hash-each ; + +: inform-compile ( word -- ) "Compiling " write . flush ; : compile-postponed ( -- ) - compile-words get dup empty? - [ dup pop (compile) compile-postponed ] unless drop ; + compile-words get dup empty? [ + dup pop + dup inform-compile + (compile) + compile-postponed + ] unless drop ; : compile ( word -- ) [ postpone-word compile-postponed ] with-compiler ; diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index 856270432f..8d56cba035 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -1,21 +1,45 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: compiler-frontend -USING: arrays compiler-backend errors generic inference kernel -lists math namespaces prettyprint sequences strings words ; +USING: arrays compiler-backend errors generic hashtables +inference kernel lists math namespaces prettyprint sequences +strings words ; : in-1 0 0 %peek-d , ; : in-2 0 1 %peek-d , 1 0 %peek-d , ; : in-3 0 2 %peek-d , 1 1 %peek-d , 2 0 %peek-d , ; : out-1 T{ vreg f 0 } 0 %replace-d , ; +! A map from words to linear IR. +SYMBOL: linearized + +! Renamed labels. To avoid problems with labels with the same +! name in different scopes. +SYMBOL: renamed-labels + +: rename-label ( label -- label ) +