Skip to content

Commit

Permalink
chore: remove langauge from NodeInterner
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed May 16, 2023
1 parent 6bfcc4e commit 92d2da7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion crates/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl Default for CompileOptions {
impl Driver {
pub fn new(language: &Language, is_opcode_supported: Box<dyn Fn(&Opcode) -> bool>) -> Self {
let mut driver = Driver { context: Context::default(), language: language.clone() };
driver.context.def_interner.set_language(language);
driver.context.def_interner.set_opcode_support(is_opcode_supported);
driver
}
Expand Down
10 changes: 7 additions & 3 deletions crates/noirc_frontend/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod type_check;

use crate::graph::{CrateGraph, CrateId};
use crate::node_interner::NodeInterner;
use acvm::Language;
use acvm::acir::circuit::Opcode;
use def_map::CrateDefMap;
use fm::FileManager;
use std::collections::HashMap;
Expand All @@ -29,15 +29,19 @@ pub struct Context {
pub type StorageSlot = u32;

impl Context {
pub fn new(file_manager: FileManager, crate_graph: CrateGraph, language: Language) -> Context {
pub fn new(
file_manager: FileManager,
crate_graph: CrateGraph,
is_opcode_supported: Box<dyn Fn(&Opcode) -> bool>,
) -> Context {
let mut ctx = Context {
def_interner: NodeInterner::default(),
def_maps: HashMap::new(),
crate_graph,
file_manager,
storage_slots: HashMap::new(),
};
ctx.def_interner.set_language(&language);
ctx.def_interner.set_opcode_support(is_opcode_supported);
ctx
}

Expand Down
7 changes: 6 additions & 1 deletion crates/noirc_frontend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ fn main() {
let crate_id = crate_graph.add_crate_root(CrateType::Library, root_file_id);

// initiate context with file manager and crate graph
let mut context = Context::new(fm, crate_graph, acvm::Language::R1CS);
let mut context = Context::new(
fm,
crate_graph,
#[allow(deprecated)]
Box::new(acvm::default_is_opcode_supported(acvm::Language::R1CS)),
);

// Now create the CrateDefMap
// This is preamble for analysis
Expand Down
6 changes: 0 additions & 6 deletions crates/noirc_frontend/src/node_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub struct NodeInterner {
next_type_variable_id: usize,

//used for fallback mechanism
language: Language,
is_opcode_supported: Box<dyn Fn(&Opcode) -> bool>,

delayed_type_checks: Vec<TypeCheckFn>,
Expand Down Expand Up @@ -259,7 +258,6 @@ impl Default for NodeInterner {
field_indices: HashMap::new(),
next_type_variable_id: 0,
globals: HashMap::new(),
language: Language::R1CS,
#[allow(deprecated)]
is_opcode_supported: Box::new(acvm::default_is_opcode_supported(Language::R1CS)),
delayed_type_checks: vec![],
Expand Down Expand Up @@ -582,10 +580,6 @@ impl NodeInterner {
self.function_definition_ids[&function]
}

pub fn set_language(&mut self, language: &Language) {
self.language = language.clone();
}

pub fn set_opcode_support(&mut self, is_opcode_supported: Box<dyn Fn(&Opcode) -> bool>) {
self.is_opcode_supported = is_opcode_supported;
}
Expand Down

0 comments on commit 92d2da7

Please sign in to comment.