Skip to main content

Crate depyler_core

Crate depyler_core 

Source
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:

  1. Parsing (ast_bridge) - Convert Python source to AST
  2. HIR (hir) - Transform AST to High-level Intermediate Representation
  3. Type Analysis (generic_inference, const_generic_inference) - Infer types and generics
  4. Ownership Analysis (borrowing, lifetime_analysis) - Determine ownership patterns
  5. Optimization (optimization, string_optimization) - Apply optimizations
  6. Code Generation (codegen, rust_gen) - Generate target code

§Key Types

  • DepylerPipeline - Main entry point for transpilation
  • [TranspileOptions] - Configuration options
  • Hir - High-level intermediate representation
  • TranspilationBackend - 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
CoreAnalyzer
DepylerPipeline
The main transpilation pipeline for converting Python code to multiple targets
DirectTranspiler
Hir
Simplified HIR structure for backend transpilation
HirParam
LazyMcpClient
PropertyVerifier
TranspileError
Context-aware transpilation error
ValidationResult

Enums§

HirBinaryOp
HirExpr
HirLiteral
HirStatement
HirType
HirUnaryOp
OptimizationLevel

Traits§

AnalyzableStage