This commit is contained in:
Michael Zhang 2021-01-25 16:08:34 -06:00
parent 9747990c12
commit acebeaa332
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
4 changed files with 34 additions and 6 deletions

View file

@ -1,7 +1,6 @@
fn main
{
urmom();
isEven();
fn main {
urmom();
isEven();
5
}

View file

@ -5,9 +5,16 @@ pub struct Program {
#[derive(Debug)]
pub enum Decl {
Mod(Mod),
Func(Func),
}
#[derive(Debug)]
pub struct Mod {
pub name: Ident,
pub decls: Vec<Decl>,
}
#[derive(Debug)]
pub struct Func {
pub name: Ident,
@ -39,3 +46,6 @@ pub enum Type {}
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct Ident(pub String);
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct Path(pub Vec<Ident>);

View file

@ -8,6 +8,10 @@ use crate::utils::Id;
type Graph = DiGraphMap<Id, ()>;
type Scopes = Vec<HashSet<String>>;
pub enum HExpr {
}
#[derive(Debug)]
pub struct Namespaces {
funcs: HashMap<Id, Func>,
@ -20,9 +24,9 @@ pub struct Namespaces {
impl Namespaces {
pub fn create(program: Program) -> Self {
let mut funcs = HashMap::new();
let mut types = HashMap::new();
let types = HashMap::new();
let mut func_names = HashMap::new();
let mut type_names = HashMap::new();
let type_names = HashMap::new();
for decl in program.decls {
match decl {
@ -31,6 +35,8 @@ impl Namespaces {
func_names.insert(func.name.0.clone(), id);
funcs.insert(id, func);
}
Decl::Mod(_mod) => {
}
}
}

13
traits Normal file
View file

@ -0,0 +1,13 @@
trait Foo {
fn foo();
}
struct Bar impls Foo {
}
fn test(f: impl Foo) {
}
x = Bar {}
test(x)