mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-11 06:27:55 +00:00
WIP objdiff 3.0 refactor
This commit is contained in:
1
objdiff-wasm/wit/.gitignore
vendored
Normal file
1
objdiff-wasm/wit/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
deps/
|
||||
4
objdiff-wasm/wit/deps.lock
Normal file
4
objdiff-wasm/wit/deps.lock
Normal file
@@ -0,0 +1,4 @@
|
||||
[logging]
|
||||
url = "https://github.com/WebAssembly/wasi-logging/archive/d31c41d0d9eed81aabe02333d0025d42acf3fb75.tar.gz"
|
||||
sha256 = "ad81d8b7f7a8ceb729cf551f1d24586f0de9560a43eea57a9bb031d2175804e1"
|
||||
sha512 = "1687ad9a02ab3e689443e67d1a0605f58fc5dea828d2e4d2c7825c6002714fac9bd4289b1a68b61a37dcca6c3b421f4c8ed4b1e6cc29f6460e0913cf1bf11c04"
|
||||
1
objdiff-wasm/wit/deps.toml
Normal file
1
objdiff-wasm/wit/deps.toml
Normal file
@@ -0,0 +1 @@
|
||||
logging = "https://github.com/WebAssembly/wasi-logging/archive/d31c41d0d9eed81aabe02333d0025d42acf3fb75.tar.gz"
|
||||
249
objdiff-wasm/wit/objdiff.wit
Normal file
249
objdiff-wasm/wit/objdiff.wit
Normal file
@@ -0,0 +1,249 @@
|
||||
package objdiff:core;
|
||||
|
||||
use wasi:logging/logging@0.1.0-draft;
|
||||
|
||||
interface diff-types {
|
||||
resource diff-config {
|
||||
constructor();
|
||||
set-property: func(id: string, value: string) -> result<_, string>;
|
||||
get-property: func(id: string) -> result<string, string>;
|
||||
}
|
||||
|
||||
record mapping-config {
|
||||
mappings: list<tuple<string, string>>,
|
||||
selecting-left: option<string>,
|
||||
selecting-right: option<string>,
|
||||
}
|
||||
|
||||
resource object {
|
||||
parse: static func(
|
||||
data: list<u8>,
|
||||
config: borrow<diff-config>,
|
||||
) -> result<object, string>;
|
||||
}
|
||||
|
||||
resource object-diff {
|
||||
find-symbol: func(
|
||||
name: string,
|
||||
section-name: option<string>
|
||||
) -> option<u32>;
|
||||
}
|
||||
|
||||
record diff-result {
|
||||
left: option<object-diff>,
|
||||
right: option<object-diff>,
|
||||
}
|
||||
}
|
||||
|
||||
interface display-types {
|
||||
type symbol-ref = u32;
|
||||
|
||||
record display-config {
|
||||
show-hidden-symbols: bool,
|
||||
show-mapped-symbols: bool,
|
||||
reverse-fn-order: bool,
|
||||
}
|
||||
|
||||
record symbol-filter {
|
||||
regex: option<string>,
|
||||
mapping: option<symbol-ref>,
|
||||
}
|
||||
|
||||
record section-display-symbol {
|
||||
symbol: symbol-ref,
|
||||
is-mapping-symbol: bool,
|
||||
}
|
||||
|
||||
record section-display {
|
||||
id: string,
|
||||
name: string,
|
||||
size: u64,
|
||||
match-percent: option<f32>,
|
||||
symbols: list<section-display-symbol>,
|
||||
}
|
||||
|
||||
enum symbol-kind {
|
||||
unknown,
|
||||
function,
|
||||
object,
|
||||
section,
|
||||
}
|
||||
|
||||
flags symbol-flags {
|
||||
global,
|
||||
local,
|
||||
weak,
|
||||
common,
|
||||
hidden,
|
||||
has-extra,
|
||||
size-inferred,
|
||||
}
|
||||
|
||||
record symbol-display {
|
||||
name: string,
|
||||
demangled-name: option<string>,
|
||||
address: u64,
|
||||
size: u64,
|
||||
kind: symbol-kind,
|
||||
section: option<u32>,
|
||||
%flags: symbol-flags,
|
||||
align: option<u32>,
|
||||
virtual-address: option<u64>,
|
||||
|
||||
target-symbol: option<symbol-ref>,
|
||||
match-percent: option<f32>,
|
||||
diff-score: option<tuple<u64, u64>>,
|
||||
row-count: u32,
|
||||
}
|
||||
|
||||
record context-menu-item-copy {
|
||||
value: string,
|
||||
label: option<string>,
|
||||
}
|
||||
|
||||
record context-menu-item-navigate {
|
||||
label: string,
|
||||
}
|
||||
|
||||
variant context-menu-item {
|
||||
copy(context-menu-item-copy),
|
||||
navigate(context-menu-item-navigate),
|
||||
}
|
||||
|
||||
enum hover-item-color {
|
||||
normal,
|
||||
emphasized,
|
||||
special,
|
||||
}
|
||||
|
||||
record hover-item {
|
||||
text: string,
|
||||
color: hover-item-color,
|
||||
}
|
||||
|
||||
record diff-text-opcode {
|
||||
mnemonic: string,
|
||||
opcode: u16,
|
||||
}
|
||||
|
||||
record diff-text-symbol {
|
||||
name: string,
|
||||
demangled-name: option<string>,
|
||||
}
|
||||
|
||||
variant diff-text {
|
||||
// Basic text (not semantically meaningful)
|
||||
basic(string),
|
||||
// Line number
|
||||
line(u32),
|
||||
// Instruction address
|
||||
address(u64),
|
||||
// Instruction mnemonic
|
||||
opcode(diff-text-opcode),
|
||||
// Instruction argument (signed)
|
||||
signed(s64),
|
||||
// Instruction argument (unsigned)
|
||||
unsigned(u64),
|
||||
// Instruction argument (opaque)
|
||||
opaque(string),
|
||||
// Instruction argument (branch destination)
|
||||
branch-dest(u64),
|
||||
// Relocation target name
|
||||
symbol(diff-text-symbol),
|
||||
// Relocation addend
|
||||
addend(s64),
|
||||
// Number of spaces
|
||||
spacing(u32),
|
||||
// End of line
|
||||
eol,
|
||||
}
|
||||
|
||||
record diff-text-segment {
|
||||
// Text to display
|
||||
text: diff-text,
|
||||
// Index for colorization
|
||||
diff-index: option<u32>,
|
||||
}
|
||||
|
||||
record instruction-diff-row {
|
||||
// Text segments
|
||||
segments: list<diff-text-segment>,
|
||||
// Diff kind
|
||||
diff-kind: instruction-diff-kind,
|
||||
}
|
||||
|
||||
enum instruction-diff-kind {
|
||||
none,
|
||||
op-mismatch,
|
||||
arg-mismatch,
|
||||
replace,
|
||||
insert,
|
||||
delete,
|
||||
}
|
||||
}
|
||||
|
||||
interface diff {
|
||||
use diff-types.{
|
||||
object,
|
||||
object-diff,
|
||||
diff-config,
|
||||
diff-result
|
||||
};
|
||||
use display-types.{
|
||||
section-display-symbol,
|
||||
section-display,
|
||||
symbol-ref,
|
||||
symbol-filter,
|
||||
symbol-display,
|
||||
context-menu-item,
|
||||
hover-item,
|
||||
display-config,
|
||||
instruction-diff-row
|
||||
};
|
||||
|
||||
run-diff: func(
|
||||
left: option<borrow<object>>,
|
||||
right: option<borrow<object>>,
|
||||
config: borrow<diff-config>,
|
||||
) -> result<diff-result, string>;
|
||||
|
||||
display-sections: func(
|
||||
diff: borrow<object-diff>,
|
||||
filter: symbol-filter,
|
||||
config: display-config,
|
||||
) -> list<section-display>;
|
||||
|
||||
display-symbol: func(
|
||||
diff: borrow<object-diff>,
|
||||
symbol: section-display-symbol,
|
||||
) -> symbol-display;
|
||||
|
||||
symbol-context: func(
|
||||
object: borrow<object>,
|
||||
symbol: symbol-ref,
|
||||
) -> list<context-menu-item>;
|
||||
|
||||
symbol-hover: func(
|
||||
object: borrow<object>,
|
||||
symbol: symbol-ref,
|
||||
) -> list<hover-item>;
|
||||
|
||||
display-instruction-row: func(
|
||||
diff: borrow<object-diff>,
|
||||
symbol: section-display-symbol,
|
||||
row-index: u32,
|
||||
config: borrow<diff-config>,
|
||||
) -> instruction-diff-row;
|
||||
}
|
||||
|
||||
world api {
|
||||
import logging;
|
||||
use logging.{level};
|
||||
|
||||
export diff;
|
||||
export diff-types;
|
||||
export display-types;
|
||||
|
||||
export init: func(level: level);
|
||||
export version: func() -> string;
|
||||
}
|
||||
Reference in New Issue
Block a user