compiler.codegen.fixup
compiler.utilities ;
FROM: namespaces => set ;
+FROM: compiler.errors => no-such-symbol ;
IN: compiler.codegen
SYMBOL: insn-counts
dll-path compiling-word get no-such-library drop
] if ;
-: stdcall-mangle ( params -- symbols )
+: decorated-symbol ( params -- symbols )
[ function>> ] [ parameters>> parameter-offsets drop number>string ] bi
- [ drop ] [ "@" glue ] [ "@" glue "_" prepend ] 2tri
- 3array ;
+ {
+ [ drop ]
+ [ "@" glue ]
+ [ "@" glue "_" prepend ]
+ [ "@" glue "@" prepend ]
+ } 2cleave
+ 4array ;
: alien-invoke-dlsym ( params -- symbols dll )
- [ dup abi>> stdcall = [ stdcall-mangle ] [ function>> ] if ]
+ [ dup abi>> callee-cleanup? [ decorated-symbol ] [ function>> ] if ]
[ library>> load-library ]
bi 2dup check-dlsym ;
[ abi>> mingw = os windows? not or ]
bi and ;
-: callee-cleanup? ( abi -- ? )
- { stdcall fastcall thiscall } member? ;
-
: stack-arg-size ( params -- n )
dup abi>> '[
alien-parameters flatten-value-types
UNION: abi stdcall thiscall fastcall cdecl mingw ;
+: callee-cleanup? ( abi -- ? )
+ { stdcall fastcall thiscall } member? ;
+
ERROR: alien-callback-error ;
: alien-callback ( return parameters abi quot -- alien )