Commit Graph

66 Commits

Author SHA1 Message Date
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