Skip to content

Commit

Permalink
chore: remove duplicate parse_all function in wasm compiler (#4411)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

This removes a function which exists in `nargo` from being defined again
in `noir_wasm`

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench committed Feb 26, 2024
1 parent 176fab4 commit ab25b5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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, file_manager_with_stdlib, prepare_crate, prepare_dependency, CompileOptions,
Expand All @@ -12,7 +15,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 @@ -152,10 +155,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()
}

#[wasm_bindgen]
pub fn compile_program(
entry_point: String,
Expand Down Expand Up @@ -309,14 +308,13 @@ fn add_noir_lib(context: &mut Context, library_name: &CrateName) -> CrateId {

#[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,9 +1,10 @@
use crate::compile::{
file_manager_with_source_map, parse_all, JsCompileContractResult, JsCompileProgramResult,
file_manager_with_source_map, JsCompileContractResult, JsCompileProgramResult,
PathToFileSourceMap,
};
use crate::errors::{CompileError, JsCompileError};
use nargo::artifacts::contract::{ContractArtifact, ContractFunctionArtifact};
use nargo::parse_all;
use noirc_driver::{
add_dep, compile_contract, compile_main, prepare_crate, prepare_dependency, CompileOptions,
NOIR_ARTIFACT_VERSION_STRING,
Expand Down Expand Up @@ -265,10 +266,11 @@ fn prepare_compiler_context(

#[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

0 comments on commit ab25b5e

Please sign in to comment.