Skip to content

Extend Op::PushCsgWrap to intersection_for -- the true last native-reentry gap - #69

Merged
revarbat merged 2 commits into
mainfrom
intersection-for-csg-wrap
Aug 1, 2026
Merged

Extend Op::PushCsgWrap to intersection_for -- the true last native-reentry gap#69
revarbat merged 2 commits into
mainfrom
intersection-for-csg-wrap

Conversation

@revarbat

@revarbat revarbat commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • intersection_for was 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 a ModularCall, its group_sizes are keyed by runtime cartesian-product loop iteration count rather than a static source-statement list).
  • Widened CompiledChunk::CsgWrapSite (node generalized ModularCall*ASTNode*, new hasArgs/includeOpParam flags) so it covers intersection_for too, reusing Op::PushCsgWrap/PopCsgWrap's existing bracket rather than a new opcode set.
  • compileIntersectionForLoop reuses compileForLoop's own cartesian-product 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.

Test plan

  • Full 729-test suite green both OSCAD_BYTECODE_VM on/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).
  • Every pre-existing intersection_for test (basic/2D/multi-body-per-iteration grouping in test_control_flow.cpp, the debug-hook body-entry-marker parity test in test_debug_hooks.cpp) already exercises the new compiled path and passes unchanged.
  • Caught and fixed a verification-process bug during this PR: the CLI binary used for empirical depth checks hadn't been relinked since the start of the session (a separate build target from the test binary), so an early manual check silently validated stale code. Confirmed with a properly rebuilt CLI: succeeds at depth 1500, was capped at 39 before this fix.
  • Version bumped to 0.13.7 (0.13.6 is claimed by the still-open Extend Op::PushBuiltinWrap to hull/minkowski/render/extrude/offset/roof #68 to avoid a collision).

🤖 Generated with Claude Code

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>
…wrap

# Conflicts:
#	include/openscad_cpp_evaluator/bytecode.hpp
#	pyproject.toml
#	tests/test_bytecode_compiler.cpp
@revarbat
revarbat merged commit 4d76e57 into main Aug 1, 2026
3 checks passed
@revarbat
revarbat deleted the intersection-for-csg-wrap branch August 1, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant