Repository navigation
Scratch to C++ transpiler experiment - #695
Draft
devin-ai-integration[bot] wants to merge 1 commit into
Draft
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
adazem009
marked this pull request as draft
October 17, 2026 14:08
- CppCodeBuilder emits a C++ class per script deriving from CppExecutableCode, registered by the FNV-1a hash of its source - scripts and procedures are C++20 coroutines (CppCoroutine) - run the shared codegen tests with the cpp backend: codegen_test_generator collects the generated code which is compiled into codegen_test - add the codebase generator and scratchcpp-transpiler tool Co-Authored-By: zemanadam893@gmail.com <zemanadam893@gmail.com>
devin-ai-integration
Bot
force-pushed
the
devin/1792234428-cpp-transpiler
branch
from
October 28, 2026 22:12
da3bb98 to
e01f83c
Compare
devin-ai-integration
Bot
changed the base branch from
master
to
cpp_architecture
October 28, 2026 22:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrites the C++ backend on top of
cpp_architecture, using C++20 coroutines. The C++17 state machine is gone.Backend (
src/engine/internal/codegen/cpp)CppCodeBuilderoutputs one class per script. The class derives fromCppExecutableCodeand overridesrunScript/runReporter/runPredicate/runProcedure. It registers itself (CppCompilerContext::registerCode) under the FNV-1a hash of its source.build()hashes the source and creates the registered class. If there is none, it reports the source throughCppCompilerContext::setSourceCallbackand returns a no-op code.CppCoroutine). A yield isco_await std::suspend_always{}, and the end-thread flag is the coroutine's return value. Warp code never suspends.kill()keeps the coroutine alive untilreset().StringPtr *first parameter. Externs are declared type-erased and cast at the call site, because the tests call one function with different signatures.Tests
codebuilder_testand operator tests now also run forcpp.codegen_test_generatorruns them once to collect the generated code. It maps ASSERT to EXPECT and restarts the test process after a crash, so every builder in a test is reached. It writes 16 shards, which are compiled intocodegen_test.cpp_testmock updated forCppCoroutine.Codebase generation
scratchcpp-transpiler <project.sb3> <output dir> [name](cpp backend only) writesproject.cpp,project_data.cpp(the embedded .sb3),main.cppand a C++20CMakeLists.txt.Also adds a missing
<bit>include instring_functions.cpp, which GCC 11 needs forstd::bit_ceil.Still not done: #682 (inlining) and type analysis. Variables stay
ValueData.