compiler.tree.propagation.recursive: better counter-class
							parent
							
								
									17b536c3a8
								
							
						
					
					
						commit
						097b40ce41
					
				| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
USING: compiler.tree compiler.tree.propagation.info
 | 
			
		||||
compiler.tree.propagation.nodes help.markup help.syntax sequences ;
 | 
			
		||||
USING: classes compiler.tree compiler.tree.propagation.info
 | 
			
		||||
compiler.tree.propagation.nodes help.markup help.syntax math.intervals
 | 
			
		||||
sequences ;
 | 
			
		||||
IN: compiler.tree.propagation.recursive
 | 
			
		||||
 | 
			
		||||
HELP: counter-class
 | 
			
		||||
{ $values { "interval" interval } { "class" class } { "class'" class } }
 | 
			
		||||
{ $description "The smallest class to use for a counter that iterates the given interval." } ;
 | 
			
		||||
 | 
			
		||||
HELP: recursive-phi-infos
 | 
			
		||||
{ $values { "node" #recursive } { "infos" sequence } }
 | 
			
		||||
{ $description "The sequence of " { $link value-info-state } " that is the input to the recursive block." } ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,22 @@
 | 
			
		|||
USING: accessors tools.test compiler.tree compiler.tree.builder
 | 
			
		||||
USING: accessors compiler.tree compiler.tree.builder
 | 
			
		||||
compiler.tree.optimizer compiler.tree.propagation.info
 | 
			
		||||
compiler.tree.propagation.recursive math.intervals kernel kernel.private
 | 
			
		||||
math literals layouts sequences ;
 | 
			
		||||
compiler.tree.propagation.recursive kernel kernel.private layouts
 | 
			
		||||
literals math math.intervals sequences sequences.private tools.test ;
 | 
			
		||||
IN: compiler.tree.propagation.recursive.tests
 | 
			
		||||
 | 
			
		||||
! counter-class
 | 
			
		||||
{
 | 
			
		||||
    array-capacity
 | 
			
		||||
    fixnum
 | 
			
		||||
    integer
 | 
			
		||||
    array-capacity
 | 
			
		||||
} [
 | 
			
		||||
    0 100 [a,b] fixnum counter-class
 | 
			
		||||
    -100 100 [a,b] fixnum counter-class
 | 
			
		||||
    0 100 [a,b] integer counter-class
 | 
			
		||||
    0 10 [a,b] array-capacity counter-class
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
! generalize-counter-interval
 | 
			
		||||
{ T{ interval f { 0 t } { 1/0. t } } } [
 | 
			
		||||
    T{ interval f { 1 t } { 1 t } }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,10 +20,8 @@ IN: compiler.tree.propagation.recursive
 | 
			
		|||
    [ latest-input-infos ] bi ;
 | 
			
		||||
 | 
			
		||||
: counter-class ( interval class -- class' )
 | 
			
		||||
    dup fixnum class<= [
 | 
			
		||||
        swap array-capacity-interval interval-subset?
 | 
			
		||||
        [ drop array-capacity ] when
 | 
			
		||||
    ] [ nip ] if ;
 | 
			
		||||
    dup fixnum class<= rot array-capacity-interval interval-subset? and
 | 
			
		||||
    [ drop array-capacity ] when ;
 | 
			
		||||
 | 
			
		||||
:: generalize-counter-interval ( interval initial-interval class -- interval' )
 | 
			
		||||
    interval class counter-class :> class
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue