Skip to content

Commit 1707cc5

Browse files
committed
feat: add bytecode module loader
Add unified module storage with lazy decoding: - Module: owns or mmaps bytecode, provides section views - Instruction/InstructionView: decoded instruction wrappers - StringsView, SymbolsView, TypesView, etc. - Update binary format documentation
1 parent 6e62e95 commit 1707cc5

5 files changed

Lines changed: 893 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/plotnik-lib/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rowan = "0.16.1"
2121
serde = { version = "1.0.228", features = ["derive"] }
2222
thiserror = "2.0.17"
2323
arborium-tree-sitter = "2.3.2"
24+
memmap2 = "0.9"
2425
plotnik-core = { version = "0.1", path = "../plotnik-core" }
2526
plotnik-langs = { version = "0.1", path = "../plotnik-langs", optional = true }
2627

@@ -31,3 +32,4 @@ default = ["plotnik-langs"]
3132
insta = { version = "=1.45.1", features = ["yaml"] }
3233
indoc = "=2.0.7"
3334
serde_json = "=1.0.148"
35+
tempfile = "3"

crates/plotnik-lib/src/bytecode/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod entrypoint;
88
mod header;
99
mod ids;
1010
mod instructions;
11+
mod module;
1112
mod nav;
1213
mod sections;
1314
mod type_meta;
@@ -21,19 +22,26 @@ pub use ids::{QTypeId, StepId, StringId};
2122

2223
pub use header::Header;
2324

24-
pub use nav::Nav;
25-
2625
pub use sections::{FieldSymbol, NodeSymbol, Slice, TriviaEntry};
2726

28-
pub use effects::{EffectOp, EffectOpcode};
29-
3027
pub use entrypoint::Entrypoint;
3128

3229
pub use type_meta::{TypeDef, TypeKind, TypeMember, TypeMetaHeader, TypeName};
3330

31+
pub use nav::Nav;
32+
33+
pub use effects::{EffectOp, EffectOpcode};
34+
3435
pub use instructions::{
3536
Call, Match, MatchView, Opcode, Return, align_to_section, select_match_opcode,
3637
};
3738

39+
pub use module::{
40+
ByteStorage, EntrypointsView, Instruction, InstructionView, Module, ModuleError, StringsView,
41+
SymbolsView, TriviaView, TypesView,
42+
};
43+
3844
#[cfg(test)]
3945
mod instructions_tests;
46+
#[cfg(test)]
47+
mod module_tests;

0 commit comments

Comments
 (0)