Merge pull request #1964 from AleoHQ/clean-symbols

Remove unused symbols and logic
This commit is contained in:
Collin Chin 2022-07-28 15:55:48 -07:00 committed by GitHub
commit 41b985f923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
571 changed files with 3 additions and 169 deletions

1
Cargo.lock generated
View File

@ -1181,7 +1181,6 @@ dependencies = [
name = "leo-core" name = "leo-core"
version = "1.5.3" version = "1.5.3"
dependencies = [ dependencies = [
"indexmap",
"leo-ast", "leo-ast",
"leo-errors", "leo-errors",
"leo-span", "leo-span",

View File

@ -31,6 +31,3 @@ version = "1.5.3"
[dependencies.leo-span] [dependencies.leo-span]
path = "../span" path = "../span"
version = "1.5.3" version = "1.5.3"
[dependencies.indexmap]
version = "1.9"

View File

@ -1,35 +0,0 @@
// Copyright (C) 2019-2022 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::Types;
use indexmap::IndexSet;
use leo_span::Symbol;
pub struct Account;
impl Types for Account {
fn types() -> IndexSet<Symbol> {
IndexSet::from([
Symbol::intern("ComputeKey"),
Symbol::intern("PrivateKey"),
Symbol::intern("Record"),
Symbol::intern("Signature"),
Symbol::intern("ViewKey"),
])
}
}

View File

@ -22,13 +22,9 @@ pub use pedersen::*;
mod poseidon; mod poseidon;
pub use poseidon::*; pub use poseidon::*;
use crate::Types;
use leo_ast::Type; use leo_ast::Type;
use leo_span::{sym, Symbol}; use leo_span::{sym, Symbol};
use indexmap::IndexSet;
/// A core instruction that maps directly to an AVM bytecode instruction. /// A core instruction that maps directly to an AVM bytecode instruction.
#[derive(Clone, PartialEq, Eq)] #[derive(Clone, PartialEq, Eq)]
pub enum CoreInstruction { pub enum CoreInstruction {
@ -233,12 +229,3 @@ const BOOL_INT64_STRING_TYPES: [Type; 10] = [
Type::U64, Type::U64,
Type::String, Type::String,
]; ];
// todo (collin): deprecate this code
pub struct Algorithms;
impl Types for Algorithms {
fn types() -> IndexSet<Symbol> {
IndexSet::from([Symbol::intern("Poseidon")])
}
}

View File

@ -16,15 +16,5 @@
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
use indexmap::IndexSet;
use leo_span::Symbol;
mod account;
pub use account::*;
mod algorithms; mod algorithms;
pub use algorithms::*; pub use algorithms::*;
pub trait Types {
fn types() -> IndexSet<Symbol>;
}

View File

@ -35,7 +35,6 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
self.parent = Some(input.name()); self.parent = Some(input.name());
input.input.iter().for_each(|i| { input.input.iter().for_each(|i| {
let input_var = i.get_variable(); let input_var = i.get_variable();
self.check_core_type_conflict(&Some(input_var.type_.clone()));
self.assert_not_tuple(input_var.span, &input_var.type_); self.assert_not_tuple(input_var.span, &input_var.type_);
// Check for conflicting variable names. // Check for conflicting variable names.

View File

@ -48,7 +48,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
.borrow() .borrow()
.lookup_fn_symbol(parent) .lookup_fn_symbol(parent)
.map(|f| f.output.clone()); .map(|f| f.output.clone());
self.check_core_type_conflict(return_type);
self.has_return = true; self.has_return = true;
@ -62,8 +61,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
VariableType::Mut VariableType::Mut
}; };
self.check_core_type_conflict(&Some(input.type_.clone()));
self.visit_expression(&input.value, &Some(input.type_.clone())); self.visit_expression(&input.value, &Some(input.type_.clone()));
if let Err(err) = self.symbol_table.borrow_mut().insert_variable( if let Err(err) = self.symbol_table.borrow_mut().insert_variable(
@ -104,7 +101,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
}; };
if var_type.is_some() { if var_type.is_some() {
self.check_core_type_conflict(&var_type);
self.visit_expression(&input.value, &var_type); self.visit_expression(&input.value, &var_type);
} }
} }
@ -140,7 +136,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
fn visit_iteration(&mut self, input: &'a IterationStatement) { fn visit_iteration(&mut self, input: &'a IterationStatement) {
let iter_type = &Some(input.type_.clone()); let iter_type = &Some(input.type_.clone());
self.assert_int_type(iter_type, input.variable.span); self.assert_int_type(iter_type, input.variable.span);
self.check_core_type_conflict(iter_type);
// Create a new scope for the loop body. // Create a new scope for the loop body.
let scope_index = self.symbol_table.borrow_mut().insert_block(); let scope_index = self.symbol_table.borrow_mut().insert_block();

View File

@ -21,7 +21,6 @@ use leo_core::*;
use leo_errors::{emitter::Handler, TypeCheckerError}; use leo_errors::{emitter::Handler, TypeCheckerError};
use leo_span::{Span, Symbol}; use leo_span::{Span, Symbol};
use indexmap::IndexSet;
use itertools::Itertools; use itertools::Itertools;
use std::cell::RefCell; use std::cell::RefCell;
@ -31,8 +30,6 @@ pub struct TypeChecker<'a> {
pub(crate) parent: Option<Symbol>, pub(crate) parent: Option<Symbol>,
pub(crate) has_return: bool, pub(crate) has_return: bool,
pub(crate) negate: bool, pub(crate) negate: bool,
pub(crate) account_types: IndexSet<Symbol>,
pub(crate) algorithms_types: IndexSet<Symbol>,
} }
const BOOLEAN_TYPE: Type = Type::Boolean; const BOOLEAN_TYPE: Type = Type::Boolean;
@ -69,8 +66,6 @@ impl<'a> TypeChecker<'a> {
parent: None, parent: None,
has_return: false, has_return: false,
negate: false, negate: false,
account_types: Account::types(),
algorithms_types: Algorithms::types(),
} }
} }
@ -310,16 +305,6 @@ impl<'a> TypeChecker<'a> {
Type::Identifier(circuit) Type::Identifier(circuit)
} }
/// Emits an error if the given type conflicts with a core library type.
pub(crate) fn check_core_type_conflict(&self, type_: &Option<Type>) {
// todo: deprecate this method.
if let Some(Type::Identifier(ident)) = type_ {
if self.account_types.contains(&ident.name) || self.algorithms_types.contains(&ident.name) {
self.emit_err(TypeCheckerError::core_type_name_conflict(&ident.name, ident.span()));
}
}
}
/// Emits an error if the type is a tuple. /// Emits an error if the type is a tuple.
pub(crate) fn assert_not_tuple(&self, span: Span, type_: &Type) { pub(crate) fn assert_not_tuple(&self, span: Span, type_: &Type) {
if matches!(type_, Type::Tuple(_)) { if matches!(type_, Type::Tuple(_)) {

View File

@ -215,13 +215,6 @@ symbols! {
owner, owner,
gates, gates,
// todo: remove these.
CONTAINER_PSEUDO_CIRCUIT: "$InputContainer",
REGISTERS_PSEUDO_CIRCUIT: "$InputRegister",
RECORD_PSEUDO_CIRCUIT: "$InputRecord",
STATE_PSEUDO_CIRCUIT: "$InputState",
STATE_LEAF_PSEUDO_CIRCUIT: "$InputStateLeaf",
// input file // input file
registers, registers,
state, state,

View File

@ -1,9 +0,0 @@
/*
namespace: Compile
expectation: Fail
*/
// todo: rewrite this test so it properly tests a compute key.
function main(public compute_key: ComputeKey, a: bool) -> bool {
return a;
}

View File

@ -1,9 +0,0 @@
/*
namespace: Compile
expectation: Fail
*/
// todo: rewrite this test so it properly tests a private key.
function main(public private_key: PrivateKey, a: bool) -> bool {
return a;
}

View File

@ -1,9 +0,0 @@
/*
namespace: Compile
expectation: Fail
*/
// todo: rewrite this test so it properly tests a record type.
function main(public record: Record, a: bool) -> bool {
return a;
}

View File

@ -1,9 +0,0 @@
/*
namespace: Compile
expectation: Fail
*/
// todo: rewrite this test so it properly tests a signature.
function main(public signature: Signature, a: bool) -> bool {
return a;
}

View File

@ -1,9 +0,0 @@
/*
namespace: Compile
expectation: Fail
*/
// todo: rewrite this test so it properly tests a view key.
function main(public view_key: ViewKey, a: bool) -> bool {
return a;
}

View File

@ -1,5 +0,0 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372010]: The type ComputeKey is a reserved core type name.\n --> compiler-test:4:35\n |\n 4 | function main(public compute_key: ComputeKey, a: bool) -> bool {\n | ^^^^^^^^^^\n"

View File

@ -1,5 +0,0 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372010]: The type PrivateKey is a reserved core type name.\n --> compiler-test:4:35\n |\n 4 | function main(public private_key: PrivateKey, a: bool) -> bool {\n | ^^^^^^^^^^\n"

View File

@ -1,5 +0,0 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [EPAR0370009]: unexpected string: expected 'identifier', found 'record'\n --> compiler-test:4:22\n |\n 4 | function main(public record: Record, a: bool) -> bool {\n | ^^^^^^"

View File

@ -1,5 +0,0 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372010]: The type Signature is a reserved core type name.\n --> compiler-test:4:33\n |\n 4 | function main(public signature: Signature, a: bool) -> bool {\n | ^^^^^^^^^\n"

View File

@ -1,5 +0,0 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372010]: The type ViewKey is a reserved core type name.\n --> compiler-test:4:32\n |\n 4 | function main(public view_key: ViewKey, a: bool) -> bool {\n | ^^^^^^^\n"

View File

@ -1,5 +0,0 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected : -- found '='\n --> compiler-test:9:16\n |\n 9 | let double = x + x;\n | ^"

Some files were not shown because too many files have changed in this diff Show More