52 Commits

Author SHA1 Message Date
Aryadev Chavali
88c9d01677 stream: Copy on stream_init_string
Just safer!
2025-10-19 23:04:40 +01:00
Aryadev Chavali
66c5134eb5 Remove impl folder 2025-10-19 23:04:04 +01:00
Aryadev Chavali
913b34588f build: simplify looking for library files 2025-10-19 22:25:24 +01:00
Aryadev Chavali
10c391367d build: Add some more warning flags for compilation-based-refactoring 2025-10-19 22:25:13 +01:00
Aryadev Chavali
cbfcf24ca2 stream: Introduce PIPE type
Main reason to have this at all is to make char-by-char reading
feasible.  This occurs at `stream_chunk`, and previously if we passed
in STDIN for `stream_init_file`, STDIN will only terminate once
STREAM_DEFAULT_CHUNK number of characters have been fed into the pipe.

This isn't desirable for STDIN (we really want to read char-by-char
for expressions), nor would it necessarily be desirable in network
applications.  So any stream marked STREAM_TYPE_PIPE will only chunk
character-by-character rather than genuine chunks.
2025-10-19 22:25:10 +01:00
Aryadev Chavali
030a289497 Some changes to how streams work, clean up alisp.org 2025-09-01 21:47:25 +01:00
Aryadev Chavali
1aa01d2a89 Merge remote-tracking branch 'origin/master' 2025-09-01 21:45:18 +01:00
Aryadev Chavali
700c3b1d1b Move implementation files into their own folder
main.c and test.c generate binary executables so they can stay in the
main folder, but the rest can go into their own dedicated folder to
make it look nicer
2025-09-01 21:26:01 +01:00
Aryadev Chavali
a9b08d3a11 Add printer for SV's that provides debug information 2025-08-29 20:04:35 +01:00
Aryadev Chavali
d62a11bb35 Modify main.c to better test stream 2025-08-29 20:04:21 +01:00
Aryadev Chavali
4d01a66401 Read an initial chunk on initialising a stream 2025-08-29 20:04:00 +01:00
Aryadev Chavali
fadbbd8927 make eoc also check feof on STREAM_TYPE_FILE 2025-08-29 20:03:43 +01:00
Aryadev Chavali
b403368d11 More tests 2025-08-29 14:53:34 +01:00
Aryadev Chavali
7595c46f5c Fix bug where chunking overwrites previously cached results 2025-08-29 14:53:18 +01:00
Aryadev Chavali
73736cf77c New example text and another test 2025-08-29 08:42:18 +01:00
Aryadev Chavali
d73380035c Fixed some more issues with streams (stdin/pipe based)
substr didn't work properly, nor did seek.  Just use the same
principle as stream_next
2025-08-29 08:42:03 +01:00
Aryadev Chavali
29d2453288 Cleaned up bugs with stream implementation
Principle was that we may have read all the content from the
underlying pipe (s.t. it set the EoF flag) but we haven't actually
iterated the content.
2025-08-29 08:28:32 +01:00
Aryadev Chavali
cc56a2ee2b Still got some failures, but a basic stream implementation
Need to fix what's going on with the example in main.c using stdin.
2025-08-28 22:55:41 +01:00
Aryadev Chavali
66c6400731 Made a load of tasks for a reader system, also task for BigIntegers 2025-08-22 00:29:12 +01:00
Aryadev Chavali
bbb405fca9 Refactor testing system, and add more tests
Couple macros to make printing nicer, use assertions instead to fail
if a test doesn't work.
2025-08-21 23:21:15 +01:00
Aryadev Chavali
49a3302fd6 Split out tests into its own file
Also adjust the build system to do some more (cleaning, building,
testing, running).
2025-08-21 22:02:23 +01:00
Aryadev Chavali
89c77a796d Add the ability to run the executable after building it in build.sh 2025-08-21 21:57:10 +01:00
Aryadev Chavali
0da524f5a8 Clean up tests a bit 2025-08-21 21:54:22 +01:00
Aryadev Chavali
85b83d7a20 Small optimisation: don't initialise a symbol table immediately on init
Why?  This way, until we use symbols, the system doesn't generate the
table and thus grow the memory usage by a couple kb.
2025-08-21 21:53:09 +01:00
Aryadev Chavali
ed37f7cd80 cons_test written 2025-08-21 21:27:01 +01:00
Aryadev Chavali
29b18bc1de Finish value constructors TODO, start container constructors TODO 2025-08-21 14:56:24 +01:00
Aryadev Chavali
0f68afd9a0 Make nicer primitive functions for car/cdr
If it isn't a CONS, we return NIL instead of failing.  This way, we
can use it in our general iteration functions.  Eventually the actual
runtime would use this as well.  The macros are mostly for internal
use to do assignment etc.
2025-08-21 14:55:54 +01:00
Aryadev Chavali
742f19886c Designed tests for make_int and intern with their destructors 2025-08-21 08:35:32 +01:00
Aryadev Chavali
e9eaba12d1 Fix issues with buffer overflow when printing products of sv_copy
Happens because we have no null terminator on the string - rookie
mistake.
2025-08-21 08:34:37 +01:00
Aryadev Chavali
7853f637c0 Some more notes 2025-08-21 00:30:07 +01:00
Aryadev Chavali
5ac3cbe6c2 Made an "issue tracker" and note holder 2025-08-21 00:07:06 +01:00
Aryadev Chavali
59946c8831 Made some tests to go through 2025-08-21 00:06:57 +01:00
Aryadev Chavali
d2bb858144 Made a little test case for vectors 2025-08-20 23:39:01 +01:00
Aryadev Chavali
847eb1a69b Refactor vectors to SBO, removing inlined entirely.
Avoid 2 levels of indirection, and having to allocate twice for small
payloads, by having an inlined array on the vector directly!
Beautiful and simple.

