Skip to content

Commit

Permalink
chore: reorganise code
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Aug 7, 2023
1 parent 8754718 commit 07d50f9
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions crates/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ impl AcirContext {
self.acir_ir.current_location = location;
}

/// Converts an [`AcirVar`] to a [`Witness`]
fn var_to_witness(&mut self, var: AcirVar) -> Result<Witness, InternalError> {
let expression = self.var_to_expression(var)?;
Ok(self.acir_ir.get_or_create_witness(&expression))
}

/// Converts an [`AcirVar`] to an [`Expression`]
fn var_to_expression(&self, var: AcirVar) -> Result<Expression, InternalError> {
let var_data = match self.vars.get(&var) {
Some(var_data) => var_data,
None => return Err(InternalError::UndeclaredAcirVar { location: self.get_location() }),
};
Ok(var_data.to_expression().into_owned())
}

/// True if the given AcirVar refers to a constant one value
pub(crate) fn is_constant_one(&self, var: &AcirVar) -> bool {
match self.vars[var] {
Expand Down Expand Up @@ -971,21 +986,6 @@ impl AcirContext {
Ok(outputs_var)
}

/// Converts an [`AcirVar`] to a [`Witness`]
fn var_to_witness(&mut self, var: AcirVar) -> Result<Witness, InternalError> {
let expression = self.var_to_expression(var)?;
Ok(self.acir_ir.get_or_create_witness(&expression))
}

/// Converts an [`AcirVar`] to an [`Expression`]
fn var_to_expression(&self, var: AcirVar) -> Result<Expression, InternalError> {
let var_data = match self.vars.get(&var) {
Some(var_data) => var_data,
None => return Err(InternalError::UndeclaredAcirVar { location: self.get_location() }),
};
Ok(var_data.to_expression().into_owned())
}

/// Constrain lhs to be less than rhs
fn less_than_constrain(
&mut self,
Expand Down

0 comments on commit 07d50f9

Please sign in to comment.