diff --git a/Cargo.lock b/Cargo.lock
index 3b8a622e03..cb7ce5771e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -955,17 +955,6 @@ dependencies = [
"wasi 0.9.0+wasi-snapshot-preview1",
]
-[[package]]
-name = "getrandom"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
-dependencies = [
- "cfg-if 1.0.0",
- "libc",
- "wasi 0.10.0+wasi-snapshot-preview1",
-]
-
[[package]]
name = "gimli"
version = "0.23.0"
@@ -1290,7 +1279,6 @@ dependencies = [
"serde_json",
"thiserror",
"typed-arena",
- "uuid",
]
[[package]]
@@ -1338,7 +1326,6 @@ dependencies = [
"snarkvm-utilities",
"thiserror",
"tracing",
- "uuid",
]
[[package]]
@@ -2148,7 +2135,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
- "getrandom 0.1.15",
+ "getrandom",
"libc",
"rand_chacha",
"rand_core 0.5.1",
@@ -2171,7 +2158,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
- "getrandom 0.1.15",
+ "getrandom",
]
[[package]]
@@ -2235,7 +2222,7 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
dependencies = [
- "getrandom 0.1.15",
+ "getrandom",
"redox_syscall",
"rust-argon2",
]
@@ -3231,16 +3218,6 @@ dependencies = [
"percent-encoding",
]
-[[package]]
-name = "uuid"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
-dependencies = [
- "getrandom 0.2.2",
- "serde",
-]
-
[[package]]
name = "vcpkg"
version = "0.2.11"
diff --git a/asg/Cargo.toml b/asg/Cargo.toml
index b6d7fbb219..39295ecead 100644
--- a/asg/Cargo.toml
+++ b/asg/Cargo.toml
@@ -37,10 +37,6 @@ path = "../ast"
version = "1.2.2"
path = "../grammar"
-[dependencies.uuid]
-version = "0.8"
-features = [ "v4", "serde" ]
-
[dependencies.num-bigint]
version = "0.3"
diff --git a/asg/src/context.rs b/asg/src/context.rs
new file mode 100644
index 0000000000..7d27ee10c0
--- /dev/null
+++ b/asg/src/context.rs
@@ -0,0 +1,46 @@
+// 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 .
+
+use std::{cell::Cell, unimplemented};
+
+use typed_arena::Arena;
+
+use crate::ArenaNode;
+
+pub struct AsgContextInner<'a> {
+ pub arena: &'a Arena>,
+ pub next_id: Cell,
+}
+
+impl<'a> AsgContextInner<'a> {
+ pub fn new(arena: &'a Arena>) -> &'a Self {
+ match arena.alloc(ArenaNode::Inner(AsgContextInner {
+ arena,
+ next_id: Cell::new(0),
+ })) {
+ ArenaNode::Inner(x) => x,
+ _ => unimplemented!(),
+ }
+ }
+
+ pub fn get_id(&self) -> u32 {
+ let next_id = self.next_id.get();
+ self.next_id.replace(next_id + 1);
+ next_id
+ }
+}
+
+pub type AsgContext<'a> = &'a AsgContextInner<'a>;
diff --git a/asg/src/input.rs b/asg/src/input.rs
index 11789a7425..f9af9c2851 100644
--- a/asg/src/input.rs
+++ b/asg/src/input.rs
@@ -39,7 +39,7 @@ pub const STATE_LEAF_PSEUDO_CIRCUIT: &str = "$InputStateLeaf";
impl<'a> Input<'a> {
fn make_header(scope: &'a Scope<'a>, name: &str) -> &'a Circuit<'a> {
scope.alloc_circuit(Circuit {
- id: uuid::Uuid::new_v4(),
+ id: scope.context.get_id(),
name: RefCell::new(Identifier::new(name.to_string())),
members: RefCell::new(IndexMap::new()),
core_mapping: RefCell::new(None),
@@ -68,7 +68,7 @@ impl<'a> Input<'a> {
);
let container_circuit = input_scope.alloc_circuit(Circuit {
- id: uuid::Uuid::new_v4(),
+ id: scope.context.get_id(),
name: RefCell::new(Identifier::new(CONTAINER_PSEUDO_CIRCUIT.to_string())),
members: RefCell::new(container_members),
core_mapping: RefCell::new(None),
@@ -83,7 +83,7 @@ impl<'a> Input<'a> {
state_leaf,
container_circuit,
container: input_scope.alloc_variable(RefCell::new(crate::InnerVariable {
- id: uuid::Uuid::new_v4(),
+ id: scope.context.get_id(),
name: Identifier::new("input".to_string()),
type_: Type::Circuit(container_circuit),
mutable: false,
diff --git a/asg/src/lib.rs b/asg/src/lib.rs
index 1fe1d8f0da..ada569edeb 100644
--- a/asg/src/lib.rs
+++ b/asg/src/lib.rs
@@ -71,9 +71,10 @@ pub use variable::*;
pub mod pass;
pub use pass::*;
-pub use leo_ast::{Ast, Identifier, Span};
+pub mod context;
+pub use context::*;
-pub type AsgContext<'a> = &'a Arena>;
+pub use leo_ast::{Ast, Identifier, Span};
use std::path::Path;
@@ -132,6 +133,10 @@ pub fn load_asg<'a, T: ImportResolver<'a>>(
InternalProgram::new(context, leo_ast::Ast::new("load_ast", &ast)?.as_repr(), resolver)
}
-pub fn new_context<'a>() -> Arena> {
+pub fn new_alloc_context<'a>() -> Arena> {
Arena::new()
}
+
+pub fn new_context<'a>(arena: &'a Arena>) -> AsgContext<'a> {
+ AsgContextInner::new(arena)
+}
diff --git a/asg/src/node.rs b/asg/src/node.rs
index 1d59dc3909..bd36815a96 100644
--- a/asg/src/node.rs
+++ b/asg/src/node.rs
@@ -15,6 +15,7 @@
// along with the Leo library. If not, see .
use crate::{
+ AsgContextInner,
AsgConvertError,
Circuit,
Expression,
@@ -50,4 +51,5 @@ pub enum ArenaNode<'a> {
Circuit(Circuit<'a>),
Function(Function<'a>),
GlobalConst(GlobalConst<'a>),
+ Inner(AsgContextInner<'a>),
}
diff --git a/asg/src/program/circuit.rs b/asg/src/program/circuit.rs
index ace54ca2c2..e44c8b8277 100644
--- a/asg/src/program/circuit.rs
+++ b/asg/src/program/circuit.rs
@@ -18,7 +18,6 @@ use crate::{AsgConvertError, Function, Identifier, Node, Scope, Span, Type};
use indexmap::IndexMap;
use std::cell::RefCell;
-use uuid::Uuid;
#[derive(Clone)]
pub enum CircuitMember<'a> {
@@ -28,7 +27,7 @@ pub enum CircuitMember<'a> {
#[derive(Clone)]
pub struct Circuit<'a> {
- pub id: Uuid,
+ pub id: u32,
pub name: RefCell,
pub core_mapping: RefCell