') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); runtime: `harm!` macro by monoid · Pull Request #55 · monoid/harm · GitHub
Skip to content

runtime: harm! macro - #55

Merged
monoid merged 2 commits into
masterfrom
runtime/harm-macro
May 11, 2026
Merged

runtime: harm! macro#55
monoid merged 2 commits into
masterfrom
runtime/harm-macro

Conversation

@monoid

@monoidmonoid commented May 11, 2026

Copy link
Copy Markdown
Owner

A convenience harm! macro.

Summary by CodeRabbit

  • New Features

    • Added a new harm! macro for streamlined instruction assembly with built-in error propagation and support for trailing commas.
  • Chores

    • Re-exported core assembler types at the crate root for easier access.

Review Change Stack

@monoidmonoid self-assigned this May 11, 2026
@coderabbitai

coderabbitaiBot commented May 11, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3535d697-16ed-4960-88c0-1c25f52c83a9

📥 Commits

Reviewing files that changed from the base of the PR and between ae1f9fb and 19e5859.

📒 Files selected for processing (1)
  • harm-runtime/src/macros.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • harm-runtime/src/macros.rs

📝 Walkthrough

Walkthrough

A new harm! macro sequences instruction appends on an assembler and returns the first error or Ok(()). The macro is exported and re-exports Assembler and AssemblerError at crate root; two unit tests were updated to use the macro. A minor enum formatting change was made.

Changes

Instruction Sequencing Macro

Layer / File(s)Summary
Macro Definition and Test
harm-runtime/src/macros.rs
harm! macro accepts an assembler and instruction sequence, appends each instruction, and propagates the first error or returns Ok(()). Dedicated feature-gated test exercises the macro with two instructions.
Crate-Level Re-exports
harm-runtime/src/lib.rs
Module macros declared with #[macro_use]; Assembler and AssemblerError re-exported from runtime at crate root.
Test Refactoring
harm-runtime/src/runtime.rs
Two unit tests (test_assembler_build, test_assembler_aarch64_execute) replace explicit asm.append() chains with single harm! { asm; ... } blocks followed by .unwrap().
Formatting
harm-runtime/src/runtime.rs
Blank line added in AssemblerError enum between PositionedMemory and ExecutableMemory variants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

harm

"A rabbit tapped the keyboard bright,
Lined up insts to stream them right,
One macro call to bind the queue,
Errors surface, builds run true,
🐇✨"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'runtime: harm! macro' directly and concisely describes the main change: introduction of a new harm! macro in the runtime module.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch runtime/harm-macro

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@monoidmonoid added enhancement New feature or request runtime The `harm`'s runtime: memory mappings, applying relocations, etc. labels May 11, 2026
@monoid

Copy link
Copy Markdown
OwnerAuthor

@coderabbitai please, review.

@coderabbitai

Copy link
Copy Markdown

@monoid Sure! I'll start reviewing the PR right away.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@monoid
monoid merged commit a6edde4 into masterMay 11, 2026
2 checks passed
@monoid
monoid deleted the runtime/harm-macro branch May 11, 2026 11:49
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or requestruntimeThe `harm`'s runtime: memory mappings, applying relocations, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@monoid