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: remove duplicate parse_all function in wasm compiler #4411

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 9 additions & 11 deletions compiler/wasm/src/compile.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use fm::FileManager;
use gloo_utils::format::JsValueSerdeExt;
use js_sys::{JsString, Object};
use nargo::artifacts::{
contract::{ContractArtifact, ContractFunctionArtifact},
program::ProgramArtifact,
use nargo::{
artifacts::{
contract::{ContractArtifact, ContractFunctionArtifact},
program::ProgramArtifact,
},
parse_all,
};
use noirc_driver::{
add_dep, compile_contract, compile_main, file_manager_with_stdlib, prepare_crate,
Expand All @@ -13,7 +16,7 @@ use noirc_driver::{
use noirc_evaluator::errors::SsaReport;
use noirc_frontend::{
graph::{CrateId, CrateName},
hir::{def_map::parse_file, Context, ParsedFiles},
hir::Context,
};
use serde::Deserialize;
use std::{collections::HashMap, path::Path};
Expand Down Expand Up @@ -140,10 +143,6 @@ impl PathToFileSourceMap {
}
}

pub(crate) fn parse_all(fm: &FileManager) -> ParsedFiles {
fm.as_file_map().all_file_ids().map(|&file_id| (file_id, parse_file(fm, file_id))).collect()
}

pub enum CompileResult {
Contract { contract: ContractArtifact, warnings: Vec<SsaReport> },
Program { program: ProgramArtifact, warnings: Vec<SsaReport> },
Expand Down Expand Up @@ -291,14 +290,13 @@ pub(crate) fn generate_contract_artifact(contract: CompiledContract) -> CompileR

#[cfg(test)]
mod test {
use nargo::parse_all;
use noirc_driver::prepare_crate;
use noirc_frontend::{graph::CrateName, hir::Context};

use crate::compile::PathToFileSourceMap;

use super::{
file_manager_with_source_map, parse_all, process_dependency_graph, DependencyGraph,
};
use super::{file_manager_with_source_map, process_dependency_graph, DependencyGraph};
use std::{collections::HashMap, path::Path};

fn setup_test_context(source_map: PathToFileSourceMap) -> Context<'static, 'static> {
Expand Down
6 changes: 4 additions & 2 deletions compiler/wasm/src/compile_new.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::compile::{
file_manager_with_source_map, generate_contract_artifact, generate_program_artifact, parse_all,
file_manager_with_source_map, generate_contract_artifact, generate_program_artifact,
JsCompileResult, PathToFileSourceMap,
};
use crate::errors::{CompileError, JsCompileError};
use nargo::parse_all;
use noirc_driver::{
add_dep, compile_contract, compile_main, prepare_crate, prepare_dependency, CompileOptions,
};
Expand Down Expand Up @@ -230,10 +231,11 @@ pub fn compile_(

#[cfg(test)]
mod test {
use nargo::parse_all;
use noirc_driver::prepare_crate;
use noirc_frontend::hir::Context;

use crate::compile::{file_manager_with_source_map, parse_all, PathToFileSourceMap};
use crate::compile::{file_manager_with_source_map, PathToFileSourceMap};

use std::path::Path;

Expand Down
Loading