var export works now lol

This commit is contained in:
Aidan Hahn 2021-11-14 22:55:52 -08:00
parent 5d345a4c73
commit c465c974d4
No known key found for this signature in database
GPG key ID: 327711E983899316

View file

@ -19,6 +19,7 @@ use std::cell::RefCell;
use std::rc::Rc;
use std::collections::HashMap;
use crate::segment::{Ctr, Ast};
use crate::eval::eval;
use crate::func::{Function, Operation, Args, FTable};
/* Mapping between a string token and a tree of Segments
* 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,
args: Args::Lazy(2),
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();
match &inner.car {
Ctr::Symbol(identifier) => {
match eval(inner.cdr) {
Ctr::Seg(val) => {
let val_tmp = val.borrow().clone();
define(b, identifier.to_string(), Rc::new(val_tmp.car));
match &inner.cdr {
Ctr::Seg(tree) => {
if let Ok(seg) = eval(tree.clone(), b.clone(), c.clone(), false) {
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;