Minor inference cleanups
parent
3aa46e5fee
commit
7223b8c637
|
@ -1,5 +1,8 @@
|
|||
+ 0.83:
|
||||
|
||||
- nasty inference regressions
|
||||
- [ [ dup call ] dup call ] infer hangs
|
||||
- the invalid recursion form case needs to be fixed, for inlines too
|
||||
- windows port from erg
|
||||
- editor:
|
||||
- scroll to caret
|
||||
|
@ -100,7 +103,6 @@
|
|||
|
||||
+ compiler/ffi:
|
||||
|
||||
- nasty inference regressions
|
||||
- instead of decompiling words, add them to a 'recompile' set; compiler
|
||||
treats words in the recompile set as if they were not compiled
|
||||
- mac intel: struct returns from objc methods
|
||||
|
@ -115,8 +117,6 @@
|
|||
- intrinsic fixnum>float float>fixnum
|
||||
- remove literal table
|
||||
- C functions returning structs by value
|
||||
- [ [ dup call ] dup call ] infer hangs
|
||||
- the invalid recursion form case needs to be fixed, for inlines too
|
||||
- code gc
|
||||
- infer which variables are read, written in a quotation
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: inference
|
||||
USING: arrays errors generic hashtables interpreter kernel math
|
||||
namespaces parser prettyprint sequences strings vectors words ;
|
||||
|
||||
: add-inputs ( n stack -- stack )
|
||||
tuck length - dup 0 >
|
||||
[ value-vector dup rot nappend ] [ drop ] if ;
|
||||
|
||||
: unify-lengths ( seq -- seq )
|
||||
#! Pad all vectors to the same length. If one vector is
|
||||
#! shorter, pad it with unknown results at the bottom.
|
||||
dup 0 [ length max ] reduce swap [ add-inputs ] map-with ;
|
||||
dup 0 [ length max ] reduce
|
||||
swap [ add-inputs nip ] map-with ;
|
||||
|
||||
: unify-values ( seq -- value )
|
||||
#! If all values in list are equal, return the value.
|
||||
|
@ -34,9 +31,8 @@ namespaces parser prettyprint sequences strings vectors words ;
|
|||
0 [ [ max ] when* ] reduce ;
|
||||
|
||||
: unbalanced-branches ( in out -- )
|
||||
{ "Unbalanced branches:" } -rot [
|
||||
swap unparse " " rot length unparse append3
|
||||
] 2map append "\n" join inference-error ;
|
||||
[ swap unparse " " rot length unparse append3 ] 2map
|
||||
"Unbalanced branches:" add* "\n" join inference-error ;
|
||||
|
||||
: unify-effect ( in out -- in out )
|
||||
#! In is a sequence of integers; out is a sequence of stacks.
|
||||
|
@ -52,7 +48,7 @@ namespaces parser prettyprint sequences strings vectors words ;
|
|||
] map-with ;
|
||||
|
||||
: datastack-effect ( seq -- )
|
||||
dup d-in active-variable
|
||||
d-in over [ hash ] map-with
|
||||
swap meta-d active-variable
|
||||
unify-effect meta-d set d-in set ;
|
||||
|
||||
|
@ -66,7 +62,7 @@ namespaces parser prettyprint sequences strings vectors words ;
|
|||
[ terminated? swap hash ] all? terminated? set ;
|
||||
|
||||
: unify-dataflow ( effects -- nodes )
|
||||
[ [ dataflow-graph get ] bind ] map ;
|
||||
[ dataflow-graph swap hash ] map ;
|
||||
|
||||
: copy-inference ( -- )
|
||||
meta-r [ clone ] change
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: inference
|
||||
USING: arrays errors generic inspector interpreter io kernel
|
||||
math namespaces parser prettyprint sequences strings
|
||||
|
@ -30,7 +30,7 @@ M: object value-literal ( value -- )
|
|||
! - infer - quotation with custom inference behavior; 'if' uses
|
||||
! this. Word is passed on the stack.
|
||||
|
||||
! Vector of results we had to add to the datastack. Ie, the
|
||||
! Number of values we had to add to the datastack. Ie, the
|
||||
! inputs.
|
||||
SYMBOL: d-in
|
||||
|
||||
|
@ -40,13 +40,13 @@ SYMBOL: d-in
|
|||
|
||||
: value-vector ( n -- vector ) [ drop <computed> ] map >vector ;
|
||||
|
||||
: add-inputs ( n stack -- n stack )
|
||||
tuck length - dup 0 >
|
||||
[ dup value-vector [ rot nappend ] keep ]
|
||||
[ drop 0 swap ] if ;
|
||||
|
||||
: ensure-values ( n -- )
|
||||
meta-d get length 2dup > [
|
||||
- dup d-in [ + ] change
|
||||
value-vector meta-d [ dupd nappend ] change
|
||||
] [
|
||||
2drop
|
||||
] if ;
|
||||
meta-d [ add-inputs ] change d-in [ + ] change ;
|
||||
|
||||
: effect ( -- { in# out# } )
|
||||
#! After inference is finished, collect information.
|
||||
|
|
Loading…
Reference in New Issue