USING: alien.c-types classes.struct compiler.cfg.builder.alien.boxing
-compiler.cfg.instructions compiler.test cpu.architecture kernel make
-system tools.test ;
+compiler.cfg.instructions compiler.cfg.registers compiler.test
+cpu.architecture kernel make system tools.test ;
IN: compiler.cfg.builder.alien.boxing.tests
STRUCT: some-struct
int base-type flatten-c-type
] unit-test
-cpu x86.64? [
+cpu x86.32?
+{
+ {
+ { int-rep t f }
+ { int-rep t f }
+ { int-rep t f }
+ { int-rep t f }
+ }
+} {
{
- { { int-rep f f } { int-rep f f } }
- } [
- some-struct base-type base-type flatten-c-type
- ] unit-test
-] when
+ { int-rep f f }
+ { int-rep f f }
+ }
+} ? [
+ some-struct base-type base-type flatten-c-type
+] unit-test
! unbox
+cpu x86.32?
{
+ { 1 }
+ { { int-rep f f } }
+ {
+ T{ ##unbox
+ { dst 1 }
+ { src 20 }
+ { unboxer "to_fixnum" }
+ { rep int-rep }
+ }
+ }
+} {
{ 20 }
{ { int-rep f f } }
-} [
- 20 int base-type unbox
+ { }
+} ? [
+ reset-vreg-counter [ 20 int base-type unbox ] { } make
] unit-test
-cpu x86.64? [
+cpu x86.32?
+{
+ { 2 3 4 5 }
{
- { 2 3 }
- { { int-rep f f } { int-rep f f } }
- V{
- T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
- T{ ##load-memory-imm
- { dst 2 }
- { base 1 }
- { offset 0 }
- { rep int-rep }
- }
- T{ ##load-memory-imm
- { dst 3 }
- { base 1 }
- { offset 8 }
- { rep int-rep }
- }
- }
- } [
- [ 20 some-struct base-type unbox ] V{ } make
- ] cfg-unit-test
-] when
+ { int-rep t f }
+ { int-rep t f }
+ { int-rep t f }
+ { int-rep t f }
+ }
+ {
+ T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
+ T{ ##load-memory-imm
+ { dst 2 }
+ { base 1 }
+ { offset 0 }
+ { rep int-rep }
+ }
+ T{ ##load-memory-imm
+ { dst 3 }
+ { base 1 }
+ { offset 4 }
+ { rep int-rep }
+ }
+ T{ ##load-memory-imm
+ { dst 4 }
+ { base 1 }
+ { offset 8 }
+ { rep int-rep }
+ }
+ T{ ##load-memory-imm
+ { dst 5 }
+ { base 1 }
+ { offset 12 }
+ { rep int-rep }
+ }
+ }
+} {
+ { 2 3 }
+ { { int-rep f f } { int-rep f f } }
+ {
+ T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
+ T{ ##load-memory-imm
+ { dst 2 }
+ { base 1 }
+ { offset 0 }
+ { rep int-rep }
+ }
+ T{ ##load-memory-imm
+ { dst 3 }
+ { base 1 }
+ { offset 8 }
+ { rep int-rep }
+ }
+ }
+} ? [
+ [ 20 some-struct base-type unbox ] { } make
+] cfg-unit-test
! unbox-parameter
{
{ 1 }
{ { int-rep f f } }
- V{ T{ ##unbox-any-c-ptr { dst 1 } { src 77 } } }
+ { T{ ##unbox-any-c-ptr { dst 1 } { src 77 } } }
} [
- [ 77 c-string base-type unbox-parameter ] V{ } make
+ [ 77 c-string base-type unbox-parameter ] { } make
] cfg-unit-test
! unboxing is only needed on 32bit archs
{
{ 1 }
{ { int-rep f f } }
- V{
+ {
T{ ##unbox
{ dst 1 }
{ src 77 }
{ rep int-rep }
}
}
-}
-{ { 77 } { { int-rep f f } } V{ } } ? [
- [ 77 int base-type unbox-parameter ] V{ } make
+} {
+ { 77 } { { int-rep f f } } { }
+} ? [
+ [ 77 int base-type unbox-parameter ] { } make
] cfg-unit-test
-USING: accessors alien.c-types alien.private kernel kernel.private
-math namespaces stack-checker.alien stack-checker.state
-stack-checker.values threads.private tools.test ;
+USING: accessors alien alien.c-types alien.private kernel
+kernel.private literals math namespaces stack-checker.alien
+stack-checker.state stack-checker.values system threads.private
+tools.test ;
IN: stack-checker.alien.tests
! alien-inputs/outputs
] unit-test
! wrap-callback-quot
-{
+${
+ cpu x86.32?
+ [
+ [
+ { integer integer } declare [ [ ] dip ] dip
+ "hello" >integer
+ ] [
+ dup current-callback eq?
+ [ drop ] [ wait-for-callback ] if
+ ] do-callback
+ ]
[
[
{ fixnum fixnum } declare [ [ ] dip ] dip
dup current-callback eq?
[ drop ] [ wait-for-callback ] if
] do-callback
- ]
+ ] ?
} [
- alien-node-params new
- int >>return { int int } >>parameters
+ int { int int } cdecl alien-node-params boa
[ "hello" ] wrap-callback-quot
] unit-test