2009-11-08 21:34:46 -05:00
|
|
|
! Copyright (C) 2009 Slava Pestov.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
|
USING: assocs classes.algebra fry kernel math namespaces
|
|
|
|
|
sequences words ;
|
|
|
|
|
IN: stack-checker.dependencies
|
|
|
|
|
|
|
|
|
|
! Words that the current quotation depends on
|
|
|
|
|
SYMBOL: dependencies
|
|
|
|
|
|
|
|
|
|
SYMBOLS: inlined-dependency flushed-dependency called-dependency ;
|
|
|
|
|
|
|
|
|
|
: index>= ( obj1 obj2 seq -- ? )
|
|
|
|
|
[ index ] curry bi@ >= ;
|
|
|
|
|
|
|
|
|
|
: dependency>= ( how1 how2 -- ? )
|
|
|
|
|
{ called-dependency flushed-dependency inlined-dependency }
|
|
|
|
|
index>= ;
|
|
|
|
|
|
|
|
|
|
: strongest-dependency ( how1 how2 -- how )
|
|
|
|
|
[ called-dependency or ] bi@ [ dependency>= ] most ;
|
|
|
|
|
|
|
|
|
|
: depends-on ( word how -- )
|
|
|
|
|
over primitive? [ 2drop ] [
|
|
|
|
|
dependencies get dup [
|
|
|
|
|
swap '[ _ strongest-dependency ] change-at
|
|
|
|
|
] [ 3drop ] if
|
|
|
|
|
] if ;
|
|
|
|
|
|
|
|
|
|
! Generic words that the current quotation depends on
|
|
|
|
|
SYMBOL: generic-dependencies
|
|
|
|
|
|
2010-01-20 16:25:53 -05:00
|
|
|
: ?class-or ( class class/f -- class' )
|
|
|
|
|
[ class-or ] when* ;
|
2009-11-08 21:34:46 -05:00
|
|
|
|
2010-01-20 16:25:53 -05:00
|
|
|
: depends-on-generic ( class generic -- )
|
2009-11-08 21:34:46 -05:00
|
|
|
generic-dependencies get dup
|
2010-01-20 16:25:53 -05:00
|
|
|
[ [ ?class-or ] change-at ] [ 3drop ] if ;
|
2010-01-29 02:15:19 -05:00
|
|
|
|
|
|
|
|
: without-dependencies ( quot -- )
|
|
|
|
|
[
|
|
|
|
|
dependencies off
|
|
|
|
|
generic-dependencies off
|
|
|
|
|
call
|
|
|
|
|
] with-scope ; inline
|