-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs sequences kernel combinators make math
 math.order math.ranges system namespaces locals layouts words

M: ppc %set-alien-double -rot STFD ;

: load-zone-ptr ( reg -- )
    "nursery" %load-vm-field-addr ;

: load-allot-ptr ( nursery-ptr allot-ptr -- )
    [ drop load-zone-ptr ] [ swap 0 LWZ ] 2bi ;

    "from_value_struct" f %alien-invoke ;

M:: ppc %restore-context ( temp1 temp2 -- )
    temp1 "ctx" %vm-field
    temp2 1 stack-frame get total-size>> ADDI
    temp2 temp1 "callstack-bottom" context-field-offset STW
    ds-reg temp1 "datastack" context-field-offset LWZ
    rs-reg temp1 "retainstack" context-field-offset LWZ ;

M:: ppc %save-context ( temp1 temp2 -- )
    temp1 "ctx" %vm-field-ptr
    1 temp1 "callstack-bottom" context-field-offset STW
    ds-reg temp1 "datastack" context-field-offset STW
    rs-reg temp1 "retainstack" context-field-offset STW ;

M: ppc %alien-invoke ( symbol dll -- )
    [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
