This commit is contained in:
Protryon 2021-03-26 05:19:42 -07:00
parent bbc6121f9d
commit 63d1b1005f
68 changed files with 401 additions and 149 deletions

View File

@ -15,7 +15,14 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
statement::*, BoolAnd, Expression, Monoid, MonoidalReducerExpression, MonoidalReducerStatement, Node, Span, statement::*,
BoolAnd,
Expression,
Monoid,
MonoidalReducerExpression,
MonoidalReducerStatement,
Node,
Span,
}; };
pub struct ReturnPathReducer { pub struct ReturnPathReducer {

View File

@ -15,8 +15,19 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, CircuitMember, ConstValue, Expression, ExpressionNode, FromAst, Function, FunctionQualifier, Node, AsgConvertError,
PartialType, Scope, Span, Type, CircuitMember,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Function,
FunctionQualifier,
Node,
PartialType,
Scope,
Span,
Type,
}; };
pub use leo_ast::{BinaryOperation, Node as AstNode}; pub use leo_ast::{BinaryOperation, Node as AstNode};

View File

@ -15,8 +15,19 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, Circuit, CircuitMember, ConstValue, Expression, ExpressionNode, FromAst, Identifier, Node, AsgConvertError,
PartialType, Scope, Span, Type, Circuit,
CircuitMember,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
Node,
PartialType,
Scope,
Span,
Type,
}; };
use std::cell::Cell; use std::cell::Cell;

View File

@ -15,8 +15,19 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, Circuit, CircuitMember, ConstValue, Expression, ExpressionNode, FromAst, Identifier, Node, AsgConvertError,
PartialType, Scope, Span, Type, Circuit,
CircuitMember,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
Node,
PartialType,
Scope,
Span,
Type,
}; };
use indexmap::{IndexMap, IndexSet}; use indexmap::{IndexMap, IndexSet};

View File

@ -15,8 +15,18 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, ConstInt, ConstValue, Expression, ExpressionNode, FromAst, GroupValue, Node, PartialType, Scope, AsgConvertError,
Span, Type, ConstInt,
ConstValue,
Expression,
ExpressionNode,
FromAst,
GroupValue,
Node,
PartialType,
Scope,
Span,
Type,
}; };
use std::cell::Cell; use std::cell::Cell;

View File

@ -15,8 +15,20 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, ConstValue, Constant, DefinitionStatement, Expression, ExpressionNode, FromAst, Node, PartialType, AsgConvertError,
Scope, Span, Statement, Type, Variable, ConstValue,
Constant,
DefinitionStatement,
Expression,
ExpressionNode,
FromAst,
Node,
PartialType,
Scope,
Span,
Statement,
Type,
Variable,
}; };
use std::cell::Cell; use std::cell::Cell;

View File

@ -15,7 +15,16 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgContextInner, AsgConvertError, Circuit, Expression, Function, PartialType, Scope, Span, Statement, Variable, AsgContextInner,
AsgConvertError,
Circuit,
Expression,
Function,
PartialType,
Scope,
Span,
Statement,
Variable,
}; };
/// A node in the abstract semantic graph. /// A node in the abstract semantic graph.

View File

@ -111,7 +111,10 @@ impl<'a> Circuit<'a> {
if asg_function.is_test() { if asg_function.is_test() {
return Err(AsgConvertError::circuit_test_function(&function.identifier.span)); return Err(AsgConvertError::circuit_test_function(&function.identifier.span));
} }
members.insert(function.identifier.name.to_string(), CircuitMember::Function(asg_function)); members.insert(
function.identifier.name.to_string(),
CircuitMember::Function(asg_function),
);
} }
} }

View File

@ -15,8 +15,18 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, BlockStatement, Circuit, FromAst, Identifier, MonoidalDirector, ReturnPathReducer, Scope, Span, AsgConvertError,
Statement, Type, Variable, BlockStatement,
Circuit,
FromAst,
Identifier,
MonoidalDirector,
ReturnPathReducer,
Scope,
Span,
Statement,
Type,
Variable,
}; };
use indexmap::IndexMap; use indexmap::IndexMap;
pub use leo_ast::Annotation; pub use leo_ast::Annotation;

