var export works now lol
This commit is contained in:
parent
5d345a4c73
commit
c465c974d4
1 changed files with 17 additions and 6 deletions
23
src/vars.rs
23
src/vars.rs
|
|
@ -19,6 +19,7 @@ use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::segment::{Ctr, Ast};
|
use crate::segment::{Ctr, Ast};
|
||||||
|
use crate::eval::eval;
|
||||||
use crate::func::{Function, Operation, Args, FTable};
|
use crate::func::{Function, Operation, Args, FTable};
|
||||||
/* Mapping between a string token and a tree of Segments
|
/* Mapping between a string token and a tree of Segments
|
||||||
* The string token can be found in any Ctr::Symbol value
|
* The string token can be found in any Ctr::Symbol value
|
||||||
|
|
@ -45,18 +46,28 @@ pub fn get_export(env_cfg: bool) -> Function {
|
||||||
eval_lazy: true,
|
eval_lazy: true,
|
||||||
args: Args::Lazy(2),
|
args: Args::Lazy(2),
|
||||||
function: Operation::Internal(
|
function: Operation::Internal(
|
||||||
|a: Ast, b: Rc<RefCell<VTable>>, _c: Rc<RefCell<FTable>>| -> Ctr {
|
|a: Ast, b: Rc<RefCell<VTable>>, c: Rc<RefCell<FTable>>| -> Ctr {
|
||||||
let inner = a.borrow_mut();
|
let inner = a.borrow_mut();
|
||||||
match &inner.car {
|
match &inner.car {
|
||||||
Ctr::Symbol(identifier) => {
|
Ctr::Symbol(identifier) => {
|
||||||
match eval(inner.cdr) {
|
match &inner.cdr {
|
||||||
Ctr::Seg(val) => {
|
Ctr::Seg(tree) => {
|
||||||
let val_tmp = val.borrow().clone();
|
if let Ok(seg) = eval(tree.clone(), b.clone(), c.clone(), false) {
|
||||||
define(b, identifier.to_string(), Rc::new(val_tmp.car));
|
match seg {
|
||||||
|
Ctr::Seg(val) => {
|
||||||
|
let val_tmp = val.borrow().clone();
|
||||||
|
define(b, identifier.to_string(), Rc::new(val_tmp.car));
|
||||||
|
},
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
eprintln!("impossible args to export");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
eprintln!("impossible args to export");
|
eprintln!("args not in standard form");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ctr::None;
|
return Ctr::None;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue