From cd3c09a5c2566d674680193042baf6474b6d0976 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 18 Oct 2026 08:11:39 +0000 Subject: feat(driver): load the embedded C++ runtime into the JIT Co-Authored-By: Claude Opus 5.5 --- tests/i/extern-cc-runtime/case.json | 1 + tests/i/extern-cc-runtime/expected.txt | 2 ++ tests/i/extern-cc-runtime/program.cps | 9 +++++++++ tests/i/extern-cc-runtime/runtime.cc | 13 +++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 tests/i/extern-cc-runtime/case.json create mode 100644 tests/i/extern-cc-runtime/expected.txt create mode 100644 tests/i/extern-cc-runtime/program.cps create mode 100644 tests/i/extern-cc-runtime/runtime.cc (limited to 'tests') diff --git a/tests/i/extern-cc-runtime/case.json b/tests/i/extern-cc-runtime/case.json new file mode 100644 index 0000000..604feef --- /dev/null +++ b/tests/i/extern-cc-runtime/case.json @@ -0,0 +1 @@ +{"objects":[{"source":"runtime.cc","output":"runtime.o"}]} diff --git a/tests/i/extern-cc-runtime/expected.txt b/tests/i/extern-cc-runtime/expected.txt new file mode 100644 index 0000000..3e5a8c6 --- /dev/null +++ b/tests/i/extern-cc-runtime/expected.txt @@ -0,0 +1,2 @@ +4099 +caught C++ diff --git a/tests/i/extern-cc-runtime/program.cps b/tests/i/extern-cc-runtime/program.cps new file mode 100644 index 0000000..74d0386 --- /dev/null +++ b/tests/i/extern-cc-runtime/program.cps @@ -0,0 +1,9 @@ +INCLUDE_OBJ "runtime.o" +EXTERN "C" EXTERN_FUNCTION string_length() RETURNS C_INT +EXTERN "C" EXTERN_PROCEDURE string_throw() +OUTPUT (INTEGER)string_length() +TRY + CALL string_throw() +CATCH + OUTPUT "caught C++" +ENDTRY diff --git a/tests/i/extern-cc-runtime/runtime.cc b/tests/i/extern-cc-runtime/runtime.cc new file mode 100644 index 0000000..fd57538 --- /dev/null +++ b/tests/i/extern-cc-runtime/runtime.cc @@ -0,0 +1,13 @@ +#include +#include +extern "C" int string_length() { + std::string text(4096, 'x'); + text += std::to_string(123); + return static_cast(text.size()); +} +extern "C" void string_throw() { + try { throw std::invalid_argument("string failure"); } + catch (const std::exception &e) { + if (std::string(e.what()) == "string failure") throw; + } +} -- cgit v1.3.1-4-g156e