]> gitweb.factorcode.org Git - factor.git/commitdiff
stack-checker.*: change pop-literal stack effect to ( -- obj )
authorBjörn Lindqvist <bjourne@gmail.com>
Thu, 4 Aug 2016 14:43:50 +0000 (16:43 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Thu, 4 Aug 2016 18:30:58 +0000 (20:30 +0200)
The rstate return value is never used so we can remove it

basis/stack-checker/alien/alien.factor
basis/stack-checker/backend/backend-docs.factor
basis/stack-checker/backend/backend-tests.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/branches/branches.factor
basis/stack-checker/known-words/known-words.factor

index b2550a13f37717bb768ef2b262da8b18000ed263..cf0e32bdefca3381752a9da7fe1b96d7ae2c7602 100644 (file)
@@ -37,22 +37,22 @@ TUPLE: alien-callback-params < alien-node-params xt ;
     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
@@ -145,7 +145,7 @@ M: callable wrap-callback-quot
     ] with-scope ;
 
 : infer-alien-callback ( -- )
-    pop-literal nip [
+    pop-literal [
         alien-callback-params new
         pop-abi
         pop-params
index 67a5905226f2607e673fd3ee0bdd16f0801442dc..c2344f58d11972aa92a3f9df4f7791d258a9e8ca 100644 (file)
@@ -1,5 +1,6 @@
-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
@@ -42,6 +43,10 @@ HELP: pop-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." } ;
index dfd9c8119f72557da8780a837b34792ae722d411..cf02e82258a7011a99d7a388e64e553a564149ec 100644 (file)
@@ -64,6 +64,20 @@ IN: stack-checker.backend.tests
     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 ;
 
index 29bb56e8444b1d4919b5c07d4399702fbfa49e3c..e65c1f5aa32f9da85dd1b1ef0fc0756d43abb539 100644 (file)
@@ -66,12 +66,10 @@ IN: stack-checker.backend
 : 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 <= [
index 04587889ef01b596bb695b15157014cc7344bc3c..0d59db3c227d9fdfd01ad6f66ae57622350a10cc 100644 (file)
@@ -167,5 +167,5 @@ M: declared-effect curried/composed? known>> curried/composed? ;
 
 : infer-dispatch ( -- )
     \ dispatch combinator set
-    pop-literal nip infer-branches
+    pop-literal infer-branches
     [ #dispatch, ] dip compute-phi-function ;
index 7e813d1b87395e927606e18522bb73334e0b4ba5..edab7e2918dc54b9c34938b84f182bf3e69aa682 100644 (file)
@@ -85,7 +85,7 @@ IN: stack-checker.known-words
     [ bad-declaration-error ] unless ;
 
 : infer-declare ( -- )
-    pop-literal nip check-declaration
+    pop-literal check-declaration
     [ length ensure-d ] keep zip
     #declare, ;
 
@@ -160,7 +160,7 @@ M: object infer-call* \ call bad-macro-input ;
 \ compose [ infer-compose ] "special" set-word-prop
 
 : infer-execute ( -- )
-    pop-literal nip
+    pop-literal
     dup word? [
         apply-object
     ] [
@@ -179,7 +179,7 @@ M: object infer-call* \ call bad-macro-input ;
 \ <tuple-boa> [ infer-<tuple-boa> ] "special" set-word-prop
 
 : infer-effect-unsafe ( word -- )
-    pop-literal nip
+    pop-literal
     add-effect-input
     apply-word/effect ;
 
@@ -194,7 +194,7 @@ M: object infer-call* \ call bad-macro-input ;
 \ 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, ;
 
@@ -206,7 +206,7 @@ M: object infer-call* \ call bad-macro-input ;
 \ 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
@@ -220,7 +220,7 @@ M: object infer-call* \ call bad-macro-input ;
 \ 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