I was coding earlier this week, but my brain was so foggy I ended up not
knowing what I was doing. After a few days break, I've cleaned up the
mess, which took hours.
Changes:
* Variables can be assigned
* Added new value types as placeholders
* Added 'compare' and 'assign' to the AST
* Added duplicate opcode
* Added functions to copy and free values
* Max name length is 255 chars
* Compound assigns are squeezed into one word
To be completed:
* Tests for this commit's changes
* Compound assignments
* Variable access
I was reworking bits of the containers to address issue #131, then
realized that the table's tests depended on a specific initial size. I'm
too buggered to finish it tonight, so I'll fix it tomorrow.
This wasn't an easy fix, as it was primarily the test pipelines that
were failing. I resorted to using forced pushes to run the CI, to try
and track down the problems.
The primary cause seems to be the differences in how each supported
platform handles file paths, specifically, slash vs. backslash.
I've also added gdb scripts to set up automated breakpoints, and to run
operations on them to check for issues - the 'gdb_init' files are mostly
empty for the time being.
commit a34b0ff5d407bbe7d70ff9504aa035ec6fbecb7c
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Fri Oct 18 11:45:40 2024 +1100
Restored the workflows
commit eb3d94f30d4dc4150139517f44cc874f2901124f
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Fri Oct 18 11:35:39 2024 +1100
I think the library path on macos is fixed
commit 964572b5e93c7cb464686f19ddbe3e9d315f391b
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Fri Oct 18 11:22:56 2024 +1100
I think the file paths are fixed
commit 1721f3da7252b4063f4347926e800ef4f7c9bf4c
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Thu Oct 17 15:57:28 2024 +1100
Added standalone tests
commit 90c783f4059d88f4a7bbaf18215a9b414f3ab66f
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Thu Oct 17 15:01:18 2024 +1100
Trying to fix the integration test pipeline
commit fccced1396568a55c1385e2f1b04fedf7c2585a5
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Wed Oct 16 00:31:39 2024 +1100
Workflow integration tests are not passing
commit 6b1e0d1e0f89291e89768bf6102f4f7ed4581496
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Tue Oct 15 20:07:20 2024 +1100
Fixed file paths in workflow
commit c0f1ec78fe79a5abb34c3e05308236cb18c23b97
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Tue Oct 15 19:46:14 2024 +1100
Moved example scripts into proper integration tests
Also adjusted makefiles to allow easy invoking of the tests.
Adjusted and updated CI to invoke tests correctly.
Fixed#141
Strings, due to their potentially large size, are stored outside of a
routine's code section, in the data section. To access the correct
string, you must read the jump index, then the real address from the
jump table - and extra layer of indirection will result in more flexible
data down the road, I hope.
Other changes include:
* Added string concat operator ..
* Added TOY_STRING_MAX_LENGTH
* Strings can't be created or concatenated longer than the max length
* The parser will display a warning if the bucket is too small for a
string at max length, but it will continue
* Added TOY_BUCKET_IDEAL to correspend with max string length
* The bucket now allocates an address that is 4-byte aligned
* Fixed missing entries in the parser rule table
* Corrected some failing TOY_BITNESS tests
To help with storing strings within tables, I've replaced the unused
'_padding' member of 'Toy_String' with 'cachedHash', which is set to
zero on string allocation.
The hash of a string isn't generated and stored until it's actually
needed, as the rope pattern means not every string needs a hash -
hopefully this will save unnecessarily wasted time.
When a hash of a string is needed, the hashing function first checks to
see if that string already has one, and if so, returns it. Again, less
time wasted.
When generating a new string hash, the hashing function takes the
string's type into account, as node-based strings first need their
contents assembled into a simple char buffer.
Other changes include:
* Changed 'TOY_VALUE_TO_*' to 'TOY_VALUE_FROM_*'
* Changed 'TOY_VALUE_IS_EQUAL' to 'TOY_VALUES_ARE_EQUAL'
* Added a missing '#pragma once' to 'toy_print.h'
The following structures are now more independant:
- Toy_Array
- Toy_Stack
- Toy_Bucket
- Toy_String
I reworked a lot of the memory allocation, so now there are more direct
calls to malloc() or realloc(), rather than relying on the macros from
toy_memory.h.
I've also split toy_memory into proper array and bucket files, because
it makes more sense this way, rather than having them both jammed into
one file. This means the eventual hashtable structure can also stand on
its own.
Toy_Array is a new wrapper around raw array pointers, and all of the
structures have their metadata embedded into their allocated memory now,
using variable length array members.
A lot of 'capacity' and 'count' variables were changed to 'size_t'
types, but this doesn't seem to be a problem anywhere.
If the workflow fails, then I'll leave it for tonight - I'm too tired,
and I don't want to overdo myself.
Strings are needed for the handling of identifiers in the key/value
variable storage, so I've got them working first. I used the rope
pattern, which seems to be quite an interesting approach.
I'll add comparison checks later.
Adjusted how buckets are handled in all tests, could've been an issue
down the line.
Added the build instructions to README.md.
At this point, only a minimal number of operations are working, and
after running any kind of source code, the 'result' is simply left on
the VM's stack. Still, it's awesome to see it reach this point.
I've expanded support to three major platforms:
- linux
- windows
- macos
The CI now runs the test suites for all of these, both under normal
conditions and under GDB (except for macos, which lacks GDB support).
TOY_BITNESS specifies the bit-width of the current platform, either 32
or 64. A value of -1 means the bit-width could not be determined. Some
tests will be disabled if the appropriate bit-width can't be determined,
and a warning is printed to stderr.
TOY_API has been tweaked, and is now dependant on different
preprocessor flags. It is defined as 'extern' on all supported
platforms except windows, which instead specifies DLL support. It
defaults to 'extern' if the platform can't be determined.
commit d0350998ecc80b8925a1962ceb2ab400da50be9d
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sun Sep 22 09:55:42 2024 +1000
Expanded GDB tests using matrix strategy
commit dc2addacc52830227ddcd0f35997c0e1668b579c
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sun Sep 22 09:05:42 2024 +1000
Reserved the yield keyword
commit f485c380f74a49092e0c5a41e599fbb06dbce235
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sat Sep 21 15:17:11 2024 +1000
Potential segfault fix
commit d8b19d21c92133feb071e631009a3cf99df0f068
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sat Sep 21 14:25:47 2024 +1000
Added testing on windows under GDB, read more
I'm hunting a segfault that only appears on windows, but I lack a
windows machine, so github's runners are all I have right now.
commit 8606db541fb5cbe91b16a39e9815fe4a27ba0c8a
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sat Sep 21 13:12:02 2024 +1000
DLL import/export macros tweaked for windows
TOY_EXPORT for making a DLL
TOY_IMPORT for using a DLL
Defaults to 'extern' if neither option is present
commit a6929666401953a5b3a93dfe83c9398e012beefc
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sat Sep 21 12:52:06 2024 +1000
Investigating bitness issue on windows
commit 8f615f735868a316e8d5a6a77ed899e72fd537f8
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sat Sep 21 12:32:55 2024 +1000
Adjusting bitness tests in test_ast.c
commit 61694f2183ac84ee7c53c855f2f6aa29f360f16c
Author: Kayne Ruse <kayneruse@gmail.com>
Date: Sat Sep 21 11:46:59 2024 +1000
Added experimental macOS CI job
* expand() will only touch the memory once
* fixed missing if-else cascade at toy_routine.c:90
* unary negate will not optimise numbers unless the '-' character is immediately prior
* fixed broken test for unary negation of groups
The tests are failing in a strange way, with the error message 'corrupted top size'. I don't know what it means, and it seems to be caused by a call to printf() within 'test_bytecode.c'. I need a break, as this is making me dizzy.
The parser now correctly produces a workable AST. I think I'll skip
over the optimizer, and begin on the compiler next session. The
optimizer will act directly on the AST, but it isn't totally necessary.
Other tools can also operate on the AST, such as for debugging - I'll
have to ask what kinds are out there.