<PRIVATE
-: (local-allot) ( size align -- alien ) local-allocation-error ;
+: local-allot ( size align -- alien ) local-allocation-error ;
-: (cleanup-allot) ( -- )
+: cleanup-allot ( -- )
! Inhibit TCO in order for the last word in the quotation
! to still be able to access scope-allocated data.
;
-MACRO: (simple-local-allot) ( c-type -- quot )
+MACRO: simple-local-allot-quot ( c-type -- quot )
[ add-depends-on-c-type ]
- [ dup '[ _ heap-size _ c-type-align (local-allot) ] ] bi ;
+ [ dup '[ _ heap-size _ c-type-align local-allot ] ] bi ;
-: [hairy-local-allot] ( c-type initial -- quot )
- over '[ _ (simple-local-allot) _ over 0 _ set-alien-value ] ;
+: hairy-local-allot-quot ( c-type initial -- quot )
+ over '[ _ simple-local-allot-quot _ over 0 _ set-alien-value ] ;
: hairy-local-allot? ( obj -- ? )
{
[ second initial: eq? ]
} 1&& ;
-MACRO: (hairy-local-allot) ( obj -- quot )
- dup hairy-local-allot?
- [ first3 nip [hairy-local-allot] ]
- [ '[ _ (simple-local-allot) ] ]
- if ;
+MACRO: hairy-local-allot ( obj -- quot )
+ dup hairy-local-allot? [
+ first3 nip hairy-local-allot-quot
+ ] [
+ '[ _ simple-local-allot-quot ]
+ ] if ;
-MACRO: (local-allots) ( c-types -- quot )
- [ '[ _ (hairy-local-allot) ] ] map [ ] join ;
+MACRO: local-allots ( c-types -- quot )
+ [ '[ _ hairy-local-allot ] ] map [ ] join ;
MACRO: box-values ( c-types -- quot )
[ c-type-boxer-quot ] map '[ _ spread ] ;
PRIVATE>
: with-scoped-allocation ( c-types quot -- )
- [ [ (local-allots) ] [ box-values ] bi ] dip call
- (cleanup-allot) ; inline
+ [ [ local-allots ] [ box-values ] bi ] dip call
+ cleanup-allot ; inline
: with-out-parameters ( c-types quot -- values... )
- [ drop (local-allots) ] [ swap out-parameters ] 2bi
- (cleanup-allot) ; inline
+ [ drop local-allots ] [ swap out-parameters ] 2bi
+ cleanup-allot ; inline
GENERIC: binary-zero? ( value -- ? )
{ byte-arrays:<byte-array> [ emit-<byte-array> ] }
{ byte-arrays:(byte-array) [ emit-(byte-array) ] }
{ kernel:<wrapper> [ emit-simple-allot ] }
- { alien.data.private:(local-allot) [ emit-local-allot ] }
- { alien.data.private:(cleanup-allot) [ emit-cleanup-allot ] }
+ { alien.data.private:local-allot [ emit-local-allot ] }
+ { alien.data.private:cleanup-allot [ emit-cleanup-allot ] }
{ alien:<displaced-alien> [ emit-<displaced-alien> ] }
{ alien.accessors:alien-unsigned-1 [ int-rep alien.c-types:uchar emit-load-memory ] }
{ alien.accessors:set-alien-unsigned-1 [ int-rep alien.c-types:uchar emit-store-memory ] }