Expand description
§Depyler Core - Transpilation Engine
Core transpilation engine for converting Python code to Rust and other targets.
§Overview
This crate provides the fundamental transpilation pipeline that converts Python source code into target languages (Rust, Ruchy) while preserving semantics and ensuring memory safety.
§Example
use depyler_core::DepylerPipeline;
let pipeline = DepylerPipeline::new();
let python = r#"
def factorial(n: int) -> int:
if n <= 1:
return 1
return n * factorial(n - 1)
"#;
match pipeline.transpile(python) {
Ok(rust_code) => println!("Generated:\n{}", rust_code),
Err(e) => eprintln!("Error: {}", e),
}§Architecture
The transpilation pipeline consists of several stages:
- Parsing (
ast_bridge) - Convert Python source to AST - HIR (
hir) - Transform AST to High-level Intermediate Representation - Type Analysis (
generic_inference,const_generic_inference) - Infer types and generics - Ownership Analysis (
borrowing,lifetime_analysis) - Determine ownership patterns - Optimization (
optimization,string_optimization) - Apply optimizations - Code Generation (
codegen,rust_gen) - Generate target code
§Key Types
DepylerPipeline- Main entry point for transpilation- [
TranspileOptions] - Configuration options Hir- High-level intermediate representationTranspilationBackend- Backend trait for target languages
Re-exports§
pub use backend::TranspilationBackend;pub use backend::TranspilationTarget;pub use backend::ValidationError;
Modules§
- annotation_
aware_ type_ mapper - ast_
bridge - backend
- Backend trait definitions for multiple transpilation targets
- borrowing
- borrowing_
context - Enhanced borrowing context for proper ownership pattern inference
- borrowing_
shim - Borrowing Shim - pure logic separated from I/O
- cargo_
first - Cargo-First Compilation Strategy (DEPYLER-CARGO-FIRST)
- cargo_
toml_ gen - Cargo.toml generation from CodeGenContext dependencies
- chaos
- codegen
- codegen_
shim - Codegen Shim - pure logic separated from I/O
- const_
generic_ inference - container_
element_ inference - Container element type inference from usage patterns
- debug
- Debugging support for Depyler
- decision_
trace - Decision Trace Module for Depyler CITL (Compiler-in-the-Loop) Training
- depylint
- DEPYLER-0951: Depylint - Proactive detection of unsupported Python features
- diagnostic
- World-class diagnostic formatting for transpilation errors
- direct_
rules - doctest_
extractor - Doctest Extractor for CITL Training Pipeline
- documentation
- Documentation generation for transpiled Rust code
- error
- error_
reporting - Enhanced error reporting with source location tracking and helpful suggestions
- escape_
analysis - Escape Analysis for Ownership Inference
- generative_
repair - Generative Code Repair Engine
- generator_
state - Generator State Analysis
- generator_
yield_ analysis - Generator Yield Point Analysis
- generic_
inference - hir
- hunt_
mode - Hunt Mode: Automated Calibration Subsystem for Depyler
- ide
- IDE integration support for Depyler
- infrastructure
- Infrastructure-First Implementation (DEPYLER-0925)
- inlining
- lambda_
codegen - lambda_
errors - lambda_
inference - Lambda event type inference engine
- lambda_
optimizer - lambda_
testing - lambda_
types - library_
mapping - DEPYLER-0903: Enterprise Library Mapping System
- lifetime_
analysis - Lifetime analysis and inference for safe Rust code generation
- lsp
- Language Server Protocol (LSP) implementation for Depyler
- migration_
suggestions - module_
mapper - Module mapping from Python to Rust equivalents
- module_
mapper_ phf - PHF-based Module Mapping with O(1) Worst-Case Lookup
- optimization
- optimizer
- Optimization passes for generated Rust code
- param_
type_ inference - Parameter type inference from usage patterns in function body
- performance_
warnings - profiling
- Profiling integration for performance analysis of transpiled code
- pytest_
extractor - Pytest Assertion Extractor for CITL Training Pipeline
- rust_
gen - scoring
- DEPYLER-SCORE-001: 100-Point Single-Shot Compile Score
- simplified_
hir - Simplified HIR for backend usage
- stdlib_
mappings - string_
optimization - test_
generation - Automatic test generation for transpiled functions
- type_
hints - type_
inference_ telemetry - DEPYLER-0970: Type Inference Telemetry for Oracle Training
- type_
mapper - type_
propagation - Cross-function type propagation for HIR
- type_
system - Type System - Constraint-based type inference with subtyping support
- typeshed_
ingest - Typeshed Stub Ingestion for Auto-Generating Module Mappings
- union_
enum_ gen
Macros§
- emit_
decision - Legacy macro for backward compatibility
- trace_
decision - Macro for instrumenting decision points in codegen
- transpile_
bail - Helper macro for bailing with a transpile error
- transpile_
error - Helper macro for creating errors with context
Structs§
- Config
- Core
Analyzer - Depyler
Pipeline - The main transpilation pipeline for converting Python code to multiple targets
- Direct
Transpiler - Hir
- Simplified HIR structure for backend transpilation
- HirParam
- Lazy
McpClient - Property
Verifier - Transpile
Error - Context-aware transpilation error
- Validation
Result