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/>.
use crate::{
statement::*, BoolAnd, Expression, Monoid, MonoidalReducerExpression, MonoidalReducerStatement, Node, Span,
statement::*,
BoolAnd,
Expression,
Monoid,
MonoidalReducerExpression,
MonoidalReducerStatement,
Node,
Span,
};
pub struct ReturnPathReducer {

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,16 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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.

View File

@ -111,7 +111,10 @@ impl<'a> Circuit<'a> {
if asg_function.is_test() {
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/>.
use crate::{
AsgConvertError, BlockStatement, Circuit, FromAst, Identifier, MonoidalDirector, ReturnPathReducer, Scope, Span,
Statement, Type, Variable,
AsgConvertError,
BlockStatement,
Circuit,
FromAst,
Identifier,
MonoidalDirector,
ReturnPathReducer,
Scope,
Span,
Statement,
Type,
Variable,
};
use indexmap::IndexMap;
pub use leo_ast::Annotation;

View File

@ -15,8 +15,22 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{
AsgConvertError, CircuitMember, ConstInt, ConstValue, Expression, ExpressionNode, FromAst, Identifier, IntegerType,
Node, PartialType, Scope, Span, Statement, Type, Variable,
AsgConvertError,
CircuitMember,
ConstInt,
ConstValue,
Expression,
ExpressionNode,
FromAst,
Identifier,
IntegerType,
Node,
PartialType,
Scope,
Span,
Statement,
Type,
Variable,
};
pub use leo_ast::AssignOperation;
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/>.
use crate::{
AsgConvertError, Expression, ExpressionNode, FromAst, InnerVariable, Node, PartialType, Scope, Span, Statement,
Type, Variable,
AsgConvertError,
Expression,
ExpressionNode,
FromAst,
InnerVariable,
Node,
PartialType,
Scope,
Span,
Statement,
Type,
Variable,
};
use std::cell::{Cell, RefCell};

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,9 @@
use crate::{common::span::Span, groups::GroupCoordinate};
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};

View File

@ -40,11 +40,7 @@ impl PublicState {
}
pub fn len(&self) -> usize {
if self.state.is_present() {
1usize
} else {
0usize
}
if self.state.is_present() { 1usize } else { 0usize }
}
/// 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/>.
use leo_input::types::{
IntegerType as InputIntegerType, SignedIntegerType as InputSignedIntegerType,
IntegerType as InputIntegerType,
SignedIntegerType as InputSignedIntegerType,
UnsignedIntegerType as InputUnsignedIntegerType,
};

View File

@ -16,7 +16,10 @@
use crate::{ArrayDimensions, Identifier, IntegerType};
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};

View File

@ -19,7 +19,10 @@
use crate::{
constraints::{generate_constraints, generate_test_constraints},
errors::CompilerError,
CompilerOptions, GroupType, OutputBytes, OutputFile,
CompilerOptions,
GroupType,
OutputBytes,
OutputFile,
};
pub use leo_asg::{new_context, AsgContext as Context, AsgContext};
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.
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};

View File

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

View File

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

View File

@ -21,7 +21,9 @@ use crate::{
errors::FunctionError,
program::ConstrainedProgram,
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,
},
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 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.
(_, Some(_), Some(_)) => {
return Err(FunctionError::double_input_declaration(

View File

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

View File

@ -17,7 +17,11 @@
//! Enforces that one return value is produced in a compiled Leo program.
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};

View File

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

View File

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

View File

@ -17,7 +17,11 @@
//! Enforces an iteration statement in a compiled Leo program.
use crate::{
program::ConstrainedProgram, value::ConstrainedValue, GroupType, IndicatorAndConstrainedValue, Integer,
program::ConstrainedProgram,
value::ConstrainedValue,
GroupType,
IndicatorAndConstrainedValue,
Integer,
StatementResult,
};
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 {
if cond {
first.clone()
} else {
second.clone()
}
if cond { first.clone() } else { second.clone() }
}
impl<F: PrimeField> CondSelectGadget<F> for Address {

View File

@ -289,11 +289,7 @@ impl<F: PrimeField> CondSelectGadget<F> for FieldType<F> {
second: &Self,
) -> Result<Self, SynthesisError> {
if let Boolean::Constant(cond) = *cond {
if cond {
Ok(first.clone())
} else {
Ok(second.clone())
}
if cond { Ok(first.clone()) } else { Ok(second.clone()) }
} else {
let first_gadget = first.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::{
edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq},
templates::twisted_edwards_extended::GroupAffine,
AffineCurve, TEModelParameters,
AffineCurve,
TEModelParameters,
};
use snarkvm_fields::{Fp256, One, Zero};
use snarkvm_gadgets::{
@ -481,11 +482,7 @@ impl CondSelectGadget<Fq> for EdwardsGroupType {
second: &Self,
) -> Result<Self, SynthesisError> {
if let Boolean::Constant(cond) = *cond {
if cond {
Ok(first.clone())
} else {
Ok(second.clone())
}
if cond { Ok(first.clone()) } else { Ok(second.clone()) }
} else {
let first_gadget = first.allocated(cs.ns(|| "first"))?;
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},
uint::{UInt128, UInt16, UInt32, UInt64, UInt8},
};
use std::convert::TryInto;
use std::fmt::Debug;
use std::{convert::TryInto, fmt::Debug};
pub trait IntegerTrait: Sized + Clone + Debug {
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/>.
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,
};

View File

@ -15,7 +15,12 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};
use leo_ast::InputValue;

View File

@ -15,7 +15,12 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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;

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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},
parse_program,
};

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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},
parse_program,
};

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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},
parse_program,
};

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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},
parse_program,
};

