Commit Graph

6 Commits

Author SHA1 Message Date
Kayne Ruse
436bd3ffca Added silent cmd args
Fixed #145
2024-11-10 10:27:50 +11:00
Kayne Ruse
14653a303f Added 'Toy_String' to 'Toy_Value' structure, read more
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'
2024-10-07 17:35:31 +11:00
Kayne Ruse
d19a90f9bd Added CONTRIBUTING.md
Also renamed 'handles' throughout the project for consistency.

Some meta files also had their file extensions added.
2024-10-05 12:17:27 +10:00
Kayne Ruse
7b453bc35f Reworked generic structures, read more
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.
2024-10-01 20:38:06 +10:00
Kayne Ruse
b00a6838be Wrote Toy_Parser with minimal features, tests missing
It's too late at night, so I'm packing this up with only a dummy warning
message for the tests. I'll keep going tomorrow, hopefully.
2024-09-12 20:53:34 +10:00
Kayne Ruse
5fd933a15e Implemented AST, ensured bucket memory worked 2024-09-10 20:25:01 +10:00