From e782898e420c7f2abd83b97c160194d0e70598dd Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 05:27:14 +0000 Subject: feat(calls): support standalone calls and void pointer casts Co-Authored-By: Claude Fable 5.1 --- tests/i/function-call-statements/case.json | 1 + tests/i/function-call-statements/expected.txt | 6 +++++ tests/i/function-call-statements/notes.md | 5 ++++ tests/i/function-call-statements/program.cps | 36 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 tests/i/function-call-statements/case.json create mode 100644 tests/i/function-call-statements/expected.txt create mode 100644 tests/i/function-call-statements/notes.md create mode 100644 tests/i/function-call-statements/program.cps (limited to 'tests/i/function-call-statements') diff --git a/tests/i/function-call-statements/case.json b/tests/i/function-call-statements/case.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/i/function-call-statements/case.json @@ -0,0 +1 @@ +{} diff --git a/tests/i/function-call-statements/expected.txt b/tests/i/function-call-statements/expected.txt new file mode 100644 index 0000000..d2576ac --- /dev/null +++ b/tests/i/function-call-statements/expected.txt @@ -0,0 +1,6 @@ +17 +23 +7 +19 +[Fatal] line 33: Division by zero +caught diff --git a/tests/i/function-call-statements/notes.md b/tests/i/function-call-statements/notes.md new file mode 100644 index 0000000..c7e0c0a --- /dev/null +++ b/tests/i/function-call-statements/notes.md @@ -0,0 +1,5 @@ +# Trace notes + +Human review: pending. + +This case exercises compiler extensions. Pointer casts preserve the addresses of INTEGER 17 and C int 23. Echo prints 7 even when its result is discarded. Discarded LENGTH calls print nothing. Two BYREF procedure calls increment 17 to 19. The argument division on line 33 throws before Echo runs; CATCH prints caught. diff --git a/tests/i/function-call-statements/program.cps b/tests/i/function-call-statements/program.cps new file mode 100644 index 0000000..403414b --- /dev/null +++ b/tests/i/function-call-statements/program.cps @@ -0,0 +1,36 @@ +TYPE Raw = C_TYPE("void*") +TYPE NativePointer = C_TYPE("int*") +TYPE IntPointer = ^INTEGER +DECLARE Number : INTEGER +DECLARE Pointer : IntPointer +DECLARE Address : Raw +DECLARE Native : C_INT +DECLARE NativeAddress : NativePointer +Number <- 17 +Pointer <- ^Number +Address <- (Raw)Pointer +Pointer <- (IntPointer)Address +OUTPUT Pointer^ +Native <- (C_INT)23 +NativeAddress <- ^Native +Address <- (Raw)NativeAddress +NativeAddress <- (NativePointer)Address +OUTPUT NativeAddress^ +FUNCTION Echo(Value : INTEGER) RETURNS INTEGER + OUTPUT Value + RETURN Value +ENDFUNCTION +Echo(7) +LENGTH("discard") +CALL LENGTH("also discard") +PROCEDURE Change(BYREF Value : INTEGER) + Value <- Value + 1 +ENDPROCEDURE +Change(Number) +CALL Change(Number) +OUTPUT Number +TRY + Echo(1 DIV 0) +CATCH + OUTPUT "caught" +ENDTRY -- cgit v1.3.1-4-g156e