From 4665d112796311dde8dac663fa6f8f7b234162ae Mon Sep 17 00:00:00 2001 From: pjht Date: Thu, 20 Oct 2022 11:29:06 -0500 Subject: [PATCH] Extract SymbolTable to separate file --- src/main.rs | 29 ++--------------------------- src/symbol_table.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 src/symbol_table.rs diff --git a/src/main.rs b/src/main.rs index 7cb99ee..d4dd4a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ mod ram; mod rom; mod storage; mod symbol; +mod symbol_table; mod term; use crate::{ backplane::Backplane, @@ -38,33 +39,7 @@ use std::{ path::Path, process, }; - -#[derive(Debug)] -pub struct SymbolTable { - symbols: HashMap, - breakpoints: IndexSet, - active: bool, -} - -impl SymbolTable { - fn new(symbols: HashMap) -> Self { - Self { - symbols, - breakpoints: IndexSet::new(), - active: true, - } - } - - fn update_symbols(&mut self, symbols: HashMap) { - self.breakpoints = self - .breakpoints - .iter() - .cloned() - .filter(|sym| symbols.contains_key(sym)) - .collect::>(); - self.symbols = symbols; - } -} +use symbol_table::SymbolTable; pub type SymbolTables = IndexMap; diff --git a/src/symbol_table.rs b/src/symbol_table.rs new file mode 100644 index 0000000..86f6d29 --- /dev/null +++ b/src/symbol_table.rs @@ -0,0 +1,30 @@ +use crate::symbol::Symbol; +use indexmap::IndexSet; +use std::collections::HashMap; + +#[derive(Debug)] +pub struct SymbolTable { + pub symbols: HashMap, + pub breakpoints: IndexSet, + pub active: bool, +} + +impl SymbolTable { + pub fn new(symbols: HashMap) -> Self { + Self { + symbols, + breakpoints: IndexSet::new(), + active: true, + } + } + + pub fn update_symbols(&mut self, symbols: HashMap) { + self.breakpoints = self + .breakpoints + .iter() + .cloned() + .filter(|sym| symbols.contains_key(sym)) + .collect::>(); + self.symbols = symbols; + } +}