mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-25 18:42:26 +03:00
Merge branch 'master' of github.com:AleoHQ/leo into feature/group-notation
This commit is contained in:
commit
ba6cc019b6
@ -13,24 +13,24 @@ use snarkos_models::curves::{Field, PrimeField};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn store_definitions(&mut self, program: Program, imported_programs: &ImportParser) -> Result<(), ImportError> {
|
||||
let program_name = program.name.clone();
|
||||
let program_name = program.name.trim_end_matches(".leo");
|
||||
|
||||
// evaluate all import statements and store imported definitions
|
||||
program
|
||||
.imports
|
||||
.iter()
|
||||
.map(|import| self.store_import(program_name.clone(), import, imported_programs))
|
||||
.map(|import| self.store_import(program_name.to_owned(), import, imported_programs))
|
||||
.collect::<Result<Vec<_>, ImportError>>()?;
|
||||
|
||||
// evaluate and store all circuit definitions
|
||||
program.circuits.into_iter().for_each(|(identifier, circuit)| {
|
||||
let resolved_circuit_name = new_scope(program_name.clone(), identifier.to_string());
|
||||
let resolved_circuit_name = new_scope(program_name.to_owned(), identifier.to_string());
|
||||
self.store(resolved_circuit_name, ConstrainedValue::CircuitDefinition(circuit));
|
||||
});
|
||||
|
||||
// evaluate and store all function definitions
|
||||
program.functions.into_iter().for_each(|(function_name, function)| {
|
||||
let resolved_function_name = new_scope(program_name.clone(), function_name.to_string());
|
||||
let resolved_function_name = new_scope(program_name.to_owned(), function_name.to_string());
|
||||
self.store(resolved_function_name, ConstrainedValue::Function(None, function));
|
||||
});
|
||||
|
||||
|
@ -10,23 +10,19 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
import: &Import,
|
||||
imported_programs: &ImportParser,
|
||||
) -> Result<(), ImportError> {
|
||||
// get imported program name from import
|
||||
// get imported symbols from from import
|
||||
// fetch dependencies for the current import
|
||||
let imported_symbols = ImportedSymbols::from(import);
|
||||
|
||||
for (package, symbol) in imported_symbols.symbols {
|
||||
// get imported program from hashmap
|
||||
// find imported program
|
||||
let program = imported_programs
|
||||
.get(&package)
|
||||
.ok_or(ImportError::unknown_package(import.package.name.clone()))?;
|
||||
|
||||
// resolve imported program's import statements
|
||||
program
|
||||
.imports
|
||||
.iter()
|
||||
.map(|import| self.store_import(package.clone(), import, imported_programs))
|
||||
.collect::<Result<Vec<()>, ImportError>>()?;
|
||||
// parse imported program
|
||||
self.store_definitions(program.clone(), imported_programs)?;
|
||||
|
||||
// store the imported symbol
|
||||
self.store_symbol(scope.clone(), package, &symbol, program)?;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
symbol: &ImportSymbol,
|
||||
program: &Program,
|
||||
) -> Result<(), ImportError> {
|
||||
// Store the symbol that was imported by another file
|
||||
if symbol.is_star() {
|
||||
// evaluate and store all circuit definitions
|
||||
program.circuits.iter().for_each(|(identifier, circuit)| {
|
||||
|
Loading…
Reference in New Issue
Block a user