From d1158708152dc450979fa3829c3d29a333ce8aba Mon Sep 17 00:00:00 2001 From: howardwu Date: Sun, 26 Apr 2020 22:37:08 -0700 Subject: [PATCH] Moves compiler.rs to leo-compiler module --- Cargo.lock | 1 + compiler/Cargo.toml | 1 + {leo => compiler/src}/compiler.rs | 6 +++--- compiler/src/lib.rs | 2 ++ leo/commands/build.rs | 2 +- leo/commands/setup.rs | 2 +- leo/lib.rs | 1 - 7 files changed, 9 insertions(+), 6 deletions(-) rename {leo => compiler/src}/compiler.rs (87%) diff --git a/Cargo.lock b/Cargo.lock index 5556ed3788..a354c85b5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -651,6 +651,7 @@ version = "0.1.0" dependencies = [ "from-pest", "lazy_static", + "log", "pest", "pest-ast", "pest_derive", diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 68ab501c4d..eee6323fbc 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -13,6 +13,7 @@ snarkos-models = { path = "../../snarkOS/models", version = "0.8.0" } from-pest = { version = "0.3.1" } lazy_static = { version = "1.3.0" } +log = { version = "0.4" } pest = { version = "2.0" } pest-ast = { version = "0.3.3" } pest_derive = { version = "2.0" } diff --git a/leo/compiler.rs b/compiler/src/compiler.rs similarity index 87% rename from leo/compiler.rs rename to compiler/src/compiler.rs index 1441db540c..14f95ffa5c 100644 --- a/leo/compiler.rs +++ b/compiler/src/compiler.rs @@ -1,4 +1,4 @@ -use leo_compiler::{self, ast}; +use crate::{ast, Program, ResolvedProgram}; use snarkos_errors::gadgets::SynthesisError; use snarkos_models::{ @@ -40,11 +40,11 @@ impl ConstraintSynthesizer for Compiler { let syntax_tree = ast::File::from_pest(&mut file).expect("infallible"); log::debug!("{:#?}", syntax_tree); - let program = leo_compiler::Program::<'_, F>::from(syntax_tree); + let program = Program::<'_, F>::from(syntax_tree); log::info!(" compiled: {:#?}", program); let program = program.name("simple".into()); - leo_compiler::ResolvedProgram::generate_constraints(cs, program); + ResolvedProgram::generate_constraints(cs, program); Ok(()) } diff --git a/compiler/src/lib.rs b/compiler/src/lib.rs index 33b53b3b98..86ef52e8bb 100644 --- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs @@ -10,6 +10,8 @@ extern crate pest_derive; pub mod ast; +pub mod compiler; + pub mod constraints; pub use self::constraints::*; diff --git a/leo/commands/build.rs b/leo/commands/build.rs index 80f5baa0b0..873ab5833b 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -1,9 +1,9 @@ use crate::{cli::*, cli_types::*}; -use crate::compiler::Compiler; use crate::directories::{OutputsDirectory, source::SOURCE_DIRECTORY_NAME}; use crate::errors::{CLIError, BuildError}; use crate::files::{MainFile, MAIN_FILE_NAME}; use crate::manifest::Manifest; +use leo_compiler::compiler::Compiler; use snarkos_curves::bls12_377::Fr; diff --git a/leo/commands/setup.rs b/leo/commands/setup.rs index 506f85ce71..36f2ca2367 100644 --- a/leo/commands/setup.rs +++ b/leo/commands/setup.rs @@ -1,7 +1,7 @@ use crate::{cli::*, cli_types::*}; use crate::commands::BuildCommand; -use crate::compiler::Compiler; use crate::errors::CLIError; +use leo_compiler::compiler::Compiler; use snarkos_algorithms::snark::{generate_random_parameters, prepare_verifying_key, Parameters, PreparedVerifyingKey}; use snarkos_curves::bls12_377::{Bls12_377, Fr}; diff --git a/leo/lib.rs b/leo/lib.rs index 84a0ef6202..55d29c86db 100644 --- a/leo/lib.rs +++ b/leo/lib.rs @@ -5,7 +5,6 @@ extern crate failure; pub mod cli; pub mod cli_types; pub mod commands; -pub mod compiler; pub mod directories; pub mod errors; pub mod files;