mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 19:22:01 +03:00
Merge pull request #1964 from AleoHQ/clean-symbols
Remove unused symbols and logic
This commit is contained in:
commit
41b985f923
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1181,7 +1181,6 @@ dependencies = [
|
||||
name = "leo-core"
|
||||
version = "1.5.3"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"leo-ast",
|
||||
"leo-errors",
|
||||
"leo-span",
|
||||
|
@ -31,6 +31,3 @@ version = "1.5.3"
|
||||
[dependencies.leo-span]
|
||||
path = "../span"
|
||||
version = "1.5.3"
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "1.9"
|
@ -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"),
|
||||
])
|
||||
}
|
||||
}
|
@ -22,13 +22,9 @@ pub use pedersen::*;
|
||||
mod poseidon;
|
||||
pub use poseidon::*;
|
||||
|
||||
use crate::Types;
|
||||
|
||||
use leo_ast::Type;
|
||||
use leo_span::{sym, Symbol};
|
||||
|
||||
use indexmap::IndexSet;
|
||||
|
||||
/// A core instruction that maps directly to an AVM bytecode instruction.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub enum CoreInstruction {
|
||||
@ -233,12 +229,3 @@ const BOOL_INT64_STRING_TYPES: [Type; 10] = [
|
||||
Type::U64,
|
||||
Type::String,
|
||||
];
|
||||
|
||||
// todo (collin): deprecate this code
|
||||
pub struct Algorithms;
|
||||
|
||||
impl Types for Algorithms {
|
||||
fn types() -> IndexSet<Symbol> {
|
||||
IndexSet::from([Symbol::intern("Poseidon")])
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,5 @@
|
||||
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
use indexmap::IndexSet;
|
||||
use leo_span::Symbol;
|
||||
|
||||
mod account;
|
||||
pub use account::*;
|
||||
|
||||
mod algorithms;
|
||||
pub use algorithms::*;
|
||||
|
||||
pub trait Types {
|
||||
fn types() -> IndexSet<Symbol>;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
||||
self.parent = Some(input.name());
|
||||
input.input.iter().for_each(|i| {
|
||||
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_);
|
||||
|
||||
// Check for conflicting variable names.
|
||||
|
@ -48,7 +48,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
|
||||
.borrow()
|
||||
.lookup_fn_symbol(parent)
|
||||
.map(|f| f.output.clone());
|
||||
self.check_core_type_conflict(return_type);
|
||||
|
||||
self.has_return = true;
|
||||
|
||||
@ -62,8 +61,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
|
||||
VariableType::Mut
|
||||
};
|
||||
|
||||
self.check_core_type_conflict(&Some(input.type_.clone()));
|
||||
|
||||
self.visit_expression(&input.value, &Some(input.type_.clone()));
|
||||
|
||||
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() {
|
||||
self.check_core_type_conflict(&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) {
|
||||
let iter_type = &Some(input.type_.clone());
|
||||
self.assert_int_type(iter_type, input.variable.span);
|
||||
self.check_core_type_conflict(iter_type);
|
||||
|
||||
// Create a new scope for the loop body.
|
||||
let scope_index = self.symbol_table.borrow_mut().insert_block();
|
||||
|
@ -21,7 +21,6 @@ use leo_core::*;
|
||||
use leo_errors::{emitter::Handler, TypeCheckerError};
|
||||
use leo_span::{Span, Symbol};
|
||||
|
||||
use indexmap::IndexSet;
|
||||
use itertools::Itertools;
|
||||
use std::cell::RefCell;
|
||||
|
||||
@ -31,8 +30,6 @@ pub struct TypeChecker<'a> {
|
||||
pub(crate) parent: Option<Symbol>,
|
||||
pub(crate) has_return: bool,
|
||||
pub(crate) negate: bool,
|
||||
pub(crate) account_types: IndexSet<Symbol>,
|
||||
pub(crate) algorithms_types: IndexSet<Symbol>,
|
||||
}
|
||||
|
||||
const BOOLEAN_TYPE: Type = Type::Boolean;
|
||||
@ -69,8 +66,6 @@ impl<'a> TypeChecker<'a> {
|
||||
parent: None,
|
||||
has_return: false,
|
||||
negate: false,
|
||||
account_types: Account::types(),
|
||||
algorithms_types: Algorithms::types(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,16 +305,6 @@ impl<'a> TypeChecker<'a> {
|
||||
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.
|
||||
pub(crate) fn assert_not_tuple(&self, span: Span, type_: &Type) {
|
||||
if matches!(type_, Type::Tuple(_)) {
|
||||
|
@ -215,13 +215,6 @@ symbols! {
|
||||
owner,
|
||||
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
|
||||
registers,
|
||||
state,
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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"
|
@ -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"
|
@ -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 | ^^^^^^"
|
@ -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"
|
@ -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"
|
@ -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
Loading…
Reference in New Issue
Block a user