mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 12:51:10 +00:00
Fix match
codegen
This commit is contained in:
parent
d63b018371
commit
771be313a9
7 changed files with 173 additions and 80 deletions
|
@ -1,19 +1,41 @@
|
|||
use crate::artifact::CompleteArtifact;
|
||||
use crate::error::CompileWarnings;
|
||||
use crate::hir::HIR;
|
||||
use crate::hir::*;
|
||||
// use crate::erg_common::traits::Stream;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct HIROptimizer {}
|
||||
|
||||
impl HIROptimizer {
|
||||
pub fn fold_constants(&mut self, mut _hir: HIR) -> HIR {
|
||||
pub fn optimize(hir: HIR) -> CompleteArtifact {
|
||||
let mut optimizer = HIROptimizer {};
|
||||
optimizer.eliminate_dead_code(hir)
|
||||
}
|
||||
|
||||
fn _fold_constants(&mut self, mut _hir: HIR) -> HIR {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn eliminate_unused_variables(&mut self, mut _hir: HIR) -> (HIR, CompileWarnings) {
|
||||
fn _eliminate_unused_variables(&mut self, mut _hir: HIR) -> (HIR, CompileWarnings) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn eliminate_dead_code(&mut self, mut _hir: HIR) -> (HIR, CompileWarnings) {
|
||||
fn eliminate_dead_code(&mut self, hir: HIR) -> CompleteArtifact {
|
||||
CompleteArtifact::new(
|
||||
self.eliminate_discarded_variables(hir),
|
||||
CompileWarnings::empty(),
|
||||
)
|
||||
}
|
||||
|
||||
/// ```erg
|
||||
/// _ = 1
|
||||
/// (a, _) = (1, True)
|
||||
/// ```
|
||||
/// ↓
|
||||
/// ```erg
|
||||
/// a = 1
|
||||
/// ```
|
||||
fn eliminate_discarded_variables(&mut self, mut _hir: HIR) -> HIR {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue