diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index 4c42ca4..2416326 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -8,7 +8,7 @@ use itertools::Itertools; use crate::util::ScopeStack; use crate::reduced_ast::{BoundVars, ReducedAST, Stmt, Expr, Lit, Func, Alternative, Subpattern}; -use crate::symbol_table::{SymbolSpec, Symbol, SymbolTable}; +use crate::symbol_table::{SymbolSpec, Symbol, SymbolTable, ScopeSegment, ScopeSegmentKind, FullyQualifiedSymbolName}; use crate::builtin::Builtin; mod test; @@ -466,7 +466,7 @@ impl<'a> State<'a> { //in the values table let symbol_table = self.symbol_table_handle.borrow(); - let value = symbol_table.lookup_by_name(&name); + let value = symbol_table.lookup_by_path(&fqsn!(name ; tr)); Ok(match value { Some(Symbol { name, spec, .. }) => match spec { //TODO I'll need this type_name later to do a table lookup diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index ac96a04..34b39ff 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -31,6 +31,7 @@ mod debugging; mod tokenizing; mod ast; mod parsing; +#[macro_use] mod symbol_table; mod builtin; mod reduced_ast; diff --git a/schala-lang/language/src/symbol_table.rs b/schala-lang/language/src/symbol_table.rs index ffd47b4..b8edf8d 100644 --- a/schala-lang/language/src/symbol_table.rs +++ b/schala-lang/language/src/symbol_table.rs @@ -12,7 +12,7 @@ type LineNumber = u32; type SymbolTrackTable = HashMap, LineNumber>; #[derive(PartialEq, Eq, Hash, Debug, Clone)] -pub struct FullyQualifiedSymbolName(Vec); +pub struct FullyQualifiedSymbolName(pub Vec); #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct ScopeSegment { @@ -20,6 +20,12 @@ pub struct ScopeSegment { kind: ScopeSegmentKind, } +impl ScopeSegment { + pub fn new(name: Rc, kind: ScopeSegmentKind) -> ScopeSegment { + ScopeSegment { name, kind } + } +} + #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum ScopeSegmentKind { Function, @@ -33,10 +39,10 @@ macro_rules! fqsn { { let mut vec = vec![]; $( - vec.push(ScopeSegment { - name: Rc::new($name.to_string()), - kind: sym_path_kind!($kind), - }); + vec.push(ScopeSegment::new( + Rc::new($name.to_string()), + sym_path_kind!($kind), + )); )* FullyQualifiedSymbolName(vec) }