mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-27 04:01:47 +03:00
Batch changes for scope.rs
This commit is contained in:
parent
0fbb797f20
commit
817a3bd450
@ -18,7 +18,7 @@ use crate::{ScopeError, VariableTable};
|
||||
use leo_static_check::{FunctionInputType, Type};
|
||||
|
||||
/// A structure for tracking the types of defined variables in a block of code.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Scope {
|
||||
pub loop_variables: VariableTable,
|
||||
pub variables: VariableTable,
|
||||
@ -32,7 +32,7 @@ impl Scope {
|
||||
///
|
||||
pub fn new(parent: Option<Scope>) -> Self {
|
||||
match parent {
|
||||
Some(scope) => scope.clone(),
|
||||
Some(scope) => scope,
|
||||
None => Self::default(),
|
||||
}
|
||||
}
|
||||
@ -73,18 +73,9 @@ impl Scope {
|
||||
///
|
||||
/// Inserts a vector of function input types into the `Scope` variable table.
|
||||
///
|
||||
pub fn insert_function_inputs(&mut self, function_inputs: &Vec<FunctionInputType>) -> Result<(), ScopeError> {
|
||||
pub fn insert_function_inputs(&mut self, function_inputs: &[FunctionInputType]) -> Result<(), ScopeError> {
|
||||
self.variables
|
||||
.insert_function_inputs(function_inputs)
|
||||
.map_err(|err| ScopeError::VariableTableError(err))
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Scope {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
loop_variables: VariableTable::default(),
|
||||
variables: VariableTable::default(),
|
||||
}
|
||||
.map_err(ScopeError::VariableTableError)
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,7 @@ impl VariableTable {
|
||||
///
|
||||
/// Inserts a vector of function input types into the variable table.
|
||||
///
|
||||
pub fn insert_function_inputs(
|
||||
&mut self,
|
||||
function_inputs: &Vec<FunctionInputType>,
|
||||
) -> Result<(), VariableTableError> {
|
||||
pub fn insert_function_inputs(&mut self, function_inputs: &[FunctionInputType]) -> Result<(), VariableTableError> {
|
||||
for input in function_inputs {
|
||||
let input_name = input.identifier().name.clone();
|
||||
let input_type = input.type_();
|
||||
|
Loading…
Reference in New Issue
Block a user