diff --git a/Cargo.toml b/Cargo.toml index dfd766f..6ebd7e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,6 @@ members = [ "linter", "codelocation", "types", - "cachectx"] + "cachectx", "typetable"] resolver = "2" diff --git a/cachectx/Cargo.toml b/cachectx/Cargo.toml index 48b78e8..15f565f 100644 --- a/cachectx/Cargo.toml +++ b/cachectx/Cargo.toml @@ -10,6 +10,7 @@ lexer = { path = "../lexer" } parser = { path = "../parser" } ast = { path = "../ast" } symtable = { path = "../symtable" } +typetable = { path = "../typetable" } types = { path = "../types" } linter = { path = "../linter" } ir = { path = "../ir" } diff --git a/cachectx/src/lib.rs b/cachectx/src/lib.rs index b007163..716dc8d 100644 --- a/cachectx/src/lib.rs +++ b/cachectx/src/lib.rs @@ -4,6 +4,7 @@ use parser::*; use std::{fs::File, io::Read, path::PathBuf, rc::Rc}; use symtable::*; use types::*; +use typetable::*; struct InternalContext { source: PathBuf, diff --git a/e2e/Cargo.toml b/e2e/Cargo.toml index eae49b2..bf50b43 100644 --- a/e2e/Cargo.toml +++ b/e2e/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] ast = { path = "../ast" } linker = { path = "../linker" } -symtable = { path = "../symtable" } +typetable = { path = "../typetable" } lexer = { path = "../lexer" } token = { path = "../token" } parser = { path = "../parser" } diff --git a/e2e/src/main.rs b/e2e/src/main.rs index 91b69e1..d4432e8 100644 --- a/e2e/src/main.rs +++ b/e2e/src/main.rs @@ -4,7 +4,7 @@ use linter::LintSource; use parser::Parser; use std::fs::File; use std::io::Read; -use symtable::TypeTable; +use typetable::TypeTable; use std::path::Path; use std::process::Command; diff --git a/ir/Cargo.toml b/ir/Cargo.toml index 734fa72..1bd0b3b 100644 --- a/ir/Cargo.toml +++ b/ir/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" [dependencies] ast = { path="../ast" } symtable = { path="../symtable" } +typetable = { path="../typetable" } token = { path="../token" } perror = { path="../perror" } lexer = { path="../lexer" } diff --git a/ir/src/lib.rs b/ir/src/lib.rs index fc2b840..bce8b61 100644 --- a/ir/src/lib.rs +++ b/ir/src/lib.rs @@ -13,6 +13,7 @@ use perror::*; use std::rc::Rc; use symtable::*; use types::*; +use typetable::*; pub struct IRSource<'tt> { package: u32, diff --git a/linter/Cargo.toml b/linter/Cargo.toml index d85ec63..c2f1820 100644 --- a/linter/Cargo.toml +++ b/linter/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] ast = { path = "../ast" } types = { path = "../types" } -symtable = { path = "../symtable" } +typetable = { path = "../typetable" } parser = { path = "../parser" } token = { path = "../token" } lexer = { path = "../lexer" } diff --git a/linter/src/lib.rs b/linter/src/lib.rs index cdeea40..546d63e 100644 --- a/linter/src/lib.rs +++ b/linter/src/lib.rs @@ -4,9 +4,9 @@ use lexer::*; use perror::LinterError; use perror::LinterErrorPoint; use std::rc::Rc; -use symtable::*; use token::Token; use types::*; +use typetable::*; type ResultTreeType = Result<(Rc>, Ty), usize>; @@ -115,7 +115,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = init.block_curried.clone(); let full = tree!(FuncInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); Ok((full, curried)) } @@ -193,7 +193,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let full = tree!(SymbolInit, sym); self.ttbl .table - .insert(symbol.val.slice.clone(), (Rc::clone(&full), 0)); + .insert(symbol.val.slice.clone(), Rc::clone(&full)); return Ok((full, curried)); } @@ -205,7 +205,6 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { .table .get(&symbol.val.slice) .unwrap() - .0 .get_curried() .clone(), }; @@ -246,7 +245,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = err_info.curried.clone(); let full = tree!(ErrorInfo, err_info); - self.ttbl.table.insert(slice.clone(), (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice.clone(), Rc::clone(&full)); return Ok((full, curried)); } @@ -343,7 +342,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = obj_info.curried.clone(); let full = tree!(StructInfo, obj_info); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, curried)); } Err(self.set_error( @@ -364,7 +363,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = init.curried.clone(); let full = tree!(PropInit, init); - self.ttbl.table.insert(slice.clone(), (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice.clone(), Rc::clone(&full)); return Ok((full, curried)); } @@ -394,10 +393,9 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = struct_init.curried.clone(); let full = tree!(StructInit, struct_init); - self.ttbl.table.insert( - prev.0.into_symbol_access().ident.clone(), - (Rc::clone(&full), 0), - ); + self.ttbl + .table + .insert(prev.0.into_symbol_access().ident.clone(), Rc::clone(&full)); return Ok((full, curried)); } Err(self.set_error( @@ -434,7 +432,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = tag_info.curried.clone(); let full = tree!(TagInfo, tag_info); - self.ttbl.table.insert(copy, (Rc::clone(&full), 0)); + self.ttbl.table.insert(copy, Rc::clone(&full)); return Ok((full, curried)); } @@ -467,7 +465,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = init.block_curried.clone(); let full = tree!(FuncInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); Ok((full, curried)) } @@ -483,11 +481,11 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = init.curried.clone(); if import.mutability.token == Token::Const { let full: Rc> = tree!(ConstInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, Ty::Const(Box::new(curried)))); } let full: Rc> = tree!(MutInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, Ty::Mut(Box::new(curried)))); } @@ -504,12 +502,12 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { if inner.mutability.token == Token::Const { init.curried = Ty::Const(Box::new(init.curried)); let full: Rc> = tree!(ConstInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, Ty::Const(Box::new(curried)))); } init.curried = Ty::Mut(Box::new(init.curried)); let full: Rc> = tree!(MutInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, Ty::Mut(Box::new(curried)))); } @@ -525,11 +523,11 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = init.curried.clone(); if td.mutability.token == Token::Const { let full: Rc> = tree!(ConstInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, Ty::Const(Box::new(curried)))); } let full: Rc> = tree!(MutInit, init); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, Ty::Mut(Box::new(curried)))); } @@ -617,7 +615,7 @@ impl<'buf, 'sym> LintSource<'buf, 'sym> { let curried = a.curried.clone(); self.curr_self = Some(a.curried.clone()); let full: Rc> = tree!(ArgInit, a); - self.ttbl.table.insert(slice, (Rc::clone(&full), 0)); + self.ttbl.table.insert(slice, Rc::clone(&full)); return Ok((full, curried)); } diff --git a/objmaker/Cargo.toml b/objmaker/Cargo.toml index 40502d9..bf2ec97 100644 --- a/objmaker/Cargo.toml +++ b/objmaker/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" [dependencies] ast = { path = "../ast" } symtable = { path = "../symtable" } +typetable = { path = "../typetable" } lexer = { path = "../lexer" } linter = { path = "../linter" } token = { path = "../token" } diff --git a/objmaker/src/lib.rs b/objmaker/src/lib.rs index bb8d747..6b7bb85 100644 --- a/objmaker/src/lib.rs +++ b/objmaker/src/lib.rs @@ -12,7 +12,7 @@ use std::io::Read; use std::path::Path; use std::path::PathBuf; use symtable::SymTable; -use symtable::TypeTable; +use typetable::TypeTable; pub fn from_buffer(contents: &str, path: &Path) -> () { let lex = TLexer::new(&contents); @@ -23,6 +23,9 @@ pub fn from_buffer(contents: &str, path: &Path) -> () { let lint_res = linter.lint_check(&ast_parsed); let mut ir = IRSource::new(0, SymTable::new(), linter.ttbl); if linter.issues.len() > 0 { + for x in linter.issues { + println!("{}", x); + } panic!("linter issues exist"); } let rc_thing = lint_res.first().unwrap().to_owned(); diff --git a/symtable/Cargo.toml b/symtable/Cargo.toml index 28b912b..e8f43e2 100644 --- a/symtable/Cargo.toml +++ b/symtable/Cargo.toml @@ -6,4 +6,3 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -types = { path = "../types" } diff --git a/symtable/src/lib.rs b/symtable/src/lib.rs index 65975ca..a21c0fe 100644 --- a/symtable/src/lib.rs +++ b/symtable/src/lib.rs @@ -1,19 +1,4 @@ use std::collections::BTreeMap; -use std::rc::Rc; -use types::*; - -//todo:: this is for when we are using the TypeTree -pub struct TypeTable { - pub table: BTreeMap>, u32)>, -} - -impl TypeTable { - pub fn new() -> Self { - TypeTable { - table: BTreeMap::new(), - } - } -} pub struct SymTable { pub table: BTreeMap, diff --git a/todos.txt b/todos.txt index 0f048a2..7afddec 100644 --- a/todos.txt +++ b/todos.txt @@ -1,6 +1,2 @@ -- readup on all conversations in zulip chat to refamiliarlize myself -- figure out data layout and how modules build in cranelift -- look up linters and how to do so -- mark down linter todos as far as what is not allowed: ie valid syntax, but incorrect context -- type work in Lexers + IR for signatures -- formalize SLT and IRSource job and how that works. +- data layout +- scopes diff --git a/typetable/Cargo.toml b/typetable/Cargo.toml new file mode 100644 index 0000000..7f94a6d --- /dev/null +++ b/typetable/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "typetable" +version = "0.1.0" +edition = "2021" + +[dependencies] +types = { path = "../types" } diff --git a/typetable/src/lib.rs b/typetable/src/lib.rs new file mode 100644 index 0000000..ba02998 --- /dev/null +++ b/typetable/src/lib.rs @@ -0,0 +1,15 @@ +use std::collections::BTreeMap; +use std::rc::Rc; +use types::*; + +pub struct TypeTable { + pub table: BTreeMap>>, +} + +impl TypeTable { + pub fn new() -> Self { + TypeTable { + table: BTreeMap::new(), + } + } +}