diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index e0810084a1..aa43a2f9d4 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -8,7 +8,6 @@ + inference/dataflow: - type inference -- handle odd base cases, with code after ifte + compiler: @@ -37,9 +36,7 @@ - stream server can hang because of exception handler limitations - listener should be multithreaded - compile all, infer all commands -- type something -- no completions -- hit another key -- not inserted - faster completion -- sidekick: still parsing too much - errors don't always disappear - NPE in ErrorHighlight - maple-like: press enter at old commands to evaluate there @@ -48,6 +45,7 @@ + kernel: +- after bootstrapping, classes hash is messed up - do partial objects cause problems? - profiler is inaccurate: wrong word on cs - better i/o scheduler diff --git a/factor/jedit/FactorCompletion.java b/factor/jedit/FactorCompletion.java index 654b77dcf1..7807fa5224 100644 --- a/factor/jedit/FactorCompletion.java +++ b/factor/jedit/FactorCompletion.java @@ -88,15 +88,21 @@ public class FactorCompletion extends SideKickCompletion public boolean handleKeystroke(int selectedIndex, char keyChar) { if(keyChar == '\t' || keyChar == '\n') + { insert(selectedIndex); + return false; + } + else if(keyChar == ' ') + { + insert(selectedIndex); + textArea.userInput(' '); + return false; + } else + { textArea.userInput(keyChar); - - boolean ws = (ReadTable.DEFAULT_READTABLE - .getCharacterType(keyChar) - == ReadTable.WHITESPACE); - - return !ws; + return true; + } } public ListCellRenderer getRenderer() diff --git a/library/inference/words.factor b/library/inference/words.factor index fdcd3c3119..6a82eb5756 100644 --- a/library/inference/words.factor +++ b/library/inference/words.factor @@ -132,20 +132,22 @@ M: symbol (apply-word) ( word -- ) ] when ] when ; +: decompose ( x y -- effect ) + #! Return a stack effect such that x*effect = y. + 2unlist >r + swap 2unlist >r + over length over length - head nip + r> append + r> 2list ; + : base-case ( word -- effect ) + effect swap [ inferring-base-case on copy-inference inline-compound inferring-base-case off - ] with-scope ; - -: decompose ( x y -- effect ) - #! Return a stack effect such that x*effect = y. - 2unlist >r swap 2unlist swap length tail append - ! workaround - [ drop object ] map - r> 2list ; + ] with-scope decompose ; : recursive-word ( word label -- ) #! Handle a recursive call, by either applying a previously @@ -155,7 +157,7 @@ M: symbol (apply-word) ( word -- ) drop word-name " does not have a base case." cat2 throw ] [ 2dup [ drop #call-label ] [ nip #call ] ifte - rot base-case effect swap decompose (consume/produce) + rot base-case (consume/produce) ] ifte ; : apply-word ( word -- ) @@ -181,10 +183,6 @@ M: symbol (apply-word) ( word -- ) \ call [ infer-call ] "infer" set-word-property -! These are due to bugs and will be removed -\ * [ [ number number ] [ number ] ] "infer-effect" set-word-property -\ gcd [ [ number number ] [ number ] ] "infer-effect" set-word-property - \ undefined-method t "terminator" set-word-property \ not-a-number t "terminator" set-word-property \ throw t "terminator" set-word-property diff --git a/library/math/integer.factor b/library/math/integer.factor index 182a11775e..520feaef39 100644 --- a/library/math/integer.factor +++ b/library/math/integer.factor @@ -40,15 +40,18 @@ USE: math (fraction>) ] ifte ; inline +: division-by-zero ( x y -- ) + "Division by zero" throw drop ; + : integer/ ( x y -- x/y ) dup 0 number= [ - "Division by zero" throw drop + division-by-zero ] [ dup 0 < [ swap neg swap neg ] when 2dup gcd tuck /i >r /i r> fraction> - ] ifte ; + ] ifte ; inline M: fixnum number= fixnum= ; M: fixnum < fixnum< ; diff --git a/library/test/inference.factor b/library/test/inference.factor index 3c88df9f67..fa519f7075 100644 --- a/library/test/inference.factor +++ b/library/test/inference.factor @@ -15,12 +15,19 @@ USE: generic [ [ [ object ] [ object object ] ] [ [ object ] f ] decompose ] unit-test -[ [ [ fixnum fixnum ] f ] ] +[ [ [ cons vector cons integer object cons ] [ cons vector cons ] ] ] [ - [ [ rational rational ] [ rational fixnum ] ] - [ [ object ] f ] decompose + [ [ vector ] [ cons vector cons integer object cons ] ] + [ [ vector ] [ cons vector cons ] ] + decompose +] + +[ [ [ object ] [ object ] ] ] +[ + [ [ object number ] [ object ] ] + [ [ object number ] [ object ] ] + decompose ] -unit-test : old-effect ( [ in-types out-types ] -- [ in | out ] ) uncons car length >r length r> cons ;