diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index b224ce7681..7843e495e3 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,3 +1,11 @@ +- flip-branches optimizer not working + +- prettyprint: + +{ V{ T{ literal T{ value f f G:110886 } f } T{ value + f f G:110887 +} } } + - make-pane: if no input, just return pane-output - intrinsic char-slot set-char-slot for x86 - closing ui does not stop timers @@ -69,8 +77,6 @@ - flushing optimization - [ [ dup call ] dup call ] infer hangs - the invalid recursion form case needs to be fixed, for inlines too -- recursion is iffy; if the stack at the recursive call doesn't match - up, throw an error - compile continuations + sequences: @@ -85,6 +91,10 @@ + kernel: +- first-class methods: + - methods outliner + - annotations for methods + - docstrings, and originating source file for methods - better handling of random arrangements of html words when prettyprinting - reader syntax for byte arrays, displaced aliens diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index de36d40210..ad11853443 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -123,7 +123,6 @@ vectors words ; "/library/inference/inference.factor" "/library/inference/branches.factor" "/library/inference/words.factor" - "/library/inference/recursive-values.factor" "/library/inference/class-infer.factor" "/library/inference/kill-literals.factor" "/library/inference/split-nodes.factor" diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index b399b04e8d..c2a0cad0a2 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -44,7 +44,7 @@ compile? [ { uncons 1+ 1- + <= > >= mod length nth-unsafe set-nth-unsafe - = string>number number>string scan solve-recursion + = string>number number>string scan kill-set kill-node (generate) } [ compile ] each ] when diff --git a/library/collections/lists.factor b/library/collections/lists.factor index fb0fc77df5..d0cd36e27a 100644 --- a/library/collections/lists.factor +++ b/library/collections/lists.factor @@ -15,15 +15,25 @@ M: cons peek ( list -- last ) #! Last element of a list. last car ; -M: f each ( list quot -- ) 2drop ; +: (list-each) ( list quot -- ) + over [ + [ >r car r> call ] 2keep >r cdr r> (list-each) + ] [ + 2drop + ] if ; inline -M: cons each ( list quot -- | quot: elt -- ) - [ >r car r> call ] 2keep >r cdr r> each ; +M: general-list each ( list quot -- | quot: elt -- ) + (list-each) ; -M: f map ( f quot -- f ) drop ; +: (list-map) ( list quot -- list ) + over [ + over cdr over >r >r >r car r> call + r> r> rot >r (list-map) r> swons + ] [ + drop + ] if ; inline -M: cons map ( cons quot -- cons ) - over cdr over >r >r >r car r> call r> r> rot >r map r> swons ; +M: general-list map ( list quot -- list ) (list-map) ; : (list-find) ( list quot i -- i elt ) pick [ diff --git a/library/collections/sequence-sort.factor b/library/collections/sequence-sort.factor index cb45f52305..870de04d59 100644 --- a/library/collections/sequence-sort.factor +++ b/library/collections/sequence-sort.factor @@ -44,8 +44,6 @@ C: sorter ( seq start end -- sorter ) ] when ] when ; inline -DEFER: (nsort) - : (nsort) ( quot seq start end -- ) 2dup < [ sort-step diff --git a/library/collections/sequences-epilogue.factor b/library/collections/sequences-epilogue.factor index 15a50a607e..6cf51c4a71 100644 --- a/library/collections/sequences-epilogue.factor +++ b/library/collections/sequences-epilogue.factor @@ -79,12 +79,13 @@ M: object >list ( seq -- list ) dup length 0 rot (>list) ; #! consecutive indices numbered from 'start'. 3dup copy-into-check dup length [ >r pick r> + pick set-nth-unsafe ] 2each 2drop ; + inline : nappend ( to from -- ) #! Add all elements of 'from' at the end of 'to'. >r dup length swap r> over length over length + pick set-length - copy-into ; + copy-into ; inline : append ( s1 s2 -- s1+s2 ) #! Outputs a new sequence of the same type as s1. @@ -122,11 +123,11 @@ M: object peek ( sequence -- element ) #! Shorten the sequence by one element. [ length 1- ] keep [ 0 -rot set-nth ] 2keep - set-length ; + set-length ; inline : pop ( sequence -- element ) #! Get value at end of sequence and remove it. - dup peek swap pop* ; + dup peek swap pop* ; inline : join ( seq glue -- seq ) #! The new sequence is of the same type as glue. diff --git a/library/collections/virtual-sequences.factor b/library/collections/virtual-sequences.factor index 0860e2fb58..3e3db5918f 100644 --- a/library/collections/virtual-sequences.factor +++ b/library/collections/virtual-sequences.factor @@ -47,9 +47,9 @@ C: slice ( from to seq -- seq ) >r 3dup check-slice r> [ set-slice-seq ] keep [ set-slice-to ] keep - [ set-slice-from ] keep ; + [ set-slice-from ] keep ; inline -: ( from to -- seq ) dup ; +: ( from to -- seq ) dup ; inline M: slice length ( range -- n ) dup slice-to swap slice-from - ; diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index b27fc4c274..48273771c3 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -19,18 +19,21 @@ M: f linearize* ( f -- ) drop ; M: node linearize* ( node -- ) linearize-next ; M: #label linearize* ( node -- ) + #! We remap the IR node's label to a new label object here, + #! to avoid problems with two IR #label nodes having the + #! same label in different lexical scopes.