merge lastest master

This commit is contained in:
gluaxspeed 2021-02-05 13:11:36 -05:00
commit 5fe61daa88
139 changed files with 794 additions and 1371 deletions

177
Cargo.lock generated
View File

@ -50,9 +50,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.37" version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
[[package]] [[package]]
name = "arrayref" name = "arrayref"
@ -277,7 +277,7 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
dependencies = [ dependencies = [
"rustc_version", "rustc_version 0.2.3",
] ]
[[package]] [[package]]
@ -801,9 +801,18 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.1.30" version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
@ -812,6 +821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink",
] ]
[[package]] [[package]]
@ -820,12 +830,35 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748"
[[package]]
name = "futures-executor"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.8" version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb"
[[package]]
name = "futures-macro"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.60",
]
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.8" version = "0.3.8"
@ -847,12 +880,17 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2"
dependencies = [ dependencies = [
"futures-channel",
"futures-core", "futures-core",
"futures-io", "futures-io",
"futures-macro",
"futures-sink",
"futures-task", "futures-task",
"memchr", "memchr",
"pin-project 1.0.2", "pin-project 1.0.2",
"pin-utils", "pin-utils",
"proc-macro-hack",
"proc-macro-nested",
"slab", "slab",
] ]
@ -874,7 +912,7 @@ dependencies = [
"cc", "cc",
"libc", "libc",
"log", "log",
"rustc_version", "rustc_version 0.2.3",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1197,9 +1235,9 @@ dependencies = [
[[package]] [[package]]
name = "jsonrpc-core" name = "jsonrpc-core"
version = "14.2.0" version = "17.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0747307121ffb9703afd93afbd0fb4f854c38fb873f2c8b90e0e902f27c7b62" checksum = "07569945133257ff557eb37b015497104cea61a2c9edaf126c1cbd6e8332397f"
dependencies = [ dependencies = [
"futures", "futures",
"log", "log",
@ -1996,6 +2034,50 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "proc-macro-crate"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
dependencies = [
"toml",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2 1.0.24",
"quote 1.0.7",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"version_check",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro-nested"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "0.4.30" version = "0.4.30"
@ -2261,6 +2343,15 @@ dependencies = [
"semver 0.9.0", "semver 0.9.0",
] ]
[[package]]
name = "rustc_version"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
dependencies = [
"semver 0.11.0",
]
[[package]] [[package]]
name = "rusty-hook" name = "rusty-hook"
version = "0.11.2" version = "0.11.2"
@ -2451,9 +2542,9 @@ dependencies = [
[[package]] [[package]]
name = "sha2" name = "sha2"
version = "0.9.2" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de"
dependencies = [ dependencies = [
"block-buffer 0.9.0", "block-buffer 0.9.0",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -2495,20 +2586,20 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.5.1" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]] [[package]]
name = "snarkvm-algorithms" name = "snarkvm-algorithms"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdc4273884a3c5b1858e9ccb3dd6d7acfa60c0c38bb4876aeeb3181936dbe5f3" checksum = "ceb01228059c36bb95507d1df131dea4e7b600c87ac26dc66c07a651d8a03f6e"
dependencies = [ dependencies = [
"blake2", "blake2",
"derivative", "derivative",
"digest 0.8.1", "digest 0.8.1",
"itertools 0.9.0", "itertools 0.10.0",
"rand", "rand",
"rand_chacha", "rand_chacha",
"rayon", "rayon",
@ -2522,14 +2613,14 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-curves" name = "snarkvm-curves"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0ab5c370fa0e394acc14474ce0ed162ca673e87ac496e733d402b5c71f177" checksum = "e7f9bb31389dce334a6c0c5855829afbb1e4469c4c03143e167c5353ccb1e307"
dependencies = [ dependencies = [
"derivative", "derivative",
"rand", "rand",
"rand_xorshift", "rand_xorshift",
"rustc_version", "rustc_version 0.3.3",
"serde", "serde",
"snarkvm-errors", "snarkvm-errors",
"snarkvm-models", "snarkvm-models",
@ -2538,10 +2629,12 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-derives" name = "snarkvm-derives"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74eecab3b4bbcef183819fb414ad3498b6c962f21a41a2afaf73af2822eec98" checksum = "1ccaf7047e41bc356a3af8257e9ffe13a5b619c9f51278c019d5201790ddd677"
dependencies = [ dependencies = [
"proc-macro-crate",
"proc-macro-error",
"proc-macro2 1.0.24", "proc-macro2 1.0.24",
"quote 1.0.7", "quote 1.0.7",
"syn 1.0.60", "syn 1.0.60",
@ -2549,15 +2642,15 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-dpc" name = "snarkvm-dpc"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a3bbd6dcb0e100d514fa0f8cfb2fd8e0422660d5d816a47409d8111c536dddc" checksum = "ea20c9a289304d22755ddfc644e164e1232f41ebe016edc8bf7f0007b828b92d"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"blake2", "blake2",
"derivative", "derivative",
"hex", "hex",
"itertools 0.9.0", "itertools 0.10.0",
"rand", "rand",
"snarkvm-algorithms", "snarkvm-algorithms",
"snarkvm-curves", "snarkvm-curves",
@ -2572,9 +2665,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-errors" name = "snarkvm-errors"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7b46326076d2797280a335f6a4c3538e5ba57db37704233e55134b3e1ab2e79" checksum = "4dcff02240b6b5b36f47953ea9be5c29aef109164b0cebd84e7260ef7bf67f6c"
dependencies = [ dependencies = [
"base58", "base58",
"bech32", "bech32",
@ -2589,13 +2682,13 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-gadgets" name = "snarkvm-gadgets"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ec20358b56a972bf280690ace5e5c1ba809e4cd31d31932f0bd15491f9be0d" checksum = "e5692f39b5b9351b6584e1f9a2739b13d82e5a4a74a074eb0b743e9d7583fdb5"
dependencies = [ dependencies = [
"derivative", "derivative",
"digest 0.8.1", "digest 0.8.1",
"itertools 0.9.0", "itertools 0.10.0",
"snarkvm-algorithms", "snarkvm-algorithms",
"snarkvm-curves", "snarkvm-curves",
"snarkvm-errors", "snarkvm-errors",
@ -2605,17 +2698,17 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-models" name = "snarkvm-models"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae6d7532cfc6b888e8566e05e62384c4c7103fa3036555c54b98726fba4bb100" checksum = "e622885901322b1d2b26c1bc8d94a717df1e83672cbc41a16f2afc4d2702afab"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
"cfg-if 0.1.10", "cfg-if 1.0.0",
"derivative", "derivative",
"fxhash", "fxhash",
"indexmap", "indexmap",
"itertools 0.9.0", "itertools 0.10.0",
"rand", "rand",
"rand_xorshift", "rand_xorshift",
"serde", "serde",
@ -2625,9 +2718,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-objects" name = "snarkvm-objects"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd3ca38c2a7744f4dca2bdae9441da634b06f40f762323c9e361d6a2582f3353" checksum = "cd47dd986ba53600dd5762c72214250b37af114720dc494770114e9bf8281819"
dependencies = [ dependencies = [
"base58", "base58",
"bech32", "bech32",
@ -2647,9 +2740,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-parameters" name = "snarkvm-parameters"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02a6590e3860f1dc78335a2ef498b21cffa4655de4cfb7cc9027d29b1093d887" checksum = "dd0e2f9bdbce0750aa0def386e4324f278c7e0d58cfbdb42128c03d246c862f4"
dependencies = [ dependencies = [
"curl", "curl",
"hex", "hex",
@ -2661,15 +2754,15 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-profiler" name = "snarkvm-profiler"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed9ec5eadd049ee06e676070d5402401373fe278a42b515141a9b14ca86a795a" checksum = "d5f9c37df04e66b18ef0c4a69861eaf1f83170f1e71509e208d6006c20e65b91"
[[package]] [[package]]
name = "snarkvm-storage" name = "snarkvm-storage"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf798e9883014175e2f019f019fc4db1756cf7d57408602315b270b93992258" checksum = "1cb4f7e299b888749224eada35624347e4c99d2e5972c1c416d2d18e005fe23b"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -2689,9 +2782,9 @@ dependencies = [
[[package]] [[package]]
name = "snarkvm-utilities" name = "snarkvm-utilities"
version = "0.0.2" version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78a4a12c67cc013d6a9574f3231aaf915589cebfd38d27d5f8ad24f1be5794f" checksum = "e7518dfe2e8dc37beeaf3131ef5c77e4e9818843e6c33e7b665240dc8ec805b1"
dependencies = [ dependencies = [
"bincode", "bincode",
"rand", "rand",

View File

@ -26,6 +26,7 @@ path = "leo/main.rs"
[workspace] [workspace]
members = [ members = [
"asg",
"ast", "ast",
"compiler", "compiler",
"gadgets", "gadgets",
@ -34,8 +35,7 @@ members = [
"input", "input",
"linter", "linter",
"package", "package",
"state", "state"
"asg"
] ]
[dependencies.leo-ast] [dependencies.leo-ast]
@ -67,27 +67,27 @@ path = "./state"
version = "1.2.0" version = "1.2.0"
[dependencies.snarkvm-algorithms] [dependencies.snarkvm-algorithms]
version = "0.0.2" version = "0.0.3"
default-features = false default-features = false
[dependencies.snarkvm-curves] [dependencies.snarkvm-curves]
version = "0.0.2" version = "0.0.3"
default-features = false default-features = false
[dependencies.snarkvm-errors] [dependencies.snarkvm-errors]
version = "0.0.2" version = "0.0.3"
default-features = false default-features = false
[dependencies.snarkvm-gadgets] [dependencies.snarkvm-gadgets]
version = "0.0.2" version = "0.0.3"
default-features = false default-features = false
[dependencies.snarkvm-models] [dependencies.snarkvm-models]
version = "0.0.2" version = "0.0.3"
default-features = false default-features = false
[dependencies.snarkvm-utilities] [dependencies.snarkvm-utilities]
version = "0.0.2" version = "0.0.3"
[dependencies.clap] [dependencies.clap]
version = "2.33.3" version = "2.33.3"

View File

@ -22,6 +22,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct ArrayAccessExpression { pub struct ArrayAccessExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -21,6 +21,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct ArrayInitExpression { pub struct ArrayInitExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -22,6 +22,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct ArrayInlineExpression { pub struct ArrayInlineExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -22,6 +22,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct ArrayRangeAccessExpression { pub struct ArrayRangeAccessExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -22,6 +22,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct BinaryExpression { pub struct BinaryExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -29,13 +29,14 @@ use crate::{
Span, Span,
Type, Type,
}; };
pub use leo_ast::BinaryOperation; pub use leo_ast::{BinaryOperation, Node as AstNode};
use std::{ use std::{
cell::RefCell, cell::RefCell,
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct CallExpression { pub struct CallExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -194,25 +195,33 @@ impl FromAst<leo_ast::CallExpression> for CallExpression {
)); ));
} }
} }
if value.arguments.len() != function.argument_types.len() { if value.arguments.len() != function.arguments.len() {
return Err(AsgConvertError::unexpected_call_argument_count( return Err(AsgConvertError::unexpected_call_argument_count(
function.argument_types.len(), function.arguments.len(),
value.arguments.len(), value.arguments.len(),
&value.span, &value.span,
)); ));
} }
let arguments = value
.arguments
.iter()
.zip(function.arguments.iter())
.map(|(expr, argument)| {
let argument = argument.borrow();
let converted =
Arc::<Expression>::from_ast(scope, expr, Some(argument.type_.clone().strong().partial()))?;
if argument.const_ && !converted.is_consty() {
return Err(AsgConvertError::unexpected_nonconst(&expr.span()));
}
Ok(converted)
})
.collect::<Result<Vec<_>, AsgConvertError>>()?;
Ok(CallExpression { Ok(CallExpression {
parent: RefCell::new(None), parent: RefCell::new(None),
span: Some(value.span.clone()), span: Some(value.span.clone()),
arguments: value arguments,
.arguments
.iter()
.zip(function.argument_types.iter())
.map(|(expr, argument)| {
Arc::<Expression>::from_ast(scope, expr, Some(argument.clone().strong().partial()))
})
.collect::<Result<Vec<_>, AsgConvertError>>()?,
function, function,
target, target,
}) })

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::{ use crate::{
AsgConvertError, AsgConvertError,
Circuit, Circuit,
@ -52,6 +36,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct CircuitAccessExpression { pub struct CircuitAccessExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -36,6 +36,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct CircuitInitExpression { pub struct CircuitInitExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -166,7 +167,7 @@ impl Into<leo_ast::CircuitInitExpression> for &CircuitInitExpression {
members: self members: self
.values .values
.iter() .iter()
.map(|(name, value)| leo_ast::CircuitVariableDefinition { .map(|(name, value)| leo_ast::CircuitImpliedVariableDefinition {
identifier: name.clone(), identifier: name.clone(),
expression: value.as_ref().into(), expression: value.as_ref().into(),
}) })

View File

@ -34,6 +34,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct Constant { pub struct Constant {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -173,6 +174,11 @@ impl FromAst<leo_ast::ValueExpression> for Constant {
span: Some(span.clone()), span: Some(span.clone()),
value: ConstValue::Field(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), value: ConstValue::Field(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?),
}, },
Some(PartialType::Type(Type::Group)) => Constant {
parent: RefCell::new(None),
span: Some(span.clone()),
value: ConstValue::Group(GroupValue::Single(value.to_string())),
},
Some(PartialType::Type(Type::Address)) => Constant { Some(PartialType::Type(Type::Address)) => Constant {
parent: RefCell::new(None), parent: RefCell::new(None),
span: Some(span.clone()), span: Some(span.clone()),

View File

@ -66,6 +66,7 @@ use crate::{AsgConvertError, ConstValue, FromAst, Node, PartialType, Scope, Span
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
#[derive(Debug)]
pub enum Expression { pub enum Expression {
VariableRef(VariableRef), VariableRef(VariableRef),
Constant(Constant), Constant(Constant),

View File

@ -21,6 +21,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct TernaryExpression { pub struct TernaryExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -21,6 +21,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct TupleAccessExpression { pub struct TupleAccessExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -21,6 +21,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct TupleInitExpression { pub struct TupleInitExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -22,6 +22,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct UnaryExpression { pub struct UnaryExpression {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -29,7 +29,6 @@ use crate::{
Statement, Statement,
Type, Type,
Variable, Variable,
VariableDeclaration,
}; };
use std::{ use std::{
@ -37,6 +36,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct VariableRef { pub struct VariableRef {
pub parent: RefCell<Option<Weak<Expression>>>, pub parent: RefCell<Option<Weak<Expression>>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -61,7 +61,7 @@ impl ExpressionNode for VariableRef {
fn enforce_parents(&self, _expr: &Arc<Expression>) {} fn enforce_parents(&self, _expr: &Arc<Expression>) {}
fn get_type(&self) -> Option<Type> { fn get_type(&self) -> Option<Type> {
Some(self.variable.borrow().type_.clone()) Some(self.variable.borrow().type_.clone().strong())
} }
fn is_mut_ref(&self) -> bool { fn is_mut_ref(&self) -> bool {
@ -103,7 +103,7 @@ impl ExpressionNode for VariableRef {
fn is_consty(&self) -> bool { fn is_consty(&self) -> bool {
let variable = self.variable.borrow(); let variable = self.variable.borrow();
if variable.declaration == VariableDeclaration::IterationDefinition { if variable.const_ {
return true; return true;
} }
if variable.mutable || variable.assignments.len() != 1 { if variable.mutable || variable.assignments.len() != 1 {

View File

@ -23,7 +23,7 @@ use std::{
}; };
/// Stores program input values as asg nodes. /// Stores program input values as asg nodes.
#[derive(Clone)] #[derive(Debug, Clone)]
pub struct Input { pub struct Input {
pub registers: Arc<CircuitBody>, pub registers: Arc<CircuitBody>,
pub state: Arc<CircuitBody>, pub state: Arc<CircuitBody>,
@ -127,8 +127,9 @@ impl Input {
container: Arc::new(RefCell::new(crate::InnerVariable { container: Arc::new(RefCell::new(crate::InnerVariable {
id: uuid::Uuid::new_v4(), id: uuid::Uuid::new_v4(),
name: Identifier::new("input".to_string()), name: Identifier::new("input".to_string()),
type_: Type::Circuit(container_circuit), type_: Type::Circuit(container_circuit).weak(),
mutable: false, mutable: false,
const_: false,
declaration: crate::VariableDeclaration::Input, declaration: crate::VariableDeclaration::Input,
references: vec![], references: vec![],
assignments: vec![], assignments: vec![],

View File

@ -67,9 +67,9 @@ pub use type_::*;
pub mod variable; pub mod variable;
pub use variable::*; pub use variable::*;
pub use leo_ast::{Identifier, Span}; pub use leo_ast::{Ast, Identifier, Span};
use std::path::Path; use std::{cell::RefCell, path::Path, sync::Arc};
/// The abstract semantic graph (ASG) for a Leo program. /// The abstract semantic graph (ASG) for a Leo program.
/// ///
@ -77,42 +77,41 @@ use std::path::Path;
/// These data types form a graph that begins from a [`Program`] type node. /// These data types form a graph that begins from a [`Program`] type node.
/// ///
/// A new [`Asg`] can be created from an [`Ast`] generated in the `ast` module. /// A new [`Asg`] can be created from an [`Ast`] generated in the `ast` module.
// #[derive(Debug, Eq, PartialEq)] #[derive(Debug, Clone)]
// pub struct Asg { pub struct Asg {
// asg: InnerProgram, asg: Arc<RefCell<InternalProgram>>,
// } }
//
// impl Asg {
// /// Creates a new asg from a given ast tree and import resolver.
// pub fn new<T: ImportResolver + 'static>(
// content: leo_ast::Program,
// resolver: &mut T,
// ) -> Result<Program, AsgConvertError> {
// InnerProgram::new(&content, resolver)
// }
//
// /// Returns a reference to the inner program ast representation.
// pub fn into_repr(self) -> Program {
// self.asg
// }
// }
pub fn load_ast<T: AsRef<Path>, Y: AsRef<str>>(path: T, content: Y) -> Result<leo_ast::Program, AsgConvertError> { impl Asg {
/// Creates a new ASG from a given AST and import resolver.
pub fn new<T: ImportResolver + 'static>(ast: &Ast, resolver: &mut T) -> Result<Self, AsgConvertError> {
Ok(Self {
asg: InternalProgram::new(&ast.as_repr(), resolver)?,
})
}
/// Returns the internal program ASG representation.
pub fn as_repr(&self) -> Arc<RefCell<InternalProgram>> {
self.asg.clone()
}
// /// Serializes the ast into a JSON string.
// pub fn to_json_string(&self) -> Result<String, serde_json::Error> {
// serde_json::to_string_pretty(&self.asg)
// }
//
// /// Deserializes the JSON string into a ast.
// pub fn from_json_string(json: &str) -> Result<Self, serde_json::Error> {
// let ast: Program = serde_json::from_str(json)?;
// Ok(Self { ast })
// }
}
// TODO (howardwu): Remove this.
pub fn load_asg<T: ImportResolver + 'static>(content: &str, resolver: &mut T) -> Result<Program, AsgConvertError> {
// Parses the Leo file and constructs a grammar ast. // Parses the Leo file and constructs a grammar ast.
let ast = leo_grammar::Grammar::new(path.as_ref(), content.as_ref()) let ast = leo_grammar::Grammar::new(&Path::new("input.leo"), content)
.map_err(|e| AsgConvertError::InternalError(format!("ast: {:?}", e)))?; .map_err(|e| AsgConvertError::InternalError(format!("ast: {:?}", e)))?;
// Parses the pest ast and constructs a Leo ast. InternalProgram::new(leo_ast::Ast::new("load_ast", &ast)?.as_repr(), resolver)
Ok(leo_ast::Ast::new("load_ast", &ast)?.into_repr())
}
pub fn load_asg_from_ast<T: ImportResolver + 'static>(
content: leo_ast::Program,
resolver: &mut T,
) -> Result<Program, AsgConvertError> {
InnerProgram::new(&content, resolver)
}
pub fn load_asg<T: ImportResolver + 'static>(content: &str, resolver: &mut T) -> Result<Program, AsgConvertError> {
InnerProgram::new(&load_ast("input.leo", content)?, resolver)
} }

View File

@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
//todo: we should merge this with core // TODO (protryon): We should merge this with core
use crate::{AsgConvertError, Program}; use crate::{AsgConvertError, Program};
// todo: make asg deep copy so we can cache resolved core modules // TODO (protryon): Make asg deep copy so we can cache resolved core modules
// todo: figure out how to do headers without bogus returns // TODO (protryon): Figure out how to do headers without bogus returns
pub fn resolve_core_module(module: &str) -> Result<Option<Program>, AsgConvertError> { pub fn resolve_core_module(module: &str) -> Result<Option<Program>, AsgConvertError> {
match module { match module {

View File

@ -23,16 +23,19 @@ use std::{
}; };
use uuid::Uuid; use uuid::Uuid;
#[derive(Debug)]
pub enum CircuitMemberBody { pub enum CircuitMemberBody {
Variable(Type), Variable(Type),
Function(Arc<FunctionBody>), Function(Arc<FunctionBody>),
} }
#[derive(Debug)]
pub enum CircuitMember { pub enum CircuitMember {
Variable(WeakType), Variable(WeakType),
Function(Arc<Function>), Function(Arc<Function>),
} }
#[derive(Debug)]
pub struct Circuit { pub struct Circuit {
pub id: Uuid, pub id: Uuid,
pub name: RefCell<Identifier>, pub name: RefCell<Identifier>,
@ -51,6 +54,7 @@ impl PartialEq for Circuit {
} }
impl Eq for Circuit {} impl Eq for Circuit {}
#[derive(Debug)]
pub struct CircuitBody { pub struct CircuitBody {
pub scope: Scope, pub scope: Scope,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -38,19 +38,20 @@ use std::{
}; };
use uuid::Uuid; use uuid::Uuid;
#[derive(PartialEq)] #[derive(Debug, PartialEq)]
pub enum FunctionQualifier { pub enum FunctionQualifier {
SelfRef, SelfRef,
MutSelfRef, MutSelfRef,
Static, Static,
} }
#[derive(Debug)]
pub struct Function { pub struct Function {
pub id: Uuid, pub id: Uuid,
pub name: RefCell<Identifier>, pub name: RefCell<Identifier>,
pub output: WeakType, pub output: WeakType,
pub has_input: bool, pub has_input: bool,
pub argument_types: Vec<WeakType>, pub arguments: Vec<Variable>,
pub circuit: RefCell<Option<Weak<Circuit>>>, pub circuit: RefCell<Option<Weak<Circuit>>>,
pub body: RefCell<Weak<FunctionBody>>, pub body: RefCell<Weak<FunctionBody>>,
pub qualifier: FunctionQualifier, pub qualifier: FunctionQualifier,
@ -66,10 +67,10 @@ impl PartialEq for Function {
} }
impl Eq for Function {} impl Eq for Function {}
#[derive(Debug)]
pub struct FunctionBody { pub struct FunctionBody {
pub span: Option<Span>, pub span: Option<Span>,
pub function: Arc<Function>, pub function: Arc<Function>,
pub arguments: Vec<Variable>,
pub body: Arc<Statement>, pub body: Arc<Statement>,
pub scope: Scope, pub scope: Scope,
} }
@ -92,7 +93,7 @@ impl Function {
let mut qualifier = FunctionQualifier::Static; let mut qualifier = FunctionQualifier::Static;
let mut has_input = false; let mut has_input = false;
let mut argument_types = vec![]; let mut arguments = vec![];
{ {
for input in value.input.iter() { for input in value.input.iter() {
match input { match input {
@ -105,8 +106,24 @@ impl Function {
FunctionInput::MutSelfKeyword(_) => { FunctionInput::MutSelfKeyword(_) => {
qualifier = FunctionQualifier::MutSelfRef; qualifier = FunctionQualifier::MutSelfRef;
} }
FunctionInput::Variable(leo_ast::FunctionInputVariable { type_, .. }) => { FunctionInput::Variable(leo_ast::FunctionInputVariable {
argument_types.push(scope.borrow().resolve_ast_type(&type_)?.into()); identifier,
mutable,
const_,
type_,
span: _span,
}) => {
let variable = Arc::new(RefCell::new(crate::InnerVariable {
id: Uuid::new_v4(),
name: identifier.clone(),
type_: scope.borrow().resolve_ast_type(&type_)?.weak(),
mutable: *mutable,
const_: *const_,
declaration: crate::VariableDeclaration::Parameter,
references: vec![],
assignments: vec![],
}));
arguments.push(variable.clone());
} }
} }
} }
@ -119,7 +136,7 @@ impl Function {
name: RefCell::new(value.identifier.clone()), name: RefCell::new(value.identifier.clone()),
output: output.into(), output: output.into(),
has_input, has_input,
argument_types, arguments,
circuit: RefCell::new(None), circuit: RefCell::new(None),
body: RefCell::new(Weak::new()), body: RefCell::new(Weak::new()),
qualifier, qualifier,
@ -134,7 +151,6 @@ impl FunctionBody {
function: Arc<Function>, function: Arc<Function>,
) -> Result<FunctionBody, AsgConvertError> { ) -> Result<FunctionBody, AsgConvertError> {
let new_scope = InnerScope::make_subscope(scope); let new_scope = InnerScope::make_subscope(scope);
let mut arguments = vec![];
{ {
let mut scope_borrow = new_scope.borrow_mut(); let mut scope_borrow = new_scope.borrow_mut();
if function.qualifier != FunctionQualifier::Static { if function.qualifier != FunctionQualifier::Static {
@ -142,8 +158,9 @@ impl FunctionBody {
let self_variable = Arc::new(RefCell::new(crate::InnerVariable { let self_variable = Arc::new(RefCell::new(crate::InnerVariable {
id: Uuid::new_v4(), id: Uuid::new_v4(),
name: Identifier::new("self".to_string()), name: Identifier::new("self".to_string()),
type_: Type::Circuit(circuit.as_ref().unwrap().upgrade().unwrap()), type_: WeakType::Circuit(circuit.as_ref().unwrap().clone()),
mutable: function.qualifier == FunctionQualifier::MutSelfRef, mutable: function.qualifier == FunctionQualifier::MutSelfRef,
const_: false,
declaration: crate::VariableDeclaration::Parameter, declaration: crate::VariableDeclaration::Parameter,
references: vec![], references: vec![],
assignments: vec![], assignments: vec![],
@ -151,30 +168,9 @@ impl FunctionBody {
scope_borrow.variables.insert("self".to_string(), self_variable); scope_borrow.variables.insert("self".to_string(), self_variable);
} }
scope_borrow.function = Some(function.clone()); scope_borrow.function = Some(function.clone());
for input in value.input.iter() { for argument in function.arguments.iter() {
match input { let name = argument.borrow().name.name.clone();
FunctionInput::InputKeyword(_) => {} scope_borrow.variables.insert(name, argument.clone());
FunctionInput::SelfKeyword(_) => {}
FunctionInput::MutSelfKeyword(_) => {}
FunctionInput::Variable(leo_ast::FunctionInputVariable {
identifier,
mutable,
type_,
span: _span,
}) => {
let variable = Arc::new(RefCell::new(crate::InnerVariable {
id: Uuid::new_v4(),
name: identifier.clone(),
type_: scope_borrow.resolve_ast_type(&type_)?,
mutable: *mutable,
declaration: crate::VariableDeclaration::Parameter,
references: vec![],
assignments: vec![],
}));
arguments.push(variable.clone());
scope_borrow.variables.insert(identifier.name.clone(), variable);
}
}
} }
} }
let main_block = BlockStatement::from_ast(&new_scope, &value.block, None)?; let main_block = BlockStatement::from_ast(&new_scope, &value.block, None)?;
@ -198,7 +194,6 @@ impl FunctionBody {
Ok(FunctionBody { Ok(FunctionBody {
span: Some(value.span.clone()), span: Some(value.span.clone()),
function, function,
arguments,
body: Arc::new(Statement::Block(main_block)), body: Arc::new(Statement::Block(main_block)),
scope: new_scope, scope: new_scope,
}) })
@ -209,14 +204,16 @@ impl Into<leo_ast::Function> for &Function {
fn into(self) -> leo_ast::Function { fn into(self) -> leo_ast::Function {
let (input, body, span) = match self.body.borrow().upgrade() { let (input, body, span) = match self.body.borrow().upgrade() {
Some(body) => ( Some(body) => (
body.arguments body.function
.arguments
.iter() .iter()
.map(|variable| { .map(|variable| {
let variable = variable.borrow(); let variable = variable.borrow();
leo_ast::FunctionInput::Variable(leo_ast::FunctionInputVariable { leo_ast::FunctionInput::Variable(leo_ast::FunctionInputVariable {
identifier: variable.name.clone(), identifier: variable.name.clone(),
mutable: variable.mutable, mutable: variable.mutable,
type_: (&variable.type_).into(), const_: variable.const_,
type_: (&variable.type_.clone().strong()).into(),
span: Span::default(), span: Span::default(),
}) })
}) })

View File

@ -32,8 +32,8 @@ use std::{cell::RefCell, sync::Arc};
use uuid::Uuid; use uuid::Uuid;
/// Stores the Leo program abstract semantic graph (ASG). /// Stores the Leo program abstract semantic graph (ASG).
#[derive(Clone)] #[derive(Debug, Clone)]
pub struct InnerProgram { pub struct InternalProgram {
/// The unique id of the program. /// The unique id of the program.
pub id: Uuid, pub id: Uuid,
@ -57,7 +57,7 @@ pub struct InnerProgram {
pub scope: Scope, pub scope: Scope,
} }
pub type Program = Arc<RefCell<InnerProgram>>; pub type Program = Arc<RefCell<InternalProgram>>;
/// Enumerates what names are imported from a package. /// Enumerates what names are imported from a package.
enum ImportSymbol { enum ImportSymbol {
@ -110,22 +110,22 @@ fn resolve_import_package_access(
} }
} }
impl InnerProgram { impl InternalProgram {
/// Returns a new Leo program asg from the given Leo program ast and imports. /// Returns a new Leo program ASG from the given Leo program AST and its imports.
/// ///
/// stages: /// Stages:
/// 1. resolve imports into super scope /// 1. resolve imports into super scope
/// 2. finalize declared types /// 2. finalize declared types
/// 3. finalize declared functions /// 3. finalize declared functions
/// 4. resolve all asg nodes /// 4. resolve all asg nodes
/// ///
pub fn new<T: ImportResolver + 'static>( pub fn new<T: ImportResolver + 'static>(
value: &leo_ast::Program, program: &leo_ast::Program,
import_resolver: &mut T, import_resolver: &mut T,
) -> Result<Program, AsgConvertError> { ) -> Result<Program, AsgConvertError> {
// Recursively extract imported symbols. // Recursively extract imported symbols.
let mut imported_symbols: Vec<(Vec<String>, ImportSymbol, Span)> = vec![]; let mut imported_symbols: Vec<(Vec<String>, ImportSymbol, Span)> = vec![];
for import in value.imports.iter() { for import in program.imports.iter() {
resolve_import_package(&mut imported_symbols, vec![], &import.package); resolve_import_package(&mut imported_symbols, vec![], &import.package);
} }
@ -213,7 +213,7 @@ impl InnerProgram {
// Prepare header-like scope entries. // Prepare header-like scope entries.
let mut proto_circuits = IndexMap::new(); let mut proto_circuits = IndexMap::new();
for (name, circuit) in value.circuits.iter() { for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name); assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = Circuit::init(circuit); let asg_circuit = Circuit::init(circuit);
@ -234,7 +234,7 @@ impl InnerProgram {
function: None, function: None,
})); }));
for (name, circuit) in value.circuits.iter() { for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name); assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = proto_circuits.get(&name.name).unwrap(); let asg_circuit = proto_circuits.get(&name.name).unwrap();
@ -242,7 +242,7 @@ impl InnerProgram {
} }
let mut proto_test_functions = IndexMap::new(); let mut proto_test_functions = IndexMap::new();
for (name, test_function) in value.tests.iter() { for (name, test_function) in program.tests.iter() {
assert_eq!(name.name, test_function.function.identifier.name); assert_eq!(name.name, test_function.function.identifier.name);
let function = Arc::new(Function::from_ast(&scope, &test_function.function)?); let function = Arc::new(Function::from_ast(&scope, &test_function.function)?);
@ -250,7 +250,7 @@ impl InnerProgram {
} }
let mut proto_functions = IndexMap::new(); let mut proto_functions = IndexMap::new();
for (name, function) in value.functions.iter() { for (name, function) in program.functions.iter() {
assert_eq!(name.name, function.identifier.name); assert_eq!(name.name, function.identifier.name);
let asg_function = Arc::new(Function::from_ast(&scope, function)?); let asg_function = Arc::new(Function::from_ast(&scope, function)?);
@ -263,7 +263,7 @@ impl InnerProgram {
// Load concrete definitions. // Load concrete definitions.
let mut test_functions = IndexMap::new(); let mut test_functions = IndexMap::new();
for (name, test_function) in value.tests.iter() { for (name, test_function) in program.tests.iter() {
assert_eq!(name.name, test_function.function.identifier.name); assert_eq!(name.name, test_function.function.identifier.name);
let function = proto_test_functions.get(&name.name).unwrap(); let function = proto_test_functions.get(&name.name).unwrap();
@ -278,7 +278,7 @@ impl InnerProgram {
} }
let mut functions = IndexMap::new(); let mut functions = IndexMap::new();
for (name, function) in value.functions.iter() { for (name, function) in program.functions.iter() {
assert_eq!(name.name, function.identifier.name); assert_eq!(name.name, function.identifier.name);
let asg_function = proto_functions.get(&name.name).unwrap(); let asg_function = proto_functions.get(&name.name).unwrap();
@ -289,7 +289,7 @@ impl InnerProgram {
} }
let mut circuits = IndexMap::new(); let mut circuits = IndexMap::new();
for (name, circuit) in value.circuits.iter() { for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name); assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = proto_circuits.get(&name.name).unwrap(); let asg_circuit = proto_circuits.get(&name.name).unwrap();
let body = Arc::new(CircuitBody::from_ast(&scope, circuit, asg_circuit.clone())?); let body = Arc::new(CircuitBody::from_ast(&scope, circuit, asg_circuit.clone())?);
@ -298,9 +298,9 @@ impl InnerProgram {
circuits.insert(name.name.clone(), body); circuits.insert(name.name.clone(), body);
} }
Ok(Arc::new(RefCell::new(InnerProgram { Ok(Arc::new(RefCell::new(InternalProgram {
id: Uuid::new_v4(), id: Uuid::new_v4(),
name: value.name.clone(), name: program.name.clone(),
test_functions, test_functions,
functions, functions,
circuits, circuits,
@ -332,7 +332,7 @@ impl Iterator for InternalIdentifierGenerator {
Some(out) Some(out)
} }
} }
/// Returns an ast from the given asg program. /// Returns an AST from the given ASG program.
pub fn reform_ast(program: &Program) -> leo_ast::Program { pub fn reform_ast(program: &Program) -> leo_ast::Program {
let mut all_programs: IndexMap<String, Program> = IndexMap::new(); let mut all_programs: IndexMap<String, Program> = IndexMap::new();
let mut program_stack = program.borrow().imported_modules.clone(); let mut program_stack = program.borrow().imported_modules.clone();
@ -417,7 +417,7 @@ pub fn reform_ast(program: &Program) -> leo_ast::Program {
} }
} }
impl Into<leo_ast::Program> for &InnerProgram { impl Into<leo_ast::Program> for &InternalProgram {
fn into(self) -> leo_ast::Program { fn into(self) -> leo_ast::Program {
leo_ast::Program { leo_ast::Program {
name: self.name.clone(), name: self.name.clone(),

View File

@ -157,7 +157,7 @@ pub trait MonoidalReducerProgram<T: Monoid>: MonoidalReducerStatement<T> {
fn reduce_program( fn reduce_program(
&mut self, &mut self,
input: &InnerProgram, input: &InternalProgram,
imported_modules: Vec<T>, imported_modules: Vec<T>,
test_functions: Vec<T>, test_functions: Vec<T>,
functions: Vec<T>, functions: Vec<T>,

View File

@ -21,6 +21,7 @@ use std::{cell::RefCell, sync::Arc};
use uuid::Uuid; use uuid::Uuid;
/// An abstract data type that track the current bindings for variables, functions, and circuits. /// An abstract data type that track the current bindings for variables, functions, and circuits.
#[derive(Debug)]
pub struct InnerScope { pub struct InnerScope {
/// The unique id of the scope. /// The unique id of the scope.
pub id: Uuid, pub id: Uuid,

View File

@ -37,6 +37,7 @@ use leo_ast::AssigneeAccess as AstAssigneeAccess;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
#[derive(Debug)]
pub enum AssignAccess { pub enum AssignAccess {
ArrayRange(Option<Arc<Expression>>, Option<Arc<Expression>>), ArrayRange(Option<Arc<Expression>>, Option<Arc<Expression>>),
ArrayIndex(Arc<Expression>), ArrayIndex(Arc<Expression>),
@ -44,6 +45,7 @@ pub enum AssignAccess {
Member(Identifier), Member(Identifier),
} }
#[derive(Debug)]
pub struct AssignStatement { pub struct AssignStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -92,7 +94,7 @@ impl FromAst<leo_ast::AssignStatement> for Arc<Statement> {
if !variable.borrow().mutable { if !variable.borrow().mutable {
return Err(AsgConvertError::immutable_assignment(&name, &statement.span)); return Err(AsgConvertError::immutable_assignment(&name, &statement.span));
} }
let mut target_type: Option<PartialType> = Some(variable.borrow().type_.clone().into()); let mut target_type: Option<PartialType> = Some(variable.borrow().type_.clone().strong().into());
let mut target_accesses = vec![]; let mut target_accesses = vec![];
for access in statement.assignee.accesses.iter() { for access in statement.assignee.accesses.iter() {

View File

@ -18,6 +18,7 @@ use crate::{AsgConvertError, FromAst, InnerScope, Node, PartialType, Scope, Span
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
#[derive(Debug)]
pub struct BlockStatement { pub struct BlockStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -18,6 +18,7 @@ use crate::{AsgConvertError, BlockStatement, Expression, FromAst, Node, PartialT
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
#[derive(Debug)]
pub struct ConditionalStatement { pub struct ConditionalStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -19,7 +19,8 @@ use leo_ast::ConsoleFunction as AstConsoleFunction;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
//todo: refactor to not require/depend on span // TODO (protryon): Refactor to not require/depend on span
#[derive(Debug)]
pub struct FormattedString { pub struct FormattedString {
pub string: String, pub string: String,
pub containers: Vec<Span>, pub containers: Vec<Span>,
@ -27,6 +28,7 @@ pub struct FormattedString {
pub span: Span, pub span: Span,
} }
#[derive(Debug)]
pub enum ConsoleFunction { pub enum ConsoleFunction {
Assert(Arc<Expression>), Assert(Arc<Expression>),
Debug(FormattedString), Debug(FormattedString),
@ -34,6 +36,7 @@ pub enum ConsoleFunction {
Log(FormattedString), Log(FormattedString),
} }
#[derive(Debug)]
pub struct ConsoleStatement { pub struct ConsoleStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -34,6 +34,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct DefinitionStatement { pub struct DefinitionStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -98,8 +99,10 @@ impl FromAst<leo_ast::DefinitionStatement> for Arc<Statement> {
id: uuid::Uuid::new_v4(), id: uuid::Uuid::new_v4(),
name: variable.identifier.clone(), name: variable.identifier.clone(),
type_: type_ type_: type_
.ok_or_else(|| AsgConvertError::unresolved_type(&variable.identifier.name, &statement.span))?, .ok_or_else(|| AsgConvertError::unresolved_type(&variable.identifier.name, &statement.span))?
.weak(),
mutable: variable.mutable, mutable: variable.mutable,
const_: false,
declaration: crate::VariableDeclaration::Definition, declaration: crate::VariableDeclaration::Definition,
references: vec![], references: vec![],
assignments: vec![], assignments: vec![],
@ -144,7 +147,7 @@ impl Into<leo_ast::DefinitionStatement> for &DefinitionStatement {
span: variable.name.span.clone(), span: variable.name.span.clone(),
}); });
if type_.is_none() { if type_.is_none() {
type_ = Some((&variable.type_).into()); type_ = Some((&variable.type_.clone().strong()).into());
} }
} }

View File

@ -18,6 +18,7 @@ use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
#[derive(Debug)]
pub struct ExpressionStatement { pub struct ExpressionStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -35,6 +35,7 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
#[derive(Debug)]
pub struct IterationStatement { pub struct IterationStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,
@ -64,8 +65,10 @@ impl FromAst<leo_ast::IterationStatement> for Arc<Statement> {
name: statement.variable.clone(), name: statement.variable.clone(),
type_: start type_: start
.get_type() .get_type()
.ok_or_else(|| AsgConvertError::unresolved_type(&statement.variable.name, &statement.span))?, .ok_or_else(|| AsgConvertError::unresolved_type(&statement.variable.name, &statement.span))?
.weak(),
mutable: false, mutable: false,
const_: true,
declaration: crate::VariableDeclaration::IterationDefinition, declaration: crate::VariableDeclaration::IterationDefinition,
references: vec![], references: vec![],
assignments: vec![], assignments: vec![],

View File

@ -46,6 +46,7 @@ use crate::{AsgConvertError, FromAst, Node, PartialType, Scope, Span};
use std::sync::Arc; use std::sync::Arc;
#[derive(Debug)]
pub enum Statement { pub enum Statement {
Return(ReturnStatement), Return(ReturnStatement),
Definition(DefinitionStatement), Definition(DefinitionStatement),

View File

@ -18,6 +18,7 @@ use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
#[derive(Debug)]
pub struct ReturnStatement { pub struct ReturnStatement {
pub parent: Option<Weak<Statement>>, pub parent: Option<Weak<Statement>>,
pub span: Option<Span>, pub span: Option<Span>,

View File

@ -22,8 +22,8 @@ use std::{
sync::{Arc, Weak}, sync::{Arc, Weak},
}; };
/// A type in an asg. /// A type in an ASG.
#[derive(Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Type { pub enum Type {
// Data types // Data types
Address, Address,
@ -38,13 +38,13 @@ pub enum Type {
Circuit(Arc<Circuit>), Circuit(Arc<Circuit>),
} }
#[derive(Clone)] #[derive(Debug, Clone)]
pub enum WeakType { pub enum WeakType {
Type(Type), // circuit not allowed Type(Type), // circuit not allowed
Circuit(Weak<Circuit>), Circuit(Weak<Circuit>),
} }
#[derive(Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum PartialType { pub enum PartialType {
Type(Type), // non-array or tuple Type(Type), // non-array or tuple
Integer(Option<IntegerType>, Option<IntegerType>), // specific, context-specific Integer(Option<IntegerType>, Option<IntegerType>), // specific, context-specific
@ -157,6 +157,10 @@ impl Type {
self.into() self.into()
} }
pub fn weak(self) -> WeakType {
self.into()
}
pub fn is_unit(&self) -> bool { pub fn is_unit(&self) -> bool {
matches!(self, Type::Tuple(t) if t.is_empty()) matches!(self, Type::Tuple(t) if t.is_empty())
} }

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{Expression, Statement, Type}; use crate::{Expression, Statement, WeakType};
use leo_ast::Identifier; use leo_ast::Identifier;
use std::{ use std::{
@ -24,7 +24,7 @@ use std::{
use uuid::Uuid; use uuid::Uuid;
/// Specifies how a program variable was declared. /// Specifies how a program variable was declared.
#[derive(PartialEq)] #[derive(Debug, PartialEq)]
pub enum VariableDeclaration { pub enum VariableDeclaration {
Definition, Definition,
IterationDefinition, IterationDefinition,
@ -33,11 +33,13 @@ pub enum VariableDeclaration {
} }
/// Stores information on a program variable. /// Stores information on a program variable.
#[derive(Debug)]
pub struct InnerVariable { pub struct InnerVariable {
pub id: Uuid, pub id: Uuid,
pub name: Identifier, pub name: Identifier,
pub type_: Type, pub type_: WeakType,
pub mutable: bool, pub mutable: bool,
pub const_: bool, // only function arguments, const var definitions NOT included
pub declaration: VariableDeclaration, pub declaration: VariableDeclaration,
pub references: Vec<Weak<Expression>>, // all Expression::VariableRef or panic pub references: Vec<Weak<Expression>>, // all Expression::VariableRef or panic
pub assignments: Vec<Weak<Statement>>, // all Statement::Assign or panic -- must be 1 if not mutable, or 0 if declaration == input | parameter pub assignments: Vec<Weak<Statement>>, // all Statement::Assign or panic -- must be 1 if not mutable, or 0 if declaration == input | parameter

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
// Expressions // Expressions

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
// Expressions // Expressions

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -13,19 +13,3 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.

View File

@ -13,19 +13,3 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -13,19 +13,3 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI128); test_int!(TestI128);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI16); test_int!(TestI16);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI32); test_int!(TestI32);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI64); test_int!(TestI64);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI8); test_int!(TestI8);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
macro_rules! test_int { macro_rules! test_int {
($name: ident) => { ($name: ident) => {
pub struct $name {} pub struct $name {}

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
pub trait IntegerTester { pub trait IntegerTester {
/// Tests defining the smallest value - 1 /// Tests defining the smallest value - 1
fn test_min_fail(); fn test_min_fail();

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
#[macro_use] #[macro_use]
pub mod int_macro; pub mod int_macro;

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU128); test_uint!(TestU128);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU16); test_uint!(TestU16);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU32); test_uint!(TestU32);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU64); test_uint!(TestU64);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU8); test_uint!(TestU8);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
macro_rules! test_uint { macro_rules! test_uint {
($name: ident) => { ($name: ident) => {
pub struct $name {} pub struct $name {}

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
pub mod address; pub mod address;
pub mod array; pub mod array;
pub mod boolean; pub mod boolean;

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -13,19 +13,3 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.

View File

@ -15,16 +15,28 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use leo_asg::*; use leo_asg::*;
use leo_ast::Ast;
use leo_grammar::Grammar;
use std::path::Path;
mod fail; mod fail;
mod pass; mod pass;
fn load_asg(content: &str) -> Result<Program, AsgConvertError> { const TESTING_FILEPATH: &str = "input.leo";
leo_asg::load_asg(content, &mut NullImportResolver) const TESTING_PROGRAM_NAME: &str = "test_program";
fn load_asg(program_string: &str) -> Result<Program, AsgConvertError> {
load_asg_imports(program_string, &mut NullImportResolver)
} }
fn load_asg_imports<T: ImportResolver + 'static>(content: &str, imports: &mut T) -> Result<Program, AsgConvertError> { fn load_asg_imports<T: ImportResolver + 'static>(
leo_asg::load_asg(content, imports) program_string: &str,
imports: &mut T,
) -> Result<Program, AsgConvertError> {
let grammar = Grammar::new(Path::new(&TESTING_FILEPATH), program_string)?;
let ast = Ast::new(TESTING_PROGRAM_NAME, &grammar)?;
InternalProgram::new(&ast.as_repr(), imports)
} }
fn mocked_resolver() -> MockedImportResolver { fn mocked_resolver() -> MockedImportResolver {

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
// Registers // Registers

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
// Expressions // Expressions

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -15,6 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::load_asg; use crate::load_asg;
use leo_ast::Ast;
use leo_grammar::Grammar;
use std::path::Path;
#[test] #[test]
fn test_basic() { fn test_basic() {
@ -73,14 +77,19 @@ fn test_imports() {
console.assert(foo() == 1u32); console.assert(foo() == 1u32);
} }
"#; "#;
let test_import_grammar = Grammar::new(Path::new("test-import.leo"), test_import).unwrap();
println!( println!(
"{}", "{}",
serde_json::to_string(&crate::load_ast("test-import.leo", test_import).unwrap()).unwrap() serde_json::to_string(Ast::new("test-import", &test_import_grammar).unwrap().as_repr()).unwrap()
); );
let test_grammar = Grammar::new(Path::new("test.leo"), program_string).unwrap();
println!( println!(
"{}", "{}",
serde_json::to_string(&crate::load_ast("test.leo", program_string).unwrap()).unwrap() serde_json::to_string(Ast::new("test", &test_grammar).unwrap().as_repr()).unwrap()
); );
let asg = crate::load_asg_imports(program_string, &mut imports).unwrap(); let asg = crate::load_asg_imports(program_string, &mut imports).unwrap();
let reformed_ast = leo_asg::reform_ast(&asg); let reformed_ast = leo_asg::reform_ast(&asg);
println!("{}", serde_json::to_string(&reformed_ast).unwrap()); println!("{}", serde_json::to_string(&reformed_ast).unwrap());

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]
@ -44,6 +28,66 @@ fn test_iteration() {
load_asg(program_string).unwrap(); load_asg(program_string).unwrap();
} }
#[test]
fn test_const_args() {
let program_string = r#"
function one(const value: u32) -> u32 {
return value + 1
}
function main() {
let mut a = 0u32;
for i in 0..10 {
a += one(i);
}
console.assert(a == 20u32);
}
"#;
load_asg(program_string).unwrap();
}
#[test]
fn test_const_args_used() {
let program_string = r#"
function index(arr: [u8; 3], const value: u32) -> u8 {
return arr[value]
}
function main() {
let mut a = 0u8;
let arr = [1u8, 2, 3];
for i in 0..3 {
a += index(arr, i);
}
console.assert(a == 6u8);
}
"#;
load_asg(program_string).unwrap();
}
#[test]
fn test_const_args_fail() {
let program_string = r#"
function index(arr: [u8; 3], const value: u32) -> u8 {
return arr[value]
}
function main(x_value: u32) {
let mut a = 0u8;
let arr = [1u8, 2, 3];
a += index(arr, x_value);
console.assert(a == 1u8);
}
"#;
load_asg(program_string).err().unwrap();
}
#[test] #[test]
fn test_iteration_repeated() { fn test_iteration_repeated() {
let program_string = include_str!("iteration_repeated.leo"); let program_string = include_str!("iteration_repeated.leo");

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]
@ -38,6 +22,16 @@ fn test_one() {
load_asg(program_string).unwrap(); load_asg(program_string).unwrap();
} }
#[test]
fn test_implicit() {
let program_string = r#"
function main() {
let element: group = 0;
}
"#;
load_asg(program_string).unwrap();
}
#[test] #[test]
fn test_zero() { fn test_zero() {
let program_string = include_str!("zero.leo"); let program_string = include_str!("zero.leo");

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::{load_asg, load_asg_imports, mocked_resolver}; use crate::{load_asg, load_asg_imports, mocked_resolver};
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
mod program_input; mod program_input;
mod program_input_and_program_state; mod program_input_and_program_state;
mod program_state; mod program_state;

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI128); test_int!(TestI128);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI16); test_int!(TestI16);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI32); test_int!(TestI32);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI64); test_int!(TestI64);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_int!(TestI8); test_int!(TestI8);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
macro_rules! test_int { macro_rules! test_int {
($name: ident) => { ($name: ident) => {
pub struct $name {} pub struct $name {}

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
pub trait IntegerTester { pub trait IntegerTester {
/// Tests defining the smalled value that can be represented by the integer type /// Tests defining the smalled value that can be represented by the integer type
fn test_min(); fn test_min();

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
#[macro_use] #[macro_use]
pub mod int_macro; pub mod int_macro;

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU128); test_uint!(TestU128);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU16); test_uint!(TestU16);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU32); test_uint!(TestU32);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU64); test_uint!(TestU64);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use super::IntegerTester; use super::IntegerTester;
test_uint!(TestU8); test_uint!(TestU8);

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
macro_rules! test_uint { macro_rules! test_uint {
($name: ident) => { ($name: ident) => {
pub struct $name {} pub struct $name {}

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
pub mod address; pub mod address;
pub mod array; pub mod array;
pub mod boolean; pub mod boolean;

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]
@ -81,7 +65,6 @@ fn test_function_input_mut() {
} }
#[test] #[test]
#[ignore]
fn test_swap() { fn test_swap() {
let program_string = include_str!("swap.leo"); let program_string = include_str!("swap.leo");
load_asg(program_string).unwrap(); load_asg(program_string).unwrap();

View File

@ -1,5 +1,5 @@
// Swap two elements of an array. // Swap two elements of an array.
function swap(mut a: [u32; 2], i: u32, j: u32) -> [u32; 2] { function swap(mut a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] {
let t = a[i]; let t = a[i];
a[i] = a[j]; a[i] = a[j];
a[j] = t; a[j] = t;

View File

@ -14,22 +14,6 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// 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/>.
use crate::load_asg; use crate::load_asg;
#[test] #[test]

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