From 4dd85fd6ecd9a67e5c2b68380873e6e114714355 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 05:30:57 +0000 Subject: feat(memory): add tracked MALLOC and FREE builtins Co-Authored-By: Claude Fable 5.1 --- tests/iii/memory-call-arity/case.json | 8 ++++++++ tests/iii/memory-call-arity/notes.md | 5 +++++ tests/iii/memory-call-arity/program.cps | 1 + tests/iii/memory-pointer-type/case.json | 8 ++++++++ tests/iii/memory-pointer-type/notes.md | 5 +++++ tests/iii/memory-pointer-type/program.cps | 4 ++++ tests/iii/memory-size-type/case.json | 8 ++++++++ tests/iii/memory-size-type/notes.md | 5 +++++ tests/iii/memory-size-type/program.cps | 1 + 9 files changed, 45 insertions(+) create mode 100644 tests/iii/memory-call-arity/case.json create mode 100644 tests/iii/memory-call-arity/notes.md create mode 100644 tests/iii/memory-call-arity/program.cps create mode 100644 tests/iii/memory-pointer-type/case.json create mode 100644 tests/iii/memory-pointer-type/notes.md create mode 100644 tests/iii/memory-pointer-type/program.cps create mode 100644 tests/iii/memory-size-type/case.json create mode 100644 tests/iii/memory-size-type/notes.md create mode 100644 tests/iii/memory-size-type/program.cps (limited to 'tests/iii') diff --git a/tests/iii/memory-call-arity/case.json b/tests/iii/memory-call-arity/case.json new file mode 100644 index 0000000..3159635 --- /dev/null +++ b/tests/iii/memory-call-arity/case.json @@ -0,0 +1,8 @@ +{ + "errors": [ + { + "reason": "FREE\\ expects\\ 1\\ arg", + "line": 1 + } + ] +} diff --git a/tests/iii/memory-call-arity/notes.md b/tests/iii/memory-call-arity/notes.md new file mode 100644 index 0000000..456445e --- /dev/null +++ b/tests/iii/memory-call-arity/notes.md @@ -0,0 +1,5 @@ +# Rejection notes + +Human review: pending. + +The explicit memory builtin rejects the invalid argument before emitting a runtime call. diff --git a/tests/iii/memory-call-arity/program.cps b/tests/iii/memory-call-arity/program.cps new file mode 100644 index 0000000..2ae44d4 --- /dev/null +++ b/tests/iii/memory-call-arity/program.cps @@ -0,0 +1 @@ +FREE() diff --git a/tests/iii/memory-pointer-type/case.json b/tests/iii/memory-pointer-type/case.json new file mode 100644 index 0000000..557c4b9 --- /dev/null +++ b/tests/iii/memory-pointer-type/case.json @@ -0,0 +1,8 @@ +{ + "errors": [ + { + "reason": "Cannot\\ implicitly\\ convert", + "line": 4 + } + ] +} diff --git a/tests/iii/memory-pointer-type/notes.md b/tests/iii/memory-pointer-type/notes.md new file mode 100644 index 0000000..456445e --- /dev/null +++ b/tests/iii/memory-pointer-type/notes.md @@ -0,0 +1,5 @@ +# Rejection notes + +Human review: pending. + +The explicit memory builtin rejects the invalid argument before emitting a runtime call. diff --git a/tests/iii/memory-pointer-type/program.cps b/tests/iii/memory-pointer-type/program.cps new file mode 100644 index 0000000..2c1abeb --- /dev/null +++ b/tests/iii/memory-pointer-type/program.cps @@ -0,0 +1,4 @@ +TYPE Raw = C_TYPE("void*") +TYPE P = ^INTEGER +DECLARE Pointer : P +FREE(Pointer) diff --git a/tests/iii/memory-size-type/case.json b/tests/iii/memory-size-type/case.json new file mode 100644 index 0000000..9753757 --- /dev/null +++ b/tests/iii/memory-size-type/case.json @@ -0,0 +1,8 @@ +{ + "errors": [ + { + "reason": "Allocation\\ size\\ must\\ be\\ INTEGER\\ or\\ a\\ C\\ integer", + "line": 1 + } + ] +} diff --git a/tests/iii/memory-size-type/notes.md b/tests/iii/memory-size-type/notes.md new file mode 100644 index 0000000..456445e --- /dev/null +++ b/tests/iii/memory-size-type/notes.md @@ -0,0 +1,5 @@ +# Rejection notes + +Human review: pending. + +The explicit memory builtin rejects the invalid argument before emitting a runtime call. diff --git a/tests/iii/memory-size-type/program.cps b/tests/iii/memory-size-type/program.cps new file mode 100644 index 0000000..0215fef --- /dev/null +++ b/tests/iii/memory-size-type/program.cps @@ -0,0 +1 @@ +MALLOC(1.5) -- cgit v1.3.1-4-g156e