Skip to content

feat(script): add flow control and bitwise opcodes#65

Merged
sgbett merged 1 commit intomasterfrom
feature/59-flow-control-equality
Feb 12, 2026
Merged

feat(script): add flow control and bitwise opcodes#65
sgbett merged 1 commit intomasterfrom
feature/59-flow-control-equality

Conversation

@sgbett
Copy link
Owner

@sgbett sgbett commented Feb 12, 2026

Summary

  • Implement conditional execution: OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF with correct nested branch tracking (checks all cond_stack entries, not just top)
  • Add OP_VERIFY, OP_RETURN (after-genesis early success), OP_NOP/NOP1-10 (CLTV/CSV as NOPs)
  • Handle reserved opcodes (OP_VER, OP_RESERVED, OP_RESERVED1/2) and always-illegal opcodes (OP_VERIF, OP_VERNOTIF — silent in non-executing branches after genesis)
  • Add bitwise operations: OP_EQUAL, OP_EQUALVERIFY, OP_AND, OP_OR, OP_XOR, OP_INVERT
  • Only one OP_ELSE per OP_IF (after-genesis semantics)

Closes #59

Test plan

  • 43 new examples across 2 spec files (flow_control, bitwise)
  • Nested conditional tests (IF inside false branch, IF inside ELSE branch)
  • RuboCop clean (0 offences across all 16 interpreter files)
  • Full suite passes (810 examples, 0 failures)

🤖 Generated with Claude Code

Implement conditional execution (IF/NOTIF/ELSE/ENDIF) with correct
nested branch tracking, OP_VERIFY, OP_RETURN (after-genesis early
success), NOP/NOP1-10 (CLTV/CSV as NOPs), reserved opcodes, and
always-illegal VERIF/VERNOTIF handling. Add bitwise operations:
EQUAL, EQUALVERIFY, AND, OR, XOR, INVERT.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 95.00000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/bsv/script/interpreter/interpreter.rb 83.33% 4 Missing ⚠️
.../bsv/script/interpreter/operations/flow_control.rb 97.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@sgbett sgbett merged commit 561041d into master Feb 12, 2026
7 checks passed
@sgbett sgbett deleted the feature/59-flow-control-equality branch February 12, 2026 16:48
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.

[Task 3] Flow control + equality/bitwise opcodes

1 participant