29 lines
908 B
Factor
29 lines
908 B
Factor
! Copyright (C) 2008, 2010 Slava Pestov.
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
USING: accessors kernel namespaces make math sequences layouts
|
|
alien.c-types cpu.architecture ;
|
|
IN: compiler.alien
|
|
|
|
: large-struct? ( type -- ? )
|
|
dup c-struct? [ return-struct-in-registers? not ] [ drop f ] if ;
|
|
|
|
: alien-parameters ( params -- seq )
|
|
dup parameters>>
|
|
swap return>> large-struct? [ struct-return-pointer-type prefix ] when ;
|
|
|
|
: alien-return ( params -- type )
|
|
return>> dup large-struct? [ drop void ] when ;
|
|
|
|
: c-type-stack-align ( type -- align )
|
|
dup c-type-stack-align? [ c-type-align ] [ drop cell ] if ;
|
|
|
|
: parameter-align ( n type -- n delta )
|
|
[ c-type-stack-align align dup ] [ drop ] 2bi - ;
|
|
|
|
: parameter-offsets ( types -- total offsets )
|
|
[
|
|
0 [
|
|
[ parameter-align drop dup , ] keep stack-size +
|
|
] reduce cell align
|
|
] { } make ;
|