use crate::{
compile::{ctx::Ctx, error::*, ir, visit::*},
syn::{ast::*, op::BinOp, span::*},
};
// basic block
pub enum Block {
Body(ir::Body),
}
pub struct TranslateAst<'c, 't> {
ctx: &'c mut Ctx,
text: &'t str,
impl<'c, 't> TranslateAst<'c, 't> {
pub fn new(ctx: &'c mut Ctx, text: &'t str) -> Self {
TranslateAst { ctx, text }
pub fn translate(&mut self, ast: &Vec<Stmt>) -> Result<ir::Body> {
todo!()
fn visit_lhs_expr(&mut self, expr: &Expr) -> Result<ir::Lhs> {
match expr {
Expr::Bin(b) if b.op == BinOp::Dot => todo!(),
Expr::Base(BaseExpr {
kind: BaseExprKind::Ident,
..
}) => {
let name = expr.text_at(self.text);
//let name_id = self.ctx.
//Ok(ir::Lhs::Name(
_ => todo!(),
impl Visit<Stmt> for TranslateAst<'_, '_> {
type Out = Result<ir::Stmt>;
fn visit(&mut self, stmt: &Stmt) -> Self::Out {
impl Visit<AssignStmt> for TranslateAst<'_, '_> {
fn visit(&mut self, stmt: &AssignStmt) -> Self::Out {
impl Visit<Expr> for TranslateAst<'_, '_> {
type Out = Result<ir::Expr>;
fn visit(&mut self, expr: &Expr) -> Self::Out {