return-prep-quot infer-quot-here ;
: pop-return ( params -- params )
- pop-literal [ add-depends-on-c-type ] [ nip >>return ] bi ;
+ pop-literal [ add-depends-on-c-type ] [ >>return ] bi ;
: pop-library ( params -- params )
- pop-literal nip >>library ;
+ pop-literal >>library ;
: pop-function ( params -- params )
- pop-literal nip >>function ;
+ pop-literal >>function ;
: pop-params ( params -- params )
- pop-literal [ [ add-depends-on-c-type ] each ] [ nip >>parameters ] bi ;
+ pop-literal [ [ add-depends-on-c-type ] each ] [ >>parameters ] bi ;
: pop-abi ( params -- params )
- pop-literal nip >>abi ;
+ pop-literal >>abi ;
: pop-quot ( params -- params )
- pop-literal nip >>quot ;
+ pop-literal >>quot ;
: infer-alien-invoke ( -- )
alien-invoke-params new
] with-scope ;
: infer-alien-callback ( -- )
- pop-literal nip [
+ pop-literal [
alien-callback-params new
pop-abi
pop-params
-USING: compiler.tree effects help.markup help.syntax math quotations sequences
-stack-checker.state stack-checker.values stack-checker.visitor words ;
+USING: compiler.tree effects help.markup help.syntax kernel math
+quotations sequences stack-checker.state stack-checker.values
+stack-checker.visitor words ;
IN: stack-checker.backend
HELP: consume-d
{ $description "Pops an item from the compile time datastack. If the datastack is empty, a new value is instead introduced." }
{ $see-also introduce-values } ;
+HELP: pop-literal
+{ $values { "obj" object } }
+{ $description "Used for popping a value off the datastack which is expected to be a literal." } ;
+
HELP: push-d
{ $values { "obj" "object" } }
{ $description "Pushes an item onto the compile time data stack." } ;
node-seqs-eq?
] unit-test
+! pop-literal
+{
+ 2
+} [
+ V{ 1 2 } clone literals set pop-literal
+] unit-test
+
+{
+ 4321
+} [
+ init-inference 4321 <literal> make-known push-d pop-literal
+] unit-test
+
+
: foo ( x -- )
drop ;
: push-literal ( obj -- )
literals get push ;
-: pop-literal ( -- rstate obj )
+: pop-literal ( -- obj )
literals get [
- pop-d
- [ 1array #drop, ]
- [ literal [ recursion>> ] [ value>> ] bi ] bi
- ] [ pop recursive-state get swap ] if-empty ;
+ pop-d [ 1array #drop, ] [ literal value>> ] bi
+ ] [ pop ] if-empty ;
: literals-available? ( n -- literals ? )
literals get 2dup length <= [
: infer-dispatch ( -- )
\ dispatch combinator set
- pop-literal nip infer-branches
+ pop-literal infer-branches
[ #dispatch, ] dip compute-phi-function ;
[ bad-declaration-error ] unless ;
: infer-declare ( -- )
- pop-literal nip check-declaration
+ pop-literal check-declaration
[ length ensure-d ] keep zip
#declare, ;
\ compose [ infer-compose ] "special" set-word-prop
: infer-execute ( -- )
- pop-literal nip
+ pop-literal
dup word? [
apply-object
] [
\ <tuple-boa> [ infer-<tuple-boa> ] "special" set-word-prop
: infer-effect-unsafe ( word -- )
- pop-literal nip
+ pop-literal
add-effect-input
apply-word/effect ;
\ call-effect-unsafe [ infer-call-effect-unsafe ] "special" set-word-prop
: infer-load-locals ( -- )
- pop-literal nip
+ pop-literal
consume-d dup copy-values dup output-r
[ [ f f ] dip ] [ swap zip ] 2bi #shuffle, ;
\ load-local [ infer-load-local ] "special" set-word-prop
:: infer-get-local ( -- )
- pop-literal nip 1 swap - :> n
+ pop-literal 1 swap - :> n
n consume-r :> in-r
in-r first copy-value 1array :> out-d
in-r copy-values :> out-r
\ get-local [ infer-get-local ] "special" set-word-prop
: infer-drop-locals ( -- )
- f f pop-literal nip consume-r f f #shuffle, ;
+ f f pop-literal consume-r f f #shuffle, ;
\ drop-locals [ infer-drop-locals ] "special" set-word-prop