compiler module builds

This commit is contained in:
collin 2022-02-03 11:59:42 -08:00
parent fa2becfb1d
commit 316c2d2592
135 changed files with 247 additions and 378 deletions

222
Cargo.lock generated
View File

@ -36,17 +36,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.4",
"once_cell",
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.18"
@ -188,24 +177,12 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base58"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bech32"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b"
[[package]]
name = "bincode"
version = "1.3.3"
@ -357,19 +334,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"serde",
"winapi 0.3.9",
]
[[package]]
name = "ci_info"
version = "0.10.2"
@ -607,36 +571,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "curl"
version = "0.4.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7de97b894edd5b5bcceef8b78d7da9b75b1d2f2f9a910569d0bde3dd31d84939"
dependencies = [
"curl-sys",
"libc",
"openssl-probe",
"openssl-sys",
"schannel",
"socket2",
"winapi 0.3.9",
]
[[package]]
name = "curl-sys"
version = "0.4.52+curl-7.81.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b8c2d1023ea5fded5b7b892e4b8e95f70038a421126a056761a84246a28971"
dependencies = [
"cc",
"libc",
"libz-sys",
"openssl-sys",
"pkg-config",
"vcpkg",
"winapi 0.3.9",
]
[[package]]
name = "derivative"
version = "2.2.0"
@ -1052,9 +986,6 @@ name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash",
]
[[package]]
name = "heck"
@ -1384,39 +1315,9 @@ dependencies = [
name = "leo-compiler"
version = "1.5.3"
dependencies = [
"bech32",
"bincode",
"indexmap",
"leo-asg",
"leo-asg-passes",
"leo-ast",
"leo-ast-passes",
"leo-errors",
"leo-imports",
"leo-input",
"leo-package",
"leo-parser",
"leo-synthesizer",
"leo-test-framework",
"num-bigint",
"pest",
"rand 0.8.4",
"rand_core 0.6.3",
"rand_xorshift",
"serde",
"serde_json",
"serde_yaml",
"sha2",
"snarkvm-algorithms",
"snarkvm-curves",
"snarkvm-dpc",
"snarkvm-fields",
"snarkvm-gadgets",
"snarkvm-r1cs",
"snarkvm-utilities",
"tempfile",
"tendril",
"tracing",
]
[[package]]
@ -1615,18 +1516,6 @@ version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
[[package]]
name = "libz-sys"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "linked-hash-map"
version = "0.5.4"
@ -1972,12 +1861,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "paste"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5"
[[package]]
name = "percent-encoding"
version = "2.1.0"
@ -2284,15 +2167,6 @@ dependencies = [
"rand_core 0.6.3",
]
[[package]]
name = "rand_xorshift"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
dependencies = [
"rand_core 0.6.3",
]
[[package]]
name = "rayon"
version = "1.5.1"
@ -2714,38 +2588,6 @@ dependencies = [
"syn 1.0.86",
]
[[package]]
name = "snarkvm-dpc"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2#51633e2fac247bc829bd316a93f59b6ba0759661"
dependencies = [
"anyhow",
"base58",
"bech32",
"bincode",
"blake2",
"chrono",
"derivative",
"hex",
"itertools 0.10.3",
"once_cell",
"rand 0.8.4",
"rayon",
"serde",
"serde_json",
"snarkvm-algorithms",
"snarkvm-curves",
"snarkvm-fields",
"snarkvm-gadgets",
"snarkvm-marlin",
"snarkvm-parameters",
"snarkvm-polycommit",
"snarkvm-profiler",
"snarkvm-r1cs",
"snarkvm-utilities",
"thiserror",
]
[[package]]
name = "snarkvm-fields"
version = "0.7.5"
@ -2780,70 +2622,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "snarkvm-marlin"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2#51633e2fac247bc829bd316a93f59b6ba0759661"
dependencies = [
"bincode",
"blake2",
"derivative",
"digest 0.9.0",
"hashbrown",
"rand 0.8.4",
"rand_chacha 0.3.1",
"rand_core 0.6.3",
"rayon",
"serde",
"smallvec",
"snarkvm-algorithms",
"snarkvm-curves",
"snarkvm-fields",
"snarkvm-gadgets",
"snarkvm-polycommit",
"snarkvm-profiler",
"snarkvm-r1cs",
"snarkvm-utilities",
]
[[package]]
name = "snarkvm-parameters"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2#51633e2fac247bc829bd316a93f59b6ba0759661"
dependencies = [
"aleo-std",
"anyhow",
"cfg-if 1.0.0",
"curl",
"hex",
"paste",
"serde_json",
"snarkvm-algorithms",
"snarkvm-utilities",
"thiserror",
]
[[package]]
name = "snarkvm-polycommit"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=51633e2#51633e2fac247bc829bd316a93f59b6ba0759661"
dependencies = [
"derivative",
"digest 0.9.0",
"hashbrown",
"itertools 0.10.3",
"rand 0.8.4",
"rand_core 0.6.3",
"rayon",
"snarkvm-algorithms",
"snarkvm-curves",
"snarkvm-fields",
"snarkvm-gadgets",
"snarkvm-profiler",
"snarkvm-r1cs",
"snarkvm-utilities",
]
[[package]]
name = "snarkvm-profiler"
version = "0.7.5"

View File

@ -26,129 +26,10 @@ version = "1.5.3"
path = "../errors"
version = "1.5.3"
[dependencies.leo-imports]
path = "../imports"
version = "1.5.3"
[dependencies.leo-input]
path = "../input"
version = "1.5.3"
[dependencies.leo-package]
path = "../package"
version = "1.5.3"
#[dependencies.leo-state]
#path = "../state"
#version = "1.5.3"
[dependencies.leo-asg]
path = "../asg"
version = "1.5.3"
[dependencies.leo-parser]
path = "../parser"
version = "1.5.3"
[dependencies.leo-asg-passes]
path = "../asg-passes"
version = "1.5.3"
[dependencies.leo-ast-passes]
path = "../ast-passes"
version = "1.5.3"
[dependencies.leo-synthesizer]
path = "../synthesizer"
version = "1.5.3"
[dev-dependencies.snarkvm-algorithms]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-curves]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-fields]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-dpc]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
features = ["testnet2"]
[dependencies.snarkvm-gadgets]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
features = [ "curves" ]
[dependencies.snarkvm-r1cs]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-utilities]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
[dependencies.bech32]
version = "0.8"
[dependencies.bincode]
version = "1.3"
[dependencies.indexmap]
version = "1.8.0"
features = [ "serde-1" ]
[dependencies.num-bigint]
version = "0.4"
[dependencies.pest]
version = "2.0"
[dependencies.rand]
version = "0.8"
[dependencies.serde]
version = "1.0"
[dependencies.serde_json]
version = "1.0"
features = [ "preserve_order" ]
[dependencies.sha2]
version = "0.10"
[dependencies.tendril]
version = "0.4"
[dependencies.tracing]
version = "0.1"
[dev-dependencies.leo-test-framework]
path = "../test-framework"
version = "1.4.0"
[dev-dependencies.rand_core]
version = "0.6.3"
[dev-dependencies.rand_xorshift]
version = "0.3"
default-features = false
[dev-dependencies.serde_yaml]
version = "0.8"
[dev-dependencies.tempfile]
version = "3.3.0"
[features]
default = [ ]
ci_skip = [ "leo-ast/ci_skip" ]

