Commit Graph

27 Commits

Author SHA1 Message Date
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
Edwin Brady
11560a5c82 Make 'with' work in where blocks
Need to set up nested names appropriately for the with function so that
the environment gets passed through correctly, and use abstractEnvType
to get the type of the with function rather than simply binding the
environment as is.
2019-07-08 23:05:04 +02:00
Edwin Brady
4ab543b83d A bit more library support, for Chapter 9
Also a tweak to errors when compiling to scheme, so that it properly
reports an error then quits if it's supposed to crash.
2019-07-05 17:24:15 +01:00
Edwin Brady
0f56c239c2 Parse pattern matching lambda
This is now enough for Chapter 5 tests to work
2019-07-03 13:04:25 +01:00
Edwin Brady
0fa61f7c4f Add compiler support files 2019-06-02 17:31:59 +01:00