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::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,11 +46,14 @@ 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(tree) => {
if let Ok(seg) = eval(tree.clone(), b.clone(), c.clone(), false) {
match seg {
Ctr::Seg(val) => { Ctr::Seg(val) => {
let val_tmp = val.borrow().clone(); let val_tmp = val.borrow().clone();
define(b, identifier.to_string(), Rc::new(val_tmp.car)); define(b, identifier.to_string(), Rc::new(val_tmp.car));
@ -59,6 +63,13 @@ pub fn get_export(env_cfg: bool) -> Function {
eprintln!("impossible args to export"); eprintln!("impossible args to export");
} }
} }
}
},
_ => {
eprintln!("args not in standard form");
}
}
return Ctr::None; return Ctr::None;
}, },
_ => { _ => {