imports functioning, next is core imports

This commit is contained in:
gluaxspeed 2021-08-18 06:23:23 -07:00
parent 14a1125d33
commit a75dbe38eb
68 changed files with 199 additions and 608 deletions

View File

@ -1,90 +0,0 @@
// 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/>.
//! Helper methods for resolving imported packages.
use std::marker::PhantomData;
use crate::{AsgContext, Program};
use leo_errors::{Result, Span};
use indexmap::IndexMap;
pub trait ImportResolver<'a> {
fn resolve_package(
&mut self,
context: AsgContext<'a>,
package_segments: &[&str],
span: &Span,
) -> Result<Option<Program<'a>>>;
}
pub struct NullImportResolver;
impl<'a> ImportResolver<'a> for NullImportResolver {
fn resolve_package(
&mut self,
_context: AsgContext<'a>,
_package_segments: &[&str],
_span: &Span,
) -> Result<Option<Program<'a>>> {
Ok(None)
}
}
pub struct CoreImportResolver<'a, 'b, T: ImportResolver<'b>> {
inner: &'a mut T,
lifetime: PhantomData<&'b ()>,
}
impl<'a, 'b, T: ImportResolver<'b>> CoreImportResolver<'a, 'b, T> {
pub fn new(inner: &'a mut T) -> Self {
CoreImportResolver {
inner,
lifetime: PhantomData,
}
}
}
impl<'a, 'b, T: ImportResolver<'b>> ImportResolver<'b> for CoreImportResolver<'a, 'b, T> {
fn resolve_package(
&mut self,
context: AsgContext<'b>,
package_segments: &[&str],
span: &Span,
) -> Result<Option<Program<'b>>> {
if !package_segments.is_empty() && package_segments.get(0).unwrap() == &"core" {
Ok(crate::resolve_core_module(context, &*package_segments[1..].join("."))?)
} else {
self.inner.resolve_package(context, package_segments, span)
}
}
}
pub struct MockedImportResolver<'a> {
pub packages: IndexMap<String, Program<'a>>,
}
impl<'a> ImportResolver<'a> for MockedImportResolver<'a> {
fn resolve_package(
&mut self,
_context: AsgContext<'a>,
package_segments: &[&str],
_span: &Span,
) -> Result<Option<Program<'a>>> {
Ok(self.packages.get(&package_segments.join(".")).cloned())
}
}

View File

