mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 07:07:07 +03:00
Merge branch 'master' into leo-wasm
This commit is contained in:
commit
85059a682d
34
.github/workflows/acl2.yml
vendored
34
.github/workflows/acl2.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: Leo-ACL2
|
||||
on: workflow_dispatch
|
||||
env:
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
# This job can only be run on linux (Ubuntu)
|
||||
@ -28,35 +28,37 @@ jobs:
|
||||
- name: Pull tgc executable
|
||||
run: |
|
||||
mkdir acl2 && cd acl2;
|
||||
wget $(curl -s https://api.github.com/repos/AleoHQ/leo-acl2-bin/releases/latest \
|
||||
| grep "browser_download_url.*.tgz" \
|
||||
| cut -d : -f 2,3 \
|
||||
| tr -d \" \
|
||||
| xargs)
|
||||
wget $( curl -s https://api.github.com/repos/AleoHQ/leo-acl2-bin/releases/latest \
|
||||
| jq -r '.assets[0].browser_download_url' )
|
||||
|
||||
echo "Unpacking $(ls):"
|
||||
tar -xvzf $(ls)
|
||||
|
||||
# Using the prepared ASTs and the pulled and unzipped tgc run theorem generation.
|
||||
|
||||
# Run theorem generation and checking using the prepared ASTs and the pulled and unzipped leo-acl2 tarball.
|
||||
- name: Run tgc over ASTs
|
||||
run: |
|
||||
canonicalization_errors=();
|
||||
type_inference_errors=();
|
||||
num_dirs=0;
|
||||
for dir in `ls tmp/tgc`;
|
||||
do
|
||||
cd tmp/tgc/$dir; # enter the directory
|
||||
num_dirs=$((num_dirs + 1));
|
||||
./../../../acl2/tgc canonicalization initial_ast.json canonicalization_ast.json canonicalization-theorem.lisp > canonicalization_result.out || canonicalization_errors+=("$dir");
|
||||
# Disabling Type inference for now
|
||||
./../../../acl2/tgc type-inference canonicalization_ast.json type_inferenced_ast.json type-inference-theorem.lisp > type_inference_result.out || type_inference_errors+=("$dir");
|
||||
cd ../../..
|
||||
done;
|
||||
|
||||
echo "----------------"
|
||||
echo "Ran tgc in ${num_dirs} directories."
|
||||
echo "----------------"
|
||||
if [ ${#canonicalization_errors[@]} -eq 0 ]; then
|
||||
echo "Canonicalization - Success!"
|
||||
else
|
||||
echo "Canonicalization Failures:";
|
||||
echo "Canonicalization Failures (total: ${#canonicalization_errors[@]}):"
|
||||
for dir in ${canonicalization_errors[@]};
|
||||
do
|
||||
echo $dir;
|
||||
echo $dir
|
||||
done;
|
||||
|
||||
#echo "Attaching logs:"
|
||||
@ -65,16 +67,16 @@ jobs:
|
||||
# cat tmp/tgc/$dir/canonicalization_result.out
|
||||
# cat tmp/tgc/$dir/canonicalization-theorem.lisp
|
||||
#done;
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "----------------"
|
||||
if [ ${#type_inference_errors[@]} -eq 0 ]; then
|
||||
echo "Type Inference - Success!"
|
||||
else
|
||||
echo "Type Inference Failures:";
|
||||
echo "Type Inference Failures (total: ${#type_inference_errors[@]}):"
|
||||
for dir in ${type_inference_errors[@]};
|
||||
do
|
||||
echo $dir;
|
||||
echo $dir
|
||||
done;
|
||||
|
||||
#echo "Attaching logs:"
|
||||
@ -82,6 +84,10 @@ jobs:
|
||||
#do
|
||||
# cat tmp/tgc/$dir/type_inference_result.out
|
||||
#done;
|
||||
fi
|
||||
|
||||
if [[ ${#canonicalization_errors[@]} -ne 0 || ${#type_inference_errors[@]} -ne 0 ]]; then
|
||||
echo "----------------"
|
||||
echo "Exiting with status 1 due to at least one tgc error."
|
||||
exit 1
|
||||
fi
|
||||
|
68
Cargo.lock
generated
68
Cargo.lock
generated
@ -590,9 +590,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "3.0.2"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
@ -925,6 +925,12 @@ version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.3"
|
||||
@ -1065,6 +1071,30 @@ dependencies = [
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "include_dir"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24b56e147e6187d61e9d0f039f10e070d0c0a887e24fe0bb9ca3f29bfde62cab"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"include_dir_impl",
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "include_dir_impl"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"proc-macro-hack",
|
||||
"proc-macro2 1.0.27",
|
||||
"quote 1.0.9",
|
||||
"syn 1.0.73",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
@ -1239,6 +1269,7 @@ dependencies = [
|
||||
"leo-ast",
|
||||
"leo-errors",
|
||||
"leo-parser",
|
||||
"leo-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1300,7 +1331,6 @@ name = "leo-imports"
|
||||
version = "1.5.3"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"leo-asg",
|
||||
"leo-ast",
|
||||
"leo-ast-passes",
|
||||
"leo-errors",
|
||||
@ -1342,6 +1372,7 @@ dependencies = [
|
||||
"leo-package",
|
||||
"leo-parser",
|
||||
"leo-state",
|
||||
"leo-stdlib",
|
||||
"leo-synthesizer",
|
||||
"notify",
|
||||
"rand 0.8.4",
|
||||
@ -1416,6 +1447,17 @@ dependencies = [
|
||||
"snarkvm-utilities",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leo-stdlib"
|
||||
version = "1.5.3"
|
||||
dependencies = [
|
||||
"include_dir",
|
||||
"indexmap",
|
||||
"leo-ast",
|
||||
"leo-errors",
|
||||
"leo-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leo-synthesizer"
|
||||
version = "1.5.3"
|
||||
@ -1441,8 +1483,10 @@ dependencies = [
|
||||
"leo-ast",
|
||||
"leo-ast-passes",
|
||||
"leo-compiler",
|
||||
"leo-errors",
|
||||
"leo-imports",
|
||||
"leo-parser",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
@ -2007,6 +2051,12 @@ dependencies = [
|
||||
"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-macro2"
|
||||
version = "0.4.30"
|
||||
@ -2997,9 +3047,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.26"
|
||||
version = "0.1.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d"
|
||||
checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"pin-project-lite",
|
||||
@ -3009,9 +3059,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.15"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2"
|
||||
checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.27",
|
||||
"quote 1.0.9",
|
||||
@ -3020,9 +3070,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.18"
|
||||
version = "0.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052"
|
||||
checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
@ -39,6 +39,7 @@ members = [
|
||||
"package",
|
||||
"parser",
|
||||
"state",
|
||||
"stdlib",
|
||||
"synthesizer",
|
||||
"test-framework",
|
||||
"wasm"
|
||||
@ -76,6 +77,10 @@ version = "1.5.3"
|
||||
path = "./state"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-stdlib]
|
||||
path = "./stdlib"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-synthesizer]
|
||||
path = "./synthesizer"
|
||||
version = "1.5.3"
|
||||
@ -111,7 +116,7 @@ color-backtrace = "0.5.1"
|
||||
version = "2.0"
|
||||
|
||||
[dependencies.dirs]
|
||||
version = "3.0.2"
|
||||
version = "4.0.0"
|
||||
|
||||
[dependencies.console]
|
||||
version = "0.14.0"
|
||||
|
89
asg/src/expression/lengthof.rs
Normal file
89
asg/src/expression/lengthof.rs
Normal file
@ -0,0 +1,89 @@
|
||||
// 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::{ConstValue, Expression, ExpressionNode, FromAst, IntegerType, Node, PartialType, Scope, Type};
|
||||
pub use leo_ast::UnaryOperation;
|
||||
use leo_errors::{Result, Span};
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LengthOfExpression<'a> {
|
||||
pub parent: Cell<Option<&'a Expression<'a>>>,
|
||||
pub span: Option<Span>,
|
||||
pub inner: Cell<&'a Expression<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> Node for LengthOfExpression<'a> {
|
||||
fn span(&self) -> Option<&Span> {
|
||||
self.span.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ExpressionNode<'a> for LengthOfExpression<'a> {
|
||||
fn set_parent(&self, parent: &'a Expression<'a>) {
|
||||
self.parent.replace(Some(parent));
|
||||
}
|
||||
|
||||
fn get_parent(&self) -> Option<&'a Expression<'a>> {
|
||||
self.parent.get()
|
||||
}
|
||||
|
||||
fn enforce_parents(&self, expr: &'a Expression<'a>) {
|
||||
self.inner.get().set_parent(expr);
|
||||
}
|
||||
|
||||
fn get_type(&self) -> Option<Type<'a>> {
|
||||
Some(Type::Integer(IntegerType::U32)) // For now we stick to U32 value type
|
||||
}
|
||||
|
||||
fn is_mut_ref(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn const_value(&self) -> Option<ConstValue> {
|
||||
None
|
||||
}
|
||||
|
||||
fn is_consty(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromAst<'a, leo_ast::LengthOfExpression> for LengthOfExpression<'a> {
|
||||
fn from_ast(
|
||||
scope: &'a Scope<'a>,
|
||||
value: &leo_ast::LengthOfExpression,
|
||||
_expected_type: Option<PartialType<'a>>,
|
||||
) -> Result<LengthOfExpression<'a>> {
|
||||
let inner = <&Expression<'a>>::from_ast(scope, &*value.inner, None)?;
|
||||
|
||||
Ok(LengthOfExpression {
|
||||
parent: Cell::new(None),
|
||||
span: Some(value.span.clone()),
|
||||
inner: Cell::new(inner),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<leo_ast::LengthOfExpression> for &LengthOfExpression<'a> {
|
||||
fn into(self) -> leo_ast::LengthOfExpression {
|
||||
leo_ast::LengthOfExpression {
|
||||
inner: Box::new(self.inner.get().into()),
|
||||
span: self.span.clone().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
@ -65,6 +65,9 @@ pub use variable_ref::*;
|
||||
mod cast;
|
||||
pub use cast::*;
|
||||
|
||||
mod lengthof;
|
||||
pub use lengthof::*;
|
||||
|
||||
use crate::{ConstValue, FromAst, Node, PartialType, Scope, Type};
|
||||
use leo_errors::{Result, Span};
|
||||
|
||||
@ -76,6 +79,7 @@ pub enum Expression<'a> {
|
||||
Unary(UnaryExpression<'a>),
|
||||
Ternary(TernaryExpression<'a>),
|
||||
Cast(CastExpression<'a>),
|
||||
LengthOf(LengthOfExpression<'a>),
|
||||
|
||||
ArrayInline(ArrayInlineExpression<'a>),
|
||||
ArrayInit(ArrayInitExpression<'a>),
|
||||
@ -107,6 +111,7 @@ impl<'a> Node for Expression<'a> {
|
||||
Unary(x) => x.span(),
|
||||
Ternary(x) => x.span(),
|
||||
Cast(x) => x.span(),
|
||||
LengthOf(x) => x.span(),
|
||||
ArrayInline(x) => x.span(),
|
||||
ArrayInit(x) => x.span(),
|
||||
ArrayAccess(x) => x.span(),
|
||||
@ -141,6 +146,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.set_parent(parent),
|
||||
Ternary(x) => x.set_parent(parent),
|
||||
Cast(x) => x.set_parent(parent),
|
||||
LengthOf(x) => x.set_parent(parent),
|
||||
ArrayInline(x) => x.set_parent(parent),
|
||||
ArrayInit(x) => x.set_parent(parent),
|
||||
ArrayAccess(x) => x.set_parent(parent),
|
||||
@ -162,6 +168,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.get_parent(),
|
||||
Ternary(x) => x.get_parent(),
|
||||
Cast(x) => x.get_parent(),
|
||||
LengthOf(x) => x.get_parent(),
|
||||
ArrayInline(x) => x.get_parent(),
|
||||
ArrayInit(x) => x.get_parent(),
|
||||
ArrayAccess(x) => x.get_parent(),
|
||||
@ -183,6 +190,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.enforce_parents(expr),
|
||||
Ternary(x) => x.enforce_parents(expr),
|
||||
Cast(x) => x.enforce_parents(expr),
|
||||
LengthOf(x) => x.enforce_parents(expr),
|
||||
ArrayInline(x) => x.enforce_parents(expr),
|
||||
ArrayInit(x) => x.enforce_parents(expr),
|
||||
ArrayAccess(x) => x.enforce_parents(expr),
|
||||
@ -204,6 +212,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.get_type(),
|
||||
Ternary(x) => x.get_type(),
|
||||
Cast(x) => x.get_type(),
|
||||
LengthOf(x) => x.get_type(),
|
||||
ArrayInline(x) => x.get_type(),
|
||||
ArrayInit(x) => x.get_type(),
|
||||
ArrayAccess(x) => x.get_type(),
|
||||
@ -225,6 +234,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.is_mut_ref(),
|
||||
Ternary(x) => x.is_mut_ref(),
|
||||
Cast(x) => x.is_mut_ref(),
|
||||
LengthOf(x) => x.is_mut_ref(),
|
||||
ArrayInline(x) => x.is_mut_ref(),
|
||||
ArrayInit(x) => x.is_mut_ref(),
|
||||
ArrayAccess(x) => x.is_mut_ref(),
|
||||
@ -246,6 +256,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.const_value(),
|
||||
Ternary(x) => x.const_value(),
|
||||
Cast(x) => x.const_value(),
|
||||
LengthOf(x) => x.const_value(),
|
||||
ArrayInline(x) => x.const_value(),
|
||||
ArrayInit(x) => x.const_value(),
|
||||
ArrayAccess(x) => x.const_value(),
|
||||
@ -267,6 +278,7 @@ impl<'a> ExpressionNode<'a> for Expression<'a> {
|
||||
Unary(x) => x.is_consty(),
|
||||
Ternary(x) => x.is_consty(),
|
||||
Cast(x) => x.is_consty(),
|
||||
LengthOf(x) => x.is_consty(),
|
||||
ArrayInline(x) => x.is_consty(),
|
||||
ArrayInit(x) => x.is_consty(),
|
||||
ArrayAccess(x) => x.is_consty(),
|
||||
@ -305,6 +317,10 @@ impl<'a> FromAst<'a, leo_ast::Expression> for &'a Expression<'a> {
|
||||
.context
|
||||
.alloc_expression(CastExpression::from_ast(scope, cast, expected_type).map(Expression::Cast)?),
|
||||
|
||||
LengthOf(lengthof) => scope.context.alloc_expression(
|
||||
LengthOfExpression::from_ast(scope, lengthof, expected_type).map(Expression::LengthOf)?,
|
||||
),
|
||||
|
||||
ArrayInline(array_inline) => scope.context.alloc_expression(
|
||||
ArrayInlineExpression::from_ast(scope, array_inline, expected_type).map(Expression::ArrayInline)?,
|
||||
),
|
||||
@ -357,6 +373,7 @@ impl<'a> Into<leo_ast::Expression> for &Expression<'a> {
|
||||
Unary(x) => leo_ast::Expression::Unary(x.into()),
|
||||
Ternary(x) => leo_ast::Expression::Ternary(x.into()),
|
||||
Cast(x) => leo_ast::Expression::Cast(x.into()),
|
||||
LengthOf(x) => leo_ast::Expression::LengthOf(x.into()),
|
||||
ArrayInline(x) => leo_ast::Expression::ArrayInline(x.into()),
|
||||
ArrayInit(x) => leo_ast::Expression::ArrayInit(x.into()),
|
||||
ArrayAccess(x) => leo_ast::Expression::ArrayAccess(x.into()),
|
||||
|
@ -163,10 +163,26 @@ impl<'a> Program<'a> {
|
||||
/// 4. resolve all asg nodes
|
||||
///
|
||||
pub fn new(context: AsgContext<'a>, program: &leo_ast::Program) -> Result<Program<'a>> {
|
||||
let mut imported_aliases: IndexMap<String, &'a Alias<'a>> = IndexMap::new();
|
||||
let mut imported_functions: IndexMap<String, &'a Function<'a>> = IndexMap::new();
|
||||
let mut imported_circuits: IndexMap<String, &'a Circuit<'a>> = IndexMap::new();
|
||||
let mut imported_global_consts: IndexMap<String, &'a DefinitionStatement<'a>> = IndexMap::new();
|
||||
|
||||
// Convert each sub AST.
|
||||
// Import all prelude symbols on the way.
|
||||
let mut imported_modules: IndexMap<Vec<String>, Program> = IndexMap::new();
|
||||
for (package, program) in program.imports.iter() {
|
||||
imported_modules.insert(package.clone(), Program::new(context, program)?);
|
||||
let sub_program = Program::new(context, program)?;
|
||||
imported_modules.insert(package.clone(), sub_program.clone());
|
||||
|
||||
let pretty_package = package.join(".");
|
||||
|
||||
if pretty_package.contains("std.prelude") {
|
||||
imported_aliases.extend(sub_program.aliases.clone().into_iter());
|
||||
imported_functions.extend(sub_program.functions.clone().into_iter());
|
||||
imported_circuits.extend(sub_program.circuits.clone().into_iter());
|
||||
imported_global_consts.extend(sub_program.global_consts.clone().into_iter());
|
||||
}
|
||||
}
|
||||
|
||||
let mut imported_symbols: Vec<(Vec<String>, ImportSymbol, Span)> = vec![];
|
||||
@ -179,11 +195,6 @@ impl<'a> Program<'a> {
|
||||
deduplicated_imports.insert(package.clone(), span.clone());
|
||||
}
|
||||
|
||||
let mut imported_aliases: IndexMap<String, &'a Alias<'a>> = IndexMap::new();
|
||||
let mut imported_functions: IndexMap<String, &'a Function<'a>> = IndexMap::new();
|
||||
let mut imported_circuits: IndexMap<String, &'a Circuit<'a>> = IndexMap::new();
|
||||
let mut imported_global_consts: IndexMap<String, &'a DefinitionStatement<'a>> = IndexMap::new();
|
||||
|
||||
for (package, symbol, span) in imported_symbols.into_iter() {
|
||||
let pretty_package = package.join(".");
|
||||
|
||||
|
@ -16,25 +16,15 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct BoolAnd(pub bool);
|
||||
|
||||
impl Default for BoolAnd {
|
||||
fn default() -> Self {
|
||||
BoolAnd(false)
|
||||
}
|
||||
}
|
||||
|
||||
impl Monoid for BoolAnd {
|
||||
fn append(self, other: Self) -> Self {
|
||||
BoolAnd(self.0 && other.0)
|
||||
}
|
||||
|
||||
fn append_all(self, others: impl Iterator<Item = Self>) -> Self {
|
||||
for item in others {
|
||||
if !item.0 {
|
||||
return BoolAnd(false);
|
||||
}
|
||||
}
|
||||
BoolAnd(true)
|
||||
fn append_all(self, mut others: impl Iterator<Item = Self>) -> Self {
|
||||
BoolAnd(others.all(|i| i.0))
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ impl<'a, T: Monoid, R: MonoidalReducerExpression<'a, T>> MonoidalDirector<'a, T,
|
||||
Expression::CircuitInit(e) => self.reduce_circuit_init(e),
|
||||
Expression::Ternary(e) => self.reduce_ternary_expression(e),
|
||||
Expression::Cast(e) => self.reduce_cast_expression(e),
|
||||
Expression::LengthOf(e) => self.reduce_lengthof_expression(e),
|
||||
Expression::Constant(e) => self.reduce_constant(e),
|
||||
Expression::TupleAccess(e) => self.reduce_tuple_access(e),
|
||||
Expression::TupleInit(e) => self.reduce_tuple_init(e),
|
||||
@ -138,6 +139,12 @@ impl<'a, T: Monoid, R: MonoidalReducerExpression<'a, T>> MonoidalDirector<'a, T,
|
||||
self.reducer.reduce_cast_expression(input, inner)
|
||||
}
|
||||
|
||||
pub fn reduce_lengthof_expression(&mut self, input: &LengthOfExpression<'a>) -> T {
|
||||
let inner = self.reduce_expression(input.inner.get());
|
||||
|
||||
self.reducer.reduce_lengthof_expression(input, inner)
|
||||
}
|
||||
|
||||
pub fn reduce_constant(&mut self, input: &Constant<'a>) -> T {
|
||||
self.reducer.reduce_constant(input)
|
||||
}
|
||||
|
@ -68,6 +68,10 @@ pub trait MonoidalReducerExpression<'a, T: Monoid> {
|
||||
inner
|
||||
}
|
||||
|
||||
fn reduce_lengthof_expression(&mut self, input: &LengthOfExpression<'a>, inner: T) -> T {
|
||||
inner
|
||||
}
|
||||
|
||||
fn reduce_constant(&mut self, input: &Constant<'a>) -> T {
|
||||
T::default()
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ impl<'a, R: ReconstructingReducerExpression<'a>> ReconstructingDirector<'a, R> {
|
||||
Expression::CircuitInit(e) => self.reduce_circuit_init(e),
|
||||
Expression::Ternary(e) => self.reduce_ternary_expression(e),
|
||||
Expression::Cast(e) => self.reduce_cast_expression(e),
|
||||
Expression::LengthOf(e) => Expression::LengthOf(e), // TODO: implement REDUCER
|
||||
Expression::Constant(e) => self.reduce_constant(e),
|
||||
Expression::TupleAccess(e) => self.reduce_tuple_access(e),
|
||||
Expression::TupleInit(e) => self.reduce_tuple_init(e),
|
||||
|
@ -76,6 +76,10 @@ pub trait ExpressionVisitor<'a> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn visit_lengthof_expression(&mut self, input: &LengthOfExpression<'a>) -> VisitResult {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn visit_constant(&mut self, input: &Constant<'a>) -> VisitResult {
|
||||
Default::default()
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ impl<'a, R: ExpressionVisitor<'a>> VisitorDirector<'a, R> {
|
||||
Expression::CircuitInit(e) => self.visit_circuit_init(e),
|
||||
Expression::Ternary(e) => self.visit_ternary_expression(e),
|
||||
Expression::Cast(e) => self.visit_cast_expression(e),
|
||||
Expression::LengthOf(e) => self.visit_lengthof_expression(e),
|
||||
Expression::Constant(e) => self.visit_constant(e),
|
||||
Expression::TupleAccess(e) => self.visit_tuple_access(e),
|
||||
Expression::TupleInit(e) => self.visit_tuple_init(e),
|
||||
@ -195,6 +196,16 @@ impl<'a, R: ExpressionVisitor<'a>> VisitorDirector<'a, R> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_lengthof_expression(&mut self, input: &LengthOfExpression<'a>) -> ConcreteVisitResult {
|
||||
match self.visitor.visit_lengthof_expression(input) {
|
||||
VisitResult::VisitChildren => {
|
||||
self.visit_expression(&input.inner)?;
|
||||
Ok(())
|
||||
}
|
||||
x => x.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_constant(&mut self, input: &Constant<'a>) -> ConcreteVisitResult {
|
||||
self.visitor.visit_constant(input).into()
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ impl<'a> Into<leo_ast::ConditionalStatement> for &ConditionalStatement<'a> {
|
||||
Statement::Block(block) => block.into(),
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
next: self.next.get().as_deref().map(|e| Box::new(e.into())),
|
||||
next: self.next.get().map(|e| Box::new(e.into())),
|
||||
span: self.span.clone().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
@ -34,3 +34,7 @@ version = "1.5.3"
|
||||
[dependencies.leo-parser]
|
||||
path = "../parser"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-stdlib]
|
||||
path = "../stdlib"
|
||||
version = "1.5.3"
|
@ -1 +1,30 @@
|
||||
# leo-ast-passes
|
||||
|
||||
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-ast)
|
||||
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
|
||||
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
|
||||
|
||||
## Usage
|
||||
|
||||
The code here is split into several usages. Each usage represents a different pass or modification when given an AST.
|
||||
|
||||
### Canonicalization
|
||||
|
||||
This pass of the code has a few changes it must complete:
|
||||
|
||||
- `Self` is not allowed outside a circuit.
|
||||
- `Self` in circuits must be replaced with an Identifier containing the Circuit Name.
|
||||
- Any 0 size array definitions should be rejected.
|
||||
- Multi-size array definitions should be expanded such that `[0u8; (2, 3)]` becomes `[[0u8; 3] 2]`.
|
||||
- Compound assignments become simple assignments such that `a += 2;` becomes `a = a + 2;`.
|
||||
- Missing function output types are replaced with an empty tuple.
|
||||
|
||||
### Import Resolution
|
||||
|
||||
This pass iterates through the import statements(nestedly), resloving all imports. Thus adding the improted file's AST to the main AST.
|
||||
|
||||
In addition, it also handles forcibly importing the stdlib prelude files.
|
||||
|
||||
## Structure
|
||||
|
||||
Each different type of pass is located in its own directory within the src directory.
|
||||
|
@ -23,6 +23,7 @@ use leo_errors::{AstError, Result, Span};
|
||||
/// Tuple array types and expressions error if a size of 0 is given.
|
||||
/// Compound operators become simple assignments.
|
||||
/// Functions missing output type return a empty tuple.
|
||||
#[derive(Default)]
|
||||
pub struct Canonicalizer {
|
||||
// If we are in a circuit keep track of the circuit name.
|
||||
circuit_name: Option<Identifier>,
|
||||
@ -37,15 +38,6 @@ impl AstPass for Canonicalizer {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Canonicalizer {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
circuit_name: None,
|
||||
in_circuit: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Canonicalizer {
|
||||
pub fn canonicalize_accesses(
|
||||
&mut self,
|
||||
|
@ -28,6 +28,9 @@ impl Importer {
|
||||
where
|
||||
T: ImportResolver,
|
||||
{
|
||||
let mut ast = program.clone();
|
||||
ast.imports.extend(leo_stdlib::resolve_prelude_modules()?);
|
||||
|
||||
let mut imported_symbols: Vec<(Vec<String>, ImportSymbol, Span)> = vec![];
|
||||
for import_statement in program.import_statements.iter() {
|
||||
resolve_import_package(&mut imported_symbols, vec![], &import_statement.package_or_packages);
|
||||
@ -53,8 +56,7 @@ impl Importer {
|
||||
resolved_packages.insert(package.clone(), resolved_package);
|
||||
}
|
||||
|
||||
let mut ast = program;
|
||||
ast.imports = resolved_packages;
|
||||
ast.imports.extend(resolved_packages);
|
||||
|
||||
Ok(Ast::new(ast))
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
use leo_ast::Program;
|
||||
use leo_errors::{Result, Span};
|
||||
use leo_stdlib::resolve_stdlib_module;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
@ -43,8 +44,8 @@ impl<'a, T: ImportResolver> CoreImportResolver<'a, T> {
|
||||
|
||||
impl<'a, T: ImportResolver> ImportResolver for CoreImportResolver<'a, T> {
|
||||
fn resolve_package(&mut self, package_segments: &[&str], span: &Span) -> Result<Option<Program>> {
|
||||
if !package_segments.is_empty() && package_segments.get(0).unwrap() == &"core" {
|
||||
Ok(resolve_core_module(&*package_segments[1..].join("."))?)
|
||||
if !package_segments.is_empty() && package_segments.get(0).unwrap() == &"std" {
|
||||
Ok(Some(resolve_stdlib_module(&*package_segments[1..].join("."))?))
|
||||
} else {
|
||||
self.inner.resolve_package(package_segments, span)
|
||||
}
|
||||
@ -60,31 +61,3 @@ impl ImportResolver for MockedImportResolver {
|
||||
Ok(self.packages.get(&package_segments.join(".")).cloned())
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this.
|
||||
pub fn load_ast(content: &str) -> Result<Program> {
|
||||
// Parses the Leo file and constructs a grammar ast.
|
||||
Ok(leo_parser::parse_ast("input.leo", content)?.into_repr())
|
||||
}
|
||||
|
||||
// TODO: We should merge this with core
|
||||
// TODO: Make asg deep copy so we can cache resolved core modules
|
||||
// TODO: Figure out how to do headers without bogus returns
|
||||
pub fn resolve_core_module(module: &str) -> Result<Option<Program>> {
|
||||
match module {
|
||||
"unstable.blake2s" => {
|
||||
let ast = load_ast(
|
||||
r#"
|
||||
circuit Blake2s {
|
||||
function hash(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] {
|
||||
return [0; 32];
|
||||
}
|
||||
}
|
||||
"#,
|
||||
)?;
|
||||
ast.set_core_mapping("blake2s");
|
||||
Ok(Some(ast))
|
||||
}
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
41
ast/src/expression/lengthof.rs
Normal file
41
ast/src/expression/lengthof.rs
Normal file
@ -0,0 +1,41 @@
|
||||
// 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::Type;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct LengthOfExpression {
|
||||
pub inner: Box<Expression>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Display for LengthOfExpression {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}.len()", self.inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for LengthOfExpression {
|
||||
fn span(&self) -> &Span {
|
||||
&self.span
|
||||
}
|
||||
|
||||
fn set_span(&mut self, span: Span) {
|
||||
self.span = span;
|
||||
}
|
||||
}
|
@ -54,6 +54,8 @@ mod call;
|
||||
pub use call::*;
|
||||
mod cast;
|
||||
pub use cast::*;
|
||||
mod lengthof;
|
||||
pub use lengthof::*;
|
||||
|
||||
/// Expression that evaluates to a value
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@ -64,6 +66,7 @@ pub enum Expression {
|
||||
Unary(UnaryExpression),
|
||||
Ternary(TernaryExpression),
|
||||
Cast(CastExpression),
|
||||
LengthOf(LengthOfExpression),
|
||||
|
||||
ArrayInline(ArrayInlineExpression),
|
||||
ArrayInit(ArrayInitExpression),
|
||||
@ -100,6 +103,7 @@ impl Node for Expression {
|
||||
CircuitStaticFunctionAccess(n) => n.span(),
|
||||
Call(n) => n.span(),
|
||||
Cast(n) => n.span(),
|
||||
LengthOf(n) => n.span(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +126,7 @@ impl Node for Expression {
|
||||
CircuitStaticFunctionAccess(n) => n.set_span(span),
|
||||
Call(n) => n.set_span(span),
|
||||
Cast(n) => n.set_span(span),
|
||||
LengthOf(n) => n.set_span(span),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,6 +151,7 @@ impl fmt::Display for Expression {
|
||||
CircuitStaticFunctionAccess(n) => n.fmt(f),
|
||||
Call(n) => n.fmt(f),
|
||||
Cast(n) => n.fmt(f),
|
||||
LengthOf(n) => n.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,18 +89,6 @@ impl Ast {
|
||||
Self { ast: program }
|
||||
}
|
||||
|
||||
/* /// Mutates the program ast by resolving the imports.
|
||||
pub fn importer<T: ImportResolver>(&mut self, importer: T) -> Result<()> {
|
||||
self.ast = ReconstructingDirector::new(Importer::new(importer)).reduce_program(self.as_repr())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Mutates the program ast by preforming canonicalization on it.
|
||||
pub fn canonicalize(&mut self) -> Result<()> {
|
||||
self.ast = ReconstructingDirector::new(Canonicalizer::default()).reduce_program(self.as_repr())?;
|
||||
Ok(())
|
||||
} */
|
||||
|
||||
/// Returns a reference to the inner program AST representation.
|
||||
pub fn as_repr(&self) -> &Program {
|
||||
&self.ast
|
||||
|
@ -88,9 +88,9 @@ impl Program {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_core_mapping(&self, mapping: &str) {
|
||||
pub fn set_core_mapping(&self, mapping: Option<&str>) {
|
||||
for (_, circuit) in self.circuits.iter() {
|
||||
circuit.core_mapping.replace(Some(mapping.to_string()));
|
||||
circuit.core_mapping.replace(mapping.map(str::to_string));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
Expression::Unary(unary) => Expression::Unary(self.reduce_unary(unary)?),
|
||||
Expression::Ternary(ternary) => Expression::Ternary(self.reduce_ternary(ternary)?),
|
||||
Expression::Cast(cast) => Expression::Cast(self.reduce_cast(cast)?),
|
||||
Expression::LengthOf(lengthof) => Expression::LengthOf(lengthof.clone()), // Expression::LengthOf(self.reduce_lengthof(lengthof)?), // TODO: add reducer
|
||||
|
||||
Expression::ArrayInline(array_inline) => Expression::ArrayInline(self.reduce_array_inline(array_inline)?),
|
||||
Expression::ArrayInit(array_init) => Expression::ArrayInit(self.reduce_array_init(array_init)?),
|
||||
|
@ -35,12 +35,13 @@ use snarkvm_r1cs::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};
|
||||
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs,
|
||||
marker::PhantomData,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
thread_local! {
|
||||
static THREAD_GLOBAL_CONTEXT: AsgContext<'static> = {
|
||||
let leaked = Box::leak(Box::new(leo_asg::new_alloc_context()));
|
||||
@ -64,7 +65,7 @@ pub struct Compiler<'a, F: PrimeField, G: GroupType<F>> {
|
||||
context: AsgContext<'a>,
|
||||
asg: Option<AsgProgram<'a>>,
|
||||
options: CompilerOptions,
|
||||
imports_map: HashMap<String, String>,
|
||||
imports_map: IndexMap<String, String>,
|
||||
ast_snapshot_options: AstSnapshotOptions,
|
||||
_engine: PhantomData<F>,
|
||||
_group: PhantomData<G>,
|
||||
@ -80,7 +81,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
output_directory: PathBuf,
|
||||
context: AsgContext<'a>,
|
||||
options: Option<CompilerOptions>,
|
||||
imports_map: HashMap<String, String>,
|
||||
imports_map: IndexMap<String, String>,
|
||||
ast_snapshot_options: Option<AstSnapshotOptions>,
|
||||
) -> Self {
|
||||
Self {
|
||||
@ -112,7 +113,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
output_directory: PathBuf,
|
||||
context: AsgContext<'a>,
|
||||
options: Option<CompilerOptions>,
|
||||
imports_map: HashMap<String, String>,
|
||||
imports_map: IndexMap<String, String>,
|
||||
ast_snapshot_options: Option<AstSnapshotOptions>,
|
||||
) -> Result<Self> {
|
||||
let mut compiler = Self::new(
|
||||
@ -153,7 +154,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
state_path: &Path,
|
||||
context: AsgContext<'a>,
|
||||
options: Option<CompilerOptions>,
|
||||
imports_map: HashMap<String, String>,
|
||||
imports_map: IndexMap<String, String>,
|
||||
ast_snapshot_options: Option<AstSnapshotOptions>,
|
||||
) -> Result<Self> {
|
||||
let mut compiler = Self::new(
|
||||
|
@ -98,6 +98,9 @@ impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
|
||||
// Cast
|
||||
Expression::Cast(_) => unimplemented!("casts not implemented"),
|
||||
|
||||
// LengthOf
|
||||
Expression::LengthOf(lengthof) => self.enforce_lengthof(cs, lengthof, span),
|
||||
|
||||
// Variables
|
||||
Expression::VariableRef(variable_ref) => self.evaluate_ref(variable_ref),
|
||||
|
||||
|
@ -43,6 +43,9 @@ pub use self::variable_ref::*;
|
||||
pub mod logical;
|
||||
pub use self::logical::*;
|
||||
|
||||
pub mod operator;
|
||||
pub use self::operator::*;
|
||||
|
||||
pub mod relational;
|
||||
pub use self::relational::*;
|
||||
|
||||
|
47
compiler/src/expression/operator/lengthof.rs
Normal file
47
compiler/src/expression/operator/lengthof.rs
Normal file
@ -0,0 +1,47 @@
|
||||
// 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/>.
|
||||
|
||||
//! Enforces a lengthof operator in a compiled Leo program.
|
||||
|
||||
use crate::{
|
||||
program::ConstrainedProgram,
|
||||
value::{ConstrainedValue, Integer},
|
||||
GroupType,
|
||||
};
|
||||
use leo_asg::{ConstInt, LengthOfExpression};
|
||||
use leo_errors::{Result, Span};
|
||||
|
||||
use snarkvm_fields::PrimeField;
|
||||
use snarkvm_r1cs::ConstraintSystem;
|
||||
|
||||
impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
|
||||
/// Enforce array expressions
|
||||
pub fn enforce_lengthof<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
lengthof: &'a LengthOfExpression<'a>,
|
||||
span: &Span,
|
||||
) -> Result<ConstrainedValue<'a, F, G>> {
|
||||
let value = self.enforce_expression(cs, lengthof.inner.get())?;
|
||||
|
||||
Ok(match value {
|
||||
ConstrainedValue::Array(array) => {
|
||||
ConstrainedValue::Integer(Integer::new(&ConstInt::U32(array.len() as u32)))
|
||||
}
|
||||
_ => return Err(leo_errors::CompilerError::lengthof_can_only_be_used_on_arrays(span).into()),
|
||||
})
|
||||
}
|
||||
}
|
18
compiler/src/expression/operator/mod.rs
Normal file
18
compiler/src/expression/operator/mod.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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 lengthof;
|
||||
pub use self::lengthof::*;
|
@ -35,21 +35,10 @@ impl Default for CompilerOptions {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct AstSnapshotOptions {
|
||||
pub initial: bool,
|
||||
pub imports_resolved: bool,
|
||||
pub canonicalized: bool,
|
||||
pub type_inferenced: bool,
|
||||
}
|
||||
|
||||
impl Default for AstSnapshotOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
initial: false,
|
||||
imports_resolved: false,
|
||||
canonicalized: false,
|
||||
type_inferenced: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
@ -32,6 +31,7 @@ use serde_yaml::Value;
|
||||
use snarkvm_curves::{bls12_377::Bls12_377, edwards_bls12::Fq};
|
||||
|
||||
use crate::{compiler::Compiler, targets::edwards_bls12::EdwardsGroupType, AstSnapshotOptions, Output};
|
||||
use indexmap::IndexMap;
|
||||
|
||||
pub type EdwardsTestCompiler = Compiler<'static, Fq, EdwardsGroupType>;
|
||||
// pub type EdwardsConstrainedValue = ConstrainedValue<'static, Fq, EdwardsGroupType>;
|
||||
@ -53,7 +53,7 @@ fn new_compiler(path: PathBuf, theorem_options: Option<AstSnapshotOptions>) -> E
|
||||
output_dir,
|
||||
make_test_context(),
|
||||
None,
|
||||
HashMap::new(),
|
||||
IndexMap::new(),
|
||||
theorem_options,
|
||||
)
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ In order to do something with the array, e.g. add all its elements and return th
|
||||
|
||||
Thus, this RFC also proposed to extend Leo with such an operator.
|
||||
A possibility is `<expression>.length`, where `<expression>` is an expression of array type.
|
||||
A variation is `<expression>.length()`, if we want it look more like a built-in method on arrays.
|
||||
A variation is `<expression>.len()`, if we want it look more like a built-in method on arrays.
|
||||
Yet another option is `length(<expression>)`, which is more like a built-in function.
|
||||
A shorter name could be `len`, leading to the three possibilities
|
||||
`<expression>.len`, `<expression>.len()`, and `len(<expression>)`.
|
||||
@ -148,4 +148,4 @@ None.
|
||||
|
||||
# Alternatives
|
||||
|
||||
None.
|
||||
None.
|
||||
|
@ -31,7 +31,7 @@ Leaving import declarations aside for the moment since they are "meta" in some s
|
||||
(as they bring in names of entities declared elsewhere),
|
||||
it may make sense for any of the four kinds of declarations above to have built-in instances, i.e., we could have some built-in functions, circuit types, global constants, and type aliases. These features are why this RFC talks of built-in declarations, more broadly than just built-in type aliases that inspired it.
|
||||
|
||||
The built-in status of the envisioned declarations will be done through explicitly declared core library files. Then these core library files must be explicitly imported. This way helps avoid unnecessary code bloat in the compilation, and any user asked for AST snapshots.
|
||||
The built-in status of the envisioned declarations will be done through explicitly declared standard library(stdlib) files. Then these stdlib files must expressly be imported, except the files found in stdlib/prelude/*. The ones found in the prelude are features determined to be helpful enough in standard programs and are auto-imported.
|
||||
|
||||
## Drawbacks
|
||||
|
||||
@ -46,15 +46,7 @@ But it should not be much different from standard libraries/packages.
|
||||
|
||||
Some alternative approaches are:
|
||||
|
||||
1. Their names could be simply available in any program,
|
||||
without any explicit declaration found anywhere for them.
|
||||
2. They could be declared in some core library files explicitly
|
||||
and be available in any program without explicitly importing them,
|
||||
like `java.lang.String` in Java or `std::Option` in Rust.
|
||||
1. Having all stdlib imports auto included.
|
||||
2. Require that all stdlib imports are explicitly imported.
|
||||
|
||||
From a user's perspective, there is not a lot of difference between cases 1 and 2 above:
|
||||
in both cases, the names are available; the only difference is that in case 2, the user can see the declaration somewhere.
|
||||
|
||||
Also, note that case 2 could be seen as having an implicit (i.e., built-in) import of the library/libraries in question. Again, imports are "meta" in this context, and what counts are the other kinds of declarations.
|
||||
|
||||
In cases 2 and the decided upon design choice, a related but somewhat independent issue is whether those declarations have Leo definitions or not. The Leo library already includes functions like BLAKE2s that are not defined in Leo but rather "natively" in Rust/R1CS though some of this may be subject to change for native definitions(see the separate RFC on those).
|
||||
The differences between the two above approaches and the chosen one are just how many imports are imported explicitly.
|
||||
|
@ -19,7 +19,13 @@
|
||||
/// with a unique error code.
|
||||
#[macro_export]
|
||||
macro_rules! create_errors {
|
||||
(@step $_code:expr,) => {};
|
||||
(@step $code:expr,) => {
|
||||
#[inline(always)]
|
||||
// Returns the number of unique exit codes that this error type can take on.
|
||||
pub fn num_exit_codes() -> i32 {
|
||||
$code
|
||||
}
|
||||
};
|
||||
($(#[$error_type_docs:meta])* $error_type:ident, exit_code_mask: $exit_code_mask:expr, error_code_prefix: $error_code_prefix:expr, $($(#[$docs:meta])* @$formatted_or_backtraced_list:ident $names:ident { args: ($($arg_names:ident: $arg_types:ty$(,)?)*), msg: $messages:expr, help: $helps:expr, })*) => {
|
||||
#[allow(unused_imports)] // Allow unused for errors that only use formatted or backtraced errors.
|
||||
use crate::{BacktracedError, FormattedError, LeoErrorCode, Span};
|
||||
@ -66,6 +72,7 @@ macro_rules! create_errors {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Steps over the list of functions with an initial error code of 0.
|
||||
impl $error_type {
|
||||
create_errors!(@step 0i32, $(($(#[$docs])* $formatted_or_backtraced_list, $names($($arg_names: $arg_types,)*), $messages, $helps),)*);
|
||||
@ -115,5 +122,4 @@ macro_rules! create_errors {
|
||||
// Steps the error code value by one and calls on the rest of the functions.
|
||||
create_errors!(@step $code + 1i32, $(($(#[$docs])* $formatted_or_backtraced_tail, $names($($tail_arg_names: $tail_arg_types,)*), $messages, $helps),)*);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -834,4 +834,11 @@ create_errors!(
|
||||
msg: format!("no implementation found for `{}`", operation),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
lengthof_can_only_be_used_on_arrays {
|
||||
args: (),
|
||||
msg: "len() can only be called on an array value".to_string(),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -90,11 +90,27 @@ create_errors!(
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// / For when the crate failed due to an IO error.
|
||||
/// For when the crate failed due to an IO error.
|
||||
@formatted
|
||||
io_error {
|
||||
args: (path: impl Display, error: impl ErrorArg),
|
||||
msg: format!("cannot read imported file '{}': {:?}", path, error),
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// For when the stdlib import file could not be found.
|
||||
@backtraced
|
||||
no_such_stdlib_file {
|
||||
args: (import: impl Display),
|
||||
msg: format!("failed to find the stdlib import file `{}`", import),
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// For when the stdlib import file could not be read.
|
||||
@backtraced
|
||||
failed_to_read_stdlib_file {
|
||||
args: (import: impl Display),
|
||||
msg: format!("failed to read the stdlib import file `{}`", import),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -476,7 +476,7 @@ Line terminators form whitespace, along with spaces and horizontal tabs.
|
||||
whitespace = space / horizontal-tab / newline
|
||||
```
|
||||
|
||||
Go to: _[newline](#user-content-newline), [space](#user-content-space), [horizontal-tab](#user-content-horizontal-tab)_;
|
||||
Go to: _[newline](#user-content-newline), [horizontal-tab](#user-content-horizontal-tab), [space](#user-content-space)_;
|
||||
|
||||
|
||||
There are two kinds of comments in Leo, as in other languages.
|
||||
@ -494,7 +494,7 @@ the ones used in the Java language reference.
|
||||
comment = block-comment / end-of-line-comment
|
||||
```
|
||||
|
||||
Go to: _[block-comment](#user-content-block-comment), [end-of-line-comment](#user-content-end-of-line-comment)_;
|
||||
Go to: _[end-of-line-comment](#user-content-end-of-line-comment), [block-comment](#user-content-block-comment)_;
|
||||
|
||||
|
||||
<a name="block-comment"></a>
|
||||
@ -590,7 +590,7 @@ lowercase-letter = %x61-7A ; a-z
|
||||
letter = uppercase-letter / lowercase-letter
|
||||
```
|
||||
|
||||
Go to: _[lowercase-letter](#user-content-lowercase-letter), [uppercase-letter](#user-content-uppercase-letter)_;
|
||||
Go to: _[uppercase-letter](#user-content-uppercase-letter), [lowercase-letter](#user-content-lowercase-letter)_;
|
||||
|
||||
|
||||
The following rules defines (ASCII) decimal, octal, and hexadecimal digits.
|
||||
@ -774,7 +774,7 @@ character-literal-element = not-single-quote-or-backslash
|
||||
/ unicode-character-escape
|
||||
```
|
||||
|
||||
Go to: _[ascii-character-escape](#user-content-ascii-character-escape), [simple-character-escape](#user-content-simple-character-escape), [unicode-character-escape](#user-content-unicode-character-escape), [not-single-quote-or-backslash](#user-content-not-single-quote-or-backslash)_;
|
||||
Go to: _[simple-character-escape](#user-content-simple-character-escape), [unicode-character-escape](#user-content-unicode-character-escape), [not-single-quote-or-backslash](#user-content-not-single-quote-or-backslash), [ascii-character-escape](#user-content-ascii-character-escape)_;
|
||||
|
||||
|
||||
<a name="single-quote-escape"></a>
|
||||
@ -829,7 +829,7 @@ simple-character-escape = single-quote-escape
|
||||
/ null-character-escape
|
||||
```
|
||||
|
||||
Go to: _[line-feed-escape](#user-content-line-feed-escape), [carriage-return-escape](#user-content-carriage-return-escape), [double-quote-escape](#user-content-double-quote-escape), [backslash-escape](#user-content-backslash-escape), [null-character-escape](#user-content-null-character-escape), [single-quote-escape](#user-content-single-quote-escape), [horizontal-tab-escape](#user-content-horizontal-tab-escape)_;
|
||||
Go to: _[carriage-return-escape](#user-content-carriage-return-escape), [backslash-escape](#user-content-backslash-escape), [line-feed-escape](#user-content-line-feed-escape), [horizontal-tab-escape](#user-content-horizontal-tab-escape), [null-character-escape](#user-content-null-character-escape), [single-quote-escape](#user-content-single-quote-escape), [double-quote-escape](#user-content-double-quote-escape)_;
|
||||
|
||||
|
||||
<a name="ascii-character-escape"></a>
|
||||
@ -865,7 +865,7 @@ string-literal-element = not-double-quote-or-backslash
|
||||
/ unicode-character-escape
|
||||
```
|
||||
|
||||
Go to: _[simple-character-escape](#user-content-simple-character-escape), [unicode-character-escape](#user-content-unicode-character-escape), [not-double-quote-or-backslash](#user-content-not-double-quote-or-backslash), [ascii-character-escape](#user-content-ascii-character-escape)_;
|
||||
Go to: _[unicode-character-escape](#user-content-unicode-character-escape), [not-double-quote-or-backslash](#user-content-not-double-quote-or-backslash), [simple-character-escape](#user-content-simple-character-escape), [ascii-character-escape](#user-content-ascii-character-escape)_;
|
||||
|
||||
|
||||
The ones above are all the atomic literals
|
||||
@ -885,7 +885,7 @@ atomic-literal = untyped-literal
|
||||
/ string-literal
|
||||
```
|
||||
|
||||
Go to: _[character-literal](#user-content-character-literal), [unsigned-literal](#user-content-unsigned-literal), [signed-literal](#user-content-signed-literal), [address-literal](#user-content-address-literal), [field-literal](#user-content-field-literal), [untyped-literal](#user-content-untyped-literal), [product-group-literal](#user-content-product-group-literal), [string-literal](#user-content-string-literal), [boolean-literal](#user-content-boolean-literal)_;
|
||||
Go to: _[untyped-literal](#user-content-untyped-literal), [character-literal](#user-content-character-literal), [unsigned-literal](#user-content-unsigned-literal), [boolean-literal](#user-content-boolean-literal), [signed-literal](#user-content-signed-literal), [address-literal](#user-content-address-literal), [field-literal](#user-content-field-literal), [string-literal](#user-content-string-literal), [product-group-literal](#user-content-product-group-literal)_;
|
||||
|
||||
|
||||
After defining the (mostly) alphanumeric tokens above,
|
||||
@ -929,7 +929,7 @@ token = keyword
|
||||
/ symbol
|
||||
```
|
||||
|
||||
Go to: _[identifier](#user-content-identifier), [annotation-name](#user-content-annotation-name), [package-name](#user-content-package-name), [keyword](#user-content-keyword), [symbol](#user-content-symbol), [atomic-literal](#user-content-atomic-literal)_;
|
||||
Go to: _[symbol](#user-content-symbol), [keyword](#user-content-keyword), [identifier](#user-content-identifier), [atomic-literal](#user-content-atomic-literal), [package-name](#user-content-package-name), [annotation-name](#user-content-annotation-name)_;
|
||||
|
||||
|
||||
Tokens, comments, and whitespace are lexemes, i.e. lexical units.
|
||||
@ -939,7 +939,7 @@ Tokens, comments, and whitespace are lexemes, i.e. lexical units.
|
||||
lexeme = token / comment / whitespace
|
||||
```
|
||||
|
||||
Go to: _[token](#user-content-token), [whitespace](#user-content-whitespace), [comment](#user-content-comment)_;
|
||||
Go to: _[token](#user-content-token), [comment](#user-content-comment), [whitespace](#user-content-whitespace)_;
|
||||
|
||||
|
||||
|
||||
@ -996,7 +996,7 @@ group-type = %s"group"
|
||||
arithmetic-type = integer-type / field-type / group-type
|
||||
```
|
||||
|
||||
Go to: _[field-type](#user-content-field-type), [group-type](#user-content-group-type), [integer-type](#user-content-integer-type)_;
|
||||
Go to: _[integer-type](#user-content-integer-type), [field-type](#user-content-field-type), [group-type](#user-content-group-type)_;
|
||||
|
||||
|
||||
The arithmetic types, along with the boolean, address, and character types,
|
||||
@ -1022,7 +1022,7 @@ character-type = %s"char"
|
||||
scalar-type = boolean-type / arithmetic-type / address-type / character-type
|
||||
```
|
||||
|
||||
Go to: _[boolean-type](#user-content-boolean-type), [arithmetic-type](#user-content-arithmetic-type), [character-type](#user-content-character-type), [address-type](#user-content-address-type)_;
|
||||
Go to: _[character-type](#user-content-character-type), [arithmetic-type](#user-content-arithmetic-type), [boolean-type](#user-content-boolean-type), [address-type](#user-content-address-type)_;
|
||||
|
||||
|
||||
A tuple type consists of zero, two, or more component types.
|
||||
@ -1043,27 +1043,28 @@ Each dimension is either a natural or is unspecified.
|
||||
|
||||
<a name="array-type"></a>
|
||||
```abnf
|
||||
array-type = "[" type ";" array-dimensions "]"
|
||||
array-type = "[" type ";" array-type-dimensions "]"
|
||||
```
|
||||
|
||||
Go to: _[array-dimensions](#user-content-array-dimensions), [type](#user-content-type)_;
|
||||
Go to: _[type](#user-content-type), [array-type-dimensions](#user-content-array-type-dimensions)_;
|
||||
|
||||
|
||||
<a name="array-dimension"></a>
|
||||
<a name="array-type-dimension"></a>
|
||||
```abnf
|
||||
array-dimension = natural / "_"
|
||||
array-type-dimension = natural / "_"
|
||||
```
|
||||
|
||||
Go to: _[natural](#user-content-natural)_;
|
||||
|
||||
|
||||
<a name="array-dimensions"></a>
|
||||
<a name="array-type-dimensions"></a>
|
||||
```abnf
|
||||
array-dimensions = array-dimension
|
||||
/ "(" array-dimension *( "," array-dimension ) ")"
|
||||
array-type-dimensions = array-type-dimension
|
||||
/ "(" array-type-dimension
|
||||
*( "," array-type-dimension ) ")"
|
||||
```
|
||||
|
||||
Go to: _[array-dimension](#user-content-array-dimension)_;
|
||||
Go to: _[array-type-dimension](#user-content-array-type-dimension)_;
|
||||
|
||||
|
||||
The keyword `Self` denotes the enclosing circuit type.
|
||||
@ -1089,7 +1090,7 @@ form all the types.
|
||||
type = scalar-type / tuple-type / array-type / identifier / self-type
|
||||
```
|
||||
|
||||
Go to: _[array-type](#user-content-array-type), [scalar-type](#user-content-scalar-type), [tuple-type](#user-content-tuple-type), [identifier](#user-content-identifier), [self-type](#user-content-self-type)_;
|
||||
Go to: _[scalar-type](#user-content-scalar-type), [array-type](#user-content-array-type), [tuple-type](#user-content-tuple-type), [self-type](#user-content-self-type), [identifier](#user-content-identifier)_;
|
||||
|
||||
|
||||
It is convenient to introduce a rule for types that are
|
||||
@ -1178,7 +1179,7 @@ primary-expression = identifier
|
||||
/ circuit-expression
|
||||
```
|
||||
|
||||
Go to: _[tuple-expression](#user-content-tuple-expression), [array-expression](#user-content-array-expression), [identifier](#user-content-identifier), [literal](#user-content-literal), [expression](#user-content-expression), [circuit-expression](#user-content-circuit-expression)_;
|
||||
Go to: _[identifier](#user-content-identifier), [array-expression](#user-content-array-expression), [literal](#user-content-literal), [expression](#user-content-expression), [tuple-expression](#user-content-tuple-expression), [circuit-expression](#user-content-circuit-expression)_;
|
||||
|
||||
|
||||
Tuple expressions construct tuples.
|
||||
@ -1228,10 +1229,19 @@ Go to: _[expression](#user-content-expression)_;
|
||||
|
||||
<a name="array-repeat-construction"></a>
|
||||
```abnf
|
||||
array-repeat-construction = "[" expression ";" array-dimensions "]"
|
||||
array-repeat-construction = "[" expression ";" array-expression-dimensions "]"
|
||||
```
|
||||
|
||||
Go to: _[expression](#user-content-expression), [array-dimensions](#user-content-array-dimensions)_;
|
||||
Go to: _[expression](#user-content-expression), [array-expression-dimensions](#user-content-array-expression-dimensions)_;
|
||||
|
||||
|
||||
<a name="array-expression-dimensions"></a>
|
||||
```abnf
|
||||
array-expression-dimensions = natural
|
||||
/ "(" natural *( "," natural ) ")"
|
||||
```
|
||||
|
||||
Go to: _[natural](#user-content-natural)_;
|
||||
|
||||
|
||||
<a name="array-construction"></a>
|
||||
@ -1239,7 +1249,7 @@ Go to: _[expression](#user-content-expression), [array-dimensions](#user-content
|
||||
array-construction = array-inline-construction / array-repeat-construction
|
||||
```
|
||||
|
||||
Go to: _[array-inline-construction](#user-content-array-inline-construction), [array-repeat-construction](#user-content-array-repeat-construction)_;
|
||||
Go to: _[array-repeat-construction](#user-content-array-repeat-construction), [array-inline-construction](#user-content-array-inline-construction)_;
|
||||
|
||||
|
||||
<a name="array-expression"></a>
|
||||
@ -1267,7 +1277,7 @@ circuit-construction = identifier-or-self-type "{"
|
||||
"}"
|
||||
```
|
||||
|
||||
Go to: _[identifier-or-self-type](#user-content-identifier-or-self-type), [circuit-inline-element](#user-content-circuit-inline-element)_;
|
||||
Go to: _[circuit-inline-element](#user-content-circuit-inline-element), [identifier-or-self-type](#user-content-identifier-or-self-type)_;
|
||||
|
||||
|
||||
<a name="circuit-inline-element"></a>
|
||||
@ -1275,7 +1285,7 @@ Go to: _[identifier-or-self-type](#user-content-identifier-or-self-type), [circu
|
||||
circuit-inline-element = identifier ":" expression / identifier
|
||||
```
|
||||
|
||||
Go to: _[identifier](#user-content-identifier), [expression](#user-content-expression)_;
|
||||
Go to: _[expression](#user-content-expression), [identifier](#user-content-identifier)_;
|
||||
|
||||
|
||||
<a name="circuit-expression"></a>
|
||||
@ -1326,7 +1336,7 @@ postfix-expression = primary-expression
|
||||
/ postfix-expression "[" [expression] ".." [expression] "]"
|
||||
```
|
||||
|
||||
Go to: _[function-arguments](#user-content-function-arguments), [primary-expression](#user-content-primary-expression), [expression](#user-content-expression), [postfix-expression](#user-content-postfix-expression), [identifier](#user-content-identifier), [natural](#user-content-natural), [identifier-or-self-type](#user-content-identifier-or-self-type)_;
|
||||
Go to: _[identifier](#user-content-identifier), [natural](#user-content-natural), [expression](#user-content-expression), [primary-expression](#user-content-primary-expression), [identifier-or-self-type](#user-content-identifier-or-self-type), [postfix-expression](#user-content-postfix-expression), [function-arguments](#user-content-function-arguments)_;
|
||||
|
||||
|
||||
Unary operators have the highest operator precedence.
|
||||
@ -1340,7 +1350,7 @@ unary-expression = postfix-expression
|
||||
/ "-" unary-expression
|
||||
```
|
||||
|
||||
Go to: _[unary-expression](#user-content-unary-expression), [postfix-expression](#user-content-postfix-expression)_;
|
||||
Go to: _[postfix-expression](#user-content-postfix-expression), [unary-expression](#user-content-unary-expression)_;
|
||||
|
||||
|
||||
Next in the operator precedence is exponentiation,
|
||||
@ -1354,7 +1364,7 @@ exponential-expression = unary-expression
|
||||
/ unary-expression "**" exponential-expression
|
||||
```
|
||||
|
||||
Go to: _[exponential-expression](#user-content-exponential-expression), [unary-expression](#user-content-unary-expression)_;
|
||||
Go to: _[unary-expression](#user-content-unary-expression), [exponential-expression](#user-content-exponential-expression)_;
|
||||
|
||||
|
||||
Next in precedence come multiplication and division, both left-associative.
|
||||
@ -1417,7 +1427,7 @@ conjunctive-expression = equality-expression
|
||||
/ conjunctive-expression "&&" equality-expression
|
||||
```
|
||||
|
||||
Go to: _[equality-expression](#user-content-equality-expression), [conjunctive-expression](#user-content-conjunctive-expression)_;
|
||||
Go to: _[conjunctive-expression](#user-content-conjunctive-expression), [equality-expression](#user-content-equality-expression)_;
|
||||
|
||||
|
||||
Next come disjunctive expressions, left-associative.
|
||||
@ -1441,7 +1451,7 @@ conditional-expression = disjunctive-expression
|
||||
":" conditional-expression
|
||||
```
|
||||
|
||||
Go to: _[expression](#user-content-expression), [disjunctive-expression](#user-content-disjunctive-expression), [conditional-expression](#user-content-conditional-expression)_;
|
||||
Go to: _[disjunctive-expression](#user-content-disjunctive-expression), [expression](#user-content-expression), [conditional-expression](#user-content-conditional-expression)_;
|
||||
|
||||
|
||||
Those above are all the expressions.
|
||||
@ -1474,7 +1484,7 @@ statement = expression-statement
|
||||
/ block
|
||||
```
|
||||
|
||||
Go to: _[loop-statement](#user-content-loop-statement), [expression-statement](#user-content-expression-statement), [console-statement](#user-content-console-statement), [block](#user-content-block), [return-statement](#user-content-return-statement), [variable-declaration](#user-content-variable-declaration), [constant-declaration](#user-content-constant-declaration), [assignment-statement](#user-content-assignment-statement), [conditional-statement](#user-content-conditional-statement)_;
|
||||
Go to: _[loop-statement](#user-content-loop-statement), [expression-statement](#user-content-expression-statement), [return-statement](#user-content-return-statement), [conditional-statement](#user-content-conditional-statement), [assignment-statement](#user-content-assignment-statement), [variable-declaration](#user-content-variable-declaration), [console-statement](#user-content-console-statement), [constant-declaration](#user-content-constant-declaration), [block](#user-content-block)_;
|
||||
|
||||
|
||||
<a name="block"></a>
|
||||
@ -1517,7 +1527,7 @@ variable-declaration = %s"let" identifier-or-identifiers [ ":" type ]
|
||||
"=" expression ";"
|
||||
```
|
||||
|
||||
Go to: _[identifier-or-identifiers](#user-content-identifier-or-identifiers), [type](#user-content-type), [expression](#user-content-expression)_;
|
||||
Go to: _[identifier-or-identifiers](#user-content-identifier-or-identifiers), [expression](#user-content-expression), [type](#user-content-type)_;
|
||||
|
||||
|
||||
<a name="constant-declaration"></a>
|
||||
@ -1526,7 +1536,7 @@ constant-declaration = %s"const" identifier-or-identifiers [ ":" type ]
|
||||
"=" expression ";"
|
||||
```
|
||||
|
||||
Go to: _[expression](#user-content-expression), [type](#user-content-type), [identifier-or-identifiers](#user-content-identifier-or-identifiers)_;
|
||||
Go to: _[identifier-or-identifiers](#user-content-identifier-or-identifiers), [type](#user-content-type), [expression](#user-content-expression)_;
|
||||
|
||||
|
||||
<a name="identifier-or-identifiers"></a>
|
||||
@ -1559,7 +1569,7 @@ conditional-statement = branch
|
||||
/ branch %s"else" conditional-statement
|
||||
```
|
||||
|
||||
Go to: _[block](#user-content-block), [conditional-statement](#user-content-conditional-statement), [branch](#user-content-branch)_;
|
||||
Go to: _[branch](#user-content-branch), [block](#user-content-block), [conditional-statement](#user-content-conditional-statement)_;
|
||||
|
||||
|
||||
A loop statement implicitly defines a loop variable
|
||||
@ -1572,7 +1582,7 @@ loop-statement = %s"for" identifier %s"in" expression ".." [ "=" ] expression
|
||||
block
|
||||
```
|
||||
|
||||
Go to: _[expression](#user-content-expression), [identifier](#user-content-identifier), [block](#user-content-block)_;
|
||||
Go to: _[block](#user-content-block), [expression](#user-content-expression), [identifier](#user-content-identifier)_;
|
||||
|
||||
|
||||
An assignment statement is straightforward.
|
||||
@ -1589,7 +1599,7 @@ assignment-operator = "=" / "+=" / "-=" / "*=" / "/=" / "**="
|
||||
assignment-statement = expression assignment-operator expression ";"
|
||||
```
|
||||
|
||||
Go to: _[expression](#user-content-expression), [assignment-operator](#user-content-assignment-operator)_;
|
||||
Go to: _[assignment-operator](#user-content-assignment-operator), [expression](#user-content-expression)_;
|
||||
|
||||
|
||||
Console statements start with the `console` keyword,
|
||||
@ -1616,7 +1626,7 @@ console-call = assert-call
|
||||
/ print-call
|
||||
```
|
||||
|
||||
Go to: _[print-call](#user-content-print-call), [assert-call](#user-content-assert-call)_;
|
||||
Go to: _[assert-call](#user-content-assert-call), [print-call](#user-content-print-call)_;
|
||||
|
||||
|
||||
<a name="assert-call"></a>
|
||||
@ -1645,7 +1655,7 @@ Go to: _[string-literal](#user-content-string-literal)_;
|
||||
print-call = print-function print-arguments
|
||||
```
|
||||
|
||||
Go to: _[print-arguments](#user-content-print-arguments), [print-function](#user-content-print-function)_;
|
||||
Go to: _[print-function](#user-content-print-function), [print-arguments](#user-content-print-arguments)_;
|
||||
|
||||
|
||||
An annotation consists of an annotation name (which starts with `@`)
|
||||
@ -1658,7 +1668,7 @@ annotation = annotation-name
|
||||
[ "(" identifier *( "," identifier ) ")" ]
|
||||
```
|
||||
|
||||
Go to: _[annotation-name](#user-content-annotation-name), [identifier](#user-content-identifier)_;
|
||||
Go to: _[identifier](#user-content-identifier), [annotation-name](#user-content-annotation-name)_;
|
||||
|
||||
|
||||
A function declaration defines a function.
|
||||
@ -1675,7 +1685,7 @@ function-declaration = *annotation %s"function" identifier
|
||||
block
|
||||
```
|
||||
|
||||
Go to: _[identifier](#user-content-identifier), [type](#user-content-type), [block](#user-content-block), [function-parameters](#user-content-function-parameters)_;
|
||||
Go to: _[type](#user-content-type), [identifier](#user-content-identifier), [function-parameters](#user-content-function-parameters), [block](#user-content-block)_;
|
||||
|
||||
|
||||
<a name="function-parameters"></a>
|
||||
@ -1754,7 +1764,7 @@ circuit-declaration = %s"circuit" identifier
|
||||
*member-function-declaration "}"
|
||||
```
|
||||
|
||||
Go to: _[identifier](#user-content-identifier), [member-variable-declarations](#user-content-member-variable-declarations)_;
|
||||
Go to: _[member-variable-declarations](#user-content-member-variable-declarations), [identifier](#user-content-identifier)_;
|
||||
|
||||
|
||||
An import declaration consists of the `import` keyword
|
||||
@ -1776,7 +1786,7 @@ by using an explicit package name before the package path.
|
||||
import-declaration = %s"import" package-name "." package-path ";"
|
||||
```
|
||||
|
||||
Go to: _[package-name](#user-content-package-name), [package-path](#user-content-package-path)_;
|
||||
Go to: _[package-path](#user-content-package-path), [package-name](#user-content-package-name)_;
|
||||
|
||||
|
||||
<a name="package-path"></a>
|
||||
@ -1787,7 +1797,7 @@ package-path = "*"
|
||||
/ "(" package-path *( "," package-path ) [","] ")"
|
||||
```
|
||||
|
||||
Go to: _[package-path](#user-content-package-path), [identifier](#user-content-identifier), [package-name](#user-content-package-name)_;
|
||||
Go to: _[package-name](#user-content-package-name), [package-path](#user-content-package-path), [identifier](#user-content-identifier)_;
|
||||
|
||||
|
||||
A type alias declaration defines an identifier to stand for a type.
|
||||
@ -1813,7 +1823,7 @@ declaration = import-declaration
|
||||
/ type-alias-declaration
|
||||
```
|
||||
|
||||
Go to: _[circuit-declaration](#user-content-circuit-declaration), [import-declaration](#user-content-import-declaration), [function-declaration](#user-content-function-declaration), [constant-declaration](#user-content-constant-declaration), [type-alias-declaration](#user-content-type-alias-declaration)_;
|
||||
Go to: _[circuit-declaration](#user-content-circuit-declaration), [type-alias-declaration](#user-content-type-alias-declaration), [function-declaration](#user-content-function-declaration), [constant-declaration](#user-content-constant-declaration), [import-declaration](#user-content-import-declaration)_;
|
||||
|
||||
|
||||
<a name="file"></a>
|
||||
|
@ -669,12 +669,13 @@ tuple-type = "(" [ type 1*( "," type ) ] ")"
|
||||
; or a tuple of one or more dimensions.
|
||||
; Each dimension is either a natural or is unspecified.
|
||||
|
||||
array-type = "[" type ";" array-dimensions "]"
|
||||
array-type = "[" type ";" array-type-dimensions "]"
|
||||
|
||||
array-dimension = natural / "_"
|
||||
array-type-dimension = natural / "_"
|
||||
|
||||
array-dimensions = array-dimension
|
||||
/ "(" array-dimension *( "," array-dimension ) ")"
|
||||
array-type-dimensions = array-type-dimension
|
||||
/ "(" array-type-dimension
|
||||
*( "," array-type-dimension ) ")"
|
||||
|
||||
; The keyword `Self` denotes the enclosing circuit type.
|
||||
; It is only allowed inside a circuit type declaration.
|
||||
@ -767,7 +768,10 @@ array-inline-construction = "["
|
||||
|
||||
array-inline-element = expression / "..." expression
|
||||
|
||||
array-repeat-construction = "[" expression ";" array-dimensions "]"
|
||||
array-repeat-construction = "[" expression ";" array-expression-dimensions "]"
|
||||
|
||||
array-expression-dimensions = natural
|
||||
/ "(" natural *( "," natural ) ")"
|
||||
|
||||
array-construction = array-inline-construction / array-repeat-construction
|
||||
|
||||
|
@ -29,10 +29,6 @@ version = "1.5.3"
|
||||
path = "../errors"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-asg]
|
||||
path = "../asg"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-parser]
|
||||
path = "../parser"
|
||||
version = "1.5.3"
|
||||
|
@ -19,7 +19,7 @@ use leo_ast_passes::ImportResolver;
|
||||
use leo_errors::{ImportError, LeoError, Result, Span};
|
||||
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Stores imported packages.
|
||||
///
|
||||
@ -30,11 +30,11 @@ pub struct ImportParser {
|
||||
program_path: PathBuf,
|
||||
partial_imports: IndexSet<String>,
|
||||
imports: IndexMap<String, Program>,
|
||||
pub imports_map: HashMap<String, String>,
|
||||
pub imports_map: IndexMap<String, String>,
|
||||
}
|
||||
|
||||
impl ImportParser {
|
||||
pub fn new(program_path: PathBuf, imports_map: HashMap<String, String>) -> Self {
|
||||
pub fn new(program_path: PathBuf, imports_map: IndexMap<String, String>) -> Self {
|
||||
ImportParser {
|
||||
program_path,
|
||||
partial_imports: Default::default(),
|
||||
@ -50,17 +50,21 @@ impl ImportResolver for ImportParser {
|
||||
if self.partial_imports.contains(&full_path) {
|
||||
return Err(ImportError::recursive_imports(full_path, span).into());
|
||||
}
|
||||
|
||||
if let Some(program) = self.imports.get(&full_path) {
|
||||
return Ok(Some(program.clone()));
|
||||
}
|
||||
|
||||
let path = self.program_path.clone();
|
||||
self.partial_imports.insert(full_path.clone());
|
||||
let mut imports = self.clone(); // Self::default() was previously
|
||||
let program = imports
|
||||
.parse_package(path, package_segments, span)
|
||||
.map_err(|x| -> LeoError { x })?;
|
||||
|
||||
self.partial_imports.remove(&full_path);
|
||||
self.imports.insert(full_path, program.clone());
|
||||
|
||||
Ok(Some(program))
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ impl ImportParser {
|
||||
let package_name = segments[0];
|
||||
|
||||
// Fetch a core package
|
||||
let core_package = package_name.eq("core");
|
||||
let core_package = package_name.eq("std");
|
||||
if core_package {
|
||||
panic!("attempted to import core package from filesystem");
|
||||
panic!("attempted to import std package from filesystem");
|
||||
}
|
||||
|
||||
// Trim path if importing from another file
|
||||
|
@ -35,7 +35,7 @@ use tracing::span::Span;
|
||||
|
||||
/// Compiler Options wrapper for Build command. Also used by other commands which
|
||||
/// require Build command output as their input.
|
||||
#[derive(StructOpt, Clone, Debug)]
|
||||
#[derive(StructOpt, Clone, Debug, Default)]
|
||||
pub struct BuildOptions {
|
||||
#[structopt(long, help = "Disable constant folding compiler optimization")]
|
||||
pub disable_constant_folding: bool,
|
||||
@ -55,21 +55,6 @@ pub struct BuildOptions {
|
||||
pub enable_type_inferenced_ast_snapshot: bool,
|
||||
}
|
||||
|
||||
impl Default for BuildOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
disable_constant_folding: false,
|
||||
disable_code_elimination: false,
|
||||
disable_all_optimizations: false,
|
||||
enable_all_ast_snapshots: false,
|
||||
enable_initial_ast_snapshot: false,
|
||||
enable_imports_resolved_ast_snapshot: false,
|
||||
enable_canonicalized_ast_snapshot: false,
|
||||
enable_type_inferenced_ast_snapshot: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BuildOptions> for CompilerOptions {
|
||||
fn from(options: BuildOptions) -> Self {
|
||||
if options.disable_all_optimizations {
|
||||
|
@ -27,6 +27,7 @@ use leo_package::{
|
||||
source::{MainFile, MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
|
||||
};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use snarkvm_curves::edwards_bls12::Fq;
|
||||
use std::{convert::TryFrom, path::PathBuf, time::Instant};
|
||||
use structopt::StructOpt;
|
||||
@ -109,7 +110,7 @@ impl Command for Test {
|
||||
output_directory.clone(),
|
||||
thread_leaked_context(),
|
||||
Some(self.compiler_options.clone().into()),
|
||||
std::collections::HashMap::new(),
|
||||
IndexMap::new(),
|
||||
Some(self.compiler_options.clone().into()),
|
||||
)?;
|
||||
|
||||
|
@ -66,19 +66,11 @@ impl Default for Update {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
||||
pub struct Config {
|
||||
pub update: Update,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
update: Update::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// Read the config from the `config.toml` file
|
||||
pub fn read_config() -> Result<Self> {
|
||||
|
@ -21,7 +21,6 @@ use indexmap::IndexMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
convert::TryFrom,
|
||||
fmt::{self, Display},
|
||||
fs::File,
|
||||
@ -74,11 +73,11 @@ impl LockFile {
|
||||
Ok(toml::to_string(self).map_err(PackageError::failed_to_serialize_lock_file)?)
|
||||
}
|
||||
|
||||
/// Form a HashMap of kind:
|
||||
/// Form a IndexMap of kind:
|
||||
/// ``` imported_name => package_name ```
|
||||
/// for all imported packages.
|
||||
pub fn to_import_map(&self) -> HashMap<String, String> {
|
||||
let mut result = HashMap::new();
|
||||
pub fn to_import_map(&self) -> IndexMap<String, String> {
|
||||
let mut result = IndexMap::new();
|
||||
for package in self.package.iter() {
|
||||
match &package.import_name {
|
||||
Some(name) => result.insert(name.clone(), package.to_string()),
|
||||
|
@ -402,8 +402,20 @@ impl ParserContext {
|
||||
///
|
||||
pub fn parse_postfix_expression(&mut self) -> Result<Expression> {
|
||||
let mut expr = self.parse_primary_expression()?;
|
||||
while let Some(token) = self.eat_any(&[Token::LeftSquare, Token::Dot, Token::LeftParen, Token::DoubleColon]) {
|
||||
while let Some(token) = self.eat_any(&[
|
||||
Token::LeftSquare,
|
||||
Token::Dot,
|
||||
Token::LeftParen,
|
||||
Token::DoubleColon,
|
||||
Token::LengthOf,
|
||||
]) {
|
||||
match token.token {
|
||||
Token::LengthOf => {
|
||||
expr = Expression::LengthOf(LengthOfExpression {
|
||||
span: expr.span().clone(),
|
||||
inner: Box::new(expr),
|
||||
})
|
||||
}
|
||||
Token::LeftSquare => {
|
||||
if self.eat(Token::DotDot).is_some() {
|
||||
let right = if self.peek_token().as_ref() != &Token::RightSquare {
|
||||
@ -727,6 +739,10 @@ impl ParserContext {
|
||||
};
|
||||
Expression::Identifier(ident)
|
||||
}
|
||||
// Token::LengthOf => Expression::LengthOf(LengthOfExpression {
|
||||
// span,
|
||||
// inner: Box::new(self.parse_primary_expression()?),
|
||||
// }),
|
||||
token => {
|
||||
return Err(ParserError::unexpected_str(token, "expression", &span).into());
|
||||
}
|
||||
|
@ -388,6 +388,9 @@ impl Token {
|
||||
return (len, Some(Token::DotDotDot));
|
||||
} else if let Some(len) = eat(input, "..") {
|
||||
return (len, Some(Token::DotDot));
|
||||
} else if let Some(len) = eat(input, ".len()") {
|
||||
// FIXME: remove this code once we allow method calls
|
||||
return (len, Some(Token::LengthOf));
|
||||
}
|
||||
return (1, Some(Token::Dot));
|
||||
}
|
||||
@ -516,7 +519,6 @@ impl Token {
|
||||
"Self" => Token::BigSelf,
|
||||
"self" => Token::LittleSelf,
|
||||
"static" => Token::Static,
|
||||
"string" => Token::String,
|
||||
"true" => Token::True,
|
||||
"type" => Token::Type,
|
||||
"u8" => Token::U8,
|
||||
|
@ -137,8 +137,12 @@ pub enum Token {
|
||||
Mut,
|
||||
Return,
|
||||
Static,
|
||||
String,
|
||||
Type,
|
||||
|
||||
// Not yet in ABNF
|
||||
// arr.len() token - hacky zone
|
||||
LengthOf,
|
||||
|
||||
// Not yet in ABNF
|
||||
// BitAnd,
|
||||
// BitAndEq,
|
||||
@ -192,9 +196,9 @@ pub const KEYWORD_TOKENS: &[Token] = &[
|
||||
Token::BigSelf,
|
||||
Token::LittleSelf,
|
||||
Token::Static,
|
||||
Token::String,
|
||||
Token::True,
|
||||
Token::Type,
|
||||
Token::LengthOf,
|
||||
Token::U8,
|
||||
Token::U16,
|
||||
Token::U32,
|
||||
@ -305,8 +309,8 @@ impl fmt::Display for Token {
|
||||
Mut => write!(f, "mut"),
|
||||
Return => write!(f, "return"),
|
||||
Static => write!(f, "static"),
|
||||
String => write!(f, "string"),
|
||||
Type => write!(f, "type"),
|
||||
LengthOf => write!(f, ".len()"), // FIXME
|
||||
Eof => write!(f, ""),
|
||||
// BitAnd => write!(f, "&"),
|
||||
// BitAndEq => write!(f, "&="),
|
||||
|
37
stdlib/Cargo.toml
Normal file
37
stdlib/Cargo.toml
Normal file
@ -0,0 +1,37 @@
|
||||
[package]
|
||||
name = "leo-stdlib"
|
||||
version = "1.5.3"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "The Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
repository = "https://github.com/AleoHQ/leo"
|
||||
keywords = [
|
||||
"aleo",
|
||||
"cryptography",
|
||||
"leo",
|
||||
"programming-language",
|
||||
"zero-knowledge"
|
||||
]
|
||||
categories = [ "cryptography::cryptocurrencies", "web-programming" ]
|
||||
include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
|
||||
license = "GPL-3.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
indexmap = "1.7.0"
|
||||
include_dir = "0.6.1"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-errors]
|
||||
path = "../errors"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.leo-parser]
|
||||
path = "../parser"
|
||||
version = "1.5.3"
|
596
stdlib/LICENSE.md
Normal file
596
stdlib/LICENSE.md
Normal file
@ -0,0 +1,596 @@
|
||||
GNU General Public License
|
||||
==========================
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <<https://fsf.org/>>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
## Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other
|
||||
kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away
|
||||
your freedom to share and change the works. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change all versions of a
|
||||
program--to make sure it remains free software for all its users. We, the Free
|
||||
Software Foundation, use the GNU General Public License for most of our software; it
|
||||
applies also to any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General
|
||||
Public Licenses are designed to make sure that you have the freedom to distribute
|
||||
copies of free software (and charge for them if you wish), that you receive source
|
||||
code or can get it if you want it, that you can change the software or use pieces of
|
||||
it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or
|
||||
asking you to surrender the rights. Therefore, you have certain responsibilities if
|
||||
you distribute copies of the software, or if you modify it: responsibilities to
|
||||
respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee,
|
||||
you must pass on to the recipients the same freedoms that you received. You must make
|
||||
sure that they, too, receive or can get the source code. And you must show them these
|
||||
terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: **(1)** assert
|
||||
copyright on the software, and **(2)** offer you this License giving you legal permission
|
||||
to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is
|
||||
no warranty for this free software. For both users' and authors' sake, the GPL
|
||||
requires that modified versions be marked as changed, so that their problems will not
|
||||
be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of
|
||||
the software inside them, although the manufacturer can do so. This is fundamentally
|
||||
incompatible with the aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we have designed
|
||||
this version of the GPL to prohibit the practice for those products. If such problems
|
||||
arise substantially in other domains, we stand ready to extend this provision to
|
||||
those domains in future versions of the GPL, as needed to protect the freedom of
|
||||
users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should
|
||||
not allow patents to restrict development and use of software on general-purpose
|
||||
computers, but in those that do, we wish to avoid the special danger that patents
|
||||
applied to a free program could make it effectively proprietary. To prevent this, the
|
||||
GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
### 0. Definitions
|
||||
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as “you”. “Licensees” and
|
||||
“recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in
|
||||
a fashion requiring copyright permission, other than the making of an exact copy. The
|
||||
resulting work is called a “modified version” of the earlier work or a
|
||||
work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on
|
||||
the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for infringement under
|
||||
applicable copyright law, except executing it on a computer or modifying a private
|
||||
copy. Propagation includes copying, distribution (with or without modification),
|
||||
making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through a computer
|
||||
network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the
|
||||
extent that it includes a convenient and prominently visible feature that **(1)**
|
||||
displays an appropriate copyright notice, and **(2)** tells the user that there is no
|
||||
warranty for the work (except to the extent that warranties are provided), that
|
||||
licensees may convey the work under this License, and how to view a copy of this
|
||||
License. If the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
### 1. Source Code
|
||||
|
||||
The “source code” for a work means the preferred form of the work for
|
||||
making modifications to it. “Object code” means any non-source form of a
|
||||
work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of interfaces
|
||||
specified for a particular programming language, one that is widely used among
|
||||
developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than
|
||||
the work as a whole, that **(a)** is included in the normal form of packaging a Major
|
||||
Component, but which is not part of that Major Component, and **(b)** serves only to
|
||||
enable use of the work with that Major Component, or to implement a Standard
|
||||
Interface for which an implementation is available to the public in source code form.
|
||||
A “Major Component”, in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system (if any) on which
|
||||
the executable work runs, or a compiler used to produce the work, or an object code
|
||||
interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the
|
||||
source code needed to generate, install, and (for an executable work) run the object
|
||||
code and to modify the work, including scripts to control those activities. However,
|
||||
it does not include the work's System Libraries, or general-purpose tools or
|
||||
generally available free programs which are used unmodified in performing those
|
||||
activities but which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for the work, and
|
||||
the source code for shared libraries and dynamically linked subprograms that the work
|
||||
is specifically designed to require, such as by intimate data communication or
|
||||
control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate
|
||||
automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
### 2. Basic Permissions
|
||||
|
||||
All rights granted under this License are granted for the term of copyright on the
|
||||
Program, and are irrevocable provided the stated conditions are met. This License
|
||||
explicitly affirms your unlimited permission to run the unmodified Program. The
|
||||
output from running a covered work is covered by this License only if the output,
|
||||
given its content, constitutes a covered work. This License acknowledges your rights
|
||||
of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without
|
||||
conditions so long as your license otherwise remains in force. You may convey covered
|
||||
works to others for the sole purpose of having them make modifications exclusively
|
||||
for you, or provide you with facilities for running those works, provided that you
|
||||
comply with the terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for you must do so
|
||||
exclusively on your behalf, under your direction and control, on terms that prohibit
|
||||
them from making any copies of your copyrighted material outside their relationship
|
||||
with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions
|
||||
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
|
||||
|
||||
No covered work shall be deemed part of an effective technological measure under any
|
||||
applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
|
||||
adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
|
||||
of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of
|
||||
technological measures to the extent such circumvention is effected by exercising
|
||||
rights under this License with respect to the covered work, and you disclaim any
|
||||
intention to limit operation or modification of the work as a means of enforcing,
|
||||
against the work's users, your or third parties' legal rights to forbid circumvention
|
||||
of technological measures.
|
||||
|
||||
### 4. Conveying Verbatim Copies
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any
|
||||
medium, provided that you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice; keep intact all notices stating that this License and
|
||||
any non-permissive terms added in accord with section 7 apply to the code; keep
|
||||
intact all notices of the absence of any warranty; and give all recipients a copy of
|
||||
this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer
|
||||
support or warranty protection for a fee.
|
||||
|
||||
### 5. Conveying Modified Source Versions
|
||||
|
||||
You may convey a work based on the Program, or the modifications to produce it from
|
||||
the Program, in the form of source code under the terms of section 4, provided that
|
||||
you also meet all of these conditions:
|
||||
|
||||
* **a)** The work must carry prominent notices stating that you modified it, and giving a
|
||||
relevant date.
|
||||
* **b)** The work must carry prominent notices stating that it is released under this
|
||||
License and any conditions added under section 7. This requirement modifies the
|
||||
requirement in section 4 to “keep intact all notices”.
|
||||
* **c)** You must license the entire work, as a whole, under this License to anyone who
|
||||
comes into possession of a copy. This License will therefore apply, along with any
|
||||
applicable section 7 additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no permission to license the
|
||||
work in any other way, but it does not invalidate such permission if you have
|
||||
separately received it.
|
||||
* **d)** If the work has interactive user interfaces, each must display Appropriate Legal
|
||||
Notices; however, if the Program has interactive interfaces that do not display
|
||||
Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are
|
||||
not by their nature extensions of the covered work, and which are not combined with
|
||||
it such as to form a larger program, in or on a volume of a storage or distribution
|
||||
medium, is called an “aggregate” if the compilation and its resulting
|
||||
copyright are not used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work in an aggregate
|
||||
does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
### 6. Conveying Non-Source Forms
|
||||
|
||||
You may convey a covered work in object code form under the terms of sections 4 and
|
||||
5, provided that you also convey the machine-readable Corresponding Source under the
|
||||
terms of this License, in one of these ways:
|
||||
|
||||
* **a)** Convey the object code in, or embodied in, a physical product (including a
|
||||
physical distribution medium), accompanied by the Corresponding Source fixed on a
|
||||
durable physical medium customarily used for software interchange.
|
||||
* **b)** Convey the object code in, or embodied in, a physical product (including a
|
||||
physical distribution medium), accompanied by a written offer, valid for at least
|
||||
three years and valid for as long as you offer spare parts or customer support for
|
||||
that product model, to give anyone who possesses the object code either **(1)** a copy of
|
||||
the Corresponding Source for all the software in the product that is covered by this
|
||||
License, on a durable physical medium customarily used for software interchange, for
|
||||
a price no more than your reasonable cost of physically performing this conveying of
|
||||
source, or **(2)** access to copy the Corresponding Source from a network server at no
|
||||
charge.
|
||||
* **c)** Convey individual copies of the object code with a copy of the written offer to
|
||||
provide the Corresponding Source. This alternative is allowed only occasionally and
|
||||
noncommercially, and only if you received the object code with such an offer, in
|
||||
accord with subsection 6b.
|
||||
* **d)** Convey the object code by offering access from a designated place (gratis or for
|
||||
a charge), and offer equivalent access to the Corresponding Source in the same way
|
||||
through the same place at no further charge. You need not require recipients to copy
|
||||
the Corresponding Source along with the object code. If the place to copy the object
|
||||
code is a network server, the Corresponding Source may be on a different server
|
||||
(operated by you or a third party) that supports equivalent copying facilities,
|
||||
provided you maintain clear directions next to the object code saying where to find
|
||||
the Corresponding Source. Regardless of what server hosts the Corresponding Source,
|
||||
you remain obligated to ensure that it is available for as long as needed to satisfy
|
||||
these requirements.
|
||||
* **e)** Convey the object code using peer-to-peer transmission, provided you inform
|
||||
other peers where the object code and Corresponding Source of the work are being
|
||||
offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the
|
||||
Corresponding Source as a System Library, need not be included in conveying the
|
||||
object code work.
|
||||
|
||||
A “User Product” is either **(1)** a “consumer product”, which
|
||||
means any tangible personal property which is normally used for personal, family, or
|
||||
household purposes, or **(2)** anything designed or sold for incorporation into a
|
||||
dwelling. In determining whether a product is a consumer product, doubtful cases
|
||||
shall be resolved in favor of coverage. For a particular product received by a
|
||||
particular user, “normally used” refers to a typical or common use of
|
||||
that class of product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected to use, the
|
||||
product. A product is a consumer product regardless of whether the product has
|
||||
substantial commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install and execute
|
||||
modified versions of a covered work in that User Product from a modified version of
|
||||
its Corresponding Source. The information must suffice to ensure that the continued
|
||||
functioning of the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for
|
||||
use in, a User Product, and the conveying occurs as part of a transaction in which
|
||||
the right of possession and use of the User Product is transferred to the recipient
|
||||
in perpetuity or for a fixed term (regardless of how the transaction is
|
||||
characterized), the Corresponding Source conveyed under this section must be
|
||||
accompanied by the Installation Information. But this requirement does not apply if
|
||||
neither you nor any third party retains the ability to install modified object code
|
||||
on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to
|
||||
continue to provide support service, warranty, or updates for a work that has been
|
||||
modified or installed by the recipient, or for the User Product in which it has been
|
||||
modified or installed. Access to a network may be denied when the modification itself
|
||||
materially and adversely affects the operation of the network or violates the rules
|
||||
and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with
|
||||
this section must be in a format that is publicly documented (and with an
|
||||
implementation available to the public in source code form), and must require no
|
||||
special password or key for unpacking, reading or copying.
|
||||
|
||||
### 7. Additional Terms
|
||||
|
||||
“Additional permissions” are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions. Additional
|
||||
permissions that are applicable to the entire Program shall be treated as though they
|
||||
were included in this License, to the extent that they are valid under applicable
|
||||
law. If additional permissions apply only to part of the Program, that part may be
|
||||
used separately under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any
|
||||
additional permissions from that copy, or from any part of it. (Additional
|
||||
permissions may be written to require their own removal in certain cases when you
|
||||
modify the work.) You may place additional permissions on material, added by you to a
|
||||
covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a
|
||||
covered work, you may (if authorized by the copyright holders of that material)
|
||||
supplement the terms of this License with terms:
|
||||
|
||||
* **a)** Disclaiming warranty or limiting liability differently from the terms of
|
||||
sections 15 and 16 of this License; or
|
||||
* **b)** Requiring preservation of specified reasonable legal notices or author
|
||||
attributions in that material or in the Appropriate Legal Notices displayed by works
|
||||
containing it; or
|
||||
* **c)** Prohibiting misrepresentation of the origin of that material, or requiring that
|
||||
modified versions of such material be marked in reasonable ways as different from the
|
||||
original version; or
|
||||
* **d)** Limiting the use for publicity purposes of names of licensors or authors of the
|
||||
material; or
|
||||
* **e)** Declining to grant rights under trademark law for use of some trade names,
|
||||
trademarks, or service marks; or
|
||||
* **f)** Requiring indemnification of licensors and authors of that material by anyone
|
||||
who conveys the material (or modified versions of it) with contractual assumptions of
|
||||
liability to the recipient, for any liability that these contractual assumptions
|
||||
directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further
|
||||
restrictions” within the meaning of section 10. If the Program as you received
|
||||
it, or any part of it, contains a notice stating that it is governed by this License
|
||||
along with a term that is a further restriction, you may remove that term. If a
|
||||
license document contains a further restriction but permits relicensing or conveying
|
||||
under this License, you may add to a covered work material governed by the terms of
|
||||
that license document, provided that the further restriction does not survive such
|
||||
relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in
|
||||
the relevant source files, a statement of the additional terms that apply to those
|
||||
files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a
|
||||
separately written license, or stated as exceptions; the above requirements apply
|
||||
either way.
|
||||
|
||||
### 8. Termination
|
||||
|
||||
You may not propagate or modify a covered work except as expressly provided under
|
||||
this License. Any attempt otherwise to propagate or modify it is void, and will
|
||||
automatically terminate your rights under this License (including any patent licenses
|
||||
granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a
|
||||
particular copyright holder is reinstated **(a)** provisionally, unless and until the
|
||||
copyright holder explicitly and finally terminates your license, and **(b)** permanently,
|
||||
if the copyright holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently
|
||||
if the copyright holder notifies you of the violation by some reasonable means, this
|
||||
is the first time you have received notice of violation of this License (for any
|
||||
work) from that copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of
|
||||
parties who have received copies or rights from you under this License. If your
|
||||
rights have been terminated and not permanently reinstated, you do not qualify to
|
||||
receive new licenses for the same material under section 10.
|
||||
|
||||
### 9. Acceptance Not Required for Having Copies
|
||||
|
||||
You are not required to accept this License in order to receive or run a copy of the
|
||||
Program. Ancillary propagation of a covered work occurring solely as a consequence of
|
||||
using peer-to-peer transmission to receive a copy likewise does not require
|
||||
acceptance. However, nothing other than this License grants you permission to
|
||||
propagate or modify any covered work. These actions infringe copyright if you do not
|
||||
accept this License. Therefore, by modifying or propagating a covered work, you
|
||||
indicate your acceptance of this License to do so.
|
||||
|
||||
### 10. Automatic Licensing of Downstream Recipients
|
||||
|
||||
Each time you convey a covered work, the recipient automatically receives a license
|
||||
from the original licensors, to run, modify and propagate that work, subject to this
|
||||
License. You are not responsible for enforcing compliance by third parties with this
|
||||
License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an organization, or
|
||||
merging organizations. If propagation of a covered work results from an entity
|
||||
transaction, each party to that transaction who receives a copy of the work also
|
||||
receives whatever licenses to the work the party's predecessor in interest had or
|
||||
could give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if the predecessor
|
||||
has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or
|
||||
affirmed under this License. For example, you may not impose a license fee, royalty,
|
||||
or other charge for exercise of rights granted under this License, and you may not
|
||||
initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that any patent claim is infringed by making, using, selling, offering for sale, or
|
||||
importing the Program or any portion of it.
|
||||
|
||||
### 11. Patents
|
||||
|
||||
A “contributor” is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The work thus
|
||||
licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or
|
||||
controlled by the contributor, whether already acquired or hereafter acquired, that
|
||||
would be infringed by some manner, permitted by this License, of making, using, or
|
||||
selling its contributor version, but do not include claims that would be infringed
|
||||
only as a consequence of further modification of the contributor version. For
|
||||
purposes of this definition, “control” includes the right to grant patent
|
||||
sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
|
||||
under the contributor's essential patent claims, to make, use, sell, offer for sale,
|
||||
import and otherwise run, modify and propagate the contents of its contributor
|
||||
version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent (such as an
|
||||
express permission to practice a patent or covenant not to sue for patent
|
||||
infringement). To “grant” such a patent license to a party means to make
|
||||
such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the
|
||||
Corresponding Source of the work is not available for anyone to copy, free of charge
|
||||
and under the terms of this License, through a publicly available network server or
|
||||
other readily accessible means, then you must either **(1)** cause the Corresponding
|
||||
Source to be so available, or **(2)** arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or **(3)** arrange, in a manner consistent with
|
||||
the requirements of this License, to extend the patent license to downstream
|
||||
recipients. “Knowingly relying” means you have actual knowledge that, but
|
||||
for the patent license, your conveying the covered work in a country, or your
|
||||
recipient's use of the covered work in a country, would infringe one or more
|
||||
identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you
|
||||
convey, or propagate by procuring conveyance of, a covered work, and grant a patent
|
||||
license to some of the parties receiving the covered work authorizing them to use,
|
||||
propagate, modify or convey a specific copy of the covered work, then the patent
|
||||
license you grant is automatically extended to all recipients of the covered work and
|
||||
works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on the
|
||||
non-exercise of one or more of the rights that are specifically granted under this
|
||||
License. You may not convey a covered work if you are a party to an arrangement with
|
||||
a third party that is in the business of distributing software, under which you make
|
||||
payment to the third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties who would receive
|
||||
the covered work from you, a discriminatory patent license **(a)** in connection with
|
||||
copies of the covered work conveyed by you (or copies made from those copies), or **(b)**
|
||||
primarily for and in connection with specific products or compilations that contain
|
||||
the covered work, unless you entered into that arrangement, or that patent license
|
||||
was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied
|
||||
license or other defenses to infringement that may otherwise be available to you
|
||||
under applicable patent law.
|
||||
|
||||
### 12. No Surrender of Others' Freedom
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise)
|
||||
that contradict the conditions of this License, they do not excuse you from the
|
||||
conditions of this License. If you cannot convey a covered work so as to satisfy
|
||||
simultaneously your obligations under this License and any other pertinent
|
||||
obligations, then as a consequence you may not convey it at all. For example, if you
|
||||
agree to terms that obligate you to collect a royalty for further conveying from
|
||||
those to whom you convey the Program, the only way you could satisfy both those terms
|
||||
and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
### 13. Use with the GNU Affero General Public License
|
||||
|
||||
Notwithstanding any other provision of this License, you have permission to link or
|
||||
combine any covered work with a work licensed under version 3 of the GNU Affero
|
||||
General Public License into a single combined work, and to convey the resulting work.
|
||||
The terms of this License will continue to apply to the part which is the covered
|
||||
work, but the special requirements of the GNU Affero General Public License, section
|
||||
13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
### 14. Revised Versions of this License
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU
|
||||
General Public License from time to time. Such new versions will be similar in spirit
|
||||
to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that
|
||||
a certain numbered version of the GNU General Public License “or any later
|
||||
version” applies to it, you have the option of following the terms and
|
||||
conditions either of that numbered version or of any later version published by the
|
||||
Free Software Foundation. If the Program does not specify a version number of the GNU
|
||||
General Public License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU
|
||||
General Public License can be used, that proxy's public statement of acceptance of a
|
||||
version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no
|
||||
additional obligations are imposed on any author or copyright holder as a result of
|
||||
your choosing to follow a later version.
|
||||
|
||||
### 15. Disclaimer of Warranty
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
|
||||
QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
### 16. Limitation of Liability
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
|
||||
COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
|
||||
PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
|
||||
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE
|
||||
OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
|
||||
WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
### 17. Interpretation of Sections 15 and 16
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be
|
||||
given local legal effect according to their terms, reviewing courts shall apply local
|
||||
law that most closely approximates an absolute waiver of all civil liability in
|
||||
connection with the Program, unless a warranty or assumption of liability accompanies
|
||||
a copy of the Program in return for a fee.
|
||||
|
||||
_END OF TERMS AND CONDITIONS_
|
||||
|
||||
## How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to
|
||||
the public, the best way to achieve this is to make it free software which everyone
|
||||
can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them
|
||||
to the start of each source file to most effectively state the exclusion of warranty;
|
||||
and each file should have at least the “copyright” line and a pointer to
|
||||
where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type 'show c' for details.
|
||||
|
||||
The hypothetical commands `show w` and `show c` should show the appropriate parts of
|
||||
the General Public License. Of course, your program's commands might be different;
|
||||
for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to
|
||||
sign a “copyright disclaimer” for the program, if necessary. For more
|
||||
information on this, and how to apply and follow the GNU GPL, see
|
||||
<<http://www.gnu.org/licenses/>>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may consider it
|
||||
more useful to permit linking proprietary applications with the library. If this is
|
||||
what you want to do, use the GNU Lesser General Public License instead of this
|
||||
License. But first, please read
|
||||
<<http://www.gnu.org/philosophy/why-not-lgpl.html>>.
|
29
stdlib/README.md
Normal file
29
stdlib/README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# leo-stdlib
|
||||
|
||||
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-ast)
|
||||
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
|
||||
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
|
||||
|
||||
This directory includes the standard library for Leo.
|
||||
|
||||
## Usage
|
||||
|
||||
The src directory is the Rust code that makes the Leo folders and files statically built into the compiler. So any added Leo folders and files under the `stdlib` directory will be automatically included at compile time.
|
||||
|
||||
See the [Structure](#structure) section for more info.
|
||||
|
||||
## Structure
|
||||
|
||||
The structure for this repository is a bit special.
|
||||
|
||||
One important thing to note is the prelude directory. Any Leo files defined in this directory will have all importable objects automatically imported to every Leo program. For example, the following program is valid without any imports:
|
||||
|
||||
```typescript
|
||||
function main() {
|
||||
let s: string = "Hello, string type alias!";
|
||||
}
|
||||
```
|
||||
|
||||
The above type alias is auto imported from `stdlib/prelude/string.leo`.
|
||||
|
||||
The other directories must have explicit imports. For example, the unstable Blake2s can be imported with `import std.unstable.blake2s.Blake2s`. Which imports the `Blake2s` circuit defined in `stdlib/unstable/blake2s.leo`.
|
1
stdlib/prelude/string.leo
Normal file
1
stdlib/prelude/string.leo
Normal file
@ -0,0 +1 @@
|
||||
type string = [char; _];
|
76
stdlib/src/lib.rs
Normal file
76
stdlib/src/lib.rs
Normal file
@ -0,0 +1,76 @@
|
||||
// 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/>.
|
||||
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
use leo_ast::Program;
|
||||
use leo_errors::{ImportError, Result};
|
||||
|
||||
#[macro_use]
|
||||
extern crate include_dir;
|
||||
|
||||
use include_dir::Dir;
|
||||
use indexmap::IndexMap;
|
||||
|
||||
static STDLIB: Dir = include_dir!(".");
|
||||
|
||||
fn resolve_file(file: &str, mapping: Option<&str>) -> Result<Program> {
|
||||
let resolved = STDLIB
|
||||
.get_file(&file)
|
||||
.ok_or_else(|| ImportError::no_such_stdlib_file(file))?
|
||||
.contents_utf8()
|
||||
.ok_or_else(|| ImportError::failed_to_read_stdlib_file(file))?;
|
||||
|
||||
let ast = leo_parser::parse_ast(&file, resolved)?.into_repr();
|
||||
ast.set_core_mapping(mapping);
|
||||
|
||||
Ok(ast)
|
||||
}
|
||||
|
||||
pub fn resolve_prelude_modules() -> Result<IndexMap<Vec<String>, Program>> {
|
||||
let mut preludes: IndexMap<Vec<String>, Program> = IndexMap::new();
|
||||
|
||||
for module in STDLIB.find("prelude/*.leo").unwrap() {
|
||||
// If on windows repalce \\ with / as all paths are stored in unix style.
|
||||
let path = module.path().to_str().unwrap_or("").replace("\\", "/");
|
||||
let program = resolve_file(&path, None)?;
|
||||
|
||||
let removed_extension = path.replace(".leo", "");
|
||||
let mut parts: Vec<String> = vec![String::from("std")];
|
||||
parts.append(
|
||||
&mut removed_extension
|
||||
.split('/')
|
||||
.map(str::to_string)
|
||||
.collect::<Vec<String>>(),
|
||||
);
|
||||
preludes.insert(parts, program);
|
||||
}
|
||||
|
||||
Ok(preludes)
|
||||
}
|
||||
|
||||
pub fn resolve_stdlib_module(module: &str) -> Result<Program> {
|
||||
let mut file_path = module.replace(".", "/");
|
||||
file_path.push_str(".leo");
|
||||
|
||||
let mapping = if module == "unstable.blake2s" {
|
||||
Some("blake2s")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
resolve_file(&file_path, mapping)
|
||||
}
|
5
stdlib/unstable/blake2s.leo
Normal file
5
stdlib/unstable/blake2s.leo
Normal file
@ -0,0 +1,5 @@
|
||||
circuit Blake2s {
|
||||
function hash(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] {
|
||||
return [0; 32];
|
||||
}
|
||||
}
|
@ -55,3 +55,11 @@ version = "1.5.2"
|
||||
|
||||
[dependencies.structopt]
|
||||
version = "0.3"
|
||||
|
||||
# List of dependencies for errcov
|
||||
[dependencies.leo-errors]
|
||||
path = "../errors"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.regex]
|
||||
version = "1.5"
|
269
test-framework/src/bin/errcov.rs
Normal file
269
test-framework/src/bin/errcov.rs
Normal file
@ -0,0 +1,269 @@
|
||||
// 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 leo_errors::{
|
||||
AsgError, AstError, CliError, CompilerError, ImportError, LeoErrorCode, PackageError, ParserError, StateError,
|
||||
};
|
||||
use leo_test_framework::{
|
||||
fetch::find_tests,
|
||||
output::TestExpectation,
|
||||
test::{extract_test_config, TestExpectationMode as Expectation},
|
||||
};
|
||||
|
||||
use regex::Regex;
|
||||
use serde_yaml::Value;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::{error::Error, fs, io, path::PathBuf};
|
||||
use structopt::{clap::AppSettings, StructOpt};
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "error-coverage", author = "The Aleo Team <hello@aleo.org>", setting = AppSettings::ColoredHelp)]
|
||||
struct Opt {
|
||||
#[structopt(
|
||||
short,
|
||||
long,
|
||||
help = "Path to the output file, defaults to stdout.",
|
||||
parse(from_os_str)
|
||||
)]
|
||||
output: Option<PathBuf>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
handle_error(run_with_args(Opt::from_args()));
|
||||
}
|
||||
|
||||
fn run_with_args(opt: Opt) -> Result<(), Box<dyn Error>> {
|
||||
// Variable that stores all the tests.
|
||||
let mut tests = Vec::new();
|
||||
let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
test_dir.push("../tests/");
|
||||
|
||||
let mut expectation_dir = test_dir.clone();
|
||||
expectation_dir.push("expectations");
|
||||
|
||||
find_tests(&test_dir, &mut tests);
|
||||
|
||||
// Store all covered error codes
|
||||
let mut found_codes = BTreeMap::new();
|
||||
let re = Regex::new(r"Error \[(?P<code>.*)\]:.*").unwrap();
|
||||
|
||||
for (path, content) in tests.into_iter() {
|
||||
if let Some(config) = extract_test_config(&content) {
|
||||
// Skip passing tests.
|
||||
if config.expectation == Expectation::Pass {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut expectation_path = expectation_dir.clone();
|
||||
|
||||
let path = PathBuf::from(path);
|
||||
let relative_path = path.strip_prefix(&test_dir).expect("path error for test");
|
||||
|
||||
let mut relative_expectation_path = relative_path.to_str().unwrap().to_string();
|
||||
relative_expectation_path += ".out";
|
||||
|
||||
// Add expectation category
|
||||
if relative_expectation_path.starts_with("compiler") {
|
||||
expectation_path.push("compiler");
|
||||
} else {
|
||||
expectation_path.push("parser");
|
||||
}
|
||||
expectation_path.push(&relative_expectation_path);
|
||||
|
||||
if expectation_path.exists() {
|
||||
let raw = std::fs::read_to_string(&expectation_path).expect("failed to read expectations file");
|
||||
let expectation: TestExpectation =
|
||||
serde_yaml::from_str(&raw).expect("invalid yaml in expectations file");
|
||||
|
||||
for value in expectation.outputs {
|
||||
if let serde_yaml::Value::String(message) = value {
|
||||
if let Some(caps) = re.captures(&message) {
|
||||
if let Some(code) = caps.name("code") {
|
||||
let files = found_codes
|
||||
.entry(code.as_str().to_string())
|
||||
.or_insert_with(HashSet::new);
|
||||
let path = expectation_path
|
||||
.strip_prefix(test_dir.clone())
|
||||
.expect("invalid prefix for expectation path");
|
||||
files.insert(PathBuf::from(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all defined error codes.
|
||||
let mut all_codes = HashSet::new();
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
AsgError::error_type(),
|
||||
AsgError::code_identifier(),
|
||||
AsgError::exit_code_mask(),
|
||||
AsgError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
AstError::error_type(),
|
||||
AstError::code_identifier(),
|
||||
AstError::exit_code_mask(),
|
||||
AstError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
CliError::error_type(),
|
||||
CliError::code_identifier(),
|
||||
CliError::exit_code_mask(),
|
||||
CliError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
CompilerError::error_type(),
|
||||
CompilerError::code_identifier(),
|
||||
CompilerError::exit_code_mask(),
|
||||
CompilerError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
ImportError::error_type(),
|
||||
ImportError::code_identifier(),
|
||||
ImportError::exit_code_mask(),
|
||||
ImportError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
PackageError::error_type(),
|
||||
PackageError::code_identifier(),
|
||||
PackageError::exit_code_mask(),
|
||||
PackageError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
ParserError::error_type(),
|
||||
ParserError::code_identifier(),
|
||||
ParserError::exit_code_mask(),
|
||||
ParserError::num_exit_codes(),
|
||||
);
|
||||
collect_error_codes(
|
||||
&mut all_codes,
|
||||
StateError::error_type(),
|
||||
StateError::code_identifier(),
|
||||
StateError::exit_code_mask(),
|
||||
StateError::num_exit_codes(),
|
||||
);
|
||||
|
||||
// Repackage data into values compatible with serde_yaml
|
||||
let mut covered_errors = serde_yaml::Mapping::new();
|
||||
let mut unknown_errors = serde_yaml::Mapping::new();
|
||||
|
||||
for (code, paths) in found_codes.iter() {
|
||||
let mut yaml_paths = Vec::with_capacity(paths.len());
|
||||
for path in paths {
|
||||
yaml_paths.push(path.to_str().unwrap());
|
||||
}
|
||||
yaml_paths.sort_unstable();
|
||||
let yaml_paths = yaml_paths.iter().map(|s| Value::String(s.to_string())).collect();
|
||||
|
||||
if all_codes.contains(code) {
|
||||
covered_errors.insert(Value::String(code.to_owned()), Value::Sequence(yaml_paths));
|
||||
} else {
|
||||
unknown_errors.insert(Value::String(code.to_owned()), Value::Sequence(yaml_paths));
|
||||
}
|
||||
all_codes.remove(code);
|
||||
}
|
||||
|
||||
let mut codes: Vec<String> = all_codes.drain().collect();
|
||||
codes.sort();
|
||||
|
||||
let mut uncovered_errors = Vec::new();
|
||||
for code in codes {
|
||||
uncovered_errors.push(Value::String(code))
|
||||
}
|
||||
|
||||
let mut uncovered_information = serde_yaml::Mapping::new();
|
||||
uncovered_information.insert(
|
||||
Value::String(String::from("count")),
|
||||
Value::Number(serde_yaml::Number::from(uncovered_errors.len())),
|
||||
);
|
||||
uncovered_information.insert(Value::String(String::from("codes")), Value::Sequence(uncovered_errors));
|
||||
|
||||
let mut covered_information = serde_yaml::Mapping::new();
|
||||
covered_information.insert(
|
||||
Value::String(String::from("count")),
|
||||
Value::Number(serde_yaml::Number::from(covered_errors.len())),
|
||||
);
|
||||
covered_information.insert(Value::String(String::from("codes")), Value::Mapping(covered_errors));
|
||||
|
||||
let mut unknown_information = serde_yaml::Mapping::new();
|
||||
unknown_information.insert(
|
||||
Value::String(String::from("count")),
|
||||
Value::Number(serde_yaml::Number::from(unknown_errors.len())),
|
||||
);
|
||||
unknown_information.insert(Value::String(String::from("codes")), Value::Mapping(unknown_errors));
|
||||
|
||||
let mut results = serde_yaml::Mapping::new();
|
||||
results.insert(
|
||||
Value::String(String::from("uncovered")),
|
||||
Value::Mapping(uncovered_information),
|
||||
);
|
||||
|
||||
results.insert(
|
||||
Value::String(String::from("covered")),
|
||||
Value::Mapping(covered_information),
|
||||
);
|
||||
results.insert(
|
||||
Value::String(String::from("unknown")),
|
||||
Value::Mapping(unknown_information),
|
||||
);
|
||||
|
||||
// Output error coverage results
|
||||
if let Some(pathbuf) = opt.output {
|
||||
let file = fs::File::create(pathbuf).expect("error creating output file");
|
||||
serde_yaml::to_writer(file, &results).expect("serialization failed for error coverage report");
|
||||
} else {
|
||||
serde_yaml::to_writer(io::stdout(), &results).expect("serialization failed for error coverage report");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn collect_error_codes(
|
||||
codes: &mut HashSet<String>,
|
||||
error_type: String,
|
||||
code_identifier: i8,
|
||||
exit_code_mask: i32,
|
||||
num_exit_codes: i32,
|
||||
) {
|
||||
for exit_code in 0..num_exit_codes {
|
||||
codes.insert(format!(
|
||||
"E{}{:0>3}{:0>4}",
|
||||
error_type,
|
||||
code_identifier,
|
||||
exit_code_mask + exit_code,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_error(res: Result<(), Box<dyn Error>>) {
|
||||
match res {
|
||||
Ok(_) => (),
|
||||
Err(err) => {
|
||||
eprintln!("Error: {}", err);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
[main]
|
||||
y: bool = true;
|
||||
n: bool = false;
|
||||
a: [char; 11] = "hello world";
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
|
9
tests/compiler/array_without_size/length.leo
Normal file
9
tests/compiler/array_without_size/length.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: input/dummy.in
|
||||
*/
|
||||
|
||||
function main(a: [char; 11], y: bool) -> bool {
|
||||
return y == (a.len() == 11);
|
||||
}
|
17
tests/compiler/array_without_size/length_function.leo
Normal file
17
tests/compiler/array_without_size/length_function.leo
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file: input/dummy.in
|
||||
*/
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
let x = 0u8;
|
||||
for i in 0..strlen("I swear to god I had something for this") {
|
||||
x += 1;
|
||||
}
|
||||
return (x == 39) == y;
|
||||
}
|
||||
|
||||
function strlen(str: [char; _]) -> u32 {
|
||||
return str.len();
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package
|
||||
|
||||
function main() {}
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import core.*; // You cannot import all dependencies from core at once
|
||||
|
||||
function main() {}
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import core.unstable.bad_circuit; // `bad_circuit` is not a core unstable package
|
||||
|
||||
function main() {}
|
@ -11,7 +11,7 @@ function main(y: bool) -> bool {
|
||||
return y == true;
|
||||
}
|
||||
|
||||
// use core import to test import order
|
||||
import core.unstable.blake2s.Blake2s;
|
||||
// use std import to test import order
|
||||
import std.unstable.blake2s.Blake2s;
|
||||
|
||||
circuit Foo {}
|
||||
|
@ -3,7 +3,7 @@
|
||||
// input_files:
|
||||
// - input/dummy.in
|
||||
|
||||
import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package
|
||||
import std.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package
|
||||
|
||||
function main() -> bool {
|
||||
return false;
|
8
tests/compiler/stdlib/core_circuit_invalid.leo
Normal file
8
tests/compiler/stdlib/core_circuit_invalid.leo
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import std.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package
|
||||
|
||||
function main() {}
|
8
tests/compiler/stdlib/core_circuit_star_fail.leo
Normal file
8
tests/compiler/stdlib/core_circuit_star_fail.leo
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import std.*; // You cannot import all dependencies from core at once
|
||||
|
||||
function main() {}
|
@ -3,6 +3,6 @@ namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import core.bad_circuit; // `bad_circuit` is not a core package
|
||||
import std.bad_circuit; // `bad_circuit` is not a core package
|
||||
|
||||
function main() {}
|
8
tests/compiler/stdlib/core_unstable_package_invalid.leo
Normal file
8
tests/compiler/stdlib/core_unstable_package_invalid.leo
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
import std.unstable.bad_circuit; // `bad_circuit` is not a core unstable package
|
||||
|
||||
function main() {}
|
15
tests/compiler/stdlib/strings.leo
Normal file
15
tests/compiler/stdlib/strings.leo
Normal file
@ -0,0 +1,15 @@
|
||||
// namespace: Compile
|
||||
// expectation: Pass
|
||||
// inputs:
|
||||
// - hello.in: |
|
||||
// [main]
|
||||
// hello: [char; 5] = "hello";
|
||||
|
||||
// [registers]
|
||||
// r0: bool = true;
|
||||
|
||||
function main(hello: [char; 5]) -> bool {
|
||||
let hello2: string = "hello";
|
||||
|
||||
return hello == hello2;
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
// [registers]
|
||||
// r0: [u8; 32] = [0; 32];
|
||||
|
||||
import core.unstable.blake2s.Blake2s;
|
||||
import std.unstable.blake2s.Blake2s;
|
||||
|
||||
function main(message: [u8; 32]) -> [u8; 32] {
|
||||
const seed: [u8; 32] = [1; 32];
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 32dcc6719d7d1214782cd1ffe02f067eec8adbf1f3820546e539887d4f1334c8
|
||||
imports_resolved_ast: 32dcc6719d7d1214782cd1ffe02f067eec8adbf1f3820546e539887d4f1334c8
|
||||
canonicalized_ast: 32dcc6719d7d1214782cd1ffe02f067eec8adbf1f3820546e539887d4f1334c8
|
||||
type_inferenced_ast: 996f46f1dba11bdde037a8e033ca97870871eb89d4e3e402b59f99fcc0c35323
|
||||
imports_resolved_ast: 4e707995ef2cb41edba1339c811ae476bf30a2f65bb09137372a2a0931285260
|
||||
canonicalized_ast: 4e707995ef2cb41edba1339c811ae476bf30a2f65bb09137372a2a0931285260
|
||||
type_inferenced_ast: e3d743b0cc61c5e785559f469d394ae364f0a338cff37974bfc926497013bdd1
|
||||
|
@ -23,6 +23,6 @@ outputs:
|
||||
type: bool
|
||||
value: "false"
|
||||
initial_ast: d9d5346dff8f825d58daabb3a4fe2fcd1471a3fb3c80e46e5583c4f6cdb12b2b
|
||||
imports_resolved_ast: d9d5346dff8f825d58daabb3a4fe2fcd1471a3fb3c80e46e5583c4f6cdb12b2b
|
||||
canonicalized_ast: d9d5346dff8f825d58daabb3a4fe2fcd1471a3fb3c80e46e5583c4f6cdb12b2b
|
||||
type_inferenced_ast: 32a303da117b08aebfb74f7454cd80dfe28b07fd464a61b6d6a3ce23d451f135
|
||||
imports_resolved_ast: e5e91879622f5e63f1b465a8d1d99b9ad10e128d3b04493def195d81e5c728f3
|
||||
canonicalized_ast: e5e91879622f5e63f1b465a8d1d99b9ad10e128d3b04493def195d81e5c728f3
|
||||
type_inferenced_ast: 436fd5fbf72020d63c2f462dd271dbeeca6161c68f625e53ab5f827cda3d3d3e
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 9961e21337ff8eed0a27fff91fc442c2530a1bfaf80da6d497a93a371896b1f8
|
||||
imports_resolved_ast: 9961e21337ff8eed0a27fff91fc442c2530a1bfaf80da6d497a93a371896b1f8
|
||||
canonicalized_ast: 9961e21337ff8eed0a27fff91fc442c2530a1bfaf80da6d497a93a371896b1f8
|
||||
type_inferenced_ast: cc47000b2cf462f5cb891467cc99f2d21c44ced2198e988dc3de59f166aa1603
|
||||
imports_resolved_ast: 763fdfbdda86ca59a4e8c18f0e9e7f87516725d886468a7bf5b5d37bfde140f8
|
||||
canonicalized_ast: 763fdfbdda86ca59a4e8c18f0e9e7f87516725d886468a7bf5b5d37bfde140f8
|
||||
type_inferenced_ast: 6acc95039938704a57b102cb2b3e61cde8375cc1e7595394b759dfc23a4fbedb
|
||||
|
@ -23,6 +23,6 @@ outputs:
|
||||
type: bool
|
||||
value: "false"
|
||||
initial_ast: 6f8e7a94ccb702790204360959a2673abf6b53027fccaaa9feed8a4e41ee05c1
|
||||
imports_resolved_ast: 6f8e7a94ccb702790204360959a2673abf6b53027fccaaa9feed8a4e41ee05c1
|
||||
canonicalized_ast: 6f8e7a94ccb702790204360959a2673abf6b53027fccaaa9feed8a4e41ee05c1
|
||||
type_inferenced_ast: 91e597663c88fbfd0c6ff787d109f5a71d5357c44d5306f7149714cda86475ae
|
||||
imports_resolved_ast: e3570e385d638499b9ce95f0266f87e1c5bd72f7ddcd2718fee3f8f7080cf218
|
||||
canonicalized_ast: e3570e385d638499b9ce95f0266f87e1c5bd72f7ddcd2718fee3f8f7080cf218
|
||||
type_inferenced_ast: c29bc0a2616f928552e44d4e46c363c5707b986737e825855fd0a6165bfa55f3
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 6349e2684562bad873bcf643e01eeb02039295bd41e2df77f1fefc7bb3f2d3bb
|
||||
imports_resolved_ast: 6349e2684562bad873bcf643e01eeb02039295bd41e2df77f1fefc7bb3f2d3bb
|
||||
canonicalized_ast: 6349e2684562bad873bcf643e01eeb02039295bd41e2df77f1fefc7bb3f2d3bb
|
||||
type_inferenced_ast: 508686ddeb2f8fad60d9ad58639b5a761e6c5f5b61e105803eb8a98d8065a2ad
|
||||
imports_resolved_ast: 2b00607e4a777539b2abb677ac95108208d03409adb6b672e00d26cada45b1e6
|
||||
canonicalized_ast: 2b00607e4a777539b2abb677ac95108208d03409adb6b672e00d26cada45b1e6
|
||||
type_inferenced_ast: f0a02b6b326925afb8b1f8fbdafb5686687e695eb4420010d2c8d1564ac0a7b2
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 9f78c996da10363fb594947ca29fef29e35a7032761ce87f69f3ae454650d47e
|
||||
imports_resolved_ast: 9f78c996da10363fb594947ca29fef29e35a7032761ce87f69f3ae454650d47e
|
||||
canonicalized_ast: 9f78c996da10363fb594947ca29fef29e35a7032761ce87f69f3ae454650d47e
|
||||
type_inferenced_ast: 103314a18ce6036da1ab4cc32c025b694cf799492460ab9553dfbd5232544a89
|
||||
imports_resolved_ast: 32e35e00fe92c3cd71959cacb44d76f19782e5fcdeb57b839f1ff6a37dee3964
|
||||
canonicalized_ast: 32e35e00fe92c3cd71959cacb44d76f19782e5fcdeb57b839f1ff6a37dee3964
|
||||
type_inferenced_ast: d6afa34bd1c84c58bb1920be76e893f16a0a7ba1a952493679d2e219b70ac13d
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: ee817c17e6bef3b458e14d3a81c087ed6a75c4554bc70b62466e8d8e43ff1b5e
|
||||
imports_resolved_ast: ee817c17e6bef3b458e14d3a81c087ed6a75c4554bc70b62466e8d8e43ff1b5e
|
||||
canonicalized_ast: ee817c17e6bef3b458e14d3a81c087ed6a75c4554bc70b62466e8d8e43ff1b5e
|
||||
type_inferenced_ast: b15c7e773ebb56e339f750401241e38aab4ab8950c20a70acc293afc1b91d917
|
||||
imports_resolved_ast: 4c477f127d0f5044d37279a8892ad04dafccb200665044e341f74e2e10152de6
|
||||
canonicalized_ast: 4c477f127d0f5044d37279a8892ad04dafccb200665044e341f74e2e10152de6
|
||||
type_inferenced_ast: 9c27915c9e63f5a0a05ead01b6a1564c53956ecbc6e90cb7b33f074d423add24
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 8d5ed3110bc3a61ddee37408133fcc1f77209b65bb83d230729203009e093f40
|
||||
imports_resolved_ast: 8d5ed3110bc3a61ddee37408133fcc1f77209b65bb83d230729203009e093f40
|
||||
canonicalized_ast: 8d5ed3110bc3a61ddee37408133fcc1f77209b65bb83d230729203009e093f40
|
||||
type_inferenced_ast: bc54ad21e90ab297b40ff570dfc379cbca61fdc9e20bd6899f4b964f726954b0
|
||||
imports_resolved_ast: 3bf9b1a7fe682434578831c20f0ab67ef37aa3a069bc302a99bd8976678158c3
|
||||
canonicalized_ast: 3bf9b1a7fe682434578831c20f0ab67ef37aa3a069bc302a99bd8976678158c3
|
||||
type_inferenced_ast: 397cf0ec0e99c094c9d2aa4f1a67df6564a2f6ff5c9a2bd82b47fac583598dca
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: f7b2eb89c51644dc8596988bcc66fbfe471489887c6f46b78ca417746c7ef442
|
||||
imports_resolved_ast: f7b2eb89c51644dc8596988bcc66fbfe471489887c6f46b78ca417746c7ef442
|
||||
canonicalized_ast: f7b2eb89c51644dc8596988bcc66fbfe471489887c6f46b78ca417746c7ef442
|
||||
type_inferenced_ast: f24ef5063928ee7998b53e5e66064c56c01bd99d55b736309d3a1d11ff2fec05
|
||||
imports_resolved_ast: 01a3839714be9b09a1ab61b19adde2a8f45ba6eeb0181f3f746dcf2646f73c7c
|
||||
canonicalized_ast: 01a3839714be9b09a1ab61b19adde2a8f45ba6eeb0181f3f746dcf2646f73c7c
|
||||
type_inferenced_ast: 4f5b9e0532f6476cb6a3f11c4c08d4c59b3e67db76f4358b77e77c6d8fdd8a22
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 66ead06ceac4fea6a24fe071a955986722a53975fa98d2ad2909a83fa8ba8525
|
||||
imports_resolved_ast: 66ead06ceac4fea6a24fe071a955986722a53975fa98d2ad2909a83fa8ba8525
|
||||
canonicalized_ast: 66ead06ceac4fea6a24fe071a955986722a53975fa98d2ad2909a83fa8ba8525
|
||||
type_inferenced_ast: 1e73226b2cbbd5c7a36ffe70b778e0e544976d2e09a1f0ba3f2b486d1b604d58
|
||||
imports_resolved_ast: 2f34d52f534da1c7ec6ebe99be8cec87483f1a73d4cfa9d1d70d40db6304922f
|
||||
canonicalized_ast: 2f34d52f534da1c7ec6ebe99be8cec87483f1a73d4cfa9d1d70d40db6304922f
|
||||
type_inferenced_ast: 26402d98870ae4395a8b7cacf9d25e9cc0920c42dbc7bf48c944ec220138289e
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 843884ddf198fe566cea0f8e84a2902f720d6211c9d8bad98299eea4da846870
|
||||
imports_resolved_ast: 843884ddf198fe566cea0f8e84a2902f720d6211c9d8bad98299eea4da846870
|
||||
canonicalized_ast: c30721e60523bc31af9a9bf342d9b89bf92a26e3886394cc0c1a574560715bdf
|
||||
type_inferenced_ast: baed608da257be0625cd54a796c2f89e9aec8b1ff60f23c7657a0c4fc260e1d1
|
||||
imports_resolved_ast: 984f2f99c58550a478b8abd5d9f84e88052dbf1ed92b79d1de2d6d251148ddd7
|
||||
canonicalized_ast: 1dee4c73f9faa33e13c2b98aecba1ce88ab110fde39b7a573e06969f8dbf84d5
|
||||
type_inferenced_ast: 3bb764584aaa81586edbf85ae1e7ae0774d2e03599c04279f8451205b71e16a4
|
||||
|
@ -23,6 +23,6 @@ outputs:
|
||||
type: bool
|
||||
value: "false"
|
||||
initial_ast: aa24022f240400d709b97a44c143ce481109bb0a66926aa5c97cf2e2d06dea2a
|
||||
imports_resolved_ast: aa24022f240400d709b97a44c143ce481109bb0a66926aa5c97cf2e2d06dea2a
|
||||
canonicalized_ast: ace5006c27d2e3784fb73d52adc641f6285a041452ba0d23de5983c5eede1139
|
||||
type_inferenced_ast: 611bc2fab64e417c9cfad3c59ca333561b8167a6fc7be957d972d96125e040ba
|
||||
imports_resolved_ast: eeccd5c884082a153d06ec18d0eefe48c7c10c7f8b2ca4eb8bf07c6135756892
|
||||
canonicalized_ast: 2871e0b38129c9fe8ffb798df90cac534f0c43d2c4bd7b78575ed3e7756027dc
|
||||
type_inferenced_ast: fdee9f43afe71741d8b1783392ce434f30f252d2602902dc964112949c772109
|
||||
|
@ -23,6 +23,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 307b6817fa2a5005462686901129e97bf75c00bf14568fafbe1de2c8afc1804d
|
||||
imports_resolved_ast: 307b6817fa2a5005462686901129e97bf75c00bf14568fafbe1de2c8afc1804d
|
||||
canonicalized_ast: cbaa304ba210d8155762701d8e6a2ddca3eaffb008a813ed7a60db1fb0043f10
|
||||
type_inferenced_ast: 47e371ce112ac17fd65bfd100d24829e8c4819e1f96cc715b8c6245f01d608bb
|
||||
imports_resolved_ast: 82b0b35a7fdddad336498a8ed852d07f0baa33083ce2777b41ffc40a4e969e12
|
||||
canonicalized_ast: 5cf7e51b880f36efee857debac30612d0f1dc8457529dec4693e1071d56858fe
|
||||
type_inferenced_ast: 113469cf66301a79575823164b365ea8f8cf627df758c1454ff31f42b36ac35e
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 6d5be1a3d383ecafa89b5327d3a4b9bce9a459f6c0241cb01f408566ec4a1cc4
|
||||
imports_resolved_ast: 6d5be1a3d383ecafa89b5327d3a4b9bce9a459f6c0241cb01f408566ec4a1cc4
|
||||
canonicalized_ast: eb64230be87deb03ac7f076961a82194a15afd964aa6966a10314b38def69684
|
||||
type_inferenced_ast: e7985a24db781a3e42c9b2a67d1e8febc78fc2ad4e388a90207d00eb89734ffd
|
||||
imports_resolved_ast: 1b2fa78c990dfcaaa8deffd18ce45ca76561da60d0dba1b3f7825f43ee0ac3ef
|
||||
canonicalized_ast: 0a756dbc1859bfbdb6b98b587054bf548402da737df3b7e9c2318cb9bbcb4a67
|
||||
type_inferenced_ast: 97199b96614f9e92928c536b34760c204383495ff1ea198a7593007de61619cc
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: aa24022f240400d709b97a44c143ce481109bb0a66926aa5c97cf2e2d06dea2a
|
||||
imports_resolved_ast: aa24022f240400d709b97a44c143ce481109bb0a66926aa5c97cf2e2d06dea2a
|
||||
canonicalized_ast: ace5006c27d2e3784fb73d52adc641f6285a041452ba0d23de5983c5eede1139
|
||||
type_inferenced_ast: 611bc2fab64e417c9cfad3c59ca333561b8167a6fc7be957d972d96125e040ba
|
||||
imports_resolved_ast: eeccd5c884082a153d06ec18d0eefe48c7c10c7f8b2ca4eb8bf07c6135756892
|
||||
canonicalized_ast: 2871e0b38129c9fe8ffb798df90cac534f0c43d2c4bd7b78575ed3e7756027dc
|
||||
type_inferenced_ast: fdee9f43afe71741d8b1783392ce434f30f252d2602902dc964112949c772109
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 0724c81ae70c56ff047b5d28ef949b72c4b581ce0bb443957064efa1636a3cab
|
||||
imports_resolved_ast: 0724c81ae70c56ff047b5d28ef949b72c4b581ce0bb443957064efa1636a3cab
|
||||
canonicalized_ast: ed0b7200a455978fed9b1df0c9e3ab9bf4815d79048f28f4205c69b420ee02df
|
||||
type_inferenced_ast: 1e5c78e15d8c9328190e95ccbc2e4e105d9ce430b98704a12472e2c3cc870526
|
||||
imports_resolved_ast: c90904ba0845fa4b092f69fe81782438ecad5bb883c3fd30d3e5c3670e6a98c9
|
||||
canonicalized_ast: 9cd79d308a80e2feafffc66139d517026b15e35b75c7d3eae49ade65bb405338
|
||||
type_inferenced_ast: e4fe63ac330b3a7087740c70e01fd18002a310c7f637de76db62f7d43d2d3c5b
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 60d0b81c9f3631aca3c9607df74cfb8e4dbc0d387836398dea86f016fa4210fd
|
||||
imports_resolved_ast: 60d0b81c9f3631aca3c9607df74cfb8e4dbc0d387836398dea86f016fa4210fd
|
||||
canonicalized_ast: 6570de0e96b21780ed7793a860948b2c6ff7a92da7ce7f3dd7775ff30d70656f
|
||||
type_inferenced_ast: ace51ab56a61b988bd2c3f65431e87234a96fa92554d36d4e83d7235832506f6
|
||||
imports_resolved_ast: 6e9dfcccc07d698f3b825fe6920bc25f8b97a8fa37b248948fb6d8308d197ff0
|
||||
canonicalized_ast: c2aaa302a5e85a3c369c4246cdfcf97c5644d0b2feb6ba164b63e2bba43959f7
|
||||
type_inferenced_ast: 7beb03c5d82bd7fa0bbe81a92d730e2f2e8689ed183848f0225638b9a39fe6ca
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 754eca05d485d80c4b710db30efc66f91c0eafdc02c2707f854238863b6c6c02
|
||||
imports_resolved_ast: 754eca05d485d80c4b710db30efc66f91c0eafdc02c2707f854238863b6c6c02
|
||||
canonicalized_ast: e5554c42dc9a45ab57ea5ac28996969640fb6f8da1ad8db805f65f5d555c8cf4
|
||||
type_inferenced_ast: aa30bccd05b7386ffb8a7df7cad89ec39117c6b5fc51a9e68624064832b4f225
|
||||
imports_resolved_ast: 74c98b37113df6f99b4ec2dbddb0e7b44c2db43553a1c5dcd168ccff36c067ca
|
||||
canonicalized_ast: a9bf64a55240d8dffde6ae374972edb8229c9284a50c49f7a8430aaf995e57dc
|
||||
type_inferenced_ast: 5153c986fce08dc7e5d9d53769de974e358cc7c6b1883e70f4cd4b7c436e76e3
|
||||
|
@ -23,6 +23,6 @@ outputs:
|
||||
type: "[u8; 3]"
|
||||
value: "\"123\""
|
||||
initial_ast: 4e74124bc410534941ef9b79ffb64656d14e145b5a79fbd14419c1aef2f0ef69
|
||||
imports_resolved_ast: 4e74124bc410534941ef9b79ffb64656d14e145b5a79fbd14419c1aef2f0ef69
|
||||
canonicalized_ast: 4e74124bc410534941ef9b79ffb64656d14e145b5a79fbd14419c1aef2f0ef69
|
||||
type_inferenced_ast: de80815f88fb65efa62ce7f5fa23c6fc4f1bbdf601954e94c1212c4eabbee1cb
|
||||
imports_resolved_ast: db3d3efd3292a3bd16296822fbe5d0b51ccae3379d0307e8bb98b6ca062ea3cd
|
||||
canonicalized_ast: db3d3efd3292a3bd16296822fbe5d0b51ccae3379d0307e8bb98b6ca062ea3cd
|
||||
type_inferenced_ast: 81e91909dd86190f8bc2b3b0bcd949c78518b4540a7e8ed6d20ab541b8708345
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 0e4761ba1228f0a490b51ff2c31df33f623a08d32f62833d64859ca103689f4a
|
||||
imports_resolved_ast: 0e4761ba1228f0a490b51ff2c31df33f623a08d32f62833d64859ca103689f4a
|
||||
canonicalized_ast: 0e4761ba1228f0a490b51ff2c31df33f623a08d32f62833d64859ca103689f4a
|
||||
type_inferenced_ast: 1494bb64c16ec2dc03bfb2e37b89f93e02a70860ced1ce0b42b5ee5ead31b0d5
|
||||
imports_resolved_ast: 1b2ba53d65d93c8ba810f1b2c241773e9d901aa987885ccd7db7b7ca606c5dc1
|
||||
canonicalized_ast: 1b2ba53d65d93c8ba810f1b2c241773e9d901aa987885ccd7db7b7ca606c5dc1
|
||||
type_inferenced_ast: 886c9c3d37af3f6d951268eaeddc5c68e1674237dbaf11eb7c76dfdb23e5ece3
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 1bf9b30e052d9ecc042a0b20bbc195a98d463ab206963469b9199de462b8be15
|
||||
imports_resolved_ast: 1bf9b30e052d9ecc042a0b20bbc195a98d463ab206963469b9199de462b8be15
|
||||
canonicalized_ast: 1bf9b30e052d9ecc042a0b20bbc195a98d463ab206963469b9199de462b8be15
|
||||
type_inferenced_ast: 6d2531af8ed5b04b23039d0b508cf388135a0fc6e1dc0de3befb4d49ce360fbc
|
||||
imports_resolved_ast: 5deb917842e525eb21498976389bc21b716fc2c8d01ee15a868ec347da41eefc
|
||||
canonicalized_ast: 5deb917842e525eb21498976389bc21b716fc2c8d01ee15a868ec347da41eefc
|
||||
type_inferenced_ast: 1cce48ed4862ddb282cb08be969db4d9be64373e83a9458174f2fd63a5a2e878
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 140097342b7a16fae8542da5d13eb9c2cb4e1b743fa226e345d815f62d0781bb
|
||||
imports_resolved_ast: 140097342b7a16fae8542da5d13eb9c2cb4e1b743fa226e345d815f62d0781bb
|
||||
canonicalized_ast: 140097342b7a16fae8542da5d13eb9c2cb4e1b743fa226e345d815f62d0781bb
|
||||
type_inferenced_ast: a2442e72c5010224894e46a1c6f245356c0d86428ce617eb31faaf57806ca2df
|
||||
imports_resolved_ast: 691c76eae0533ac08a723ea21c999e9c8fafb71d81dd5a1ff5cf856d98b79cd9
|
||||
canonicalized_ast: 691c76eae0533ac08a723ea21c999e9c8fafb71d81dd5a1ff5cf856d98b79cd9
|
||||
type_inferenced_ast: 6bce331b2bcabd251d039695ea7821e39864bf37f9ba255ab743dddba26c6643
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 002cb467a5c1357617b45f955944bb4a79ab465dc13f3eb5eb8db4c158b8c745
|
||||
imports_resolved_ast: 002cb467a5c1357617b45f955944bb4a79ab465dc13f3eb5eb8db4c158b8c745
|
||||
canonicalized_ast: 002cb467a5c1357617b45f955944bb4a79ab465dc13f3eb5eb8db4c158b8c745
|
||||
type_inferenced_ast: 323fc99ac247b37bb395eb08691d451a3b6b563a15bb94b5af6a0193ccc0bd34
|
||||
imports_resolved_ast: f6f225fdc57fa21359f0188361043bc7dc653cadec3936d4a94cf0c19058cb89
|
||||
canonicalized_ast: f6f225fdc57fa21359f0188361043bc7dc653cadec3936d4a94cf0c19058cb89
|
||||
type_inferenced_ast: 9203e04d2522f45db24dfd1582d6d5708256483a9eb52474b1ab006bfa1e8121
|
||||
|
@ -17,6 +17,6 @@ outputs:
|
||||
type: bool
|
||||
value: "true"
|
||||
initial_ast: 97fd9b78f7912a7627e2b2f5615ae35e39304af6122fab85f9b49fcf6a85d8f2
|
||||
imports_resolved_ast: 97fd9b78f7912a7627e2b2f5615ae35e39304af6122fab85f9b49fcf6a85d8f2
|
||||
canonicalized_ast: cf8a8faae5f2847199324cbef87583e9af1249c03891ae31f3ce0093879326d5
|
||||
type_inferenced_ast: 731117b4aa8260da475471088df325cb540d84c536ce60f3488e01a4428e84ae
|
||||
imports_resolved_ast: 4132a31ee94a7c187c50f27d1992e25f346bd3c6efabf02106a62a814d9b336a
|
||||
canonicalized_ast: b130bb4ab886d1d855d1f7afbd6af787f7681fbedbd05fcd1cd2561224695bac
|
||||
type_inferenced_ast: a6a9b6069b3f805da8a6ea4fe2fb0530a24b19eb9687ef047f8f3b49d5497590
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user