Required a bit of refactoring around the board, but overall the result
makes me feel happier.
2025-08-20 23:37:08 +01:00
Aryadev Chavali
13142dc7f3 refactor lisp runtime to use vec_t* instead of ivec_t*
bit nicer to look at, should have about the same painful performance
hit anyway.
2025-08-20 22:43:23 +01:00
Aryadev Chavali
6e2db6825d Stable vector implementation
Stable vectors will be used in the lisp runtime to implement actual
vectors, instead of using the disgusting lvec trick.  This way we at
least can get attributes about the vector through one pointer hop.
2025-08-20 22:33:40 +01:00
Aryadev Chavali
2369185b26 remove parameter names in header 2025-08-20 22:33:31 +01:00
Aryadev Chavali
e1294a28cd ivec_ensure_remaining -> ivec_ensure_free 2025-08-20 22:32:45 +01:00
Aryadev Chavali
55293ae396 vec -> ivec
I'm going to implement a normal stable vector instead of an inline
vector so we have both options for use.  I think that's smarter than
just sticking to one.
2025-08-20 22:19:14 +01:00
Aryadev Chavali
df558da7e1 Use sv_t instead of raw char*
We're storing them as sv_t's anyway, we're fucked with regards to
indirection.  Thus, let's be nice to ourselves, and deal with the
structures.  We get the size of the structure for free anyway!
2025-08-20 21:50:58 +01:00
Aryadev Chavali
643896e2c8 rename base.h -> alisp.h
Makes more sense when you think about including it as an external
library
2025-08-20 21:24:07 +01:00
Aryadev Chavali
3074ba5bab Constructors and context -> sys
We can register memory we've allocated onto the heap into a ~sys_t~
instance for examination (read: garbage collection) later.  We can
also add items to the symbol table it has internally.
2025-08-20 21:12:46 +01:00
Aryadev Chavali
99396b0533 README 2025-08-20 00:10:34 +01:00
Aryadev Chavali
0d6b0de88d Basic template for a system context and constructors 2025-08-20 00:00:33 +01:00
Aryadev Chavali
f8c2ec86ae Test for tagging integers 2025-08-19 23:22:12 +01:00
Aryadev Chavali
779c4b8305 Conses and Vectors for my tagging scheme
Unfortunately, due to how vectors are implemented, pointers to them
are unstable.  We need to box them one more time (therefore adding a
level of indirection) in order to stabilise them.  This is annoying
but currently necessary.

Even if we implemented vectors as {u64, u64, ptr} instead of {u64,
u64, bytes...}, we'd still have the same problem at access - two
levels of indirection.  I guess size and capacity checks would be one
level of indirection which is nice at least, but we're already screwed
at the point of doing lookup either way.
2025-08-19 23:21:41 +01:00
Aryadev Chavali
7ac2a80b11 Pointer tagging!
Copied from oats, just the basics required for tagging integers or
symbols.
2025-08-19 23:08:35 +01:00
Aryadev Chavali
6dfe3e72a1 Make sym_table_find return the c-string in question directly
I think we fall into a few traps if we return an sv_t directly.  Think
intent is clearer by returning the c-string directly.
2025-08-19 23:02:07 +01:00
Aryadev Chavali
e7f4b0440c Add sanitisers to build 2025-08-19 22:55:20 +01:00
Aryadev Chavali
78aa7d6fb3 Separate out implementation to make looking at code files easier 2025-08-19 22:53:19 +01:00