Commit Graph

54 Commits

Author SHA1 Message Date
Edwin Brady
560449e087 Check bounds on substring
Fixes #379
2020-05-16 13:50:37 +01:00
Edwin Brady
263d5fa3a1 More system functions
exit, and getting the whole environment
2020-05-16 13:02:48 +01:00
Edwin Brady
dc67515611 Fix and test directory code 2020-05-14 12:40:48 +01:00
Edwin Brady
68081ed86c Some scheme generation fixes
In racket, importing date and srfi/19 fails. Also some minor edits to
gambit support code.
2020-05-13 12:41:38 +01:00
Edwin Brady
18dff43d2b Move Concurrency.Raw to new FFI 2020-05-13 12:18:21 +01:00
Edwin Brady
1b36dd99b1 Move putChar, getChar etc primitives to C
Back ends can still shortcut these and use their own primitives, but
doing things this way gives consistent behaviour between the simple IO
primitives and file IO, and allow us to use stdin/stdout consistently
(e.g. to flush stdout).
This also fixes the behaviour of 'replWith' to be consistent with the
Idris 1 version.
2020-05-13 11:09:05 +01:00
Edwin Brady
2d1d7be949 Move directory code to C
...and remove the scheme support for it on the way
2020-05-13 00:09:52 +01:00
Edwin Brady
cadd7e1322 Move more support code to C
System mostly calls C now, except for getting command line arguments,
which may be too back end dependent so maybe we should think of another
approach here later.
2020-05-12 23:31:39 +01:00
Edwin Brady
3ab68fb7c8 Add some more file operations
I've also added some windows support headers (taken straight from the
rts/Idris 1) but I have no way to test, and the Makefile doesn't build
them. Please can someone who is familiar with windows fix this? Thanks!
2020-05-12 22:49:58 +01:00
Edwin Brady
38e43f2c17 Move file management to C support library
This removes the need for some external primitives, and allows the
details to be shared between all the backends (plus we don't have to do
things a certain way just because Scheme chooses to)
2020-05-12 22:35:14 +01:00
G. Allais
f72f91c67a
[ fix ] build by installing support before tests (#369) 2020-05-12 15:23:42 +01:00
Edwin Brady
7adb4d3342 Move buffer API to C
It's slightly different wrt to file reading and writing, and now
requires the created buffer to be explicitly freed (since unlike Idris 1
the run time can't be told to manage C values) but this makes the buffer
code more portable by not requiring it to run via scheme.
Performance appears more or less the same as before.
2020-05-11 18:10:08 +01:00
Edwin Brady
6681131957 Make a start on C support code
It would be nice to have some common routines that all back ends that
can talk to C can use, rather than relying on Scheme for standard
library code.
2020-05-11 18:10:08 +01:00
Edwin Brady
15c6a0d137 Remove chicken back end
(Which was commented out anyway)
Three scheme back ends is enough to maintain, and Gambit does the same
job as chicken (fast startup of the interpreter, generating via C) but
seems to deal with the code Idris generates better.
2020-05-09 13:57:27 +01:00
Edwin Brady
158b6fb4dc
Merge pull request #347 from ziman/fix-racket
Fix order of arguments in write-string for Racket
2020-05-09 13:10:22 +01:00
Edwin Brady
5a81884d2b
Merge branch 'master' into system.clock 2020-05-09 12:57:10 +01:00
Edwin Brady
600412f9f3
Merge pull request #354 from rgrover/system.random
Add System.Random
2020-05-09 12:54:23 +01:00
Rohit Grover
edb063eb50 Add System.Clock to fetch current time for various clock types. 2020-05-09 17:21:23 +12:00
Rohit Grover
a190408aa1 add srand to allow setting the random seed 2020-05-07 21:41:04 +12:00
Abdelhakim Qbaich
1fb84ca255 Further tweaks to Gambit support file 2020-05-07 03:11:41 -04:00
Rohit Grover
7cfb3419cb Add System.Random 2020-05-06 11:26:58 +12:00
Abdelhakim Qbaich
21ef0ddb43 Improving support file of Gambit 2020-05-03 17:37:39 -04:00
Matus Tejiscak
50c9531efd Fix order of arguments in write-string for Racket. 2020-05-02 19:21:02 +02:00
Abdelhakim Qbaich
3f1a1b4e9b Macro for FFI with C structs on Gambit 2020-05-01 23:27:45 -04:00
Abdelhakim Qbaich
3f1e88814f Vector related fixes for Gambit 2020-05-01 23:27:45 -04:00
Abdelhakim Qbaich
19e78ca3ef Extracting errno for an os-exception in Gambit 2020-05-01 23:27:45 -04:00
Abdelhakim Qbaich
0182c7147a Support library for Gambit Scheme 2020-05-01 23:27:45 -04:00
Kamil Shakirov
cce312bb15 Check for EOF when reading from an input port
1) Check for EOF when reading from an input port (Chez backend).

2) Fix `getLine` to read and return a string without the trailing newline.
2020-04-24 12:32:58 +06:00
Edwin Brady
71cae356e2
Merge pull request #281 from ziman/fix-cast-double-int
Fix cast to integral types
2020-04-21 11:24:09 +01:00
Edwin Brady
8fccd5f2a3 Properly erase constructor arguments
That is, really erase the argument position rather than just putting
'erased there. It doesn't make a huge difference to the generated scheme
performance, but since we can always do this for constructors, we might
as well.
2020-04-19 19:43:51 +01:00
Matus Tejiscak
41ef3fdd2a Don't use exact-floor in cast-string-int. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
c3b6b130fd Also fix up cast-string-int. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
7a3ebd9a2f Use exact-floor. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
18962eeacf Fix casting in integral division. 2020-04-14 22:44:32 +02:00
Matus Tejiscak
cf177f95a4 Fix conversion from Double to integral types. 2020-04-14 22:44:32 +02:00
Edwin Brady
31a2c46383
Merge pull request #250 from ziman/fix-cast
Fix runtime error in `the Int (cast "")`
2020-03-31 18:17:23 +01:00
Edwin Brady
b0e55b53eb A bit more library support 2020-03-30 13:06:59 +01:00
Matus Tejiscak
16e027218b Use cond and equal? in destroy-prefix. 2020-03-29 22:26:42 +02:00
Matus Tejiscak
2cadbd2cd1 Fix runtime error in (the Int (cast "")). 2020-03-29 20:33:46 +02:00
Edwin Brady
2938e86421 Ints in buffers are 32 bit
...for consistency with Idris 1 (probably to be revisited later). So,
when working via the scheme primitives, we need to read/write 32 bits.
2020-03-27 20:54:39 +00:00
Kamil Shakirov
c8c0c5fb49 Add getChar, putChar and putCharLn to prelude 2020-03-05 14:55:20 +06:00
Edwin Brady
66d67c84cc Add directory reading functions
and support for Chez and Racket
2020-02-23 12:17:36 +00:00
Edwin Brady
8227859760 Add System.Directory
Currently supports creating and changing directories. Support for
reading contents of directories still missing.
2020-02-01 18:43:28 +00:00
Edwin Brady
2465e5a149 Some buffer updates
Initialising buffers from files, error checking on creation, resizing.
2020-01-31 16:49:31 +00:00
Edwin Brady
e69c1529d9 Bitwise operators 2020-01-31 16:25:19 +00:00
Edwin Brady
854e39936e Some Data.Buffer bits
Need to know length of strings in bytes sometimes, not just characters,
to check we have enough space.
Also add copyData
2020-01-30 18:36:59 +00:00
Edwin Brady
78e44a4353 Reading/writing buffers can fail
So, make them return and Either and wrap the scheme definitions in an
exception handler that returns an error code on failure
2019-09-28 18:33:46 +01:00
Edwin Brady
bf69b89b0d Support for buffers and file erros in Racket CG 2019-09-28 18:10:14 +01:00
Edwin Brady
bb246a072a Experimenting with a new FFI
Functions can be declared as %foreign with a list of calling
conventions, which a backend will work through until it finds one it can
understand. Currently implemented only in Chez backend. If this works
out, I'll implement it for Racket too, and remove the old primitive
functions.

There's a bit more boiler plate here than before, but it has the benefit
of being more extensible and portable between different back ends.

Some examples, pending proper documentation:

%foreign "C:puts,libc" "scheme:display"
putline : String -> PrimIO ()

%foreign "C:exp, libm.so.6, math.h"
fexp : Double -> Double

%foreign "C:initscr, ncurses_glue.so, ncurses.h"
prim_initscr : PrimIO ()
2019-09-02 17:10:48 +01:00
Edwin Brady
2bb496f74b Chapter 11 examples now working 2019-07-08 23:46:20 +02:00