Use proper symbol_table lookup in eval
This commit is contained in:
parent
16dc973aa6
commit
f6dcd7f0b8
@ -8,7 +8,7 @@ use itertools::Itertools;
|
|||||||
|
|
||||||
use crate::util::ScopeStack;
|
use crate::util::ScopeStack;
|
||||||
use crate::reduced_ast::{BoundVars, ReducedAST, Stmt, Expr, Lit, Func, Alternative, Subpattern};
|
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;
|
use crate::builtin::Builtin;
|
||||||
|
|
||||||
mod test;
|
mod test;
|
||||||
@ -466,7 +466,7 @@ impl<'a> State<'a> {
|
|||||||
//in the values table
|
//in the values table
|
||||||
|
|
||||||
let symbol_table = self.symbol_table_handle.borrow();
|
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 {
|
Ok(match value {
|
||||||
Some(Symbol { name, spec, .. }) => match spec {
|
Some(Symbol { name, spec, .. }) => match spec {
|
||||||
//TODO I'll need this type_name later to do a table lookup
|
//TODO I'll need this type_name later to do a table lookup
|
||||||
|
@ -31,6 +31,7 @@ mod debugging;
|
|||||||
mod tokenizing;
|
mod tokenizing;
|
||||||
mod ast;
|
mod ast;
|
||||||
mod parsing;
|
mod parsing;
|
||||||
|
#[macro_use]
|
||||||
mod symbol_table;
|
mod symbol_table;
|
||||||
mod builtin;
|
mod builtin;
|
||||||
mod reduced_ast;
|
mod reduced_ast;
|
||||||
|
@ -12,7 +12,7 @@ type LineNumber = u32;
|
|||||||
type SymbolTrackTable = HashMap<Rc<String>, LineNumber>;
|
type SymbolTrackTable = HashMap<Rc<String>, LineNumber>;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||||
pub struct FullyQualifiedSymbolName(Vec<ScopeSegment>);
|
pub struct FullyQualifiedSymbolName(pub Vec<ScopeSegment>);
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||||
pub struct ScopeSegment {
|
pub struct ScopeSegment {
|
||||||
@ -20,6 +20,12 @@ pub struct ScopeSegment {
|
|||||||
kind: ScopeSegmentKind,
|
kind: ScopeSegmentKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ScopeSegment {
|
||||||
|
pub fn new(name: Rc<String>, kind: ScopeSegmentKind) -> ScopeSegment {
|
||||||
|
ScopeSegment { name, kind }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||||
pub enum ScopeSegmentKind {
|
pub enum ScopeSegmentKind {
|
||||||
Function,
|
Function,
|
||||||
@ -33,10 +39,10 @@ macro_rules! fqsn {
|
|||||||
{
|
{
|
||||||
let mut vec = vec![];
|
let mut vec = vec![];
|
||||||
$(
|
$(
|
||||||
vec.push(ScopeSegment {
|
vec.push(ScopeSegment::new(
|
||||||
name: Rc::new($name.to_string()),
|
Rc::new($name.to_string()),
|
||||||
kind: sym_path_kind!($kind),
|
sym_path_kind!($kind),
|
||||||
});
|
));
|
||||||
)*
|
)*
|
||||||
FullyQualifiedSymbolName(vec)
|
FullyQualifiedSymbolName(vec)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user