View File

@ -22,45 +22,44 @@
#![allow(clippy::upper_case_acronyms)]
#![doc = include_str!("../README.md")]
pub mod compiler;
use leo_errors::emitter::Handler;
use leo_errors::{CompilerError, Result};
pub mod console;
pub use console::*;
use std::fs;
use std::path::PathBuf;
pub mod constraints;
pub use constraints::*;
/// The primary entry point of the Leo compiler.
pub struct RunCompiler<'a> {
handler: &'a Handler,
main_file_path: PathBuf,
}
pub mod definition;
impl<'a> RunCompiler<'a> {
///
/// Returns a new Leo compiler.
///
pub fn new(handler: &'a Handler, main_file_path: PathBuf) -> Self {
Self {
handler,
main_file_path,
}
}
pub mod expression;
pub use expression::*;
///
/// Returns a compiled Leo program.
///
pub fn run(self) -> Result<leo_ast::Ast> {
// Load the program file.
let program_string = fs::read_to_string(&self.main_file_path)
.map_err(|e| CompilerError::file_read_error(self.main_file_path.clone(), e))?;
pub mod function;
pub use function::*;
// Use the parser to construct the abstract syntax tree (ast).
let ast: leo_ast::Ast = leo_parser::parse_ast(
self.handler,
self.main_file_path.to_str().unwrap_or_default(),
program_string,
)?;
pub mod output;
pub use output::*;
pub mod program;
pub use program::*;
pub mod statement;
pub use statement::*;
pub mod prelude;
pub use prelude::*;
pub mod value;
pub use value::*;
pub mod phase;
pub use phase::*;
pub mod phases;
pub use phases::*;
pub mod option;
pub use option::*;
#[cfg(test)]
mod test;
Ok(ast)
}
}

