mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 11:12:48 +03:00
symbol table optimizations
This commit is contained in:
parent
3b23eb595a
commit
ed4e094377
@ -127,7 +127,9 @@ impl FunctionType {
|
||||
pub fn num_inputs(&self) -> usize {
|
||||
self.inputs
|
||||
.iter()
|
||||
.fold(0, |acc, function_input| acc + function_input.count())
|
||||
.filter(|function_input| !function_input.is_self())
|
||||
.count()
|
||||
// .fold(0, |acc, function_input| acc + function_input.arguments())
|
||||
}
|
||||
|
||||
///
|
||||
@ -139,13 +141,10 @@ impl FunctionType {
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a vector of [&FunctionInputType] removing `self` and `mut self` inputs.
|
||||
/// Returns an iterator of [&FunctionInputType] removing `self` and `mut self` inputs.
|
||||
///
|
||||
pub fn filter_self_inputs(&self) -> Vec<&FunctionInputType> {
|
||||
self.inputs
|
||||
.iter()
|
||||
.filter(|input| !input.is_self())
|
||||
.collect::<Vec<&FunctionInputType>>()
|
||||
pub fn filter_self_inputs(&self) -> impl Iterator<Item = &FunctionInputType> {
|
||||
self.inputs.iter().filter(|input| !input.is_self())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,15 +77,6 @@ impl FunctionInputType {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `0` if the function input is a `self` or `mut self` keyword which does not have to
|
||||
/// provided in a call to the function.
|
||||
/// Returns `1` if a variable must be provided in a call to the function.
|
||||
///
|
||||
pub fn count(&self) -> usize {
|
||||
if self.is_self() { 0 } else { 1 }
|
||||
}
|
||||
|
||||
///
|
||||
/// Return a new `FunctionInputType` from a given `FunctionInput`.
|
||||
///
|
||||
|
@ -1120,10 +1120,8 @@ impl Frame {
|
||||
}
|
||||
|
||||
// Filter out `self` and `mut self` keywords.
|
||||
let expected_inputs = function_type.filter_self_inputs();
|
||||
|
||||
// Assert function inputs are correct types.
|
||||
for (expected_input, actual_input) in expected_inputs.iter().zip(inputs) {
|
||||
for (expected_input, actual_input) in function_type.filter_self_inputs().zip(inputs) {
|
||||
// Parse expected input type.
|
||||
let expected_type = expected_input.type_();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user