Misc tidying up around KclValue, etc. (#5653)
* Make some things a little less public Signed-off-by: Nick Cameron <nrc@ncameron.org> * Rename KclValue::Array to MixedArray Signed-off-by: Nick Cameron <nrc@ncameron.org> * Add settings to KclValue::Function Signed-off-by: Nick Cameron <nrc@ncameron.org> * Remove a bunch of dead code, simplifying mock exec and meaning KclValue no longer needs to deserialize Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -588,6 +588,7 @@ impl ExecutorContext {
|
||||
KclValue::Function {
|
||||
value: FunctionSource::User {
|
||||
ast: function_expression.clone(),
|
||||
settings: exec_state.mod_local.settings.clone(),
|
||||
memory: exec_state.mut_stack().snapshot(),
|
||||
},
|
||||
meta: vec![metadata.to_owned()],
|
||||
@ -754,7 +755,7 @@ impl Node<MemberExpression> {
|
||||
}
|
||||
};
|
||||
|
||||
let KclValue::Array { value: array, meta: _ } = array else {
|
||||
let KclValue::MixedArray { value: array, meta: _ } = array else {
|
||||
return Err(KclError::Semantic(KclErrorDetails {
|
||||
message: format!("MemberExpression array is not an array: {:?}", array),
|
||||
source_ranges: vec![self.clone().into()],
|
||||
@ -804,7 +805,7 @@ impl Node<MemberExpression> {
|
||||
source_ranges: vec![self.clone().into()],
|
||||
}))
|
||||
}
|
||||
(KclValue::Array { value: arr, meta: _ }, Property::UInt(index)) => {
|
||||
(KclValue::MixedArray { value: arr, meta: _ }, Property::UInt(index)) => {
|
||||
let value_of_arr = arr.get(index);
|
||||
if let Some(value) = value_of_arr {
|
||||
Ok(value.to_owned())
|
||||
@ -815,7 +816,7 @@ impl Node<MemberExpression> {
|
||||
}))
|
||||
}
|
||||
}
|
||||
(KclValue::Array { .. }, p) => {
|
||||
(KclValue::MixedArray { .. }, p) => {
|
||||
let t = p.type_name();
|
||||
let article = article_for(t);
|
||||
Err(KclError::Semantic(KclErrorDetails {
|
||||
@ -1489,7 +1490,7 @@ impl Node<ArrayExpression> {
|
||||
results.push(value);
|
||||
}
|
||||
|
||||
Ok(KclValue::Array {
|
||||
Ok(KclValue::MixedArray {
|
||||
value: results,
|
||||
meta: vec![self.into()],
|
||||
})
|
||||
@ -1538,7 +1539,7 @@ impl Node<ArrayRangeExpression> {
|
||||
let meta = vec![Metadata {
|
||||
source_range: self.into(),
|
||||
}];
|
||||
Ok(KclValue::Array {
|
||||
Ok(KclValue::MixedArray {
|
||||
value: range
|
||||
.into_iter()
|
||||
.map(|num| KclValue::Number {
|
||||
@ -1952,7 +1953,7 @@ impl FunctionSource {
|
||||
|
||||
func(exec_state, args).await.map(Some)
|
||||
}
|
||||
FunctionSource::User { ast, memory } => {
|
||||
FunctionSource::User { ast, memory, .. } => {
|
||||
call_user_defined_function(args, *memory, ast, exec_state, ctx).await
|
||||
}
|
||||
FunctionSource::None => unreachable!(),
|
||||
|
Reference in New Issue
Block a user