Skip to content

Commit

Permalink
chore: Rename NodeObject::Obj variant to NodeObject:Variable (#846)
Browse files Browse the repository at this point in the history
NodeObject::Obj -> NodeObject:Variable
  • Loading branch information
kevaundray authored Feb 15, 2023
1 parent 589c45f commit e298429
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl InternalVarCache {
let field_value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be());
InternalVar::from_constant(field_value)
}
NodeObject::Obj(variable) => {
NodeObject::Variable(variable) => {
let variable_type = variable.get_type();
match variable_type {
ObjectType::Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn resolve_node_id(
) -> Vec<FunctionInput> {
let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}");
match node_object {
node::NodeObject::Obj(v) => {
node::NodeObject::Variable(v) => {
let node_obj_type = node_object.get_type();
match node_obj_type {
// If the `Variable` represents a Pointer
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 @@ -421,7 +421,7 @@ impl SsaContext {
pub fn get_variable(&self, id: NodeId) -> Result<&node::Variable, RuntimeErrorKind> {
match self.nodes.get(id.0) {
Some(t) => match t {
node::NodeObject::Obj(o) => Ok(o),
node::NodeObject::Variable(o) => Ok(o),
_ => Err(RuntimeErrorKind::UnstructuredError {
message: "Not an object".to_string(),
}),
Expand All @@ -436,7 +436,7 @@ impl SsaContext {
) -> Result<&mut node::Variable, RuntimeErrorKind> {
match self.nodes.get_mut(id.0) {
Some(t) => match t {
node::NodeObject::Obj(o) => Ok(o),
node::NodeObject::Variable(o) => Ok(o),
_ => Err(RuntimeErrorKind::UnstructuredError {
message: "Not an object".to_string(),
}),
Expand Down Expand Up @@ -467,9 +467,9 @@ impl SsaContext {
}

pub fn add_variable(&mut self, obj: node::Variable, root: Option<NodeId>) -> NodeId {
let id = NodeId(self.nodes.insert(NodeObject::Obj(obj)));
let id = NodeId(self.nodes.insert(NodeObject::Variable(obj)));
match &mut self[id] {
node::NodeObject::Obj(v) => {
node::NodeObject::Variable(v) => {
v.id = id;
v.root = root;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/noirc_evaluator/src/ssa/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ fn evaluate_one(
let value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be());
Ok(NodeEval::Const(value, c.get_type()))
}
NodeObject::Obj(_) => Ok(NodeEval::VarOrInstruction(obj_id)),
NodeObject::Variable(_) => Ok(NodeEval::VarOrInstruction(obj_id)),
NodeObject::Function(f, id, _) => Ok(NodeEval::Function(*f, *id)),
}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ fn evaluate_object(
let value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be());
Ok(NodeEval::Const(value, c.get_type()))
}
NodeObject::Obj(_) => Ok(NodeEval::VarOrInstruction(obj_id)),
NodeObject::Variable(_) => Ok(NodeEval::VarOrInstruction(obj_id)),
NodeObject::Function(f, id, _) => Ok(NodeEval::Function(*f, *id)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_evaluator/src/ssa/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn get_obj_max_value(
let obj = &ctx[id];

let result = match obj {
NodeObject::Obj(v) => (BigUint::one() << v.size_in_bits()) - BigUint::one(), //TODO check for signed type
NodeObject::Variable(v) => (BigUint::one() << v.size_in_bits()) - BigUint::one(), //TODO check for signed type
NodeObject::Instr(i) => get_instruction_max(ctx, i, max_map, value_map),
NodeObject::Const(c) => c.value.clone(), //TODO panic for string constants
NodeObject::Function(..) => BigUint::zero(),
Expand Down
12 changes: 6 additions & 6 deletions crates/noirc_evaluator/src/ssa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl std::fmt::Display for NodeObject {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use FunctionKind::*;
match self {
NodeObject::Obj(o) => write!(f, "{o}"),
NodeObject::Variable(o) => write!(f, "{o}"),
NodeObject::Instr(i) => write!(f, "{i}"),
NodeObject::Const(c) => write!(f, "{c}"),
NodeObject::Function(Normal(id), ..) => write!(f, "f{}", id.0),
Expand Down Expand Up @@ -60,7 +60,7 @@ impl Node for Variable {
impl Node for NodeObject {
fn get_type(&self) -> ObjectType {
match self {
NodeObject::Obj(o) => o.get_type(),
NodeObject::Variable(o) => o.get_type(),
NodeObject::Instr(i) => i.res_type,
NodeObject::Const(o) => o.value_type,
NodeObject::Function(..) => ObjectType::Function,
Expand All @@ -69,7 +69,7 @@ impl Node for NodeObject {

fn size_in_bits(&self) -> u32 {
match self {
NodeObject::Obj(o) => o.size_in_bits(),
NodeObject::Variable(o) => o.size_in_bits(),
NodeObject::Instr(i) => i.res_type.bits(),
NodeObject::Const(c) => c.size_in_bits(),
NodeObject::Function(..) => 0,
Expand All @@ -78,7 +78,7 @@ impl Node for NodeObject {

fn id(&self) -> NodeId {
match self {
NodeObject::Obj(o) => o.id(),
NodeObject::Variable(o) => o.id(),
NodeObject::Instr(i) => i.id,
NodeObject::Const(c) => c.id(),
NodeObject::Function(_, id, _) => *id,
Expand Down Expand Up @@ -114,7 +114,7 @@ impl NodeId {

#[derive(Debug)]
pub enum NodeObject {
Obj(Variable),
Variable(Variable),
Instr(Instruction),
Const(Constant),
Function(FunctionKind, NodeId, /*name:*/ String),
Expand Down Expand Up @@ -308,7 +308,7 @@ impl NodeEval {
NodeEval::Const(value, c.get_type())
}
NodeObject::Function(f, id, _name) => NodeEval::Function(*f, *id),
NodeObject::Obj(_) | NodeObject::Instr(_) => NodeEval::VarOrInstruction(id),
NodeObject::Variable(_) | NodeObject::Instr(_) => NodeEval::VarOrInstruction(id),
}
}

Expand Down

0 comments on commit e298429

Please sign in to comment.