Skip to content

Commit

Permalink
effects: fix clone of row variadic effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Sep 15, 2019
1 parent d26d36c commit 2657e75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions core/effects/effects-tests.factor
Expand Up @@ -60,3 +60,5 @@ sequences tools.test math ;

{ "( :( :integer -- :integer ) :float -- :bignum )" }
[ ( :( :integer -- :integer ) :float -- :bignum ) unparse ] unit-test

{ t } [ ( ..a x quot: ( ..a -- ..b ) -- ..b ) dup clone = ] unit-test
29 changes: 19 additions & 10 deletions core/effects/effects.factor
Expand Up @@ -61,20 +61,23 @@ M: pair effect>string
nip effect>string ":" prepend
] if ;

: stack-picture ( seq -- string )
[ [ effect>string % CHAR: \s , ] each ] "" make ;
<PRIVATE

: var-picture ( var -- string )
[ ".." " " surround ]
[ "" ] if* ;
: stack-picture% ( seq -- )
[ effect>string % CHAR: \s , ] each ;

: var-picture% ( var -- )
[ ".." % % CHAR: \s , ] when* ;

PRIVATE>

M: effect effect>string ( effect -- string )
[
"( " %
dup in-var>> var-picture %
dup in>> stack-picture % "-- " %
dup out-var>> var-picture %
dup out>> stack-picture %
dup in-var>> var-picture%
dup in>> stack-picture% "-- " %
dup out-var>> var-picture%
dup out>> stack-picture%
dup terminated?>> [ "* " % ] when
drop
")" %
Expand Down Expand Up @@ -102,7 +105,13 @@ M: word stack-effect
M: deferred stack-effect call-next-method ( -- * ) or ;

M: effect clone
[ in>> clone ] [ out>> clone ] bi <effect> ;
{
[ in>> clone ]
[ out>> clone ]
[ terminated?>> ]
[ in-var>> ]
[ out-var>> ]
} cleave effect boa ;

: stack-height ( word -- n )
stack-effect effect-height ; inline
Expand Down

0 comments on commit 2657e75

Please sign in to comment.