stack-checker.values: docs and tests
parent
bd376f5094
commit
086dffc53a
|
@ -1,6 +1,45 @@
|
|||
USING: help.markup help.syntax math quotations sequences words ;
|
||||
USING: hashtables help.markup help.syntax math quotations sequences words ;
|
||||
IN: stack-checker.values
|
||||
|
||||
HELP: curried
|
||||
{ $class-description "Result of curry." } ;
|
||||
|
||||
HELP: composed
|
||||
{ $class-description "Result of compose." } ;
|
||||
|
||||
HELP: input-parameter
|
||||
{ $class-description "Symbol used to indicate that some known value is an input parameter to the word. If it is, then the stack checker can't infer any information for it." } ;
|
||||
|
||||
HELP: known
|
||||
{ $values { "value" number } { "known" "obj" } }
|
||||
{ $description "Fetches a previously registered literal value given an abstract number." } ;
|
||||
|
||||
HELP: known-values
|
||||
{ $var-description "A " { $link hashtable } " that maps from abstract values to literals and input parameters." }
|
||||
{ $see-also input-parameter } ;
|
||||
|
||||
HELP: literal-tuple
|
||||
{ $class-description "Represents a literal " { $link quotation } ". Its stack effect can be determined at compile-time." } ;
|
||||
|
||||
HELP: <literal>
|
||||
{ $values { "obj" "object" } { "value" literal-tuple } }
|
||||
{ $description "Creates a new literal tuple." } ;
|
||||
|
||||
HELP: <value>
|
||||
{ $values { "value" number } }
|
||||
{ $description "Outputs a series of monotonically increasing numbers. They are used to assign unique ids to nodes " { $slot "in-d" } " and " { $slot "out-d" } " slots." } ;
|
||||
|
||||
ARTICLE: "stack-checker.values" "Abstract stack checker values"
|
||||
"When the stack checker analyzes the data and retain stacks, it only uses integer values for convenience. They are then mapped to literals and input parameters using a " { $link hashtable } "."
|
||||
$nl
|
||||
"Reading and writing known value data:"
|
||||
{ $subsections
|
||||
copy-value
|
||||
copy-values
|
||||
known
|
||||
known-values
|
||||
make-known
|
||||
set-known
|
||||
} ;
|
||||
|
||||
ABOUT: "stack-checker.values"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
USING: kernel namespaces stack-checker.backend stack-checker.values
|
||||
tools.test ;
|
||||
IN: stack-checker.values.tests
|
||||
|
||||
{ H{ { 3 input-parameter } } } [
|
||||
init-known-values
|
||||
input-parameter 3 set-known
|
||||
known-values get
|
||||
] unit-test
|
|
@ -5,7 +5,6 @@ stack-checker.recursive-state stack-checker.errors
|
|||
quotations ;
|
||||
IN: stack-checker.values
|
||||
|
||||
! Values
|
||||
: <value> ( -- value ) \ <value> counter ;
|
||||
|
||||
SYMBOL: known-values
|
||||
|
@ -37,7 +36,6 @@ GENERIC: (input-value?) ( value -- ? )
|
|||
|
||||
GENERIC: (literal) ( known -- literal )
|
||||
|
||||
! Literal value
|
||||
TUPLE: literal-tuple < identity-tuple value recursion ;
|
||||
|
||||
: literal ( value -- literal ) known (literal) ;
|
||||
|
@ -58,7 +56,6 @@ M: literal-tuple (literal) ;
|
|||
[ [ [ value>> ] bi@ ] dip call ] [ drop nip recursion>> ] 3bi
|
||||
\ literal-tuple boa ; inline
|
||||
|
||||
! Result of curry
|
||||
TUPLE: curried obj quot ;
|
||||
|
||||
C: <curried> curried
|
||||
|
@ -72,7 +69,6 @@ M: curried (literal-value?) >curried< [ literal-value? ] both? ;
|
|||
|
||||
M: curried (literal) >curried< [ curry ] curried/composed-literal ;
|
||||
|
||||
! Result of compose
|
||||
TUPLE: composed quot1 quot2 ;
|
||||
|
||||
C: <composed> composed
|
||||
|
@ -87,7 +83,6 @@ M: composed (literal-value?) >composed< [ literal-value? ] both? ;
|
|||
|
||||
M: composed (literal) >composed< [ compose ] curried/composed-literal ;
|
||||
|
||||
! Input parameters
|
||||
SINGLETON: input-parameter
|
||||
|
||||
SYMBOL: current-word
|
||||
|
@ -135,4 +130,3 @@ M: curried known>callable
|
|||
prefix ;
|
||||
M: declared-effect known>callable
|
||||
known>> known>callable ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue