start accounting for pure/impure builtins

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2024-06-12 11:13:34 -07:00
parent 2809569c35
commit 143173f046
6 changed files with 38 additions and 0 deletions

View file

@ -199,6 +199,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: CONS_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(cons_callback)),
optimizable: true,
..Default::default()
},
);
@ -211,6 +212,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: LEN_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(len_callback)),
optimizable: true,
..Default::default()
},
);
@ -223,6 +225,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: CAR_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(car_callback)),
optimizable: true,
..Default::default()
},
);
@ -235,6 +238,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: CDR_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(cdr_callback)),
optimizable: true,
..Default::default()
},
);
@ -247,6 +251,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: POP_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(pop_callback)),
optimizable: true,
..Default::default()
},
);
@ -259,6 +264,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: DEQUEUE_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(dequeue_callback)),
optimizable: true,
..Default::default()
},
);
@ -271,6 +277,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: REVERSE_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(reverse_callback)),
optimizable: true,
..Default::default()
},
);
@ -283,6 +290,7 @@ pub fn add_list_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ISLIST_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(islist_callback)),
optimizable: true,
..Default::default()
},
);

View file

@ -150,6 +150,7 @@ pub fn add_bool_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: AND_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(and_callback)),
optimizable: true,
..Default::default()
},
);
@ -162,6 +163,7 @@ pub fn add_bool_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: BOOLCAST_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(boolcast_callback)),
optimizable: true,
..Default::default()
},
);
@ -174,6 +176,7 @@ pub fn add_bool_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: OR_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(or_callback)),
optimizable: true,
..Default::default()
},
);
@ -186,6 +189,7 @@ pub fn add_bool_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: NOT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(not_callback)),
optimizable: true,
..Default::default()
},
);
@ -198,6 +202,7 @@ pub fn add_bool_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ISEQ_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(iseq_callback)),
optimizable: true,
..Default::default()
},
);

View file

@ -432,6 +432,7 @@ pub fn add_control_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ASSERT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(assert_callback)),
optimizable: true,
..Default::default()
},
);
@ -444,6 +445,7 @@ pub fn add_control_lib(syms: &mut SymTable) {
conditional_branches: true,
docs: IF_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(if_callback)),
optimizable: true,
..Default::default()
},
);
@ -480,6 +482,7 @@ pub fn add_control_lib(syms: &mut SymTable) {
conditional_branches: true,
docs: CIRCUIT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(circuit_callback)),
optimizable: true,
..Default::default()
},
);

View file

@ -532,6 +532,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ADD_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(add_callback)),
optimizable: true,
..Default::default()
},
);
@ -544,6 +545,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: SUB_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(sub_callback)),
optimizable: true,
..Default::default()
},
);
@ -556,6 +558,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: DIV_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(div_callback)),
optimizable: true,
..Default::default()
},
);
@ -568,6 +571,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: MUL_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(mul_callback)),
optimizable: true,
..Default::default()
},
);
@ -580,6 +584,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: INTCAST_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(intcast_callback)),
optimizable: true,
..Default::default()
},
);
@ -592,6 +597,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: FLOATCAST_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(floatcast_callback)),
optimizable: true,
..Default::default()
},
);
@ -603,6 +609,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
args: Args::Lazy(2),
conditional_branches: false,
docs: EXP_DOCSTRING.to_string(),
optimizable: true,
value: ValueType::Internal(Rc::new(exp_callback)),
..Default::default()
},
@ -616,6 +623,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: MOD_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(mod_callback)),
optimizable: true,
..Default::default()
},
);
@ -628,6 +636,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ISGT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(isgt_callback)),
optimizable: true,
..Default::default()
},
);
@ -640,6 +649,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ISLT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(islt_callback)),
optimizable: true,
..Default::default()
},
);
@ -652,6 +662,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ISGTE_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(isgte_callback)),
optimizable: true,
..Default::default()
},
);
@ -664,6 +675,7 @@ pub fn add_math_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: ISLTE_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(islte_callback)),
optimizable: true,
..Default::default()
},
);

View file

@ -201,6 +201,7 @@ pub fn add_string_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: CONCAT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(concat_callback)),
optimizable: true,
..Default::default()
},
);
@ -213,6 +214,7 @@ pub fn add_string_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: SUBSTR_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(substr_callback)),
optimizable: true,
..Default::default()
},
);
@ -225,6 +227,7 @@ pub fn add_string_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: SPLIT_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(split_callback)),
optimizable: true,
..Default::default()
},
);
@ -237,6 +240,7 @@ pub fn add_string_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: STRLEN_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(strlen_callback)),
optimizable: true,
..Default::default()
},
);
@ -249,6 +253,7 @@ pub fn add_string_lib(syms: &mut SymTable) {
conditional_branches: false,
docs: STRCAST_DOCSTRING.to_string(),
value: ValueType::Internal(Rc::new(strcast_callback)),
optimizable: true,
..Default::default()
},
);

View file

@ -70,6 +70,10 @@ pub struct Symbol {
// see SymTable::Insert
// (only pub begrudgingly)
pub __generation: usize,
// here this means either that
// a variable is constant or that
// a function is pure.
pub optimizable: bool,
}
impl SymTable {
@ -545,6 +549,7 @@ impl Default for Symbol {
args: Args::None,
conditional_branches: false,
__generation: 0,
optimizable: false
}
}
}