Add support for memory operations (CLR, FIL, ROL, ROR)#11
Merged
Conversation
Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for new memory operations in LODA
Add support for memory operations (CLR, FIL, ROL, ROR)
Oct 19, 2025
ckrause
reviewed
Oct 19, 2025
Contributor
ckrause
left a comment
There was a problem hiding this comment.
@copilot Please check my comment.
| CLR = 31 # clear | ||
| SEQ = 32 # sequence | ||
| DBG = 33 # debug | ||
| FIL = 34 # fill |
Contributor
There was a problem hiding this comment.
Move the three new operations up after CLR.
Contributor
|
@copilot Please check my comments. |
ckrause
approved these changes
Oct 19, 2025
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.
Overview
This PR implements support for four LODA memory operations:
clr,fil,rol, andror. These operations were previously missing from the Python runtime but are documented in the LODA language reference and implemented in the C++ version.Changes
Operation Types
Added three new operation types to the
Operation.Typeenum (CLRalready existed but was not implemented):FIL(34): Fill memory rangeROL(35): Rotate leftROR(36): Rotate rightMemory Operation Functions
Implemented four memory operation functions in
loda/runtime/operations.py:clr(mem, start, length): Clears (sets to zero) all memory cells in the specified rangefil(mem, start, length): Fills all cells in the range with the value at the start positionrol(mem, start, length): Rotates values in the range left by one position with wrap-aroundror(mem, start, length): Rotates values in the range right by one position with wrap-aroundAll operations support positive, negative, and zero-length ranges following the C++ semantics:
[start, start+length)[start+length+1, start+1)(backward range)Interpreter Updates
Extended the interpreter to handle memory operations:
get_address=TrueExample Usage
Testing
Added comprehensive test suite (
tests/test_memory_operations.py) with 17 tests covering:All existing tests continue to pass, confirming backward compatibility.
Security
max_memoryparameter to prevent DoS attacks through unbounded memory allocationFixes #[issue_number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/loda-lang/loda-cpp/contents/src/langcurl -s REDACTED(http block)loda-lang.orgcurl -s REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #10
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.