View File

@ -15,8 +15,22 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, CircuitMember, ConstInt, ConstValue, Expression, ExpressionNode, FromAst, Identifier, IntegerType, AsgConvertError,
Node, PartialType, Scope, Span, Statement, Type, Variable, CircuitMember,
ConstInt,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
IntegerType,
Node,
PartialType,
Scope,
Span,
Statement,
Type,
Variable,
}; };
pub use leo_ast::AssignOperation; pub use leo_ast::AssignOperation;
use leo_ast::AssigneeAccess as AstAssigneeAccess; use leo_ast::AssigneeAccess as AstAssigneeAccess;

View File

@ -15,8 +15,18 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
AsgConvertError, Expression, ExpressionNode, FromAst, InnerVariable, Node, PartialType, Scope, Span, Statement, AsgConvertError,
Type, Variable, Expression,
ExpressionNode,
FromAst,
InnerVariable,
Node,
PartialType,
Scope,
Span,
Statement,
Type,
Variable,
}; };
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};

View File

@ -17,7 +17,16 @@
use leo_ast::IntegerType; use leo_ast::IntegerType;
use crate::{ use crate::{
AsgConvertError, Expression, ExpressionNode, FromAst, InnerVariable, Node, PartialType, Scope, Span, Statement, AsgConvertError,
Expression,
ExpressionNode,
FromAst,
InnerVariable,
Node,
PartialType,
Scope,
Span,
Statement,
Variable, Variable,
}; };

View File

@ -21,9 +21,13 @@ use tendril::StrTendril;
use crate::Node; use crate::Node;
use serde::{ use serde::{
de::{ de::{
Visitor, {self}, Visitor,
{self},
}, },
Deserialize, Deserializer, Serialize, Serializer, Deserialize,
Deserializer,
Serialize,
Serializer,
}; };
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,

View File

@ -15,7 +15,13 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
ArrayDimensions, CircuitImpliedVariableDefinition, GroupValue, Identifier, IntegerType, PositiveNumber, Span, ArrayDimensions,
CircuitImpliedVariableDefinition,
GroupValue,
Identifier,
IntegerType,
PositiveNumber,
Span,
SpreadOrExpression, SpreadOrExpression,
}; };

View File

