Improved API - Memory manipulation#98
Conversation
Added `getMemory` to API
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... 📒 Files selected for processing (1)
Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant DebuggerAPI
participant Interpreter
Note over DebuggerAPI,Interpreter: getMemory flow (new)
Caller->>DebuggerAPI: getMemory(address, length)
DebuggerAPI->>Interpreter: readMemory(address, length)
alt success
Interpreter-->>DebuggerAPI: bytes
DebuggerAPI-->>Caller: Uint8Array (bytes)
else fault or no interpreter
Interpreter-->>DebuggerAPI: fault / no-response
DebuggerAPI-->>Caller: null
end
Note over DebuggerAPI,Interpreter: setMemory flow (new)
Caller->>DebuggerAPI: setMemory(address, data)
DebuggerAPI->>Interpreter: writeMemory(address, data)
alt success
Interpreter-->>DebuggerAPI: ack
DebuggerAPI-->>Caller: true
else fault or no interpreter
Interpreter-->>DebuggerAPI: fault / no-response
DebuggerAPI-->>Caller: false
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
assembly/api-debugger.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-16T15:17:10.841Z
Learnt from: tomusdrw
PR: tomusdrw/anan-as#92
File: assembly/api-debugger.ts:170-182
Timestamp: 2025-10-16T15:17:10.841Z
Learning: In assembly/memory.ts, the `bytesRead` method signature is: `bytesRead(faultRes: MaybePageFault, address: u32, destination: Uint8Array, destinationOffset: u32): void`. The last parameter is the offset within the destination buffer to start writing at, not the number of bytes to read. The method reads until the destination buffer is filled from destinationOffset to destination.length.
Applied to files:
assembly/api-debugger.ts
🧬 Code graph analysis (1)
assembly/api-debugger.ts (3)
assembly/interpreter.ts (1)
Interpreter(21-200)assembly/memory.ts (1)
MaybePageFault(15-19)assembly/memory-page.ts (1)
data(42-47)
🔇 Additional comments (1)
assembly/api-debugger.ts (1)
170-182: Breaking API change confirmed, but no internal callers need updating.The return type changes are intentional breaking changes to the public API:
getMemory: now returnsnullon errors (interpreter absent or page fault) instead of emptyUint8ArraysetMemory: now returnsbooleanto indicate success/failureVerification shows zero internal callers of these functions in the codebase—they are public API exports for external WebAssembly consumers. The code changes are correct and the error-signaling improvements are sound. External API consumers will need to adapt to these breaking changes, but that is outside the scope of this repository.
|
hmm, why i have so many commits :c |
Seems that you've added some commits on a branch that was already merged. Please cherry-pick the commits that add new functionality onto a new branch and force push to rename this one or just start a new pr. |
Co-authored-by: Tomek Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Tomek Drwięga <tomusdrw@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
assembly/api-debugger.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-16T15:17:10.864Z
Learnt from: tomusdrw
PR: tomusdrw/anan-as#92
File: assembly/api-debugger.ts:170-182
Timestamp: 2025-10-16T15:17:10.864Z
Learning: In assembly/memory.ts, the `bytesRead` method signature is: `bytesRead(faultRes: MaybePageFault, address: u32, destination: Uint8Array, destinationOffset: u32): void`. The last parameter is the offset within the destination buffer to start writing at, not the number of bytes to read. The method reads until the destination buffer is filled from destinationOffset to destination.length.
Applied to files:
assembly/api-debugger.ts
📚 Learning: 2025-04-22T15:58:24.284Z
Learnt from: tomusdrw
PR: tomusdrw/anan-as#49
File: assembly/memory.ts:335-335
Timestamp: 2025-04-22T15:58:24.284Z
Learning: In the bytesWrite method, memory writes should be atomic. If a page fault occurs during a multi-page write, no memory should be altered (current implementation allows partial writes).
Applied to files:
assembly/api-debugger.ts
🧬 Code graph analysis (1)
assembly/api-debugger.ts (3)
assembly/interpreter.ts (1)
Interpreter(21-200)assembly/memory.ts (1)
MaybePageFault(15-19)assembly/memory-page.ts (1)
data(42-47)
🪛 GitHub Actions: Node.js CI
assembly/api-debugger.ts
[error] 168-176: Prettier formatting check failed. File content differs from formatting output.
🔇 Additional comments (2)
assembly/api-debugger.ts (2)
170-187: LGTM! Excellent improvement to error signaling.The changes properly implement explicit null return for fault conditions, making the API clearer and more robust. The JSDoc comment accurately describes the behavior, and the logic correctly handles both missing interpreter and page fault scenarios.
189-208: LGTM! Boolean return improves error signaling.The changes successfully implement explicit boolean return values for fault conditions, making the API clearer. The JSDoc comment accurately describes the behavior, and the function correctly propagates failure states to callers.
Note: The partial write atomicity concern raised in previous reviews remains but is already tracked in issue #51.
Added values for memory manipulation that could clearly indicate success or error.
Summary by CodeRabbit
New Features
Breaking Changes
Documentation