Skip to content

Commit

Permalink
chore: Follow rust naming convention (#801)
Browse files Browse the repository at this point in the history
* chore: follow rust naming convention

* chore: fmt

* chore: revert lvalue changes
  • Loading branch information
0xYYY authored Feb 12, 2023
1 parent 1b80f55 commit 62d02a1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions crates/noirc_evaluator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use errors::{RuntimeError, RuntimeErrorKind};
use iter_extended::btree_map;
use noirc_abi::{AbiType, AbiVisibility};
use noirc_frontend::monomorphization::ast::*;
use ssa::{node, ssa_gen::IRGenerator};
use ssa::{node, ssa_gen::IrGenerator};
use std::collections::BTreeMap;

pub struct Evaluator {
Expand Down Expand Up @@ -110,7 +110,7 @@ impl Evaluator {
program: Program,
enable_logging: bool,
) -> Result<(), RuntimeError> {
let mut ir_gen = IRGenerator::new(program);
let mut ir_gen = IrGenerator::new(program);
self.parse_abi_alt(&mut ir_gen);

// Now call the main function
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Evaluator {
def: Definition,
param_type: &AbiType,
visibility: &AbiVisibility,
ir_gen: &mut IRGenerator,
ir_gen: &mut IrGenerator,
) -> Result<(), RuntimeErrorKind> {
match param_type {
AbiType::Field => {
Expand Down Expand Up @@ -274,7 +274,7 @@ impl Evaluator {
/// Noted in the noirc_abi, it is possible to convert Toml -> NoirTypes
/// However, this intermediate representation is useful as it allows us to have
/// intermediate Types which the core type system does not know about like Strings.
fn parse_abi_alt(&mut self, ir_gen: &mut IRGenerator) {
fn parse_abi_alt(&mut self, ir_gen: &mut IrGenerator) {
// XXX: Currently, the syntax only supports public witnesses
// u8 and arrays are assumed to be private
// This is not a short-coming of the ABI, but of the grammar
Expand Down
8 changes: 4 additions & 4 deletions crates/noirc_evaluator/src/ssa/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::ssa::{
acir_gen::Acir,
block::{BasicBlock, BlockId},
conditional::{DecisionTree, TreeBuilder},
function::{FuncIndex, SSAFunction},
function::{FuncIndex, SsaFunction},
inline::StackFrame,
mem::{ArrayId, Memory},
node::{
Expand Down Expand Up @@ -32,7 +32,7 @@ pub struct SsaContext {
pub sealed_blocks: HashSet<BlockId>,
pub mem: Memory,

pub functions: HashMap<FuncId, function::SSAFunction>,
pub functions: HashMap<FuncId, function::SsaFunction>,
pub opcode_ids: HashMap<builtin::Opcode, NodeId>,

//Adjacency Matrix of the call graph; list of rows where each row indicates the functions called by the function whose FuncIndex is the row number
Expand Down Expand Up @@ -374,7 +374,7 @@ impl SsaContext {
id
}

pub fn ssa_func(&self, func_id: FuncId) -> Option<&SSAFunction> {
pub fn ssa_func(&self, func_id: FuncId) -> Option<&SsaFunction> {
self.functions.get(&func_id)
}

Expand All @@ -385,7 +385,7 @@ impl SsaContext {
}
}

pub fn try_get_ssa_func(&self, id: NodeId) -> Option<&SSAFunction> {
pub fn try_get_ssa_func(&self, id: NodeId) -> Option<&SsaFunction> {
self.try_get_func_id(id).and_then(|id| self.ssa_func(id))
}

Expand Down
16 changes: 8 additions & 8 deletions crates/noirc_evaluator/src/ssa/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ssa::{
context::SsaContext,
mem::ArrayId,
node::{Node, NodeId, ObjectType, Opcode, Operation},
ssa_gen::IRGenerator,
ssa_gen::IrGenerator,
{block, builtin, node, ssa_form},
};
use iter_extended::try_vecmap;
Expand All @@ -22,7 +22,7 @@ impl FuncIndex {
}

#[derive(Clone, Debug)]
pub struct SSAFunction {
pub struct SsaFunction {
pub entry_block: BlockId,
pub id: FuncId,
pub idx: FuncIndex,
Expand All @@ -35,15 +35,15 @@ pub struct SSAFunction {
pub decision: DecisionTree,
}

impl SSAFunction {
impl SsaFunction {
pub fn new(
id: FuncId,
name: &str,
block_id: BlockId,
idx: FuncIndex,
ctx: &mut SsaContext,
) -> SSAFunction {
SSAFunction {
) -> SsaFunction {
SsaFunction {
entry_block: block_id,
id,
node_id: ctx.push_function_id(id, name),
Expand All @@ -55,7 +55,7 @@ impl SSAFunction {
}
}

pub fn compile(&self, ir_gen: &mut IRGenerator) -> Result<DecisionTree, RuntimeError> {
pub fn compile(&self, ir_gen: &mut IrGenerator) -> Result<DecisionTree, RuntimeError> {
let function_cfg = block::bfs(self.entry_block, None, &ir_gen.context);
block::compute_sub_dom(&mut ir_gen.context, &function_cfg);
//Optimization
Expand Down Expand Up @@ -137,7 +137,7 @@ impl SSAFunction {
}
}

impl IRGenerator {
impl IrGenerator {
/// Creates an ssa function and returns its type upon success
pub fn create_function(
&mut self,
Expand All @@ -150,7 +150,7 @@ impl IRGenerator {

let function = &mut self.program[func_id];
let mut func =
SSAFunction::new(func_id, &function.name, func_block, index, &mut self.context);
SsaFunction::new(func_id, &function.name, func_block, index, &mut self.context);

//arguments:
for (param_id, mutable, name, typ) in std::mem::take(&mut function.parameters) {
Expand Down
6 changes: 3 additions & 3 deletions crates/noirc_evaluator/src/ssa/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl StackFrame {
//Return false if the inlined function performs a function call
pub fn inline(
ctx: &mut SsaContext,
ssa_func: &function::SSAFunction,
ssa_func: &function::SsaFunction,
args: &[NodeId],
arrays: &[(ArrayId, u32)],
block: BlockId,
Expand Down Expand Up @@ -437,7 +437,7 @@ impl node::Operation {
return id;
}
}
function::SSAFunction::get_mapped_value(Some(&id), ctx, inline_map, block_id)
function::SsaFunction::get_mapped_value(Some(&id), ctx, inline_map, block_id)
});
}
//However we deliberately not use the default case to force review of the behavior if a new type of operation is added.
Expand All @@ -450,7 +450,7 @@ impl node::Operation {
| Operation::Return(_) | Operation::Load {.. } | Operation::Store { .. } | Operation::Call { .. }
=> {
self.map_id_mut(|id| {
function::SSAFunction::get_mapped_value(Some(&id), ctx, inline_map, block_id)
function::SsaFunction::get_mapped_value(Some(&id), ctx, inline_map, block_id)
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/noirc_evaluator/src/ssa/ssa_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use num_bigint::BigUint;
use num_traits::Zero;
use std::collections::{BTreeMap, HashMap};

pub struct IRGenerator {
pub struct IrGenerator {
pub context: SsaContext,
pub function_context: Option<FuncIndex>,

Expand All @@ -32,9 +32,9 @@ pub struct IRGenerator {
pub program: Program,
}

impl IRGenerator {
pub fn new(program: Program) -> IRGenerator {
IRGenerator {
impl IrGenerator {
pub fn new(program: Program) -> IrGenerator {
IrGenerator {
context: SsaContext::new(),
variable_values: HashMap::new(),
function_context: None,
Expand Down

0 comments on commit 62d02a1

Please sign in to comment.