mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-28 02:23:44 +03:00
[ racket ] Add library loading (#3049)
This commit is contained in:
parent
115c9e0889
commit
694b1650c8
@ -40,6 +40,12 @@
|
||||
* Non-recursive top-level constants are compiled to eagerly evaluated
|
||||
constants in Chez Scheme.
|
||||
|
||||
#### Racket
|
||||
|
||||
* FFI declarations can now specify which `require` to perform, i.e. which
|
||||
library to load before executing the FFI.
|
||||
The syntax is `scheme,racket:my-function,my-library`.
|
||||
|
||||
#### Node.js/Browser
|
||||
|
||||
* Generated JavaScript files now include a shebang when using the Node.js backend
|
||||
|
@ -280,6 +280,9 @@ useCC appdir fc ccs args ret
|
||||
Just ("scheme,racket", [sfn]) =>
|
||||
do let body = schemeCall fc sfn (map fst args) ret
|
||||
pure ("", body)
|
||||
Just ("scheme,racket", [sfn, racketlib]) =>
|
||||
do let body = schemeCall fc sfn (map fst args) ret
|
||||
pure (fromString $ "(require " ++ racketlib ++ ")", body)
|
||||
Just ("scheme", [sfn]) =>
|
||||
do let body = schemeCall fc sfn (map fst args) ret
|
||||
pure ("", body)
|
||||
|
@ -339,6 +339,7 @@ racketTests = MkTestPool "Racket backend" [] (Just Racket)
|
||||
, "conditions005"
|
||||
-- , "conditions006"
|
||||
-- , "conditions007"
|
||||
, "ffi001"
|
||||
]
|
||||
|
||||
nodeTests : TestPool
|
||||
|
8
tests/racket/ffi001/RacketLib.idr
Normal file
8
tests/racket/ffi001/RacketLib.idr
Normal file
@ -0,0 +1,8 @@
|
||||
%foreign "scheme,racket:(lambda (x) (if (port-number? x) 1 0)),racket/tcp"
|
||||
isPortNumber : Int -> Bool
|
||||
|
||||
main : IO ()
|
||||
main = do
|
||||
putStrLn $ "0 is port: " ++ show (isPortNumber 0)
|
||||
putStrLn $ "1 is port: " ++ show (isPortNumber 1)
|
||||
putStrLn $ "2 is port: " ++ show (isPortNumber 2)
|
3
tests/racket/ffi001/expected
Normal file
3
tests/racket/ffi001/expected
Normal file
@ -0,0 +1,3 @@
|
||||
0 is port: False
|
||||
1 is port: True
|
||||
2 is port: True
|
1
tests/racket/ffi001/run
Normal file
1
tests/racket/ffi001/run
Normal file
@ -0,0 +1 @@
|
||||
$1 --no-banner --no-color --console-width 0 --cg racket RacketLib.idr --exec main
|
Loading…
Reference in New Issue
Block a user