Change number inputs to be f32 instead of f64 for most nodes (#1543)

This commit is contained in:
Dennis Kobert
2024-01-05 14:13:26 +01:00
committed by GitHub
parent d268afb7fb
commit 6bfb2bf344
6 changed files with 28 additions and 18 deletions

View File

@@ -20,6 +20,7 @@ pub enum TaggedValue {
None,
String(String),
U32(u32),
U64(u64),
F32(f32),
F64(f64),
Bool(bool),
@@ -82,6 +83,7 @@ impl Hash for TaggedValue {
Self::None => {}
Self::String(x) => x.hash(state),
Self::U32(x) => x.hash(state),
Self::U64(x) => x.hash(state),
Self::F32(x) => x.to_bits().hash(state),
Self::F64(x) => x.to_bits().hash(state),
Self::Bool(x) => x.hash(state),
@@ -159,6 +161,7 @@ impl<'a> TaggedValue {
TaggedValue::None => Box::new(()),
TaggedValue::String(x) => Box::new(x),
TaggedValue::U32(x) => Box::new(x),
TaggedValue::U64(x) => Box::new(x),
TaggedValue::F32(x) => Box::new(x),
TaggedValue::F64(x) => Box::new(x),
TaggedValue::Bool(x) => Box::new(x),
@@ -219,6 +222,7 @@ impl<'a> TaggedValue {
TaggedValue::None => "()".to_string(),
TaggedValue::String(x) => format!("\"{x}\""),
TaggedValue::U32(x) => x.to_string() + "_u32",
TaggedValue::U64(x) => x.to_string() + "_u64",
TaggedValue::F32(x) => x.to_string() + "_f32",
TaggedValue::F64(x) => x.to_string() + "_f64",
TaggedValue::Bool(x) => x.to_string(),
@@ -233,6 +237,7 @@ impl<'a> TaggedValue {
TaggedValue::None => concrete!(()),
TaggedValue::String(_) => concrete!(String),
TaggedValue::U32(_) => concrete!(u32),
TaggedValue::U64(_) => concrete!(u64),
TaggedValue::F32(_) => concrete!(f32),
TaggedValue::F64(_) => concrete!(f64),
TaggedValue::Bool(_) => concrete!(bool),
@@ -296,6 +301,7 @@ impl<'a> TaggedValue {
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
x if x == TypeId::of::<String>() => Ok(TaggedValue::String(*downcast(input).unwrap())),
x if x == TypeId::of::<u32>() => Ok(TaggedValue::U32(*downcast(input).unwrap())),
x if x == TypeId::of::<u64>() => Ok(TaggedValue::U64(*downcast(input).unwrap())),
x if x == TypeId::of::<f32>() => Ok(TaggedValue::F32(*downcast(input).unwrap())),
x if x == TypeId::of::<f64>() => Ok(TaggedValue::F64(*downcast(input).unwrap())),
x if x == TypeId::of::<bool>() => Ok(TaggedValue::Bool(*downcast(input).unwrap())),