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,5 +1,4 @@
fn main fn main {
{
urmom(); urmom();
isEven(); isEven();
5 5

View file

@ -5,9 +5,16 @@ pub struct Program {
#[derive(Debug)] #[derive(Debug)]
pub enum Decl { pub enum Decl {
Mod(Mod),
Func(Func), Func(Func),
} }
#[derive(Debug)]
pub struct Mod {
pub name: Ident,
pub decls: Vec<Decl>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Func { pub struct Func {
pub name: Ident, pub name: Ident,
@ -39,3 +46,6 @@ pub enum Type {}
#[derive(Clone, Debug, Hash, PartialEq, Eq)] #[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct Ident(pub String); 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 Graph = DiGraphMap<Id, ()>;
type Scopes = Vec<HashSet<String>>; type Scopes = Vec<HashSet<String>>;
pub enum HExpr {
}
#[derive(Debug)] #[derive(Debug)]
pub struct Namespaces { pub struct Namespaces {
funcs: HashMap<Id, Func>, funcs: HashMap<Id, Func>,
@ -20,9 +24,9 @@ pub struct Namespaces {
impl Namespaces { impl Namespaces {
pub fn create(program: Program) -> Self { pub fn create(program: Program) -> Self {
let mut funcs = HashMap::new(); let mut funcs = HashMap::new();
let mut types = HashMap::new(); let types = HashMap::new();
let mut func_names = HashMap::new(); let mut func_names = HashMap::new();
let mut type_names = HashMap::new(); let type_names = HashMap::new();
for decl in program.decls { for decl in program.decls {
match decl { match decl {
@ -31,6 +35,8 @@ impl Namespaces {
func_names.insert(func.name.0.clone(), id); func_names.insert(func.name.0.clone(), id);
funcs.insert(id, func); 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)