From 67e24b1d2aecd885ec785f1f1e5f887931c00c27 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Apr 2010 18:10:25 -0500 Subject: [PATCH] compiler.codegen: need to do name decoration with fastcall as well --- basis/compiler/codegen/codegen.factor | 14 ++++++++++---- basis/cpu/x86/32/32.factor | 3 --- core/alien/alien.factor | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) mode change 100644 => 100755 core/alien/alien.factor diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index ffccf9f118..b16f471d11 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -18,6 +18,7 @@ compiler.cfg.builder compiler.codegen.fixup compiler.utilities ; FROM: namespaces => set ; +FROM: compiler.errors => no-such-symbol ; IN: compiler.codegen SYMBOL: insn-counts @@ -415,13 +416,18 @@ M: array dlsym-valid? '[ _ dlsym ] any? ; 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 ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 40c6bd40db..05c627fb99 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -315,9 +315,6 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) [ 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 diff --git a/core/alien/alien.factor b/core/alien/alien.factor old mode 100644 new mode 100755 index 27e326a557..d67e0a12b9 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -68,6 +68,9 @@ SINGLETONS: stdcall thiscall fastcall cdecl mingw ; 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 )