Added simple assignment, read more

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
This commit is contained in:
2024-10-25 22:48:24 +11:00
parent 5b17c5e1e9
commit 3148a56ce0
17 changed files with 653 additions and 182 deletions

View File

@@ -122,7 +122,7 @@ int test_bytecode_from_source(Toy_Bucket** bucketHandle) {
*(int*)(offset + bc.ptr + 36) != 2 ||
*((unsigned char*)(offset + bc.ptr + 40)) != TOY_OPCODE_ADD ||
*((unsigned char*)(offset + bc.ptr + 41)) != 0 ||
*((unsigned char*)(offset + bc.ptr + 41)) != TOY_OPCODE_PASS ||
*((unsigned char*)(offset + bc.ptr + 42)) != 0 ||
*((unsigned char*)(offset + bc.ptr + 43)) != 0 ||
@@ -140,13 +140,13 @@ int test_bytecode_from_source(Toy_Bucket** bucketHandle) {
*(int*)(offset + bc.ptr + 56) != 4 ||
*((unsigned char*)(offset + bc.ptr + 60)) != TOY_OPCODE_ADD ||
*((unsigned char*)(offset + bc.ptr + 61)) != 0 ||
*((unsigned char*)(offset + bc.ptr + 61)) != TOY_OPCODE_PASS ||
*((unsigned char*)(offset + bc.ptr + 62)) != 0 ||
*((unsigned char*)(offset + bc.ptr + 63)) != 0 ||
//multiply the two values
*((unsigned char*)(offset + bc.ptr + 64)) != TOY_OPCODE_MULTIPLY ||
*((unsigned char*)(offset + bc.ptr + 65)) != 0 ||
*((unsigned char*)(offset + bc.ptr + 65)) != TOY_OPCODE_PASS ||
*((unsigned char*)(offset + bc.ptr + 66)) != 0 ||
*((unsigned char*)(offset + bc.ptr + 67)) != 0 ||