This repository has been archived on 2020-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
Files
not-python-old.2020-08-27/src/compile/block.rs

65 lines
1.4 KiB
Rust
Raw Normal View History

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.
todo!()
//Ok(ir::Lhs::Name(
}
_ => todo!(),
}
}
}
impl Visit<Stmt> for TranslateAst<'_, '_> {
type Out = Result<ir::Stmt>;
fn visit(&mut self, _stmt: &Stmt) -> Self::Out {
todo!()
}
}
impl Visit<AssignStmt> for TranslateAst<'_, '_> {
type Out = Result<ir::Stmt>;
fn visit(&mut self, _stmt: &AssignStmt) -> Self::Out {
todo!()
}
}
impl Visit<Expr> for TranslateAst<'_, '_> {
type Out = Result<ir::Expr>;
fn visit(&mut self, _expr: &Expr) -> Self::Out {
todo!()
}
}