Sort symbols in debug
This commit is contained in:
parent
58251d3f28
commit
5a9f3c1850
@ -11,7 +11,7 @@ use crate::typechecking::TypeName;
|
|||||||
type LineNumber = u32;
|
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, PartialOrd, Ord)]
|
||||||
pub struct FullyQualifiedSymbolName(pub Vec<ScopeSegment>);
|
pub struct FullyQualifiedSymbolName(pub Vec<ScopeSegment>);
|
||||||
|
|
||||||
impl fmt::Display for FullyQualifiedSymbolName {
|
impl fmt::Display for FullyQualifiedSymbolName {
|
||||||
@ -24,7 +24,7 @@ impl fmt::Display for FullyQualifiedSymbolName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||||
pub struct ScopeSegment {
|
pub struct ScopeSegment {
|
||||||
pub name: Rc<String>, //TODO maybe this could be a &str, for efficiency?
|
pub name: Rc<String>, //TODO maybe this could be a &str, for efficiency?
|
||||||
pub kind: ScopeSegmentKind,
|
pub kind: ScopeSegmentKind,
|
||||||
@ -49,7 +49,7 @@ impl ScopeSegment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||||
pub enum ScopeSegmentKind {
|
pub enum ScopeSegmentKind {
|
||||||
Function,
|
Function,
|
||||||
Type,
|
Type,
|
||||||
@ -220,7 +220,9 @@ impl SymbolTable {
|
|||||||
}
|
}
|
||||||
pub fn debug_symbol_table(&self) -> String {
|
pub fn debug_symbol_table(&self) -> String {
|
||||||
let mut output = format!("Symbol table\n");
|
let mut output = format!("Symbol table\n");
|
||||||
for (name, sym) in &self.symbol_path_to_symbol {
|
let mut sorted_symbols: Vec<(&FullyQualifiedSymbolName, &Symbol)> = self.symbol_path_to_symbol.iter().collect();
|
||||||
|
sorted_symbols.sort_by(|(fqsn, _), (other_fqsn, _)| fqsn.cmp(other_fqsn));
|
||||||
|
for (name, sym) in sorted_symbols.iter() {
|
||||||
write!(output, "{} -> {}\n", name, sym).unwrap();
|
write!(output, "{} -> {}\n", name, sym).unwrap();
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
|
Loading…
Reference in New Issue
Block a user