@ -35,9 +35,6 @@ pub use const_value::*;
pub mod expression;
pub use expression::*;
pub mod import;
pub use import::*;
mod input;
pub use input::*;
@ -118,7 +115,7 @@ impl<'a> Asg<'a> {
}
// TODO (howardwu): Remove this.
pub fn load_asg<'a, T: ImportResolver<'a>>(
/* pub fn load_asg<'a, T: ImportResolver<'a>>(
context: AsgContext<'a>,
content: &str,
resolver: &mut T,
@ -127,7 +124,7 @@ pub fn load_asg<'a, T: ImportResolver<'a>>(
let ast = leo_parser::parse_ast("input.leo", content)?;
Program::new(context, ast.as_repr())
}
} */
pub fn new_alloc_context<'a>() -> Arena<ArenaNode<'a>> {
Arena::new()

View File

@ -16,13 +16,13 @@
// TODO (protryon): We should merge this with core
use crate::{AsgContext, Program};
use leo_errors::Result;
// use crate::{AsgContext, Program};
// use leo_errors::Result;
// TODO (protryon): Make asg deep copy so we can cache resolved core modules
// TODO (protryon): Figure out how to do headers without bogus returns
pub fn resolve_core_module<'a>(context: AsgContext<'a>, module: &str) -> Result<Option<Program<'a>>> {
/* pub fn resolve_core_module<'a>(context: AsgContext<'a>, module: &str) -> Result<Option<Program<'a>>> {
match module {
"unstable.blake2s" => {
let asg = crate::load_asg(
@ -42,3 +42,4 @@ pub fn resolve_core_module<'a>(context: AsgContext<'a>, module: &str) -> Result<
_ => Ok(None),
}
}
*/

View File

@ -68,20 +68,10 @@ 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_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();
let mut imported_modules: IndexMap<String, Program> = IndexMap::new();
for (name, program) in program.imports.iter() {
let program = Program::new(context, program)?;
// TODO only take the ones specified.
imported_functions.extend(program.functions.clone());
imported_circuits.extend(program.circuits.clone());
imported_global_consts.extend(program.global_consts.clone());
imported_modules.insert(name.clone(), program);
imported_modules.insert(name.clone(), Program::new(context, program)?);
}
let import_scope = match context.arena.alloc(ArenaNode::Scope(Box::new(Scope {
@ -89,9 +79,9 @@ impl<'a> Program<'a> {
id: context.get_id(),
parent_scope: Cell::new(None),
variables: RefCell::new(IndexMap::new()),
functions: RefCell::new(imported_functions),
global_consts: RefCell::new(imported_global_consts),
circuits: RefCell::new(imported_circuits),
functions: RefCell::new(IndexMap::new()),
global_consts: RefCell::new(IndexMap::new()),
circuits: RefCell::new(IndexMap::new()),
function: Cell::new(None),
input: Cell::new(None),
}))) {
@ -113,25 +103,22 @@ impl<'a> Program<'a> {
// Prepare header-like scope entries.
for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = Circuit::init(scope, circuit)?;
scope.circuits.borrow_mut().insert(name.name.to_string(), asg_circuit);
scope.circuits.borrow_mut().insert(name.clone(), asg_circuit);
}
// Second pass for circuit members.
for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = Circuit::init_member(scope, circuit)?;
scope.circuits.borrow_mut().insert(name.name.to_string(), asg_circuit);
scope.circuits.borrow_mut().insert(name.clone(), asg_circuit);
}
for (name, function) in program.functions.iter() {
assert_eq!(name.name, function.identifier.name);
let function = Function::init(scope, function)?;
scope.functions.borrow_mut().insert(name.name.to_string(), function);
scope.functions.borrow_mut().insert(name.clone(), function);
}
for (name, global_const) in program.global_consts.iter() {
@ -159,12 +146,11 @@ impl<'a> Program<'a> {
let mut functions = IndexMap::new();
for (name, function) in program.functions.iter() {
assert_eq!(name.name, function.identifier.name);
let asg_function = *scope.functions.borrow().get(name.name.as_ref()).unwrap();
let asg_function = *scope.functions.borrow().get(name).unwrap();
asg_function.fill_from_ast(function)?;
let name = name.name.to_string();
let name = name.clone();
if functions.contains_key(&name) {
return Err(AsgError::duplicate_function_definition(name, &function.span).into());
@ -175,12 +161,11 @@ impl<'a> Program<'a> {
let mut circuits = IndexMap::new();
for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = *scope.circuits.borrow().get(name.name.as_ref()).unwrap();
let asg_circuit = *scope.circuits.borrow().get(name).unwrap();
asg_circuit.fill_from_ast(circuit)?;
circuits.insert(name.name.to_string(), asg_circuit);
circuits.insert(name.clone(), asg_circuit);
}
Ok(Program {
@ -195,9 +180,9 @@ impl<'a> Program<'a> {
})
}
pub(crate) fn set_core_mapping(&self, mapping: &str) {
/* pub(crate) fn set_core_mapping(&self, mapping: &str) {
for (_, circuit) in self.circuits.iter() {
circuit.core_mapping.replace(Some(mapping.to_string()));
}
}
} */
}

View File

@ -1,15 +0,0 @@
// Copyright (C) 2019-2021 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.

View File

@ -24,7 +24,6 @@ pub mod definition;
pub mod field;
pub mod function;
// pub mod group; // we dont do context-specific type checking for groups
pub mod import;
pub mod integers;
pub mod mutability;
pub mod statements;

View File

@ -24,22 +24,13 @@ mod pass;
const TESTING_FILEPATH: &str = "input.leo";
fn load_asg(program_string: &str) -> Result<Program<'static>, LeoError> {
load_asg_imports(make_test_context(), program_string, &mut NullImportResolver)
load_asg_imports(make_test_context(), program_string)
}
fn load_asg_imports<'a, T: ImportResolver<'a>>(
context: AsgContext<'a>,
program_string: &str,
imports: &mut T,
) -> Result<Program<'a>, LeoError> {
fn load_asg_imports<'a>(context: AsgContext<'a>, program_string: &str) -> Result<Program<'a>, LeoError> {
let mut ast = parse_ast(&TESTING_FILEPATH, program_string)?;
ast.canonicalize()?;
Program::new(context, &ast.as_repr(), imports)
}
fn mocked_resolver(_context: AsgContext<'_>) -> MockedImportResolver<'_> {
let packages = indexmap::IndexMap::new();
MockedImportResolver { packages }
Program::new(context, &ast.as_repr())
}
//convenience function for tests, leaks memory

View File

@ -1,5 +0,0 @@
import test-import.foo as bar;
function main() {
console.assert(bar() == 1u32);
}

View File

@ -1,5 +0,0 @@
import test-import.foo;
function main() {
console.assert(foo() == 1u32);
}

View File

@ -1 +0,0 @@
output/

View File

@ -1,3 +0,0 @@
[package]
name = "bar"
version = "0.1.0"

View File

@ -1,3 +0,0 @@
circuit Bat {
t: u32;
}

View File

@ -1,7 +0,0 @@
circuit Baz {
z: u32;
}
circuit Bazzar {
a: u32;
}

View File

@ -1,3 +0,0 @@
circuit Bar {
r: u32;
}

View File

@ -1 +0,0 @@
output/

View File

@ -1,3 +0,0 @@
[package]
name = "car"
version = "0.1.0"

View File

@ -1,3 +0,0 @@
circuit Car {
c: u32;
}

View File

@ -1,26 +0,0 @@
import test-import.( // local import
Point,
foo,
);
import bar.( // imports directory import
Bar,
baz.(Baz, Bazzar),
bat.bat.Bat,
);
import car.Car; // imports directory import
function main() {
const point = Point { x: 1u32, y: 1u32 };
const foo = foo();
const bar = Bar { r: 1u32 };
const baz = Baz { z: 1u32 };
const bazzar = Bazzar { a: 1u32 };
const bat = Bat { t: 1u32 };
const car = Car { c: 1u32 };
console.assert(car.c == 1u32);
}

View File

@ -1,19 +0,0 @@
import test-import.*; // local import
import bar.*; // imports directory import
import bar.baz.*; // imports directory import
import bar.bat.bat.*; // imports directory import
import car.*; // imports directory import
function main() {
const point = Point { x: 1u32, y: 1u32 };
const foo = foo();
const bar = Bar { r: 1u32 };
const bat = Bat { t: 1u32 };
const baz = Baz { z: 1u32 };
const car = Car { c: 1u32 };
console.assert(car.c == 1u32);
}

View File

@ -1,154 +0,0 @@
// Copyright (C) 2019-2021 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{load_asg, load_asg_imports, make_test_context, mocked_resolver};
#[test]
fn test_basic() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
load_asg(include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("basic.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_multiple() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
load_asg(include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("multiple.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_star() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
load_asg(include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("star.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_alias() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
load_asg(include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("alias.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}
// naming tests
#[test]
fn test_name() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"hello-world".to_string(),
load_asg(include_str!("src/hello-world.leo")).unwrap(),
);
imports
.packages
.insert("a0-f".to_string(), load_asg(include_str!("src/a0-f.leo")).unwrap());
imports
.packages
.insert("a-9".to_string(), load_asg(include_str!("src/a-9.leo")).unwrap());
let program_string = include_str!("names.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}
// more complex tests
#[test]
fn test_many_import() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
load_asg(include_str!("src/test-import.leo")).unwrap(),
);
imports.packages.insert(
"bar".to_string(),
load_asg(include_str!("imports/bar/src/lib.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
load_asg(include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
load_asg(include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.bat.bat".to_string(),
load_asg(include_str!("imports/bar/src/bat/bat.leo")).unwrap(),
);
imports.packages.insert(
"car".to_string(),
load_asg(include_str!("imports/car/src/lib.leo")).unwrap(),
);
let program_string = include_str!("many_import.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_many_import_star() {
let context = make_test_context();
let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
load_asg(include_str!("src/test-import.leo")).unwrap(),
);
imports.packages.insert(
"bar".to_string(),
load_asg(include_str!("imports/bar/src/lib.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
load_asg(include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
load_asg(include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.bat.bat".to_string(),
load_asg(include_str!("imports/bar/src/bat/bat.leo")).unwrap(),
);
imports.packages.insert(
"car".to_string(),
load_asg(include_str!("imports/car/src/lib.leo")).unwrap(),
);
let program_string = include_str!("many_import_star.leo");
load_asg_imports(&context, program_string, &mut imports).unwrap();
}

View File

@ -1,10 +0,0 @@
import test-import.(
Point,
foo
);
function main() {
const a = Point { x: 1u32, y: 0u32 };
console.assert(a.x == 1u32);
}

View File

@ -1,5 +0,0 @@
import a0-f.foo;
import a-9.bar;
import hello-world.hello;
function main() {}

View File

@ -1 +0,0 @@
function bar() {}

View File

@ -1 +0,0 @@
function foo() {}

View File

@ -1 +0,0 @@
function hello() {}

View File

@ -1,8 +0,0 @@
circuit Point {
x: u32;
y: u32;
}
function foo() -> u32 {
return 1u32;
}

View File

@ -1,7 +0,0 @@
import test-import.*;
function main() {
const a = Point { x: 1u32, y: 0u32 };
console.assert(foo() == 1u32);
}

View File

@ -24,7 +24,6 @@ pub mod definition;
pub mod field;
pub mod function;
pub mod group;
pub mod import;
pub mod input_files;
pub mod integers;
pub mod mutability;

View File

@ -17,7 +17,7 @@
//! A Leo program consists of import, circuit, and function definitions.
//! Each defined type consists of ast statements and expressions.
use crate::{Circuit, DefinitionStatement, Function, FunctionInput, Identifier, ImportStatement};
use crate::{Circuit, DefinitionStatement, Function, FunctionInput, ImportStatement};
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
@ -30,9 +30,9 @@ pub struct Program {
pub expected_input: Vec<FunctionInput>,
pub import_statements: Vec<ImportStatement>,
pub imports: IndexMap<String, Program>,
pub circuits: IndexMap<Identifier, Circuit>,
pub circuits: IndexMap<String, Circuit>,
pub global_consts: IndexMap<String, DefinitionStatement>,
pub functions: IndexMap<Identifier, Function>,
pub functions: IndexMap<String, Function>,
}
impl AsRef<Program> for Program {

View File

@ -24,9 +24,6 @@ where
T: ImportResolver,
{
import_resolver: T,
functions_to_import: Vec<(String, Option<String>)>,
circuits_to_import: Vec<(String, Option<String>)>,
global_consts_to_import: Vec<(String, Option<String>)>,
}
impl<T> Importer<T>
@ -34,12 +31,7 @@ where
T: ImportResolver,
{
pub fn new(import_resolver: T) -> Self {
Self {
import_resolver,
functions_to_import: Vec::new(),
circuits_to_import: Vec::new(),
global_consts_to_import: Vec::new(),
}
Self { import_resolver }
}
}
@ -103,7 +95,7 @@ fn resolve_import_package_access(
PackageAccess::Multiple(packages) => {
package_segments.push(packages.name.name.to_string());
for subaccess in packages.accesses.iter() {
resolve_import_package_access(output, package_segments.clone(), &subaccess);
resolve_import_package_access(output, package_segments.clone(), subaccess);
}
}
}
@ -125,12 +117,12 @@ where
expected_input: Vec<FunctionInput>,
import_statements: Vec<ImportStatement>,
empty_imports: IndexMap<String, Program>,
circuits: IndexMap<Identifier, Circuit>,
functions: IndexMap<Identifier, Function>,
global_consts: IndexMap<String, DefinitionStatement>,
mut circuits: IndexMap<String, Circuit>,
mut functions: IndexMap<String, Function>,
mut global_consts: IndexMap<String, DefinitionStatement>,
) -> Result<Program> {
if !empty_imports.is_empty() {
// TODO THROW ERR
// TODO THROW ERROR
}
let mut imported_symbols: Vec<(Vec<String>, ImportSymbol, Span)> = vec![];
@ -149,6 +141,7 @@ where
for (package, span) in deduplicated_imports {
let _pretty_package = package.join(".");
// TODO FIX ERROR
let resolved_package =
match wrapped_resolver.resolve_package(&package.iter().map(|x| &**x).collect::<Vec<_>>()[..], &span)? {
Some(x) => x,
@ -158,35 +151,43 @@ where
resolved_packages.insert(package.clone(), resolved_package);
}
// TODO Errors
// TODO ERROR
// TODO copyable AST.
// TODO should imports be renamed in imported program?
for (package, symbol, span) in imported_symbols.into_iter() {
let _pretty_package = package.join(".");
let resolved_package = resolved_packages
.get_mut(&package)
.expect("could not find preloaded package");
match symbol {
ImportSymbol::Alias(name, alias) => {
let lookup_ident = Identifier::new(name.clone().into());
if let Some((ident, function)) = resolved_package.functions.remove_entry(&lookup_ident) {
let mut alias_identifier = ident.clone();
alias_identifier.name = alias.into();
resolved_package.functions.insert(alias_identifier, function.clone());
} else if let Some((ident, circuit)) = resolved_package.circuits.remove_entry(&lookup_ident) {
let mut alias_identifier = ident.clone();
alias_identifier.name = alias.into();
resolved_package.circuits.insert(alias_identifier, circuit.clone());
} else if let Some(global_const) = resolved_package.global_consts.remove(&name) {
resolved_package
.global_consts
.insert(alias.clone(), global_const.clone());
ImportSymbol::All => {
functions.extend(resolved_package.functions.clone().into_iter());
circuits.extend(resolved_package.circuits.clone().into_iter());
global_consts.extend(resolved_package.global_consts.clone().into_iter());
}
ImportSymbol::Direct(name) => {
if let Some(function) = resolved_package.functions.get(&name) {
functions.insert(name.clone(), function.clone());
} else if let Some(circuit) = resolved_package.circuits.get(&name) {
circuits.insert(name.clone(), circuit.clone());
} else if let Some(global_const) = resolved_package.global_consts.get(&name) {
global_consts.insert(name.clone(), global_const.clone());
} else {
return Err(AstError::empty_string(&span).into());
}
}
ImportSymbol::Alias(name, alias) => {
if let Some(function) = resolved_package.functions.get(&name) {
functions.insert(alias.clone(), function.clone());
} else if let Some(circuit) = resolved_package.circuits.get(&name) {
circuits.insert(alias.clone(), circuit.clone());
} else if let Some(global_const) = resolved_package.global_consts.get(&name) {
global_consts.insert(alias.clone(), global_const.clone());
} else {
return Err(AstError::empty_string(&span).into());
}
}
_ => {}
}
}

View File

@ -428,14 +428,14 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
let mut circuits = IndexMap::new();
self.reducer.swap_in_circuit();
for (identifier, circuit) in program.circuits.iter() {
circuits.insert(self.reduce_identifier(identifier)?, self.reduce_circuit(circuit)?);
for (name, circuit) in program.circuits.iter() {
circuits.insert(name.clone(), self.reduce_circuit(circuit)?);
}
self.reducer.swap_in_circuit();
let mut functions = IndexMap::new();
for (identifier, function) in program.functions.iter() {
functions.insert(self.reduce_identifier(identifier)?, self.reduce_function(function)?);
for (name, function) in program.functions.iter() {
functions.insert(name.clone(), self.reduce_function(function)?);
}
let mut global_consts = IndexMap::new();

View File

@ -374,6 +374,7 @@ pub trait ReconstructingReducer {
})
}
#[allow(clippy::too_many_arguments)]
// Program
fn reduce_program(
&mut self,
@ -381,8 +382,8 @@ pub trait ReconstructingReducer {
expected_input: Vec<FunctionInput>,
import_statements: Vec<ImportStatement>,
imports: IndexMap<String, Program>,
circuits: IndexMap<Identifier, Circuit>,
functions: IndexMap<Identifier, Function>,
circuits: IndexMap<String, Circuit>,
functions: IndexMap<String, Function>,
global_consts: IndexMap<String, DefinitionStatement>,
) -> Result<Program> {
Ok(Program {

View File

@ -242,6 +242,10 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
// Preform import resolution.
ast.importer(leo_imports::ImportParser::new(self.main_file_path.clone()))?;
if self.ast_snapshot_options.imports_resolved {
ast.to_json_file(self.output_directory.clone(), "imports_resolved.json")?;
}
// Preform canonicalization of AST always.
ast.canonicalize()?;

View File

@ -38,6 +38,7 @@ impl Default for CompilerOptions {
#[derive(Clone)]
pub struct AstSnapshotOptions {
pub initial: bool,
pub imports_resolved: bool,
pub canonicalized: bool,
pub type_inferenced: bool,
}
@ -46,6 +47,7 @@ impl Default for AstSnapshotOptions {
fn default() -> Self {
Self {
initial: false,
imports_resolved: false,
canonicalized: false,
type_inferenced: false,
}

View File

@ -88,6 +88,7 @@ struct CompileOutput {
pub circuit: SummarizedCircuit,
pub output: Vec<OutputItem>,
pub initial_ast: String,
pub imports_resolved_ast: String,
pub canonicalized_ast: String,
pub type_inferenced_ast: String,
}
@ -113,6 +114,7 @@ impl Namespace for CompileNamespace {
&test.content,
Some(AstSnapshotOptions {
initial: true,
imports_resolved: true,
canonicalized: true,
type_inferenced: true,
}),
@ -209,19 +211,25 @@ impl Namespace for CompileNamespace {
let initial_ast: String = hash(
Ast::from_json_file("/tmp/output/initial_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading initial theorem.".to_string())))
.unwrap_or_else(|_| Ast::new(Program::new("Error reading initial snapshot.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
let imports_resolved_ast: String = hash(
Ast::from_json_file("/tmp/output/imports_resolved_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading imports resolved snapshot.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
let canonicalized_ast: String = hash(
Ast::from_json_file("/tmp/output/canonicalization_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading canonicalized theorem.".to_string())))
.unwrap_or_else(|_| Ast::new(Program::new("Error reading canonicalized snapshot.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
let type_inferenced_ast = hash(
Ast::from_json_file("/tmp/output/type_inferenced_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading type inferenced theorem.".to_string())))
.unwrap_or_else(|_| Ast::new(Program::new("Error reading type inferenced snapshot.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
@ -234,6 +242,7 @@ impl Namespace for CompileNamespace {
circuit: last_circuit.unwrap(),
output: output_items,
initial_ast,
imports_resolved_ast,
canonicalized_ast,
type_inferenced_ast,
};

View File

@ -15,7 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::ImportParser;
use leo_ast::{Identifier, ImportResolver, Program};
use leo_ast::Program;
use leo_errors::{ImportError, Result, Span};
use std::{fs, fs::DirEntry, path::PathBuf};

View File

@ -47,6 +47,8 @@ pub struct BuildOptions {
pub enable_all_ast_snapshots: bool,
#[structopt(long, help = "Writes AST snapshot of the initial parse.")]
pub enable_initial_ast_snapshot: bool,
#[structopt(long, help = "Writes AST snapshot after the import resolution phase.")]
pub enable_imports_resolved_ast_snapshot: bool,
#[structopt(long, help = "Writes AST snapshot after the canonicalization phase.")]
pub enable_canonicalized_ast_snapshot: bool,
#[structopt(long, help = "Writes AST snapshot after the type inference phase.")]
@ -61,6 +63,7 @@ impl Default for BuildOptions {
disable_all_optimizations: true,
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,
}
@ -88,12 +91,14 @@ impl From<BuildOptions> for AstSnapshotOptions {
if options.enable_all_ast_snapshots {
AstSnapshotOptions {
initial: true,
imports_resolved: true,
canonicalized: true,
type_inferenced: true,
}
} else {
AstSnapshotOptions {
initial: options.enable_initial_ast_snapshot,
imports_resolved: options.enable_imports_resolved_ast_snapshot,
canonicalized: options.enable_canonicalized_ast_snapshot,
type_inferenced: options.enable_type_inferenced_ast_snapshot,
}

View File

@ -402,14 +402,14 @@ impl ParserContext {
/// Returns an [`(Identifier, Circuit)`] tuple of AST nodes if the next tokens represent a
/// circuit name and definition statement.
///
pub fn parse_circuit(&mut self) -> Result<(Identifier, Circuit)> {
pub fn parse_circuit(&mut self) -> Result<(String, Circuit)> {
self.expect(Token::Circuit)?;
let name = self.expect_ident()?;
self.expect(Token::LeftCurly)?;
let members = self.parse_circuit_declaration()?;
Ok((
name.clone(),
name.name.to_string(),
Circuit {
circuit_name: name,
members,
@ -466,7 +466,7 @@ impl ParserContext {
/// Returns an [`(Identifier, Function)`] AST node if the next tokens represent a function name
/// and function definition.
///
pub fn parse_function_declaration(&mut self) -> Result<(Identifier, Function)> {
pub fn parse_function_declaration(&mut self) -> Result<(String, Function)> {
let mut annotations = Vec::new();
while self.peek_token().as_ref() == &Token::At {
annotations.push(self.parse_annotation()?);
@ -490,7 +490,7 @@ impl ParserContext {
};
let block = self.parse_block()?;
Ok((
name.clone(),
name.name.to_string(),
Function {
annotations,
identifier: name,

View File

@ -1,15 +1,18 @@
{
"name": "",
"expected_input": [],
"imports": [],
"import_statements": [],
"imports": {},
"circuits": {},
"global_consts": {},
"functions": {
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": {
"main": {
"annotations": [],
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\",\\\"content\\\":\\\"function main() {\\\"}\"}",
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"C:\\\\\\\\Users\\\\\\\\jonat\\\\\\\\AppData\\\\\\\\Roaming\\\\\\\\work\\\\\\\\tester\\\\\\\\src/main.leo\\\",\\\"content\\\":\\\"function main() -> u8 {\\\"}\"}",
"input": [],
"output": null,
"output": {
"IntegerType": "U8"
},
"block": {
"statements": [
{
@ -18,30 +21,32 @@
"Binary": {
"left": {
"Value": {
"Implicit": [
"Integer": [
"U8",
"1",
{
"line_start": 2,
"line_stop": 2,
"col_start": 12,
"col_stop": 13,
"path": "test",
"content": " return 1 + 1"
"col_stop": 15,
"path": "C:\\Users\\jonat\\AppData\\Roaming\\work\\tester\\src/main.leo",
"content": " return 1u8 + 1u8;"
}
]
}
},
"right": {
"Value": {
"Implicit": [
"Integer": [
"U8",
"1",
{
"line_start": 2,
"line_stop": 2,
"col_start": 16,
"col_stop": 17,
"path": "test",
"content": " return 1 + 1"
"col_start": 18,
"col_stop": 21,
"path": "C:\\Users\\jonat\\AppData\\Roaming\\work\\tester\\src/main.leo",
"content": " return 1u8 + 1u8;"
}
]
}
@ -51,9 +56,9 @@
"line_start": 2,
"line_stop": 2,
"col_start": 12,
"col_stop": 17,
"path": "test",
"content": " return 1 + 1"
"col_stop": 21,
"path": "C:\\Users\\jonat\\AppData\\Roaming\\work\\tester\\src/main.leo",
"content": " return 1u8 + 1u8;"
}
}
},
@ -61,9 +66,9 @@
"line_start": 2,
"line_stop": 2,
"col_start": 5,
"col_stop": 17,
"path": "test",
"content": " return 1 + 1"
"col_stop": 21,
"path": "C:\\Users\\jonat\\AppData\\Roaming\\work\\tester\\src/main.leo",
"content": " return 1u8 + 1u8;"
}
}
}
@ -71,10 +76,10 @@
"span": {
"line_start": 1,
"line_stop": 3,
"col_start": 17,
"col_start": 23,
"col_stop": 2,
"path": "test",
"content": "function main() {\n...\n}"
"path": "C:\\Users\\jonat\\AppData\\Roaming\\work\\tester\\src/main.leo",
"content": "function main() -> u8 {\n ...\n}"
}
},
"span": {
@ -82,8 +87,8 @@
"line_stop": 3,
"col_start": 1,
"col_stop": 2,
"path": "test",
"content": "function main() {\n...\n}"
"path": "C:\\Users\\jonat\\AppData\\Roaming\\work\\tester\\src/main.leo",
"content": "function main() -> u8 {\n ...\n}"
}
}
}

View File

@ -1,3 +1,3 @@
function main() {
return 1 + 1;
return 1u8 + 1u8;
}

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members:
- CircuitFunction:

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members: []
global_consts: {}

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members:
- CircuitVariable:

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members:
- CircuitVariable:

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members:
- CircuitFunction:

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members:
- CircuitFunction:

View File

@ -4,9 +4,10 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits:
"{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}":
X:
circuit_name: "{\"name\":\"X\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit X {\\\"}\"}"
members:
- CircuitFunction:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
x:
annotations:
- span:
line_start: 3

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
x:
annotations:
- span:
line_start: 3

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
x:
annotations:
- span:
line_start: 3

View File

@ -4,76 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}":
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}"
input:
- Variable:
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}"
const_: false
mutable: true
type_:
IntegerType: U32
span:
line_start: 3
line_stop: 3
col_start: 12
col_stop: 13
path: ""
content: "function x(x: u32, const y: i32) {"
- Variable:
identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}"
const_: true
mutable: false
type_:
IntegerType: I32
span:
line_start: 3
line_stop: 3
col_start: 26
col_stop: 27
path: ""
content: "function x(x: u32, const y: i32) {"
output: ~
block:
statements:
- Return:
expression:
TupleInit:
elements: []
span:
line_start: 4
line_stop: 4
col_start: 12
col_stop: 14
path: ""
content: " return ();"
span:
line_start: 4
line_stop: 4
col_start: 5
col_stop: 14
path: ""
content: " return ();"
span:
line_start: 3
line_stop: 5
col_start: 34
col_stop: 2
path: ""
content: "function x(x: u32, const y: i32) {\n ...\n}"
span:
line_start: 3
line_stop: 5
col_start: 1
col_stop: 2
path: ""
content: "function x(x: u32, const y: i32) {\n ...\n}"
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const self) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const self) {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {\\\"}\"}"
input: []

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {}\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() {}\\\"}\"}"
input: []

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; 12]) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: [u8; 12]) {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: MyCircuit) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: MyCircuit) {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: (u32, i32)) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: (u32, i32)) {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) -> u32 {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, y: i32) -> u32 {\\\"}\"}"
input:

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> u32 {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> u32 {\\\"}\"}"
input: []

View File

@ -4,11 +4,12 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports: []
import_statements: []
imports: {}
circuits: {}
global_consts: {}
functions:
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> (u32, u32) {\\\"}\"}":
x:
annotations: []
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x() -> (u32, u32) {\\\"}\"}"
input: []

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Package:
name: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":9,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import a.b as bar;\\\"}\"}"
@ -33,6 +33,7 @@ outputs:
col_stop: 18
path: ""
content: import a.b as bar;
imports: {}
circuits: {}
global_consts: {}
functions: {}

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Package:
name: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":9,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import a.b;\\\"}\"}"
@ -33,6 +33,7 @@ outputs:
col_stop: 11
path: ""
content: import a.b;
imports: {}
circuits: {}
global_consts: {}
functions: {}

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Packages:
name: "{\"name\":\"test-import\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import test-import.( // local import\\\"}\"}"
@ -131,6 +131,7 @@ outputs:
col_stop: 16
path: ""
content: "import bar.( // imports directory import\n ...\n ...\n bat.bat.Bat,"
imports: {}
circuits: {}
global_consts: {}
functions: {}

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Package:
name: "{\"name\":\"test-import\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import test-import.*; // local import\\\"}\"}"
@ -165,6 +165,7 @@ outputs:
col_stop: 13
path: ""
content: import car.*; // imports directory import
imports: {}
circuits: {}
global_consts: {}
functions: {}

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Package:
name: "{\"name\":\"a0-f\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import a0-f.foo;\\\"}\"}"
@ -89,6 +89,7 @@ outputs:
col_stop: 25
path: ""
content: import hello-world.hello;
imports: {}
circuits: {}
global_consts: {}
functions: {}

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Package:
name: "{\"name\":\"hello_world\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import hello_world.foo;\\\"}\"}"
@ -33,6 +33,7 @@ outputs:
col_stop: 23
path: ""
content: import hello_world.foo;
imports: {}
circuits: {}
global_consts: {}
functions: {}

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
imports:
import_statements:
- package_or_packages:
Package:
name: "{\"name\":\"test-import\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":8,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"import test-import.*;\\\"}\"}"
@ -31,6 +31,7 @@ outputs:
col_stop: 21
path: ""
content: import test-import.*;
imports: {}
circuits: {}
global_consts: {}
functions: {}