fabric_rs_codegen/lib.rs
1//! Pure-Rust JVM bytecode generator, JAR SDK indexer, and Rust binding emitter for FLR v2.
2//!
3//! `fabric-rs-codegen` synthesizes verifiable `.class` files (complete with automatic `StackMapTable`
4//! frames) without requiring `javac` or Java ASM at package time:
5//!
6//! - [`jvm_writer`]: Constant pool builder, bytecode instruction emitter (`CodeWriter`), annotations, and `.class` serializer.
7//! - [`class_reader`]: Classfile parser for JAR indexing ([`build_sdk_index_from_jars`]) and constant-pool relocation ([`relocate_class_bytes`]).
8//! - [`bootstrap_gen`]: Isolated per-mod `FlrLoader.class`, `RustBootstrap.class`, and optional `NativeBridge.class`.
9//! - [`mixin_gen`]: SpongePowered Mixin `.class` synthesis, `MixinTrampolines.class`, `*.mixins.json`, and `*.refmap.json`.
10//! - [`subclass_gen`]: Custom Java subclass `.class` emission with `flrHandle`, overrides, and `invokespecial` super bridges.
11//! - [`rust_emitter`]: Generates typed Rust wrappers ([`emit_rust_binding`]) used by `bind_class!` and `cargo fabric bindings`.
12
13/// Isolated per-mod loader, `RustBootstrap`, and dynamic `NativeBridge` generators.
14pub mod bootstrap_gen;
15/// JVM `.class` reader, constant-pool class relocator, and JAR SDK indexer.
16pub mod class_reader;
17/// Pure-Rust JVM classfile writer with basic-block label patching and `StackMapTable` generation.
18pub mod jvm_writer;
19/// Mixin classfile, trampoline, config, and Intermediary refmap generators.
20pub mod mixin_gen;
21/// Rust wrapper struct/method code emitter backing `bind_class!` and `cargo fabric bindings`.
22pub mod rust_emitter;
23/// Automatic CFG dataflow bytecode analyzer for `StackMapTable` and frame limits.
24pub mod stack_map;
25/// Custom Java subclass `.class` and `SubclassTrampolines` generators.
26pub mod subclass_gen;
27
28pub use bootstrap_gen::{
29 generate_native_bridge, generate_neoforge_bootstrap, generate_neoforge_event_relay,
30 generate_rust_bootstrap, relocate_runtime_loader,
31};
32pub use class_reader::{build_sdk_index_from_jars, parse_class_bytes, relocate_class_bytes};
33pub use jvm_writer::{
34 access_flags, opcodes, Annotation, BootstrapMethod, ClassWriter, CodeWriter, ElementValue,
35 ExceptionHandler, FieldWriter, InnerClassEntry, LabelId, MethodHandleKind, MethodWriter,
36 VerificationType,
37};
38pub use mixin_gen::{generate_mixin_class, generate_mixins_json, generate_refmap_json};
39pub use rust_emitter::emit_rust_binding;
40pub use subclass_gen::generate_subclass_bytes;