extract get_signature() for working sets analogous to the same function on the engine state

This commit is contained in:
Gwendolyn 2024-07-31 11:13:52 +02:00
parent 368ab10efe
commit 8637a2f1a2
2 changed files with 10 additions and 7 deletions

View File

@ -954,12 +954,7 @@ pub fn parse_internal_call(
let _ = working_set.add_span(call.head);
let decl = working_set.get_decl(decl_id);
let signature = if let Some(block_id) = decl.block_id() {
let block = working_set.get_block(block_id);
*block.signature.clone()
} else {
decl.signature()
};
let signature = working_set.get_signature(decl);
let output = signature.get_output_type();
// storing the var ID for later due to borrowing issues

View File

@ -5,7 +5,7 @@ use crate::{
StateDelta, Variable, VirtualPath, Visibility,
},
BlockId, Category, CompileError, Config, DeclId, FileId, GetSpan, Module, ModuleId, ParseError,
ParseWarning, Span, SpanId, Type, Value, VarId, VirtualPathId,
ParseWarning, Signature, Span, SpanId, Type, Value, VarId, VirtualPathId,
};
use core::panic;
use std::{
@ -708,6 +708,14 @@ impl<'a> StateWorkingSet<'a> {
}
}
pub fn get_signature(&self, decl: &dyn Command) -> Signature {
if let Some(block_id) = decl.block_id() {
*self.get_block(block_id).signature.clone()
} else {
decl.signature()
}
}
pub fn find_commands_by_predicate(
&self,
predicate: impl Fn(&[u8]) -> bool,