Formatting
This commit is contained in:
+28
-19
@@ -168,11 +168,7 @@ impl RecordLayout {
|
||||
return None;
|
||||
}
|
||||
let idx = self.fmap[offset];
|
||||
if idx < 0 {
|
||||
None
|
||||
} else {
|
||||
Some(idx as usize)
|
||||
}
|
||||
if idx < 0 { None } else { Some(idx as usize) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +176,7 @@ impl RecordLayout {
|
||||
pub trait Object: fmt::Debug {
|
||||
fn type_name(&self) -> &'static str;
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
|
||||
/// Optional optimization: If this object behaves like a time series (indexable lookbacks),
|
||||
/// it can return a reference to its Series trait implementation.
|
||||
fn as_series(&self) -> Option<&dyn Series> {
|
||||
@@ -295,11 +291,11 @@ pub enum StaticType {
|
||||
DateTime,
|
||||
Text,
|
||||
Keyword,
|
||||
Optional(Box<StaticType>), // Represents T | Void (e.g. for filter pipes)
|
||||
List(Box<StaticType>), // Legacy / Dynamic list
|
||||
Series(Box<StaticType>), // Time series of a specific type
|
||||
Tuple(Vec<StaticType>), // Heterogeneous fixed-size
|
||||
Vector(Box<StaticType>, usize), // Homogeneous fixed-size
|
||||
Optional(Box<StaticType>), // Represents T | Void (e.g. for filter pipes)
|
||||
List(Box<StaticType>), // Legacy / Dynamic list
|
||||
Series(Box<StaticType>), // Time series of a specific type
|
||||
Tuple(Vec<StaticType>), // Heterogeneous fixed-size
|
||||
Vector(Box<StaticType>, usize), // Homogeneous fixed-size
|
||||
Matrix(Box<StaticType>, Vec<usize>), // Multi-dimensional homogeneous
|
||||
Record(std::sync::Arc<RecordLayout>),
|
||||
FieldAccessor(Keyword),
|
||||
@@ -371,7 +367,12 @@ impl fmt::Display for StaticType {
|
||||
impl StaticType {
|
||||
/// Returns true if `other` can be assigned to a location of type `self`.
|
||||
pub fn is_assignable_from(&self, other: &StaticType) -> bool {
|
||||
if self == other || matches!(self, StaticType::Any) || matches!(other, StaticType::Any) || matches!(self, StaticType::Error) || matches!(other, StaticType::Error) {
|
||||
if self == other
|
||||
|| matches!(self, StaticType::Any)
|
||||
|| matches!(other, StaticType::Any)
|
||||
|| matches!(self, StaticType::Error)
|
||||
|| matches!(other, StaticType::Error)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -411,9 +412,7 @@ impl StaticType {
|
||||
}
|
||||
}
|
||||
// Records are assignable if their layouts match (Structural identity via interning)
|
||||
(StaticType::Record(a), StaticType::Record(b)) => {
|
||||
std::sync::Arc::ptr_eq(a, b)
|
||||
}
|
||||
(StaticType::Record(a), StaticType::Record(b)) => std::sync::Arc::ptr_eq(a, b),
|
||||
// Series are assignable if their inner types are assignable
|
||||
(StaticType::Series(inner_a), StaticType::Series(inner_b)) => {
|
||||
inner_a.is_assignable_from(inner_b)
|
||||
@@ -550,7 +549,7 @@ impl Value {
|
||||
}
|
||||
Value::Record(layout, _) => StaticType::Record(layout.clone()),
|
||||
Value::FieldAccessor(k) => StaticType::FieldAccessor(*k),
|
||||
Value::Function(_) => StaticType::Any, // Dynamic function
|
||||
Value::Function(_) => StaticType::Any, // Dynamic function
|
||||
Value::Object(o) => StaticType::Object(o.type_name()),
|
||||
Value::Cell(c) => c.borrow().static_type(),
|
||||
Value::TailCallRequest(_) => StaticType::Any, // Internal state, but typable as Any
|
||||
@@ -596,10 +595,20 @@ impl fmt::Display for Value {
|
||||
Value::FieldAccessor(k) => write!(f, ".{}", k.name()),
|
||||
Value::Function(f_meta) => write!(f, "<native fn, {:?}>", f_meta.purity),
|
||||
Value::Object(o) => {
|
||||
if let Some(pipe) = o.as_any().downcast_ref::<crate::ast::rtl::streams::PipelineNode>() {
|
||||
if let Some(pipe) = o
|
||||
.as_any()
|
||||
.downcast_ref::<crate::ast::rtl::streams::PipelineNode>()
|
||||
{
|
||||
write!(f, "PipelineNode[last: {:?}]", pipe.series.get_item(0))
|
||||
} else if let Some(val_series) = o.as_any().downcast_ref::<crate::ast::rtl::series::SharedValueSeries>() {
|
||||
write!(f, "SharedValueSeries[len: {}]", val_series.buffer.borrow().len())
|
||||
} else if let Some(val_series) =
|
||||
o.as_any()
|
||||
.downcast_ref::<crate::ast::rtl::series::SharedValueSeries>()
|
||||
{
|
||||
write!(
|
||||
f,
|
||||
"SharedValueSeries[len: {}]",
|
||||
val_series.buffer.borrow().len()
|
||||
)
|
||||
} else {
|
||||
write!(f, "<{}>", o.type_name())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user