type checking !?!?
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use crate::ir::{IRUInstruction, VarID};
|
||||
use crate::ir::{IRUInstruction, VarInst};
|
||||
|
||||
use super::{PBlock, FnLowerCtx, FnLowerable, PStatement};
|
||||
use super::{FnLowerCtx, FnLowerable, PBlock, PStatement};
|
||||
|
||||
impl FnLowerable for PBlock {
|
||||
type Output = VarID;
|
||||
fn lower(&self, ctx: &mut FnLowerCtx) -> Option<VarID> {
|
||||
type Output = VarInst;
|
||||
fn lower(&self, ctx: &mut FnLowerCtx) -> Option<VarInst> {
|
||||
let ctx = &mut ctx.sub();
|
||||
for statement in &self.statements {
|
||||
statement.lower(ctx);
|
||||
@@ -14,20 +14,20 @@ impl FnLowerable for PBlock {
|
||||
}
|
||||
|
||||
impl FnLowerable for PStatement {
|
||||
type Output = VarID;
|
||||
fn lower(&self, ctx: &mut FnLowerCtx) -> Option<VarID> {
|
||||
type Output = VarInst;
|
||||
fn lower(&self, ctx: &mut FnLowerCtx) -> Option<VarInst> {
|
||||
match self {
|
||||
super::PStatement::Let(def, e) => {
|
||||
let def = def.lower(ctx.map, ctx.output)?;
|
||||
let res = e.lower(ctx);
|
||||
if let Some(res) = res {
|
||||
ctx.map.name_var(&def, res);
|
||||
ctx.map.name_var(&def, res.id);
|
||||
}
|
||||
None
|
||||
}
|
||||
super::PStatement::Return(e) => {
|
||||
let src = e.lower(ctx)?;
|
||||
ctx.push(IRUInstruction::Ret { src });
|
||||
ctx.push_at(IRUInstruction::Ret { src }, src.span);
|
||||
None
|
||||
}
|
||||
super::PStatement::Expr(e) => e.lower(ctx),
|
||||
|
||||
Reference in New Issue
Block a user