From 0dd0b0908300eee08a06ee51d9eb48b85fd97d74 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 27 Oct 2026 13:27:14 +0000 Subject: refactor(memory)!: move allocation functions into memory.cps Route keyword NEW and DELETE through the same library runtime and retain allocation tracking, runtime diagnostics and exception behavior. BREAKING CHANGE: -no-std programs using NEW or DELETE must explicitly import memory.cps. Co-Authored-By: Claude Opus 5.5 --- tests/iii/memory-call-arity/case.json | 2 +- tests/iii/memory-no-std/case.json | 27 +++++++++++++++++++++++++++ tests/iii/memory-no-std/program.cps | 10 ++++++++++ tests/iii/memory-pointer-type/case.json | 2 +- tests/iii/memory-size-type/case.json | 4 ++-- tests/iii/template-explicit-errors/case.json | 2 +- 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tests/iii/memory-no-std/case.json create mode 100644 tests/iii/memory-no-std/program.cps (limited to 'tests/iii') diff --git a/tests/iii/memory-call-arity/case.json b/tests/iii/memory-call-arity/case.json index 3159635..08583d7 100644 --- a/tests/iii/memory-call-arity/case.json +++ b/tests/iii/memory-call-arity/case.json @@ -1,7 +1,7 @@ { "errors": [ { - "reason": "FREE\\ expects\\ 1\\ arg", + "reason": "No matching overload for FREE", "line": 1 } ] diff --git a/tests/iii/memory-no-std/case.json b/tests/iii/memory-no-std/case.json new file mode 100644 index 0000000..34a3e90 --- /dev/null +++ b/tests/iii/memory-no-std/case.json @@ -0,0 +1,27 @@ +{ + "compiler_args": [ + "-no-std" + ], + "errors": [ + { + "reason": "Call to undefined function MALLOC", + "line": 6 + }, + { + "reason": "Call to undefined function REALLOC", + "line": 7 + }, + { + "reason": "Call to undefined function FREE", + "line": 8 + }, + { + "reason": "NEW/DELETE requires memory.cps", + "line": 9 + }, + { + "reason": "NEW/DELETE requires memory.cps", + "line": 10 + } + ] +} diff --git a/tests/iii/memory-no-std/program.cps b/tests/iii/memory-no-std/program.cps new file mode 100644 index 0000000..69941d6 --- /dev/null +++ b/tests/iii/memory-no-std/program.cps @@ -0,0 +1,10 @@ +CLASS Item + Value : INTEGER +ENDCLASS +TYPE Raw = C_TYPE("void*") +DECLARE Obj : Item +MALLOC(8) +REALLOC((Raw)0, 8) +FREE((Raw)0) +Obj <- NEW Item() +DELETE Obj diff --git a/tests/iii/memory-pointer-type/case.json b/tests/iii/memory-pointer-type/case.json index 557c4b9..973a4c9 100644 --- a/tests/iii/memory-pointer-type/case.json +++ b/tests/iii/memory-pointer-type/case.json @@ -1,7 +1,7 @@ { "errors": [ { - "reason": "Cannot\\ implicitly\\ convert", + "reason": "No matching overload for FREE", "line": 4 } ] diff --git a/tests/iii/memory-size-type/case.json b/tests/iii/memory-size-type/case.json index 6354ba8..d5848f2 100644 --- a/tests/iii/memory-size-type/case.json +++ b/tests/iii/memory-size-type/case.json @@ -1,11 +1,11 @@ { "errors": [ { - "reason": "Allocation\\ size\\ must\\ be\\ INTEGER\\ or\\ a\\ C\\ integer", + "reason": "No matching overload for MALLOC", "line": 1 }, { - "reason": "Allocation size must be INTEGER or a C integer", + "reason": "No matching overload for REALLOC", "line": 4 } ] diff --git a/tests/iii/template-explicit-errors/case.json b/tests/iii/template-explicit-errors/case.json index 657f69e..e705356 100644 --- a/tests/iii/template-explicit-errors/case.json +++ b/tests/iii/template-explicit-errors/case.json @@ -4,7 +4,7 @@ {"reason": "No matching overload for Max", "line": 20}, {"reason": "Explicit template arguments require a function template: Plain", "line": 21}, {"reason": "Explicit template arguments are not allowed on builtin EOF", "line": 22}, - {"reason": "Explicit template arguments are not allowed on builtin MALLOC", "line": 23}, + {"reason": "Explicit template arguments require a function template: MALLOC", "line": 23}, {"reason": "Ambiguous call to Tied", "line": 24} ] } -- cgit v1.3.1-4-g156e