Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Getter naming refactor #803

Merged
merged 2 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/fm/src/file_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl FileId {
pub struct File<'input>(&'input SimpleFile<PathString, String>);

impl<'input> File<'input> {
pub fn get_source(self) -> &'input str {
pub fn source(self) -> &'input str {
self.0.source()
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/noirc_evaluator/src/ssa/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ impl SsaContext {
None
}

pub fn get_root_value(&self, id: NodeId) -> NodeId {
self.get_variable(id).map(|v| v.get_root()).unwrap_or(id)
pub fn root_value(&self, id: NodeId) -> NodeId {
self.get_variable(id).map(|v| v.root()).unwrap_or(id)
}

pub fn add_variable(&mut self, obj: node::Variable, root: Option<NodeId>) -> NodeId {
Expand All @@ -502,7 +502,7 @@ impl SsaContext {
new_value: NodeId,
block_id: BlockId,
) {
let root_id = self.get_root_value(var_id);
let root_id = self.root_value(var_id);
let root = self.get_variable(root_id).unwrap();
let root_name = root.name.clone();
let cb = &mut self[block_id];
Expand Down Expand Up @@ -907,7 +907,7 @@ impl SsaContext {
witness: None,
parent_block: self.current_block,
};
let ls_root = lhs_obj.get_root();
let ls_root = lhs_obj.root();
//ssa: we create a new variable a1 linked to a
let new_var_id = self.add_variable(new_var, Some(ls_root));
let op = Operation::Binary(node::Binary {
Expand Down Expand Up @@ -998,7 +998,7 @@ impl SsaContext {
witness: None,
parent_block: self.current_block,
};
let ls_root = lhs_obj.get_root();
let ls_root = lhs_obj.root();
//ssa: we create a new variable a1 linked to a
let new_var_id = self.add_variable(new_var, Some(ls_root));
//ass
Expand Down
14 changes: 7 additions & 7 deletions crates/noirc_evaluator/src/ssa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::ops::{Add, BitAnd, BitOr, BitXor, Mul, Shl, Shr, Sub};

pub trait Node: std::fmt::Display {
fn get_type(&self) -> ObjectType;
fn get_id(&self) -> NodeId;
fn id(&self) -> NodeId;
fn size_in_bits(&self) -> u32;
}

Expand Down Expand Up @@ -52,7 +52,7 @@ impl Node for Variable {
self.get_type().bits()
}

fn get_id(&self) -> NodeId {
fn id(&self) -> NodeId {
self.id
}
}
Expand All @@ -76,11 +76,11 @@ impl Node for NodeObject {
}
}

fn get_id(&self) -> NodeId {
fn id(&self) -> NodeId {
match self {
NodeObject::Obj(o) => o.get_id(),
NodeObject::Obj(o) => o.id(),
NodeObject::Instr(i) => i.id,
NodeObject::Const(c) => c.get_id(),
NodeObject::Const(c) => c.id(),
NodeObject::Function(_, id, _) => *id,
}
}
Expand All @@ -95,7 +95,7 @@ impl Node for Constant {
self.value.bits().try_into().unwrap()
}

fn get_id(&self) -> NodeId {
fn id(&self) -> NodeId {
self.id
}
}
Expand Down Expand Up @@ -149,7 +149,7 @@ pub struct Variable {
}

impl Variable {
pub fn get_root(&self) -> NodeId {
pub fn root(&self) -> NodeId {
self.root.unwrap_or(self.id)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_evaluator/src/ssa/ssa_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn get_current_value_in_block(
var_id: NodeId,
block_id: BlockId,
) -> NodeId {
let root = ctx.get_root_value(var_id);
let root = ctx.root_value(var_id);

ctx[block_id]
.get_current_value(root) //Local value numbering
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn parse_file(
all_errors: &mut Vec<FileDiagnostic>,
) -> ParsedModule {
let file = fm.fetch_file(file_id);
let (program, errors) = parse_program(file.get_source());
let (program, errors) = parse_program(file.source());
all_errors.extend(errors.into_iter().map(|error| error.in_file(file_id)));
program
}
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/lexer/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a> Lexer<'a> {
}

pub fn from_file(source: File<'a>) -> Self {
let source_file = source.get_source();
let source_file = source.source();
Lexer::new(source_file)
}

Expand Down