Run cargo fmt

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-20 15:25:10 -04:00
parent 161166da15
commit 0eaa5060a2
19 changed files with 69 additions and 120 deletions

View File

@@ -1,11 +1,6 @@
use crate::{
compile::{ctx::Ctx, error::*, ir, visit::*},
syn::{ast::*, op::BinOp, span::*},
compile::{
ctx::Ctx,
error::*,
ir,
visit::*,
},
};
// basic block
@@ -20,10 +15,7 @@ pub struct TranslateAst<'c, 't> {
impl<'c, 't> TranslateAst<'c, 't> {
pub fn new(ctx: &'c mut Ctx, text: &'t str) -> Self {
TranslateAst {
ctx,
text,
}
TranslateAst { ctx, text }
}
pub fn translate(&mut self, ast: &Vec<Stmt>) -> Result<ir::Body> {
@@ -33,13 +25,16 @@ impl<'c, 't> TranslateAst<'c, 't> {
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, .. }) => {
Expr::Base(BaseExpr {
kind: BaseExprKind::Ident,
..
}) => {
let name = expr.text_at(self.text);
//let name_id = self.ctx.
todo!()
todo!()
//Ok(ir::Lhs::Name(
}
_ => todo!()
_ => todo!(),
}
}
}

View File

@@ -1,7 +1,4 @@
use crate::{
compile::name::NameStack,
obj::Sym,
};
use crate::{compile::name::NameStack, obj::Sym};
use std::collections::HashMap;
pub struct Ctx {
@@ -35,8 +32,6 @@ impl Ctx {
pub fn add_sym(&mut self, name: String) -> Sym {
let next_sym = self.syms().len();
*self.syms_mut()
.entry(name)
.or_insert(next_sym.into())
*self.syms_mut().entry(name).or_insert(next_sym.into())
}
}

View File

@@ -4,9 +4,7 @@ use snafu::Snafu;
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("invalid assignment target"))]
InvalidLhs {
span: Span,
}
InvalidLhs { span: Span },
}
pub type Result<T, E = Error> = std::result::Result<T, E>;

View File

@@ -1,7 +1,4 @@
use crate::{
obj::Sym,
syn::span::*,
};
use crate::{obj::Sym, syn::span::*};
pub type Body = Vec<Stmt>;

View File

@@ -1,4 +1,5 @@
#[macro_use] pub mod visit;
#[macro_use]
pub mod visit;
pub mod block;
pub mod ctx;
pub mod error;
@@ -8,4 +9,3 @@ pub mod name;
// * Desugar
// * Collect names as symbols
// * Create basic blocks

View File

@@ -11,8 +11,7 @@ pub trait Accept {
Self: Sized;
}
pub trait DefaultAccept<V: Visit<Self>>: Accept + Sized
{
pub trait DefaultAccept<V: Visit<Self>>: Accept + Sized {
fn default_accept(&self, visitor: &mut V) -> V::Out;
}
@@ -35,7 +34,7 @@ macro_rules! empty_visitor {
type Out = ();
fn visit(&mut self, _: &$default) -> Self::Out {}
}
}
};
}
macro_rules! impl_accept {