Commit Graph

139 Commits

Author SHA1 Message Date
Kayne Ruse 4aec343b6c BUGFIX: scopes weren't expanding as intended 2026-04-24 12:46:05 +10:00
Kayne Ruse 9a75226491 Implemented the attribute operator, using a period 2026-04-24 11:31:54 +10:00
Kayne Ruse d2ac1eeb8e Syntax fix 2026-04-23 11:09:25 +10:00
Kayne Ruse 5a867ac627 Fixed some 'size_t' issues and a bug caught on a different platform 2026-04-23 10:40:00 +10:00
Kayne Ruse 63dfd33e5e Added arrays and tables to the bytecode inspector
Currently searching for an issue related to compounds.
2026-04-22 14:31:17 +10:00
Kayne Ruse 9bb115f732 Disabled bloated and verbose testing output 2026-04-22 13:06:14 +10:00
Kayne Ruse 8875b6968b Updated VM unit tests 2026-04-22 12:53:02 +10:00
Kayne Ruse 97d16c1184 Updated compiler unit tests 2026-04-22 12:07:40 +10:00
Kayne Ruse 47c5d49069 Updated parser unit test, fixed a missing stack pop for binary exprStmt 2026-04-22 11:40:53 +10:00
Kayne Ruse 5b101d763e Expanded bytecode inspector, added functions to Toy_copyValue 2026-04-17 11:55:46 +10:00
Kayne Ruse f9790b99ce Moved type coersion check, functions can be compared
Also updated some tagged comments
2026-04-15 15:04:54 +10:00
Kayne Ruse 8eefbc8a0c Added remaining opcodes to inspector
Also used some coloring for terminal outputs
2026-04-12 23:04:31 +10:00
Kayne Ruse c0c03a4110 Functions are working, tests incomplete
This required a massive cross-cutting rework to the scope system,
multiple subtle bugfixes and relearning of the parser internals, but it
does appear that functions are working correctly.

A few caveats: for now, parameters are always constant, regardless of
type, return values can't be specified, and some script tests have been
written.

Most importantly, a key feature is working: closures.
2026-04-12 11:52:58 +10:00
Kayne Ruse b0d9c15d33 Added a benchmark for JS 2026-04-12 08:55:15 +10:00
Kayne Ruse 24e5d8081c Tweaked a doc 2026-04-12 08:42:06 +10:00
Kayne Ruse 42aef306a9 Added a lua benchmark for performance comparisons 2026-04-12 08:40:28 +10:00
Kayne Ruse baa81b1aa9 Removed annoying workingdir thing 2026-04-11 01:55:11 +10:00
Kayne Ruse 9553edef9c Added tools for vscode 2026-04-11 01:48:30 +10:00
Kayne Ruse 547229e150 Script tests re-added, all tests can run under gdb
Also fixed a minor bug with printing, and removed the ability to
configure the parser.

Added and updated QUICKSTART.md as a quick way to get people started.

There's some broken scripts under 'scripts/' that require functions to
work properly.
2026-04-10 15:28:56 +10:00
Kayne Ruse 3a24fbf6e1 Tweaked CI 2026-04-07 22:00:54 +10:00
Kayne Ruse 842f041a50 VM test is passing 2026-04-07 21:34:05 +10:00
Kayne Ruse 7408a24a12 Scope test is working 2026-04-07 20:48:32 +10:00
Kayne Ruse 09fc6d5279 Compiler test is passing 2026-04-07 20:36:58 +10:00
Kayne Ruse f25e81cd09 Parser test is passing 2026-04-07 20:14:27 +10:00
Kayne Ruse 48072f0dd1 AST test is passing 2026-04-07 20:06:44 +10:00
Kayne Ruse 522fc3e64b Value test is passing 2026-04-07 19:44:28 +10:00
Kayne Ruse f4ce6ad9f1 String test is passing
Note: String fragmentation is no longer supported
2026-04-07 19:22:31 +10:00
Kayne Ruse fbb7e1bc54 WIP: Retreived the unit tests (formerly test cases)
Some of these still work, others have just been dummied out for now.

Also added tests for console colors tool, and tweaked it to work
properly.
2026-04-05 18:42:56 +10:00
Kayne Ruse 98208f4bb5 Began cleaning up this project for a soft reboot 2026-04-04 19:32:45 +11:00
Kayne Ruse d3b59eb0da WIP functions working, untested, memory issues, read more
I've ripped out the deep copying, and flattened the bucket usage, but
this results in no memory being freed or reused for the lifetime of the
program.

This is shown most clearly with this script:

```toy
fn makeCounter() {
	var counter: int = 0;

	fn increment() {
		return ++counter;
	}

	return increment;
}

var tally = makeCounter();

while (true) {
	var result = tally();

	if (result >= 10_000_000) {
		break;
	}
}
```

The number of calls vs amount of memory consumed is:

```
function calls -> memory used in megabytes
1_000 -> 0.138128
10_000 -> 2.235536
100_000 -> 21.7021
1_000_000 -> 216.1712
10_000_000 -> 1520.823
```

Obviously this needs to be fixed, as ballooning to gigabytes of memory
in only a moment isn't practical. That will be the next task - to find
some way to free memory that isn't needed anymore.

See #163, #160
2025-02-21 11:41:27 +11:00
Kayne Ruse 639250f028 WIP return keyword, read more
Functions are having issues with being copied around, especially
between buckets, leading to the scopes getting looped. The program gets
stuck in 'incrementRefCount()'.

It's past my time limit, so I'll keep working on it tomorrow with a
fresh mind.

All function stuff is still untested.

See #163
2025-02-17 19:10:24 +11:00
Kayne Ruse 02dfc996b4 Functions are successfully called, read more
Return keyword is not yet implemented.

Functions are untested.

See #163
2025-02-17 14:05:07 +11:00
NishiOwO 1006b6e216 Add bitness definitions, and platform definitions 2025-02-08 22:14:32 +09:00
Kayne Ruse 7c054db9e6 Compiler now reuses existing strings in the data, read more
If a string exists in the data, instead of being written, the function
'emitCStringToData()' will instead return the address of the match
within the data section.

Then, I can search the jump table for that address, and use the existing
jump entry or append a new one.

Fixes #168
2025-02-08 17:27:47 +11:00
Kayne Ruse c646904407 replaced void* with unsigned char* everywhere 2025-02-08 00:53:23 +11:00
Kayne Ruse 470836a390 Renamed Toy_ModuleBuilder to Toy_ModuleCompiler
I also noticed that Toy_ModuleBundle isn't being used right now.
2025-02-08 00:23:19 +11:00
Kayne Ruse b93ea5006c Functions are WIP, read more
They're no-ops in compilation for now, and param types aren't parsed.

'return' keyword needs to be implemented.

Was distracted by bugfixes in v2 and v2-docs.
2025-02-02 17:26:47 +11:00
Kayne Ruse 336616a1bf Tweaked truthiness, fixed int to float coersion 2025-02-02 16:38:46 +11:00
Kayne Ruse 63cc530899 Fixed continue keyword, was pointing at break's target 2025-02-02 16:15:20 +11:00
Kayne Ruse 3c0a50c4cd Tweaked AST bitness test 2025-02-01 10:04:19 +11:00
Kayne Ruse 481d17f040 Tests are passing, added preserveScope to VM API 2025-01-31 13:51:53 +11:00
Kayne Ruse 05451af8d7 What is the most bullshit error you've ever seen?
'error: no newline at end of file'

This only occurs in the MacOS builds.
2025-01-15 08:40:22 +11:00
Kayne Ruse 14696833fd Postfix '++' & '--' works (prefix & postfix are both tested) 2025-01-09 18:33:10 +11:00
Kayne Ruse 6f16c31f24 Prefix '++' working (postfix is next) 2025-01-09 16:45:48 +11:00
Kayne Ruse b55192e513 Removed stubs for types as values
Also potentially fixed a bug in the previous commit, not certain
2025-01-09 11:46:29 +11:00
Kayne Ruse 90ffe9b40e Disallow empty bodies in control flow statements, added 'pass' keyword
Fixed #170
2025-01-09 11:03:03 +11:00
Kayne Ruse 23eb3e45df Keywords 'break' & 'continue' tested
There were a couple bugs - I'm glad I'm so thorough with these tests.

See #152
2024-12-30 16:56:57 +11:00
Kayne Ruse cc4ff3f6d8 Fixed logical AND and OR operators, read more
The definition of '&&':
  Return the first falsy value, or the last value, skipping the evaluation of other operands.

The definition of '||':
  Return the first truthy value, or the last value, skipping the evaluation of other operands.

Toy now follows these definitions.

Fixed #154
2024-12-26 16:09:16 +11:00
Kayne Ruse 9cb138a7d6 Added tables to integration tests, tweaked a lot of comments 2024-12-25 11:04:18 +11:00
Kayne Ruse 223db840c8 Benchmarked memory models for Toy_Array, read more
The results can be found in
'tests/benchmarks/array_allocation/results.md'

The results are disappointing, as 'malloc()' is simply faster in every
possible situation compared to my custom arena allocator.
2024-12-24 10:37:54 +11:00