diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000000..d758e2dadd
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,163 @@
+version: 2.1
+commands:
+ setup_environment:
+ description: "Setup environment"
+ parameters:
+ cache_key:
+ type: string
+ default: leo-stable-cache
+ steps:
+ - run: set -e
+ - setup_remote_docker
+ - run:
+ name: Prepare environment and install dependencies
+ command: |
+ export SCCACHE_CACHE_SIZE=200M
+ export WORK_DIR="$CIRCLE_WORKING_DIRECTORY/.cache/sccache"
+ export SCCACHE_DIR="$CIRCLE_WORKING_DIRECTORY/.cache/sccache"
+ mkdir -p "$CIRCLE_WORKING_DIRECTORY/.bin"
+ wget https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
+ tar -C "$CIRCLE_WORKING_DIRECTORY/.bin" -xvf sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
+ mv $CIRCLE_WORKING_DIRECTORY/.bin/sccache-0.2.13-x86_64-unknown-linux-musl/sccache $CIRCLE_WORKING_DIRECTORY/.bin/sccache
+ export PATH="$PATH:$CIRCLE_WORKING_DIRECTORY/.bin"
+ export RUSTC_WRAPPER="sccache"
+ rm -rf "$CIRCLE_WORKING_DIRECTORY/.cargo/registry"
+ sudo apt-get update && sudo apt-get install -y clang llvm-dev llvm pkg-config xz-utils make libssl-dev libssl-dev
+ - restore_cache:
+ keys:
+ - << parameters.cache_key >>
+ clear_environment:
+ description: "Clear environment"
+ parameters:
+ cache_key:
+ type: string
+ default: leo-stable-cache
+ steps:
+ - run: (sccache -s||true)
+ - run: set +e
+ - save_cache:
+ key: << parameters.cache_key >>
+ paths:
+ - .cache/sccache
+ - .cargo
+jobs:
+
+ rust-stable:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - checkout
+ - setup_environment:
+ cache_key: leo-stable-cache
+ - run:
+ name: Build and run tests
+ no_output_timeout: 30m
+ command: cargo install --path . --root .
+ - persist_to_workspace:
+ root: ~/
+ paths: project/
+ - clear_environment:
+ cache_key: leo-stable-cache
+
+ leo-new:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - attach_workspace:
+ at: /home/circleci/project/
+ - run:
+ name: leo new
+ command: |
+ export LEO=/home/circleci/project/project/bin/leo
+ ./project/.circleci/leo-new.sh
+
+ leo-init:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - attach_workspace:
+ at: /home/circleci/project/
+ - run:
+ name: leo init
+ command: |
+ export LEO=/home/circleci/project/project/bin/leo
+ ./project/.circleci/leo-init.sh
+
+ leo-clean:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - attach_workspace:
+ at: /home/circleci/project/
+ - run:
+ name: leo clean
+ command: |
+ export LEO=/home/circleci/project/project/bin/leo
+ ./project/.circleci/leo-clean.sh
+
+ leo-setup:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - attach_workspace:
+ at: /home/circleci/project/
+ - run:
+ name: leo setup
+ command: |
+ export LEO=/home/circleci/project/project/bin/leo
+ ./project/.circleci/leo-setup.sh
+
+ leo-add-remove:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - attach_workspace:
+ at: /home/circleci/project/
+ - run:
+ name: leo add & remove
+ command: |
+ export LEO=/home/circleci/project/project/bin/leo
+ ./project/.circleci/leo-add-remove.sh
+
+ leo-login-logout:
+ docker:
+ - image: cimg/rust:1.50.0
+ resource_class: xlarge
+ steps:
+ - attach_workspace:
+ at: /home/circleci/project/
+ - run:
+ name: leo login & logout
+ command: |
+ export LEO=/home/circleci/project/project/bin/leo
+ ./project/.circleci/leo-login-logout.sh
+
+workflows:
+ version: 2
+ main-workflow:
+ jobs:
+ - rust-stable
+ - leo-new:
+ requires:
+ - rust-stable
+ - leo-init:
+ requires:
+ - rust-stable
+ - leo-clean:
+ requires:
+ - rust-stable
+ - leo-setup:
+ requires:
+ - rust-stable
+ - leo-add-remove:
+ requires:
+ - rust-stable
+ - leo-login-logout:
+ requires:
+ - rust-stable
\ No newline at end of file
diff --git a/.circleci/leo-add-remove.sh b/.circleci/leo-add-remove.sh
new file mode 100755
index 0000000000..e7eb352934
--- /dev/null
+++ b/.circleci/leo-add-remove.sh
@@ -0,0 +1,6 @@
+# leo add (w/o login) & remove
+
+$LEO new my-app && cd my-app
+$LEO add howard/silly-sudoku
+$LEO remove silly-sudoku
+$LEO clean
diff --git a/.circleci/leo-clean.sh b/.circleci/leo-clean.sh
new file mode 100755
index 0000000000..46bd90880c
--- /dev/null
+++ b/.circleci/leo-clean.sh
@@ -0,0 +1,34 @@
+# leo new hello-world
+
+$LEO new hello-world
+ls -la
+cd hello-world && ls -la
+$LEO run
+
+# Assert that the 'outputs' folder is not empty
+
+cd outputs || exit 1
+if [ "$(ls -A $DIR)" ]; then
+ echo "$DIR is not empty"
+else
+ echo "$DIR is empty"
+ exit 1
+fi
+cd ..
+
+# leo clean
+
+$LEO clean
+cd outputs && ls -la
+cd ..
+
+# Assert that the 'outputs' folder is empty
+
+cd outputs || exit 1
+if [ "$(ls -A $DIR)" ]; then
+ echo "$DIR is not empty"
+ exit 1
+else
+ echo "$DIR is empty"
+ exit 0
+fi
diff --git a/.circleci/leo-init.sh b/.circleci/leo-init.sh
new file mode 100755
index 0000000000..ab7724cd4a
--- /dev/null
+++ b/.circleci/leo-init.sh
@@ -0,0 +1,4 @@
+mkdir hello-world && cd hello-world || exit 1
+$LEO init
+ls -la
+$LEO run
diff --git a/.circleci/leo-login-logout.sh b/.circleci/leo-login-logout.sh
new file mode 100755
index 0000000000..1353b18d72
--- /dev/null
+++ b/.circleci/leo-login-logout.sh
@@ -0,0 +1,7 @@
+# leo login & logout
+
+$LEO new my-app && cd my-app || exit 1
+$LEO login -u "$ALEO_PM_USERNAME" -p "$ALEO_PM_PASSWORD"
+$LEO add howard/silly-sudoku
+$LEO remove silly-sudoku
+$LEO logout
diff --git a/.circleci/leo-new.sh b/.circleci/leo-new.sh
new file mode 100755
index 0000000000..cb24618546
--- /dev/null
+++ b/.circleci/leo-new.sh
@@ -0,0 +1,4 @@
+$LEO new hello-world
+ls -la
+cd hello-world && ls -la
+$LEO run
diff --git a/.circleci/leo-setup.sh b/.circleci/leo-setup.sh
new file mode 100755
index 0000000000..ae6e23803f
--- /dev/null
+++ b/.circleci/leo-setup.sh
@@ -0,0 +1,7 @@
+# leo setup
+
+cd ./project/examples/pedersen-hash || exit 1
+$LEO setup
+$LEO setup
+$LEO setup --skip-key-check
+$LEO clean
diff --git a/.github/workflows/leo-add-remove.yml b/.github/workflows/leo-add-remove.yml
deleted file mode 100644
index 8a0912ba96..0000000000
--- a/.github/workflows/leo-add-remove.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-name: leo-add-remove
-on:
- pull_request:
- push:
- branches:
- - master
- paths-ignore:
- - 'docs/**'
- - 'documentation/**'
-env:
- RUST_BACKTRACE: 1
-
-jobs:
- add:
- name: Add Package ('leo add')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly
- override: true
- components: rustfmt
-
- - name: Install Leo
- uses: actions-rs/cargo@v1
- env:
- CARGO_NET_GIT_FETCH_WITH_CLI: true
- with:
- command: install
- args: --path .
-
- - name: 'leo add (w/o login) & remove'
- run: |
- cd .. && leo new my-app && cd my-app
- leo add argus4130/xnor
- leo remove xnor
- leo clean
-
diff --git a/.github/workflows/leo-clean.yml b/.github/workflows/leo-clean.yml
deleted file mode 100644
index 177ed73fdc..0000000000
--- a/.github/workflows/leo-clean.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-name: leo-clean
-on:
- pull_request:
- push:
- branches:
- - master
- paths-ignore:
- - 'docs/**'
- - 'documentation/**'
-env:
- RUST_BACKTRACE: 1
-
-jobs:
- new:
- name: Hello Leo ('leo new hello-world')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly
- override: true
- components: rustfmt
-
- - uses: actions/cache@v2
- with:
- path: |
- ~/.cargo/registry
- ~/.cargo/git
- target
- key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
- - name: Install Leo
- uses: actions-rs/cargo@v1
- with:
- command: install
- args: --path .
-
- - name: 'leo new hello-world'
- run: |
- cd ..
- leo new hello-world
- ls -la
- cd hello-world && ls -la
- leo run
-
- - name: Assert that the 'outputs' folder is not empty
- run: |
- cd ../hello-world/outputs
- if [ "$(ls -A $DIR)" ]; then
- echo "$DIR is not empty"
- else
- echo "$DIR is empty"
- exit 1
- fi
-
- - name: 'leo clean'
- run: |
- cd ../hello-world
- leo clean
- cd outputs && ls -la
-
- - name: Assert that the 'outputs' folder is empty
- run: |
- cd ../hello-world/outputs
- if [ "$(ls -A $DIR)" ]; then
- echo "$DIR is not empty"
- exit 1
- else
- echo "$DIR is empty"
- exit 0
- fi
diff --git a/.github/workflows/leo-init.yml b/.github/workflows/leo-init.yml
deleted file mode 100644
index 1821d1de86..0000000000
--- a/.github/workflows/leo-init.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-name: leo-init
-on:
- pull_request:
- push:
- branches:
- - master
- paths-ignore:
- - 'docs/**'
- - 'documentation/**'
-env:
- RUST_BACKTRACE: 1
-
-jobs:
- init:
- name: Hello Leo ('leo init')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly
- override: true
- components: rustfmt
-
- - uses: actions/cache@v2
- with:
- path: |
- ~/.cargo/registry
- ~/.cargo/git
- target
- key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
- - name: Install Leo
- uses: actions-rs/cargo@v1
- with:
- command: install
- args: --path .
-
- - name: 'leo init'
- run: |
- cd .. && mkdir hello-world && cd hello-world
- leo init
- ls -la
- leo run
diff --git a/.github/workflows/leo-login-logout.yml b/.github/workflows/leo-login-logout.yml
deleted file mode 100644
index 95a17e42ed..0000000000
--- a/.github/workflows/leo-login-logout.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-name: leo-login-logout
-on:
- pull_request:
- push:
- branches:
- - master
- paths-ignore:
- - 'docs/**'
- - 'documentation/**'
-env:
- RUST_BACKTRACE: 1
-
-jobs:
- add:
- name: Add Package ('leo add')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly
- override: true
- components: rustfmt
-
- - name: Install Leo
- uses: actions-rs/cargo@v1
- env:
- CARGO_NET_GIT_FETCH_WITH_CLI: true
- with:
- command: install
- args: --path .
-
- - name: 'leo login & logout'
- env:
- USER: ${{ secrets.ALEO_PM_USERNAME }}
- PASS: ${{ secrets.ALEO_PM_PASSWORD }}
- run: |
- cd .. && leo new my-app && cd my-app
- leo login -u "$USER" -p "$PASS"
- leo add argus4130/xnor
- leo remove xnor
- leo logout
-
diff --git a/.github/workflows/leo-new.yml b/.github/workflows/leo-new.yml
deleted file mode 100644
index 842d553897..0000000000
--- a/.github/workflows/leo-new.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-name: leo-new
-on:
- pull_request:
- push:
- branches:
- - master
- paths-ignore:
- - 'docs/**'
- - 'documentation/**'
-env:
- RUST_BACKTRACE: 1
-
-jobs:
- new:
- name: Hello Leo ('leo new hello-world')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly
- override: true
- components: rustfmt
-
- - uses: actions/cache@v2
- with:
- path: |
- ~/.cargo/registry
- ~/.cargo/git
- target
- key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
- - name: Install Leo
- uses: actions-rs/cargo@v1
- with:
- command: install
- args: --path .
-
- - name: 'leo new hello-world'
- run: |
- cd ..
- leo new hello-world
- ls -la
- cd hello-world && ls -la
- leo run
diff --git a/.github/workflows/leo-setup.yml b/.github/workflows/leo-setup.yml
deleted file mode 100644
index 7bad2924c2..0000000000
--- a/.github/workflows/leo-setup.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-name: leo-setup
-on:
- pull_request:
- push:
- branches:
- - master
- paths-ignore:
- - 'docs/**'
- - 'documentation/**'
-env:
- RUST_BACKTRACE: 1
-
-jobs:
- add:
- name: Add Package ('leo add')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Install Rust
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: nightly
- override: true
- components: rustfmt
-
- - name: Install Leo
- uses: actions-rs/cargo@v1
- env:
- CARGO_NET_GIT_FETCH_WITH_CLI: true
- with:
- command: install
- args: --path .
-
- - name: 'leo setup for examples'
- env:
- USER: ${{ secrets.ALEO_PM_USERNAME }}
- PASS: ${{ secrets.ALEO_PM_PASSWORD }}
- run: |
- cd examples/pedersen-hash
- leo setup
- leo setup
- leo setup --skip-key-check
- leo clean
-
diff --git a/.gitignore b/.gitignore
index 169d72f25d..f9e224d6a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,9 @@
/tmp/
**.idea/
*.DS_Store
+
+**/process.yml
+
+**/.crates.toml
+**/.crates2.json
+**/bin/
diff --git a/.resources/leo.png b/.resources/banner.png
similarity index 100%
rename from .resources/leo.png
rename to .resources/banner.png
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
new file mode 100644
index 0000000000..357d549c32
--- /dev/null
+++ b/DEVELOPMENT.md
@@ -0,0 +1,31 @@
+# Development Guide
+
+## Running CircleCI locally
+
+### Step 1: Install CircleCI
+
+If you wish to run CircleCI locally, start by installing it:
+
+- macOS
+```
+brew install circleci
+```
+
+- Linux (via Snap)
+```
+sudo snap install docker circleci
+sudo snap connect circleci:docker docker
+```
+
+- Windows (via Chocolatey)
+```
+choco install circleci-cli -y
+```
+
+### Step 2: Run CircleCI
+
+To run a job, export the config to `process.yml`, and specify it when executing:
+```shell
+circleci config process .circleci/config.yml > process.yml
+circleci local execute -c process.yml --job JOB_NAME
+```
diff --git a/README.md b/README.md
index ca19dd7fe9..e09580624c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
The Leo Programming Language
@@ -27,6 +27,7 @@ Leo is a functional, statically-typed programming language built for writing pri
## 1. Overview
+
Welcome to the Leo programming language.
Leo provides a high-level language that abstracts low-level cryptographic concepts and makes it easy to
diff --git a/asg/tests/mod.rs b/asg/tests/mod.rs
index 1eb54e4854..8135675649 100644
--- a/asg/tests/mod.rs
+++ b/asg/tests/mod.rs
@@ -40,7 +40,7 @@ fn load_asg_imports<'a, T: ImportResolver<'a>>(
InternalProgram::new(context, &ast.as_repr(), imports)
}
-fn mocked_resolver<'a>(_ctx: AsgContext<'a>) -> MockedImportResolver<'a> {
+fn mocked_resolver<'a>(_context: AsgContext<'a>) -> MockedImportResolver<'a> {
let packages = indexmap::IndexMap::new();
MockedImportResolver { packages }
}
diff --git a/asg/tests/pass/form_ast.rs b/asg/tests/pass/form_ast.rs
index 5248b0ecf9..15ba86942b 100644
--- a/asg/tests/pass/form_ast.rs
+++ b/asg/tests/pass/form_ast.rs
@@ -25,8 +25,8 @@ use std::path::Path;
#[test]
fn test_basic() {
let program_string = include_str!("./circuits/pedersen_mock.leo");
- let ctx = new_context();
- let asg = load_asg(&ctx, program_string).unwrap();
+ let context = new_context();
+ let asg = load_asg(&context, program_string).unwrap();
let reformed_ast = leo_asg::reform_ast(&asg);
println!("{}", reformed_ast);
// panic!();
@@ -51,8 +51,8 @@ fn test_function_rename() {
console.assert(total == 20);
}
"#;
- let ctx = new_context();
- let asg = load_asg(&ctx, program_string).unwrap();
+ let context = new_context();
+ let asg = load_asg(&context, program_string).unwrap();
let reformed_ast = leo_asg::reform_ast(&asg);
println!("{}", reformed_ast);
// panic!();
@@ -60,8 +60,8 @@ fn test_function_rename() {
#[test]
fn test_imports() {
- let ctx = new_context();
- let mut imports = crate::mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = crate::mocked_resolver(&context);
let test_import = r#"
circuit Point {
x: u32
@@ -74,7 +74,7 @@ fn test_imports() {
"#;
imports
.packages
- .insert("test-import".to_string(), load_asg(&ctx, test_import).unwrap());
+ .insert("test-import".to_string(), load_asg(&context, test_import).unwrap());
let program_string = r#"
import test-import.foo;
@@ -95,7 +95,7 @@ fn test_imports() {
serde_json::to_string(Ast::new("test", &test_grammar).unwrap().as_repr()).unwrap()
);
- let asg = crate::load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ let asg = crate::load_asg_imports(&context, program_string, &mut imports).unwrap();
let reformed_ast = leo_asg::reform_ast(&asg);
println!("{}", serde_json::to_string(&reformed_ast).unwrap());
// panic!();
diff --git a/asg/tests/pass/import/mod.rs b/asg/tests/pass/import/mod.rs
index b7ecea72c2..176f806658 100644
--- a/asg/tests/pass/import/mod.rs
+++ b/asg/tests/pass/import/mod.rs
@@ -20,138 +20,139 @@ use crate::{load_asg, load_asg_imports, mocked_resolver};
#[test]
fn test_basic() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
- load_asg(&ctx, include_str!("src/test-import.leo")).unwrap(),
+ load_asg(&context, include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("basic.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_multiple() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
- load_asg(&ctx, include_str!("src/test-import.leo")).unwrap(),
+ load_asg(&context, include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("multiple.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_star() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
- load_asg(&ctx, include_str!("src/test-import.leo")).unwrap(),
+ load_asg(&context, include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("star.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_alias() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
- load_asg(&ctx, include_str!("src/test-import.leo")).unwrap(),
+ load_asg(&context, include_str!("src/test-import.leo")).unwrap(),
);
let program_string = include_str!("alias.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
// naming tests
#[test]
fn test_name() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"hello-world".to_string(),
- load_asg(&ctx, include_str!("src/hello-world.leo")).unwrap(),
+ load_asg(&context, include_str!("src/hello-world.leo")).unwrap(),
);
imports.packages.insert(
"a0-f".to_string(),
- load_asg(&ctx, include_str!("src/a0-f.leo")).unwrap(),
+ load_asg(&context, include_str!("src/a0-f.leo")).unwrap(),
+ );
+ imports.packages.insert(
+ "a-9".to_string(),
+ load_asg(&context, include_str!("src/a-9.leo")).unwrap(),
);
- imports
- .packages
- .insert("a-9".to_string(), load_asg(&ctx, include_str!("src/a-9.leo")).unwrap());
let program_string = include_str!("names.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
// more complex tests
#[test]
fn test_many_import() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
- load_asg(&ctx, include_str!("src/test-import.leo")).unwrap(),
+ load_asg(&context, include_str!("src/test-import.leo")).unwrap(),
);
imports.packages.insert(
"bar".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/lib.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/lib.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/baz.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/baz.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.bat.bat".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/bat/bat.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/bat/bat.leo")).unwrap(),
);
imports.packages.insert(
"car".to_string(),
- load_asg(&ctx, include_str!("imports/car/src/lib.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/car/src/lib.leo")).unwrap(),
);
let program_string = include_str!("many_import.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
#[test]
fn test_many_import_star() {
- let ctx = new_context();
- let mut imports = mocked_resolver(&ctx);
+ let context = new_context();
+ let mut imports = mocked_resolver(&context);
imports.packages.insert(
"test-import".to_string(),
- load_asg(&ctx, include_str!("src/test-import.leo")).unwrap(),
+ load_asg(&context, include_str!("src/test-import.leo")).unwrap(),
);
imports.packages.insert(
"bar".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/lib.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/lib.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/baz.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.baz".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/baz.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/baz.leo")).unwrap(),
);
imports.packages.insert(
"bar.bat.bat".to_string(),
- load_asg(&ctx, include_str!("imports/bar/src/bat/bat.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/bar/src/bat/bat.leo")).unwrap(),
);
imports.packages.insert(
"car".to_string(),
- load_asg(&ctx, include_str!("imports/car/src/lib.leo")).unwrap(),
+ load_asg(&context, include_str!("imports/car/src/lib.leo")).unwrap(),
);
let program_string = include_str!("many_import_star.leo");
- load_asg_imports(&ctx, program_string, &mut imports).unwrap();
+ load_asg_imports(&context, program_string, &mut imports).unwrap();
}
diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs
index 0a92f251de..bda752ed86 100644
--- a/compiler/src/compiler.rs
+++ b/compiler/src/compiler.rs
@@ -63,7 +63,7 @@ pub struct Compiler<'a, F: PrimeField, G: GroupType> {
output_directory: PathBuf,
program: Program,
program_input: Input,
- ctx: AsgContext<'a>,
+ context: AsgContext<'a>,
asg: Option>,
_engine: PhantomData,
_group: PhantomData,
@@ -73,7 +73,12 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> {
///
/// Returns a new Leo program compiler.
///
- pub fn new(package_name: String, main_file_path: PathBuf, output_directory: PathBuf, ctx: AsgContext<'a>) -> Self {
+ pub fn new(
+ package_name: String,
+ main_file_path: PathBuf,
+ output_directory: PathBuf,
+ context: AsgContext<'a>,
+ ) -> Self {
Self {
program_name: package_name.clone(),
main_file_path,
@@ -81,7 +86,7 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> {
program: Program::new(package_name),
program_input: Input::new(),
asg: None,
- ctx,
+ context,
_engine: PhantomData,
_group: PhantomData,
}
@@ -98,9 +103,9 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> {
package_name: String,
main_file_path: PathBuf,
output_directory: PathBuf,
- ctx: AsgContext<'a>,
+ context: AsgContext<'a>,
) -> Result {
- let mut compiler = Self::new(package_name, main_file_path, output_directory, ctx);
+ let mut compiler = Self::new(package_name, main_file_path, output_directory, context);
compiler.parse_program()?;
@@ -124,9 +129,9 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> {
input_path: &Path,
state_string: &str,
state_path: &Path,
- ctx: AsgContext<'a>,
+ context: AsgContext<'a>,
) -> Result {
- let mut compiler = Self::new(package_name, main_file_path, output_directory, ctx);
+ let mut compiler = Self::new(package_name, main_file_path, output_directory, context);
compiler.parse_input(input_string, input_path, state_string, state_path)?;
@@ -205,7 +210,7 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> {
tracing::debug!("Program parsing complete\n{:#?}", self.program);
// Create a new symbol table from the program, imported_programs, and program_input.
- let asg = Asg::new(self.ctx, &core_ast, &mut leo_imports::ImportParser::default())?;
+ let asg = Asg::new(self.context, &core_ast, &mut leo_imports::ImportParser::default())?;
tracing::debug!("ASG generation complete");
diff --git a/imports/src/parser/import_parser.rs b/imports/src/parser/import_parser.rs
index b8376265bb..300408cffb 100644
--- a/imports/src/parser/import_parser.rs
+++ b/imports/src/parser/import_parser.rs
@@ -34,7 +34,7 @@ pub struct ImportParser<'a> {
impl<'a> ImportResolver<'a> for ImportParser<'a> {
fn resolve_package(
&mut self,
- ctx: AsgContext<'a>,
+ context: AsgContext<'a>,
package_segments: &[&str],
span: &Span,
) -> Result