Never modify working code without re-testing ...
I inverted two lines in the code I gave.
Yves
Yves Jaradin wrote :
fun{Bind F Name Type}
NumArgs = {Width Type.2}
in if NumArgs == 0 then
proc {$ R}
Fun
in
{FFI.bind F Name Fun}
{FFI.call Fun Type nil R}
end
elseif NumArgs == 1 then
proc {$ A R}
Fun
in
{FFI.bind F Name Fun}
{FFI.call Fun Type [ A ] R}
end
else
Res in
thread
{{Compiler.assemble
{Flatten
[
lbl(1)
definition(x(0)
2
pid({VirtualString.toAtom Name} NumArgs+1 pos('' 1 0) nil
NumArgs+1)
unit
[g(0) g(1) g(2) g(3) g(4)])
allocateL3
move(x(0) y(0))
move(x(1) y(1))
move(x(NumArgs) y(2))
putConstant(nil x(0))
for P in NumArgs-1..0;~1 collect:C do
R=if P>1 then x(P) else y(P) end
in
{C [
move(x(0) x(1))
putList(x(0))
setValue(R)
setValue(x(1))
]}
end
move(x(0) y(0))
move(g(2) x(0))
move(g(3) x(1))
createVariableMove(y(1) x(2))
callGlobal(g(0) 6)
move(y(1) x(0))
move(g(4) x(1))
move(y(0) x(2))
move(y(2) x(3))
deAllocateL3
callGlobal(g(1) 9)
endDefinition(1)
lbl(2)
unify(x(0) g(5))
]
}
[FFI.bind FFI.call F Name Type Res]
default
$
_}}
end
{Wait Res}
Res
end
end
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users