refmt
This commit is contained in:
parent
f805290a4b
commit
be73b0b828
17 changed files with 588 additions and 675 deletions
36
src/stl.rs
36
src/stl.rs
|
|
@ -15,24 +15,24 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::segment::{Ctr};
|
||||
use crate::str::{get_echo, get_concat};
|
||||
use crate::append::get_append;
|
||||
use crate::func::{FTable, func_declare};
|
||||
use crate::vars::{VTable, get_export};
|
||||
use std::rc::Rc;
|
||||
use crate::func::{func_declare, FTable};
|
||||
use crate::segment::Ctr;
|
||||
use crate::str::{get_concat, get_echo};
|
||||
use crate::vars::{get_export, VTable};
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn get_stdlib(conf: Rc<RefCell<VTable>>) -> Result<Rc<RefCell<FTable>>, String> {
|
||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_echo()))) {
|
||||
return Err(s)
|
||||
return Err(s);
|
||||
}
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_append()))) {
|
||||
return Err(s)
|
||||
return Err(s);
|
||||
}
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_concat()))) {
|
||||
return Err(s)
|
||||
return Err(s);
|
||||
}
|
||||
|
||||
let mut cfg_env = true;
|
||||
|
|
@ -40,22 +40,18 @@ pub fn get_stdlib(conf: Rc<RefCell<VTable>>) -> Result<Rc<RefCell<FTable>>, Stri
|
|||
None => {
|
||||
println!("CFG_RELISH_ENV not defined. defaulting to ON.")
|
||||
}
|
||||
Some(ctr) => {
|
||||
match (**ctr).clone() {
|
||||
Ctr::String(ref s) => {
|
||||
cfg_env = s.eq("0")
|
||||
}
|
||||
_ => {
|
||||
println!("Invalid value for CFG_RELISH_ENV. must be a string (0 or 1).");
|
||||
println!("Defaulting CFG_RELISH_ENV to ON");
|
||||
}
|
||||
Some(ctr) => match (**ctr).clone() {
|
||||
Ctr::String(ref s) => cfg_env = s.eq("0"),
|
||||
_ => {
|
||||
println!("Invalid value for CFG_RELISH_ENV. must be a string (0 or 1).");
|
||||
println!("Defaulting CFG_RELISH_ENV to ON");
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_export(cfg_env)))) {
|
||||
return Err(s)
|
||||
return Err(s);
|
||||
}
|
||||
|
||||
return Ok(ft)
|
||||
return Ok(ft);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue