implement hideously inefficient fix to work around rust
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
a1e19a19d9
commit
c70cbc701d
1 changed files with 13 additions and 3 deletions
16
src/sym.rs
16
src/sym.rs
|
|
@ -68,7 +68,7 @@ pub struct Symbol {
|
|||
|
||||
impl SymTable {
|
||||
pub fn new() -> SymTable {
|
||||
SymTable{0: HashMap::<String, Symbol>::new()}
|
||||
SymTable(HashMap::<String, Symbol>::new())
|
||||
}
|
||||
|
||||
pub fn get(&self, arg: &String) -> Option<&Symbol> {
|
||||
|
|
@ -84,7 +84,7 @@ impl SymTable {
|
|||
}
|
||||
|
||||
pub fn call_symbol(&mut self, name: &String, args: &Seg, call_func: bool) -> Result<Box<Ctr>, String> {
|
||||
let symbol = match self.get(name) {
|
||||
let symbol = match self.remove(name) {
|
||||
Some(s) => s,
|
||||
None => return Err(format!("undefined symbol: {}", name)),
|
||||
};
|
||||
|
|
@ -100,7 +100,16 @@ impl SymTable {
|
|||
cond_args = &outer_scope_seg_holder;
|
||||
}
|
||||
|
||||
symbol.call(cond_args, self)
|
||||
let res = symbol.call(cond_args, self);
|
||||
self.insert(name.to_string(), symbol);
|
||||
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SymTable {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +203,7 @@ impl Symbol {
|
|||
let outer_scope_eval: Box<Ctr>;
|
||||
if self.conditional_branches {
|
||||
let outer_scope_eval_result = eval(args, syms);
|
||||
// dont listen to clippy. using ? will move the value.
|
||||
if let Err(s) = outer_scope_eval_result {
|
||||
return Err(s);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue