Add lookup_by_name to symbol table
This commit is contained in:
parent
da59fae0d3
commit
5f336ec1a9
@ -290,7 +290,7 @@ impl<'a> State<'a> {
|
||||
//in the values table
|
||||
|
||||
let symbol_table = self.symbol_table_handle.borrow();
|
||||
let value = symbol_table.values.get(&name);
|
||||
let value = symbol_table.lookup_by_name(&name);
|
||||
Ok(match value {
|
||||
Some(Symbol { name, spec }) => match spec {
|
||||
SymbolSpec::DataConstructor { type_name, type_args, .. } => {
|
||||
|
@ -117,7 +117,7 @@ impl Expression {
|
||||
BinExp(binop, lhs, rhs) => binop.reduce(symbol_table, lhs, rhs),
|
||||
PrefixExp(op, arg) => op.reduce(symbol_table, arg),
|
||||
Value(name) => {
|
||||
match symbol_table.values.get(name) {
|
||||
match symbol_table.lookup_by_name(name) {
|
||||
Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::NewConstructor {
|
||||
type_name: type_name.clone(),
|
||||
name: name.clone(),
|
||||
|
@ -17,6 +17,10 @@ impl SymbolTable {
|
||||
pub fn new() -> SymbolTable {
|
||||
SymbolTable { values: HashMap::new() }
|
||||
}
|
||||
|
||||
pub fn lookup_by_name(&self, name: &Rc<String>) -> Option<&Symbol> {
|
||||
self.values.get(name)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user