feat: finish to_ex_mem for constant
Co-authored-by: Kasey White <kwhitemsg@gmail.com>
This commit is contained in:
parent
f332dfeb38
commit
77a7b11467
|
@ -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,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue