Fixing inference after cleanup
parent
5e2c7e769d
commit
cdad6df422
|
@ -25,16 +25,12 @@ PREDICATE: class math-class ( object -- ? )
|
||||||
[ [ math-precedence ] compare 0 > ] most ;
|
[ [ math-precedence ] compare 0 > ] most ;
|
||||||
|
|
||||||
: (math-upgrade) ( max class -- quot )
|
: (math-upgrade) ( max class -- quot )
|
||||||
dupd = [
|
dupd = [ drop [ ] ] [ "coercer" word-prop [ ] or ] if ;
|
||||||
drop [ ]
|
|
||||||
] [
|
|
||||||
"coercer" word-prop [ ] or
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: math-upgrade ( class1 class2 -- quot )
|
: math-upgrade ( class1 class2 -- quot )
|
||||||
[ math-class-max ] 2keep
|
[ math-class-max ] 2keep
|
||||||
>r over r> (math-upgrade)
|
>r over r> (math-upgrade) >r (math-upgrade)
|
||||||
>r (math-upgrade) dup empty? [ [ dip ] curry ] unless
|
dup empty? [ [ dip ] curry [ ] like ] unless
|
||||||
r> append ;
|
r> append ;
|
||||||
|
|
||||||
TUPLE: no-math-method left right generic ;
|
TUPLE: no-math-method left right generic ;
|
||||||
|
|
|
@ -89,7 +89,7 @@ M: wrapper apply-object wrapped apply-literal ;
|
||||||
r> recursive-state set ;
|
r> recursive-state set ;
|
||||||
|
|
||||||
: infer-quot-recursive ( quot word label -- )
|
: infer-quot-recursive ( quot word label -- )
|
||||||
2array add* infer-quot ;
|
recursive-state get -rot 2array add* infer-quot ;
|
||||||
|
|
||||||
: time-bomb ( error -- )
|
: time-bomb ( error -- )
|
||||||
[ throw ] curry recursive-state get infer-quot ;
|
[ throw ] curry recursive-state get infer-quot ;
|
||||||
|
@ -106,7 +106,7 @@ TUPLE: recursive-quotation-error quot ;
|
||||||
dup value-literal callable? [
|
dup value-literal callable? [
|
||||||
dup value-literal
|
dup value-literal
|
||||||
over value-recursion
|
over value-recursion
|
||||||
rot f infer-quot-recursive
|
rot f 2array add* infer-quot
|
||||||
] [
|
] [
|
||||||
drop bad-call
|
drop bad-call
|
||||||
] if
|
] if
|
||||||
|
@ -364,11 +364,12 @@ TUPLE: effect-error word effect ;
|
||||||
over recorded get push
|
over recorded get push
|
||||||
"inferred-effect" set-word-prop ;
|
"inferred-effect" set-word-prop ;
|
||||||
|
|
||||||
: infer-compound ( word -- )
|
: infer-compound ( word -- effect )
|
||||||
[
|
[
|
||||||
init-inference
|
init-inference
|
||||||
dup word-def over dup infer-quot-recursive
|
dup word-def over dup infer-quot-recursive
|
||||||
finish-word
|
finish-word
|
||||||
|
current-effect
|
||||||
] with-scope ;
|
] with-scope ;
|
||||||
|
|
||||||
M: compound infer-word
|
M: compound infer-word
|
||||||
|
@ -413,7 +414,7 @@ TUPLE: recursive-declare-error word ;
|
||||||
[
|
[
|
||||||
copy-inference nest-node
|
copy-inference nest-node
|
||||||
dup word-def swap gensym
|
dup word-def swap gensym
|
||||||
recursive-state get pick pick infer-quot-recursive
|
[ infer-quot-recursive ] 2keep
|
||||||
#label unnest-node
|
#label unnest-node
|
||||||
] H{ } make-assoc ;
|
] H{ } make-assoc ;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ IN: inference.transforms
|
||||||
: pop-literals ( n -- rstate seq )
|
: pop-literals ( n -- rstate seq )
|
||||||
dup zero? [ drop f ] [
|
dup zero? [ drop f ] [
|
||||||
[ ensure-values ] keep [ d-tail ] keep (consume-values)
|
[ ensure-values ] keep [ d-tail ] keep (consume-values)
|
||||||
dup value-recursion swap [ value-literal ] map
|
dup first value-recursion swap [ value-literal ] map
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: transform-quot ( quot n -- newquot )
|
: transform-quot ( quot n -- newquot )
|
||||||
|
@ -19,6 +19,7 @@ IN: inference.transforms
|
||||||
: define-transform ( word quot n -- )
|
: define-transform ( word quot n -- )
|
||||||
transform-quot "infer" set-word-prop ;
|
transform-quot "infer" set-word-prop ;
|
||||||
|
|
||||||
|
! Combinators
|
||||||
\ cond [
|
\ cond [
|
||||||
cond>quot
|
cond>quot
|
||||||
] 1 define-transform
|
] 1 define-transform
|
||||||
|
@ -35,6 +36,7 @@ IN: inference.transforms
|
||||||
] if
|
] if
|
||||||
] 1 define-transform
|
] 1 define-transform
|
||||||
|
|
||||||
|
! Bitfields
|
||||||
GENERIC: (bitfield-quot) ( spec -- quot )
|
GENERIC: (bitfield-quot) ( spec -- quot )
|
||||||
|
|
||||||
M: integer (bitfield-quot) ( spec -- quot )
|
M: integer (bitfield-quot) ( spec -- quot )
|
||||||
|
@ -58,5 +60,5 @@ M: pair (bitfield-quot) ( spec -- quot )
|
||||||
\ set-slots [ <reversed> [get-slots] ] 1 define-transform
|
\ set-slots [ <reversed> [get-slots] ] 1 define-transform
|
||||||
|
|
||||||
\ construct-boa [
|
\ construct-boa [
|
||||||
[ dup literalize , tuple-size , \ <tuple-boa> , ] [ ] make
|
dup tuple-size [ <tuple-boa> ] 2curry
|
||||||
] 1 define-transform
|
] 1 define-transform
|
||||||
|
|
|
@ -43,6 +43,6 @@ M: curry nth
|
||||||
>r 1- r> curry-quot nth
|
>r 1- r> curry-quot nth
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: curry like drop [ ] like ;
|
M: curry like drop dup callable? [ >quotation ] unless ;
|
||||||
|
|
||||||
INSTANCE: curry immutable-sequence
|
INSTANCE: curry immutable-sequence
|
||||||
|
|
Loading…
Reference in New Issue