Implemented garbage collection

As a whole, this is still tentative.
This commit is contained in:
2026-05-08 16:28:12 +10:00
parent be84a8dfe2
commit 6c055a0435
15 changed files with 267 additions and 80 deletions
+4 -4
View File
@@ -1,12 +1,12 @@
//calculate the nth fibonacci number, and print it
var counter: int = 0;
var counter: Int = 0;
var first: int = 1;
var second: int = 0;
var first: Int = 1;
var second: Int = 0;
while (counter < 100_000) {
var third: int = first + second;
var third: Int = first + second;
first = second;
second = third;
+2 -2
View File
@@ -1,9 +1,9 @@
//standard example, using 'while' instead of 'for', because it's not ready yet
var counter: int = 0;
var counter: Int = 0;
while (++counter <= 100) {
var result: string = "";
var result: String = "";
if (counter % 3 == 0) {
result = result .. "fizz";
+1
View File
@@ -9,4 +9,5 @@ var b = 69;
var c;
var d;
//BUG: still causes a segfault
c, d = swap(a, b);
+1 -1
View File
@@ -1,5 +1,5 @@
//find the leap years
fn isLeapYear(n: int) {
fn isLeapYear(n: Int) {
if (n % 400 == 0) return true;
if (n % 100 == 0) return false;
return n % 4 == 0;
+1 -1
View File
@@ -1,5 +1,5 @@
fn makeCounter() {
var counter: int = 0;
var counter: Int = 0;
fn increment() {
return ++counter;
-35
View File
@@ -1,35 +0,0 @@
//array outside a table
var a = [
[1, 2, 3],
["alpha": 1, "beta": 2, "gamma": 3],
[7, 8, 9],
];
print a;
//table outside an array
var t = [
"alpha": [1,2,3],
"beta": [4,5,6],
"gamma": [7,8,9],
];
print t;
//we need to go deeper
var deeper = [
[1, 2, 3],
[
"alpha": [1,2,3],
"beta": [4,5,6],
"gamma": [7,[
"delta":10,"epsilon":11,"foxtrot":12
],9],
],
[7, 8, 9],
];
print deeper;
-14
View File
@@ -1,14 +0,0 @@
//snipped out of the tests, this seems fine?
//nested
var example = [
"outer": ["inner": true],
"alpha": 1,
"beta": 2,
"gamma": 3
];
print example;
assert example == ["alpha": 1, "beta": 2, "gamma": 3, "outer": ["inner": true]], "nested tables failed";
return example;