factor/core/inference/state/state.factor

48 lines
1.1 KiB
Factor
Raw Normal View History

2008-01-01 14:54:14 -05:00
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2008-02-25 04:38:37 -05:00
USING: assocs namespaces sequences kernel words ;
2008-01-01 14:54:14 -05:00
IN: inference.state
! Nesting state to solve recursion
SYMBOL: recursive-state
! Number of inputs current word expects from the stack
SYMBOL: d-in
! Compile-time data stack
SYMBOL: meta-d
: push-d meta-d get push ;
: pop-d meta-d get pop ;
: peek-d meta-d get peek ;
! Compile-time retain stack
SYMBOL: meta-r
: push-r meta-r get push ;
: pop-r meta-r get pop ;
: peek-r meta-r get peek ;
! Head of dataflow IR
SYMBOL: dataflow-graph
SYMBOL: current-node
! Words that the current dataflow IR depends on
SYMBOL: dependencies
2008-01-12 04:25:16 -05:00
: depends-on ( word how -- )
swap dependencies get dup [
2dup at +inlined+ eq? [ 3drop ] [ set-at ] if
] [ 3drop ] if ;
2008-01-01 14:54:14 -05:00
: computing-dependencies ( quot -- dependencies )
2008-01-12 04:25:16 -05:00
H{ } clone [ dependencies rot with-variable ] keep ;
2008-01-01 14:54:14 -05:00
inline
! Did the current control-flow path throw an error?
SYMBOL: terminated?
! Words we've inferred the stack effect of, for rollback
SYMBOL: recorded