circuit handles load commands better
Signed-off-by: Ava Hahn <ava@sunnypup.io>
This commit is contained in:
parent
921deb9e5e
commit
ab14ba4b5e
7 changed files with 43 additions and 14 deletions
|
|
@ -314,10 +314,14 @@ pub fn circuit_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
Ctr::Seg(s) if expand_eval_res => {
|
||||
if let Ctr::Bool(b) = *s.car {
|
||||
return b;
|
||||
} else if let Ctr::Integer(i) = *s.car {
|
||||
return i==0;
|
||||
} else {
|
||||
error = "impossible condition in circuit form".to_string();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Ctr::Integer(i) => return i == 0,
|
||||
|
||||
_ => error = format!("{cursor} form did not evaluate to a boolean"),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -211,7 +211,8 @@ pub fn load_posix_shell(syms: &mut SymTable, shell_state: Rc<RefCell<ShellState>
|
|||
}
|
||||
|
||||
|
||||
// these clones are needed for callbacks which consume references
|
||||
// these clones are needed for callbacks which move references
|
||||
let load_ss = shell_state.clone();
|
||||
let bg_ss = shell_state.clone();
|
||||
let q_ss = shell_state.clone();
|
||||
|
||||
|
|
@ -229,6 +230,20 @@ pub fn load_posix_shell(syms: &mut SymTable, shell_state: Rc<RefCell<ShellState>
|
|||
},
|
||||
);
|
||||
|
||||
syms.insert(
|
||||
String::from("load"),
|
||||
Symbol {
|
||||
name: String::from("load"),
|
||||
args: Args::Infinite,
|
||||
conditional_branches: true,
|
||||
docs: String::from(LOAD_DOCSTRING),
|
||||
value: ValueType::Internal(Rc::new(move |ast: &Seg, symtable: &mut SymTable| -> Result<Ctr, String> {
|
||||
load_callback(ast, symtable, &mut load_ss.borrow_mut())
|
||||
})),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
||||
syms.insert(
|
||||
String::from("bg"),
|
||||
Symbol {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue