-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.disassembly-view { | ||
padding: 5px; | ||
font-family: monospace; | ||
font-size: 10px; | ||
background-color: #1e1e1e; | ||
color: #e4e4e4; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import "./DisassemblyView.css"; | ||
import loadR2 from "./r2.js"; | ||
import { useRef } from "react"; | ||
import { useStayAtBottom } from "react-stay-at-bottom"; | ||
|
||
let r2Output = ""; | ||
|
||
export default function DisassemblyView() { | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
|
||
useStayAtBottom(containerRef, { | ||
initialStay: true, | ||
autoStay: true | ||
}); | ||
|
||
return ( | ||
<div ref={containerRef} className="disassembly-view" dangerouslySetInnerHTML={{__html: r2Output}} /> | ||
); | ||
} | ||
|
||
async function start() { | ||
const r2 = await loadR2(); | ||
|
||
const _run = r2.cwrap("run", "number", ["string"]); | ||
|
||
const rawResult = _run("x"); | ||
try { | ||
const result = r2.UTF8ToString(rawResult); | ||
r2Output = result; | ||
} finally { | ||
r2._free(rawResult) | ||
} | ||
} | ||
|
||
start() | ||
.catch(e => { | ||
console.error("Unable to load r2:", e); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// TypeScript bindings for emscripten-generated code. Automatically generated at compile time. | ||
declare namespace RuntimeExports { | ||
/** | ||
* @param {string=} returnType | ||
* @param {Array=} argTypes | ||
* @param {Object=} opts | ||
*/ | ||
function cwrap(ident: any, returnType?: string | undefined, argTypes?: any[] | undefined, opts?: any | undefined): any; | ||
/** | ||
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the | ||
* emscripten HEAP, returns a copy of that string as a Javascript String object. | ||
* | ||
* @param {number} ptr | ||
* @param {number=} maxBytesToRead - An optional length that specifies the | ||
* maximum number of bytes to read. You can omit this parameter to scan the | ||
* string until the first 0 byte. If maxBytesToRead is passed, and the string | ||
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the | ||
* string will cut short at that byte index (i.e. maxBytesToRead will not | ||
* produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing | ||
* frequent uses of UTF8ToString() with and without maxBytesToRead may throw | ||
* JS JIT optimizations off, so it is worth to consider consistently using one | ||
* @return {string} | ||
*/ | ||
function UTF8ToString(ptr: number, maxBytesToRead?: number | undefined): string; | ||
let HEAPF32: any; | ||
let HEAPF64: any; | ||
let HEAP_DATA_VIEW: any; | ||
let HEAP8: any; | ||
let HEAPU8: any; | ||
let HEAP16: any; | ||
let HEAPU16: any; | ||
let HEAP32: any; | ||
let HEAPU32: any; | ||
let HEAP64: any; | ||
let HEAPU64: any; | ||
} | ||
interface WasmModule { | ||
_main(_0: number, _1: number): number; | ||
_run(_0: number): number; | ||
_free(_0: number): void; | ||
} | ||
|
||
export type MainModule = WasmModule & typeof RuntimeExports; | ||
export default function MainModuleFactory (options?: unknown): Promise<MainModule>; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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