Big referencing refactor
- RC+RefCell pattern used... everywhere - Ast type implemented - unit tests for func_call - more changes, but this commit scope has grown significantly and I cannot list them all
This commit is contained in:
parent
76b12a8214
commit
3434a49cc1
9 changed files with 446 additions and 391 deletions
17
src/vars.rs
17
src/vars.rs
|
|
@ -15,22 +15,23 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::boxed::Box;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::collections::HashMap;
|
||||
use crate::cell::{Ctr};
|
||||
use crate::segment::{Ctr};
|
||||
|
||||
/* Mapping between a string token and a tree of Cells
|
||||
/* Mapping between a string token and a tree of Segments
|
||||
* The string token can be found in any Ctr::Symbol value
|
||||
* it is expected that the trees stored are already evaluated
|
||||
*/
|
||||
pub type VTable = HashMap<String, Box<Ctr>>;
|
||||
pub type VTable = HashMap<String, Rc<Ctr>>;
|
||||
|
||||
pub fn define(
|
||||
vt: &mut Box<VTable>,
|
||||
vt: Rc<RefCell<VTable>>,
|
||||
identifier: String,
|
||||
var_tree: Box<Ctr>
|
||||
var_tree: Rc<Ctr>
|
||||
) {
|
||||
if let Some(boxed_cell) = vt.insert(identifier, var_tree) {
|
||||
drop(boxed_cell);
|
||||
if let Some(rc_segment) = vt.borrow_mut().insert(identifier, var_tree) {
|
||||
drop(rc_segment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue