Add id_to_fqsn table on symbol table
This commit is contained in:
parent
c9052e0a3b
commit
6ebe893acb
@ -9,7 +9,7 @@ mod operators;
|
||||
pub use operators::*;
|
||||
|
||||
/// An abstract identifier for an AST node
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||
pub struct ItemId {
|
||||
idx: u32,
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::fmt;
|
||||
use std::fmt::Write;
|
||||
|
||||
use crate::ast;
|
||||
use crate::ast::{Meta, TypeBody, TypeSingletonName, Signature, Statement, StatementKind};
|
||||
use crate::ast::{ItemId, Meta, TypeBody, TypeSingletonName, Signature, Statement, StatementKind};
|
||||
use crate::typechecking::TypeName;
|
||||
|
||||
type LineNumber = u32;
|
||||
@ -81,6 +81,7 @@ macro_rules! sym_path_kind {
|
||||
//cf. p. 150 or so of Language Implementation Patterns
|
||||
pub struct SymbolTable {
|
||||
symbol_path_to_symbol: HashMap<FullyQualifiedSymbolName, Symbol>,
|
||||
id_to_fqsn: HashMap<ItemId, FullyQualifiedSymbolName>,
|
||||
}
|
||||
|
||||
//TODO add various types of lookups here, maybe multiple hash tables internally?
|
||||
@ -88,9 +89,14 @@ impl SymbolTable {
|
||||
pub fn new() -> SymbolTable {
|
||||
SymbolTable {
|
||||
symbol_path_to_symbol: HashMap::new(),
|
||||
id_to_fqsn: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_id_to_fqsn(&mut self, id: &ItemId, fqsn: FullyQualifiedSymbolName) {
|
||||
self.id_to_fqsn.insert(id.clone(), fqsn);
|
||||
}
|
||||
|
||||
fn add_new_symbol(&mut self, name: &Rc<String>, scope_path: &Vec<ScopeSegment>, spec: SymbolSpec) {
|
||||
let mut vec: Vec<ScopeSegment> = scope_path.clone();
|
||||
vec.push(ScopeSegment { name: name.clone(), kind: ScopeSegmentKind::Terminal });
|
||||
|
Loading…
Reference in New Issue
Block a user