feat: finish to_ex_mem for constant

Co-authored-by: Kasey White <kwhitemsg@gmail.com>
This commit is contained in:
rvcas 2022-07-20 23:52:26 -04:00 committed by Kasey White
parent f332dfeb38
commit 77a7b11467
1 changed files with 1 additions and 5 deletions

View File

@ -359,20 +359,16 @@ impl Value {
pub fn to_ex_mem(&self) -> i64 { pub fn to_ex_mem(&self) -> i64 {
match self { match self {
// TODO: this is not 1
Value::Con(c) => match c { Value::Con(c) => match c {
Constant::Integer(i) => { Constant::Integer(i) => {
if *i == 0 { if *i == 0 {
1 1
} else { } else {
//TODO ((i.abs() as f64).log2().floor() as i64 / 64) + 1
// std::mem::size_of( i.abs()
1
} }
} }
Constant::ByteString(b) => (((b.len() - 1) / 8) + 1) as i64, Constant::ByteString(b) => (((b.len() - 1) / 8) + 1) as i64,
Constant::String(s) => s.chars().count() as i64, Constant::String(s) => s.chars().count() as i64,
Constant::Char(_) => 1,
Constant::Unit => 1, Constant::Unit => 1,
Constant::Bool(_) => 1, Constant::Bool(_) => 1,
}, },