ladybird/Libraries/LibJS/Rust/src/bytecode/mod.rs
Andreas Kling 6cdfbd01a6 LibJS: Add alternative source-to-bytecode pipeline in Rust
Implement a complete Rust reimplementation of the LibJS frontend:
lexer, parser, AST, scope collector, and bytecode code generator.

The Rust pipeline is built via Corrosion (CMake-Cargo bridge) and
linked into LibJS as a static library. It is gated behind a build
flag (ENABLE_RUST, on by default except on Windows) and two runtime
environment variables:

- LIBJS_CPP: Use the C++ pipeline instead of Rust
- LIBJS_COMPARE_PIPELINES=1: Run both pipelines in lockstep,
  aborting on any difference in AST or bytecode generated.

The C++ side communicates with Rust through a C FFI layer
(RustIntegration.cpp/h) that passes source text to Rust and receives
a populated Executable back via a BytecodeFactory interface.
2026-02-24 09:39:42 +01:00

27 lines
964 B
Rust

/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
//! Bytecode generator infrastructure for the parser.
//!
//! This module contains the types and machinery needed to generate
//! bytecode from the AST. The generated bytecode is binary-
//! compatible with the C++ `Bytecode::Executable` format.
//!
//! ## Submodules
//!
//! - `operand` -- Register, Operand, Label, and table index types
//! - `instruction` -- Instruction enum (generated from Bytecode.def by build.rs)
//! - `basic_block` -- BasicBlock: list of instructions with control flow metadata
//! - `generator` -- Generator: manages registers, constants, tables, and assembly
//! - `codegen` -- AST-walking code that emits instructions via the Generator
//! - `ffi` -- FFI bridge to create C++ Executable and SharedFunctionInstanceData
pub mod basic_block;
pub mod codegen;
pub mod ffi;
pub mod generator;
pub mod instruction;
pub mod operand;