View File

@ -0,0 +1,146 @@
[package]
name = "leo-compiler"
version = "1.5.3"
authors = [ "The Aleo Team <hello@aleo.org>" ]
description = "Compiler of the Leo programming language"
homepage = "https://aleo.org"
repository = "https://github.com/AleoHQ/leo"
keywords = [
"aleo",
"cryptography",
"leo",
"programming-language",
"zero-knowledge"
]
categories = [ "cryptography::cryptocurrencies", "web-programming" ]
include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
license = "GPL-3.0"
edition = "2021"
rust-version = "1.56.1"
[dependencies.leo-ast]
path = "../ast"
version = "1.5.3"
[dependencies.leo-errors]
path = "../errors"
version = "1.5.3"
#
#[dependencies.leo-imports]
#path = "../imports"
#version = "1.5.3"
#
#[dependencies.leo-input]
#path = "../input"
#version = "1.5.3"
#
#[dependencies.leo-package]
#path = "../package"
#version = "1.5.3"
[dependencies.leo-parser]
path = "../parser"
version = "1.5.3"
#
#[dependencies.leo-asg-passes]
#path = "../asg-passes"
#version = "1.5.3"
#
#[dependencies.leo-ast-passes]
#path = "../ast-passes"
#version = "1.5.3"
#
#[dependencies.leo-synthesizer]
#path = "../synthesizer"
#version = "1.5.3"
[dev-dependencies.snarkvm-algorithms]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-curves]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-fields]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-dpc]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
features = ["testnet2"]
[dependencies.snarkvm-gadgets]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
features = [ "curves" ]
[dependencies.snarkvm-r1cs]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
default-features = false
[dependencies.snarkvm-utilities]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "51633e2"
[dependencies.bech32]
version = "0.8"
[dependencies.bincode]
version = "1.3"
[dependencies.indexmap]
version = "1.8.0"
features = [ "serde-1" ]
[dependencies.num-bigint]
version = "0.4"
[dependencies.pest]
version = "2.0"
[dependencies.rand]
version = "0.8"
[dependencies.serde]
version = "1.0"
[dependencies.serde_json]
version = "1.0"
features = [ "preserve_order" ]
[dependencies.sha2]
version = "0.10"
[dependencies.tendril]
version = "0.4"
[dependencies.tracing]
version = "0.1"
[dev-dependencies.leo-test-framework]
path = "../test-framework"
version = "1.4.0"
[dev-dependencies.rand_core]
version = "0.6.3"
[dev-dependencies.rand_xorshift]
version = "0.3"
default-features = false
[dev-dependencies.serde_yaml]
version = "0.8"
[dev-dependencies.tempfile]
version = "3.3.0"
[features]
default = [ ]
ci_skip = [ "leo-ast/ci_skip" ]

View File

@ -27,7 +27,6 @@ use leo_imports::ImportParser;
use leo_input::LeoInputParser;
use leo_package::inputs::InputPairs;
use leo_parser::parse_ast;
// use leo_state::verify_local_data_commitment;
use snarkvm_fields::PrimeField;
use snarkvm_r1cs::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};

View File

@ -0,0 +1,66 @@
// Copyright (C) 2019-2021 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
//! The compiler for Leo programs.
//!
//! The [`Compiler`] type compiles Leo programs into R1CS circuits.
#![allow(clippy::module_inception)]
#![allow(clippy::upper_case_acronyms)]
#![doc = include_str!("../README.md")]
pub mod compiler;
pub mod console;
pub use console::*;
pub mod constraints;
pub use constraints::*;
pub mod definition;
pub mod expression;
pub use expression::*;
pub mod function;
pub use function::*;
pub mod output;
pub use output::*;
pub mod program;
pub use program::*;
pub mod statement;
pub use statement::*;
pub mod prelude;
pub use prelude::*;
pub mod value;
pub use value::*;
pub mod phase;
pub use phase::*;
pub mod phases;
pub use phases::*;
pub mod option;
pub use option::*;
#[cfg(test)]
mod test;

Some files were not shown because too many files have changed in this diff Show More