Extend Op::PushCsgWrap to intersection_for -- the true last native-reentry gap - #69
Merged
Conversation
intersection_for was the one remaining construct still falling to Op::NativeStatement when it wraps a recursive call, capped at the old kMaxDriveVmNativeDepth=40 native-reentry ceiling -- unlike every other builtin fixed so far, it isn't a ModularCall at all, and its own group_sizes (resolveIntersectionFor, control.cpp) are keyed by RUNTIME cartesian-product loop iteration count rather than a static list of source statements, so it couldn't just reuse emitCsgWrap's own shape. Widened CompiledChunk::CsgWrapSite (`node` generalized from ModularCall* to ASTNode*, new `hasArgs`/`includeOpParam` flags, both false only for intersection_for -- it has no `.arguments` to resolve and no "op" key in its own CSGParams) so Op::PushCsgWrap/PopCsgWrap's existing bracket covers it too. compileIntersectionForLoop reuses compileForLoop's own cartesian-loop scaffold verbatim (Op::NativeIterMaterialize/ ForIterNext/ForIterEnd/IterReset -- verified Op::ForIterNext's own ctx construction is exactly equivalent to resolveIntersectionFor's own recurse lambda), with Op::CsgGroupStart/CsgGroupEnd wrapped around the body so each full iteration becomes one group instead of one source statement. Verified with a properly-relinked CLI binary (a stale one earlier in this investigation silently hid the fix on first attempt) -- succeeds at depth 1500, was capped at 39 before. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 tasks
…wrap # Conflicts: # include/openscad_cpp_evaluator/bytecode.hpp # pyproject.toml # tests/test_bytecode_compiler.cpp
This was referenced Aug 1, 2026
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.
Summary
intersection_forwas the one remaining construct with the recursive-wrapping native-reentry exposure, flagged as a separate follow-up in Extend Op::PushBuiltinWrap to hull/minkowski/render/extrude/offset/roof #68 (harder than everything else there: not aModularCall, itsgroup_sizesare keyed by runtime cartesian-product loop iteration count rather than a static source-statement list).CompiledChunk::CsgWrapSite(nodegeneralizedModularCall*→ASTNode*, newhasArgs/includeOpParamflags) so it coversintersection_fortoo, reusingOp::PushCsgWrap/PopCsgWrap's existing bracket rather than a new opcode set.compileIntersectionForLoopreusescompileForLoop's own cartesian-product loop scaffold verbatim (Op::NativeIterMaterialize/ForIterNext/ForIterEnd/IterReset) — verifiedOp::ForIterNext's own ctx construction is exactly equivalent toresolveIntersectionFor's own recurse lambda — withOp::CsgGroupStart/CsgGroupEndwrapped around the body so each full iteration becomes one group instead of one source statement.Test plan
OSCAD_BYTECODE_VMon/off, up from 727 (2 new tests: recursion-depth past the old ceiling, and a 2-dimensional cartesian-product correctness check verifying the loop scaffold reuse is right for more than one dimension).intersection_fortest (basic/2D/multi-body-per-iteration grouping intest_control_flow.cpp, the debug-hook body-entry-marker parity test intest_debug_hooks.cpp) already exercises the new compiled path and passes unchanged.🤖 Generated with Claude Code