View File

@ -15,7 +15,10 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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},
parse_program,
};

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};
use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};
use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};
use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};
use leo_ast::InputValue;

View File

@ -15,7 +15,11 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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,
};
use leo_ast::InputValue;

View File

@ -41,7 +41,10 @@ pub mod tuples;
use leo_asg::{new_alloc_context, new_context, AsgContext};
use leo_ast::{InputValue, MainInput};
use leo_compiler::{
compiler::Compiler, errors::CompilerError, group::targets::edwards_bls12::EdwardsGroupType, ConstrainedValue,
compiler::Compiler,
errors::CompilerError,
group::targets::edwards_bls12::EdwardsGroupType,
ConstrainedValue,
OutputBytes,
};
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/>.
use crate::{
assert_satisfied, expect_compiler_error, generate_main_input, generate_test_input_u32, get_output, parse_program,
parse_program_with_input, EdwardsTestCompiler,
assert_satisfied,
expect_compiler_error,
generate_main_input,
generate_test_input_u32,
get_output,
parse_program,
parse_program_with_input,
EdwardsTestCompiler,
};
use leo_ast::InputValue;

View File

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

View File

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

View File

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

View File

@ -23,7 +23,19 @@ pub mod updater;
use commands::{
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;
@ -163,13 +175,10 @@ fn main() {
if !opt.quiet {
// init logger with optional debug flag
logger::init_logger(
"leo",
match opt.debug {
false => 1,
true => 2,
},
);
logger::init_logger("leo", match opt.debug {
false => 1,
true => 2,
});
}
handle_error(match opt.command {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -299,13 +299,10 @@ impl ParserContext {
let member = self.parse_circuit_member()?;
members.push(member);
}
Ok((
name.clone(),
Circuit {
circuit_name: name,
members,
},
))
Ok((name.clone(), Circuit {
circuit_name: name,
members,
}))
}
///
@ -332,7 +329,7 @@ impl ParserContext {
};
if name.name.as_ref() == "self" {
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 {
name.span = &mutable.span + &name.span;
@ -390,16 +387,13 @@ impl ParserContext {
None
};
let block = self.parse_block()?;
Ok((
name.clone(),
Function {
annotations,
identifier: name,
input: inputs,
output,
span: start + block.span.clone(),
block,
},
))
Ok((name.clone(), Function {
annotations,
identifier: name,
input: inputs,
output,
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() {
break;
} else if token_len == 0 {
return Err(TokenError::unexpected_token(
&input[index..index + 1],
&Span {
line_start: line_no,
line_stop: line_no,
col_start: index - line_start + 1,
col_stop: index - line_start + 2,
path,
content: input.subtendril(
line_start as u32,
input[line_start..].find('\n').unwrap_or_else(|| input.len()) as u32,
),
},
));
return Err(TokenError::unexpected_token(&input[index..index + 1], &Span {
line_start: line_no,
line_stop: line_no,
col_start: index - line_start + 1,
col_stop: index - line_start + 2,
path,
content: input.subtendril(
line_start as u32,
input[line_start..].find('\n').unwrap_or_else(|| input.len()) as u32,
),
}));
}
if input.as_bytes()[index] == b'\n' {
line_no += 1;

View File

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