@ -16,8 +16,11 @@
use crate::common::span::Span; use crate::common::span::Span;
use leo_input::values::{ use leo_input::values::{
GroupCoordinate as InputGroupCoordinate, Inferred as InputInferred, NumberValue as InputNumberValue, GroupCoordinate as InputGroupCoordinate,
SignHigh as InputSignHigh, SignLow as InputSignLow, Inferred as InputInferred,
NumberValue as InputNumberValue,
SignHigh as InputSignHigh,
SignLow as InputSignLow,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -16,7 +16,9 @@
use crate::{common::span::Span, groups::GroupCoordinate}; use crate::{common::span::Span, groups::GroupCoordinate};
use leo_input::values::{ use leo_input::values::{
GroupRepresentation as InputGroupRepresentation, GroupTuple as InputGroupTuple, GroupValue as InputGroupValue, GroupRepresentation as InputGroupRepresentation,
GroupTuple as InputGroupTuple,
GroupValue as InputGroupValue,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -40,11 +40,7 @@ impl PublicState {
} }
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
if self.state.is_present() { if self.state.is_present() { 1usize } else { 0usize }
1usize
} else {
0usize
}
} }
/// Parse all input variables included in a file and store them in `self`. /// Parse all input variables included in a file and store them in `self`.

View File

@ -15,7 +15,8 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use leo_input::types::{ use leo_input::types::{
IntegerType as InputIntegerType, SignedIntegerType as InputSignedIntegerType, IntegerType as InputIntegerType,
SignedIntegerType as InputSignedIntegerType,
UnsignedIntegerType as InputUnsignedIntegerType, UnsignedIntegerType as InputUnsignedIntegerType,
}; };

View File

@ -16,7 +16,10 @@
use crate::{ArrayDimensions, Identifier, IntegerType}; use crate::{ArrayDimensions, Identifier, IntegerType};
use leo_input::types::{ use leo_input::types::{
ArrayType as InputArrayType, DataType as InputDataType, TupleType as InputTupleType, Type as InputType, ArrayType as InputArrayType,
DataType as InputDataType,
TupleType as InputTupleType,
Type as InputType,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -19,7 +19,10 @@
use crate::{ use crate::{
constraints::{generate_constraints, generate_test_constraints}, constraints::{generate_constraints, generate_test_constraints},
errors::CompilerError, errors::CompilerError,
CompilerOptions, GroupType, OutputBytes, OutputFile, CompilerOptions,
GroupType,
OutputBytes,
OutputFile,
}; };
pub use leo_asg::{new_context, AsgContext as Context, AsgContext}; pub use leo_asg::{new_context, AsgContext as Context, AsgContext};
use leo_asg::{Asg, AsgPass, FormattedError, Program as AsgProgram}; use leo_asg::{Asg, AsgPass, FormattedError, Program as AsgProgram};

View File

@ -17,7 +17,11 @@
//! Enforces an assert equals statement in a compiled Leo program. //! Enforces an assert equals statement in a compiled Leo program.
use crate::{ use crate::{
errors::ConsoleError, get_indicator_value, program::ConstrainedProgram, value::ConstrainedValue, GroupType, errors::ConsoleError,
get_indicator_value,
program::ConstrainedProgram,
value::ConstrainedValue,
GroupType,
}; };
use leo_asg::{Expression, Span}; use leo_asg::{Expression, Span};

View File

@ -15,8 +15,15 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::errors::{ use crate::errors::{
AddressError, BooleanError, ExpressionError, FieldError, GroupError, IntegerError, OutputBytesError, AddressError,
StatementError, ValueError, BooleanError,
ExpressionError,
FieldError,
GroupError,
IntegerError,
OutputBytesError,
StatementError,
ValueError,
}; };
use leo_asg::AsgConvertError; use leo_asg::AsgConvertError;
use leo_ast::{FormattedError, LeoError, Span}; use leo_ast::{FormattedError, LeoError, Span};

View File

@ -24,7 +24,8 @@ use crate::{
relational::*, relational::*,
resolve_core_circuit, resolve_core_circuit,
value::{Address, ConstrainedValue, Integer}, value::{Address, ConstrainedValue, Integer},
FieldType, GroupType, FieldType,
GroupType,
}; };
use leo_asg::{expression::*, ConstValue, Expression, Node, Span}; use leo_asg::{expression::*, ConstValue, Expression, Node, Span};

View File

@ -21,7 +21,9 @@ use crate::{
errors::FunctionError, errors::FunctionError,
program::ConstrainedProgram, program::ConstrainedProgram,
value::{ value::{
boolean::input::bool_from_input, field::input::field_from_input, group::input::group_from_input, boolean::input::bool_from_input,
field::input::field_from_input,
group::input::group_from_input,
ConstrainedValue, ConstrainedValue,
}, },
FieldType, FieldType,

View File

@ -62,7 +62,11 @@ impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
let input_variable = input_variable.get().borrow(); let input_variable = input_variable.get().borrow();
let name = input_variable.name.name.clone(); let name = input_variable.name.name.clone();
let input_value = match (input_variable.const_, input.get(&name), input.get_constant(name.as_ref())) { let input_value = match (
input_variable.const_,
input.get(&name),
input.get_constant(name.as_ref()),
) {
// If variable is in both [main] and [constants] sections - error. // If variable is in both [main] and [constants] sections - error.
(_, Some(_), Some(_)) => { (_, Some(_), Some(_)) => {
return Err(FunctionError::double_input_declaration( return Err(FunctionError::double_input_declaration(

View File

@ -17,11 +17,21 @@
//! Resolves assignees in a compiled Leo program. //! Resolves assignees in a compiled Leo program.
use crate::{ use crate::{
errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType, ResolvedAssigneeAccess, errors::StatementError,
program::ConstrainedProgram,
value::ConstrainedValue,
GroupType,
ResolvedAssigneeAccess,
}; };
use leo_asg::{ use leo_asg::{
ArrayAccessExpression, ArrayRangeAccessExpression, CircuitAccessExpression, Expression, Node, Span, ArrayAccessExpression,
TupleAccessExpression, Variable, ArrayRangeAccessExpression,
CircuitAccessExpression,
Expression,
Node,
Span,
TupleAccessExpression,
Variable,
}; };
use snarkvm_fields::PrimeField; use snarkvm_fields::PrimeField;

View File

@ -17,7 +17,11 @@
//! Enforces that one return value is produced in a compiled Leo program. //! Enforces that one return value is produced in a compiled Leo program.
use crate::{ use crate::{
errors::StatementError, get_indicator_value, program::ConstrainedProgram, value::ConstrainedValue, GroupType, errors::StatementError,
get_indicator_value,
program::ConstrainedProgram,
value::ConstrainedValue,
GroupType,
}; };
use leo_asg::{Span, Type}; use leo_asg::{Span, Type};

View File

@ -21,7 +21,8 @@ use crate::errors::OutputFileError;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -17,8 +17,12 @@
//! Methods to enforce constraints on statements in a compiled Leo program. //! Methods to enforce constraints on statements in a compiled Leo program.
use crate::{ use crate::{
errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType, errors::StatementError,
IndicatorAndConstrainedValue, StatementResult, program::ConstrainedProgram,
value::ConstrainedValue,
GroupType,
IndicatorAndConstrainedValue,
StatementResult,
}; };
use leo_asg::ConditionalStatement; use leo_asg::ConditionalStatement;

View File

@ -17,7 +17,11 @@
//! Enforces an iteration statement in a compiled Leo program. //! Enforces an iteration statement in a compiled Leo program.
use crate::{ use crate::{
program::ConstrainedProgram, value::ConstrainedValue, GroupType, IndicatorAndConstrainedValue, Integer, program::ConstrainedProgram,
value::ConstrainedValue,
GroupType,
IndicatorAndConstrainedValue,
Integer,
StatementResult, StatementResult,
}; };
use leo_asg::IterationStatement; use leo_asg::IterationStatement;

View File

@ -198,11 +198,7 @@ impl<F: PrimeField> ConditionalEqGadget<F> for Address {
} }
fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address { fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address {
if cond { if cond { first.clone() } else { second.clone() }
first.clone()
} else {
second.clone()
}
} }
impl<F: PrimeField> CondSelectGadget<F> for Address { impl<F: PrimeField> CondSelectGadget<F> for Address {

View File

@ -289,11 +289,7 @@ impl<F: PrimeField> CondSelectGadget<F> for FieldType<F> {
second: &Self, second: &Self,
) -> Result<Self, SynthesisError> { ) -> Result<Self, SynthesisError> {
if let Boolean::Constant(cond) = *cond { if let Boolean::Constant(cond) = *cond {
if cond { if cond { Ok(first.clone()) } else { Ok(second.clone()) }
Ok(first.clone())
} else {
Ok(second.clone())
}
} else { } else {
let first_gadget = first.allocated(&mut cs)?; let first_gadget = first.allocated(&mut cs)?;
let second_gadget = second.allocated(&mut cs)?; let second_gadget = second.allocated(&mut cs)?;

View File

@ -20,7 +20,8 @@ use leo_asg::{GroupCoordinate, GroupValue, Span};
use snarkvm_curves::{ use snarkvm_curves::{
edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq}, edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq},
templates::twisted_edwards_extended::GroupAffine, templates::twisted_edwards_extended::GroupAffine,
AffineCurve, TEModelParameters, AffineCurve,
TEModelParameters,
}; };
use snarkvm_fields::{Fp256, One, Zero}; use snarkvm_fields::{Fp256, One, Zero};
use snarkvm_gadgets::{ use snarkvm_gadgets::{
@ -481,11 +482,7 @@ impl CondSelectGadget<Fq> for EdwardsGroupType {
second: &Self, second: &Self,
) -> Result<Self, SynthesisError> { ) -> Result<Self, SynthesisError> {
if let Boolean::Constant(cond) = *cond { if let Boolean::Constant(cond) = *cond {
if cond { if cond { Ok(first.clone()) } else { Ok(second.clone()) }
Ok(first.clone())
} else {
Ok(second.clone())
}
} else { } else {
let first_gadget = first.allocated(cs.ns(|| "first"))?; let first_gadget = first.allocated(cs.ns(|| "first"))?;
let second_gadget = second.allocated(cs.ns(|| "second"))?; let second_gadget = second.allocated(cs.ns(|| "second"))?;

View File

@ -19,8 +19,7 @@ use snarkvm_gadgets::traits::utilities::{
int::{Int128, Int16, Int32, Int64, Int8}, int::{Int128, Int16, Int32, Int64, Int8},
uint::{UInt128, UInt16, UInt32, UInt64, UInt8}, uint::{UInt128, UInt16, UInt32, UInt64, UInt8},
}; };
use std::convert::TryInto; use std::{convert::TryInto, fmt::Debug};
use std::fmt::Debug;
pub trait IntegerTrait: Sized + Clone + Debug { pub trait IntegerTrait: Sized + Clone + Debug {
fn get_value(&self) -> Option<String>; fn get_value(&self) -> Option<String>;

View File

@ -15,7 +15,12 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, get_output, parse_program, parse_program_with_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
get_output,
parse_program,
parse_program_with_input,
EdwardsTestCompiler, EdwardsTestCompiler,
}; };

View File

@ -15,7 +15,12 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, get_output, parse_program, parse_program_with_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
get_output,
parse_program,
parse_program_with_input,
EdwardsTestCompiler, EdwardsTestCompiler,
}; };

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, parse_program, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
parse_program,
parse_program_with_input, parse_program_with_input,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -15,7 +15,12 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, generate_main_input, get_output, parse_program, parse_program_with_input, assert_satisfied,
expect_asg_error,
generate_main_input,
get_output,
parse_program,
parse_program_with_input,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::{expect_computation_error, IntegerTester}, integers::{expect_computation_error, IntegerTester},
parse_program, parse_program,
}; };

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::{expect_computation_error, IntegerTester}, integers::{expect_computation_error, IntegerTester},
parse_program, parse_program,
}; };

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::{expect_computation_error, IntegerTester}, integers::{expect_computation_error, IntegerTester},
parse_program, parse_program,
}; };

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::{expect_computation_error, IntegerTester}, integers::{expect_computation_error, IntegerTester},
parse_program, parse_program,
}; };

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::{expect_computation_error, IntegerTester}, integers::{expect_computation_error, IntegerTester},
parse_program, parse_program,
}; };

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, integers::IntegerTester, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::IntegerTester,
parse_program, parse_program,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, integers::IntegerTester, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::IntegerTester,
parse_program, parse_program,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, integers::IntegerTester, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::IntegerTester,
parse_program, parse_program,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, integers::IntegerTester, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::IntegerTester,
parse_program, parse_program,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, integers::IntegerTester, assert_satisfied,
expect_asg_error,
expect_compiler_error,
generate_main_input,
integers::IntegerTester,
parse_program, parse_program,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -41,7 +41,10 @@ pub mod tuples;
use leo_asg::{new_alloc_context, new_context, AsgContext}; use leo_asg::{new_alloc_context, new_context, AsgContext};
use leo_ast::{InputValue, MainInput}; use leo_ast::{InputValue, MainInput};
use leo_compiler::{ use leo_compiler::{
compiler::Compiler, errors::CompilerError, group::targets::edwards_bls12::EdwardsGroupType, ConstrainedValue, compiler::Compiler,
errors::CompilerError,
group::targets::edwards_bls12::EdwardsGroupType,
ConstrainedValue,
OutputBytes, OutputBytes,
}; };
use leo_input::types::{IntegerType, U32Type, UnsignedIntegerType}; use leo_input::types::{IntegerType, U32Type, UnsignedIntegerType};

View File

@ -15,8 +15,14 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ use crate::{
assert_satisfied, expect_compiler_error, generate_main_input, generate_test_input_u32, get_output, parse_program, assert_satisfied,
parse_program_with_input, EdwardsTestCompiler, expect_compiler_error,
generate_main_input,
generate_test_input_u32,
get_output,
parse_program,
parse_program_with_input,
EdwardsTestCompiler,
}; };
use leo_ast::InputValue; use leo_ast::InputValue;

View File

@ -17,7 +17,8 @@
use anyhow::{anyhow, Error, Result}; use anyhow::{anyhow, Error, Result};
use reqwest::{ use reqwest::{
blocking::{Client, Response}, blocking::{Client, Response},
Method, StatusCode, Method,
StatusCode,
}; };
use serde::Serialize; use serde::Serialize;

View File

@ -20,7 +20,8 @@ use anyhow::{anyhow, Result};
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::{Read, Write}, io::{Read, Write},
path::Path, path::Path,

View File

@ -16,7 +16,9 @@
use std::{ use std::{
fs::{ fs::{
create_dir_all, File, {self}, create_dir_all,
File,
{self},
}, },
io, io,
io::prelude::*, io::prelude::*,

View File

@ -23,7 +23,19 @@ pub mod updater;
use commands::{ use commands::{
package::{Add, Clone, Login, Logout, Publish, Remove}, package::{Add, Clone, Login, Logout, Publish, Remove},
Build, Clean, Command, Deploy, Init, Lint, New, Prove, Run, Setup, Test, Update, Watch, Build,
Clean,
Command,
Deploy,
Init,
Lint,
New,
Prove,
Run,
Setup,
Test,
Update,
Watch,
}; };
use anyhow::Error; use anyhow::Error;
@ -163,13 +175,10 @@ fn main() {
if !opt.quiet { if !opt.quiet {
// init logger with optional debug flag // init logger with optional debug flag
logger::init_logger( logger::init_logger("leo", match opt.debug {
"leo", false => 1,
match opt.debug { true => 2,
false => 1, });
true => 2,
},
);
} }
handle_error(match opt.command { handle_error(match opt.command {

View File

@ -21,7 +21,14 @@ use anyhow::Result;
use crate::{ use crate::{
commands::{ commands::{
package::{Login, Logout}, package::{Login, Logout},
Build, Command, Prove, Run, Setup, Test, Update, UpdateAutomatic, Build,
Command,
Prove,
Run,
Setup,
Test,
Update,
UpdateAutomatic,
}, },
context::{create_context, Context}, context::{create_context, Context},
}; };

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::Write, io::Write,
path::Path, path::Path,

View File

@ -21,8 +21,12 @@ use crate::{
imports::IMPORTS_DIRECTORY_NAME, imports::IMPORTS_DIRECTORY_NAME,
inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION}, inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION},
outputs::{ outputs::{
CHECKSUM_FILE_EXTENSION, CIRCUIT_FILE_EXTENSION, OUTPUTS_DIRECTORY_NAME, PROOF_FILE_EXTENSION, CHECKSUM_FILE_EXTENSION,
PROVING_KEY_FILE_EXTENSION, VERIFICATION_KEY_FILE_EXTENSION, CIRCUIT_FILE_EXTENSION,
OUTPUTS_DIRECTORY_NAME,
PROOF_FILE_EXTENSION,
PROVING_KEY_FILE_EXTENSION,
VERIFICATION_KEY_FILE_EXTENSION,
}, },
root::{MANIFEST_FILENAME, README_FILENAME}, root::{MANIFEST_FILENAME, README_FILENAME},
source::{SOURCE_DIRECTORY_NAME, SOURCE_FILE_EXTENSION}, source::{SOURCE_DIRECTORY_NAME, SOURCE_FILE_EXTENSION},
@ -32,7 +36,8 @@ use serde::Deserialize;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{ fs::{
File, {self}, File,
{self},
}, },
io::{Read, Write}, io::{Read, Write},
path::Path, path::Path,

View File

@ -22,7 +22,8 @@ pub mod manifest;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::{ use std::{
cell::RefCell, cell::RefCell,
env, fs, env,
fs,
path::PathBuf, path::PathBuf,
sync::atomic::{AtomicUsize, Ordering}, sync::atomic::{AtomicUsize, Ordering},
}; };

View File

@ -91,9 +91,6 @@ impl SyntaxError {
} }
pub fn illegal_self_const(span: &Span) -> Self { pub fn illegal_self_const(span: &Span) -> Self {
Self::new_from_span( Self::new_from_span("cannot have const self".to_string(), span)
"cannot have const self".to_string(),
span,
)
} }
} }

View File

@ -299,13 +299,10 @@ impl ParserContext {
let member = self.parse_circuit_member()?; let member = self.parse_circuit_member()?;
members.push(member); members.push(member);
} }
Ok(( Ok((name.clone(), Circuit {
name.clone(), circuit_name: name,
Circuit { members,
circuit_name: name, }))
members,
},
))
} }
/// ///
@ -332,7 +329,7 @@ impl ParserContext {
}; };
if name.name.as_ref() == "self" { if name.name.as_ref() == "self" {
if let Some(const_) = const_.as_ref() { if let Some(const_) = const_.as_ref() {
return Err(SyntaxError::illegal_self_const(&(&name.span + &const_.span))) return Err(SyntaxError::illegal_self_const(&(&name.span + &const_.span)));
} }
if let Some(mutable) = &mutable { if let Some(mutable) = &mutable {
name.span = &mutable.span + &name.span; name.span = &mutable.span + &name.span;
@ -390,16 +387,13 @@ impl ParserContext {
None None
}; };
let block = self.parse_block()?; let block = self.parse_block()?;
Ok(( Ok((name.clone(), Function {
name.clone(), annotations,
Function { identifier: name,
annotations, input: inputs,
identifier: name, output,
input: inputs, span: start + block.span.clone(),
output, block,
span: start + block.span.clone(), }))
block,
},
))
} }
} }

View File

@ -81,20 +81,17 @@ pub(crate) fn tokenize(path: &str, input: StrTendril) -> Result<Vec<SpannedToken
if token_len == 0 && index == input.len() { if token_len == 0 && index == input.len() {
break; break;
} else if token_len == 0 { } else if token_len == 0 {
return Err(TokenError::unexpected_token( return Err(TokenError::unexpected_token(&input[index..index + 1], &Span {
&input[index..index + 1], line_start: line_no,
&Span { line_stop: line_no,
line_start: line_no, col_start: index - line_start + 1,
line_stop: line_no, col_stop: index - line_start + 2,
col_start: index - line_start + 1, path,
col_stop: index - line_start + 2, content: input.subtendril(
path, line_start as u32,
content: input.subtendril( input[line_start..].find('\n').unwrap_or_else(|| input.len()) as u32,
line_start as u32, ),
input[line_start..].find('\n').unwrap_or_else(|| input.len()) as u32, }));
),
},
));
} }
if input.as_bytes()[index] == b'\n' { if input.as_bytes()[index] == b'\n' {
line_no += 1; line_no += 1;

View File

@ -21,7 +21,9 @@ use leo_state::verify_local_data_commitment;
use snarkvm_algorithms::traits::{CommitmentScheme, CRH}; use snarkvm_algorithms::traits::{CommitmentScheme, CRH};
use snarkvm_dpc::{ use snarkvm_dpc::{
base_dpc::{instantiated::*, record_payload::RecordPayload, DPC}, base_dpc::{instantiated::*, record_payload::RecordPayload, DPC},
Account, AccountScheme, Record, Account,
AccountScheme,
Record,
}; };
use snarkvm_utilities::{bytes::ToBytes, to_bytes}; use snarkvm_utilities::{bytes::ToBytes, to_bytes};
@ -70,11 +72,13 @@ fn test_generate_values_from_dpc() {
let noop_program_snark_pp = let noop_program_snark_pp =
InstantiatedDPC::generate_noop_program_snark_parameters(&system_parameters, &mut rng).unwrap(); InstantiatedDPC::generate_noop_program_snark_parameters(&system_parameters, &mut rng).unwrap();
let noop_program_id = to_bytes![ProgramVerificationKeyCRH::hash( let noop_program_id = to_bytes![
&system_parameters.program_verification_key_crh, ProgramVerificationKeyCRH::hash(
&to_bytes![noop_program_snark_pp.verification_key].unwrap() &system_parameters.program_verification_key_crh,
) &to_bytes![noop_program_snark_pp.verification_key].unwrap()
.unwrap()] )
.unwrap()
]
.unwrap(); .unwrap();
let signature_parameters = &system_parameters.account_signature; let signature_parameters = &system_parameters.account_signature;