diff --git a/Cargo.lock b/Cargo.lock index 886d9325a8..55740416fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -610,6 +610,19 @@ dependencies = [ "fe-parser", ] +[[package]] +name = "fe-analyzer" +version = "0.1.0-alpha" +dependencies = [ + "ansi_term 0.12.1", + "fe-common", + "fe-parser", + "hex", + "num-bigint", + "rstest", + "tiny-keccak 2.0.2", +] + [[package]] name = "fe-common" version = "0.1.0-alpha" @@ -625,9 +638,9 @@ dependencies = [ "ethabi", "evm", "evm-runtime", + "fe-analyzer", "fe-common", "fe-parser", - "fe-semantics", "hex", "primitive-types", "rand", @@ -652,19 +665,6 @@ dependencies = [ "wasm-bindgen-test", ] -[[package]] -name = "fe-semantics" -version = "0.1.0-alpha" -dependencies = [ - "ansi_term 0.12.1", - "fe-common", - "fe-parser", - "hex", - "num-bigint", - "rstest", - "tiny-keccak 2.0.2", -] - [[package]] name = "fixed-hash" version = "0.6.1" diff --git a/semantics/Cargo.toml b/analyzer/Cargo.toml similarity index 95% rename from semantics/Cargo.toml rename to analyzer/Cargo.toml index 702c86e546..8932047174 100644 --- a/semantics/Cargo.toml +++ b/analyzer/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "fe-semantics" +name = "fe-analyzer" version = "0.1.0-alpha" authors = ["Ethereum Foundation "] edition = "2018" diff --git a/semantics/src/builtins.rs b/analyzer/src/builtins.rs similarity index 100% rename from semantics/src/builtins.rs rename to analyzer/src/builtins.rs diff --git a/semantics/src/errors.rs b/analyzer/src/errors.rs similarity index 100% rename from semantics/src/errors.rs rename to analyzer/src/errors.rs diff --git a/semantics/src/lib.rs b/analyzer/src/lib.rs similarity index 99% rename from semantics/src/lib.rs rename to analyzer/src/lib.rs index 3d9ef068fd..29c7634a5a 100644 --- a/semantics/src/lib.rs +++ b/analyzer/src/lib.rs @@ -310,7 +310,7 @@ impl Context { /// Performs semantic analysis of the source program and returns a `Context` /// instance. -pub fn analysis(module: &fe::Module) -> Result { +pub fn analyze(module: &fe::Module) -> Result { let context = Context::new_shared(); traversal::module::module(Rc::clone(&context), module)?; Ok(Rc::try_unwrap(context) diff --git a/semantics/src/namespace/events.rs b/analyzer/src/namespace/events.rs similarity index 100% rename from semantics/src/namespace/events.rs rename to analyzer/src/namespace/events.rs diff --git a/semantics/src/namespace/mod.rs b/analyzer/src/namespace/mod.rs similarity index 100% rename from semantics/src/namespace/mod.rs rename to analyzer/src/namespace/mod.rs diff --git a/semantics/src/namespace/operations.rs b/analyzer/src/namespace/operations.rs similarity index 100% rename from semantics/src/namespace/operations.rs rename to analyzer/src/namespace/operations.rs diff --git a/semantics/src/namespace/scopes.rs b/analyzer/src/namespace/scopes.rs similarity index 100% rename from semantics/src/namespace/scopes.rs rename to analyzer/src/namespace/scopes.rs diff --git a/semantics/src/namespace/types.rs b/analyzer/src/namespace/types.rs similarity index 100% rename from semantics/src/namespace/types.rs rename to analyzer/src/namespace/types.rs diff --git a/semantics/src/traversal/_utils.rs b/analyzer/src/traversal/_utils.rs similarity index 100% rename from semantics/src/traversal/_utils.rs rename to analyzer/src/traversal/_utils.rs diff --git a/semantics/src/traversal/assignments.rs b/analyzer/src/traversal/assignments.rs similarity index 100% rename from semantics/src/traversal/assignments.rs rename to analyzer/src/traversal/assignments.rs diff --git a/semantics/src/traversal/contracts.rs b/analyzer/src/traversal/contracts.rs similarity index 100% rename from semantics/src/traversal/contracts.rs rename to analyzer/src/traversal/contracts.rs diff --git a/semantics/src/traversal/declarations.rs b/analyzer/src/traversal/declarations.rs similarity index 100% rename from semantics/src/traversal/declarations.rs rename to analyzer/src/traversal/declarations.rs diff --git a/semantics/src/traversal/expressions.rs b/analyzer/src/traversal/expressions.rs similarity index 100% rename from semantics/src/traversal/expressions.rs rename to analyzer/src/traversal/expressions.rs diff --git a/semantics/src/traversal/functions.rs b/analyzer/src/traversal/functions.rs similarity index 100% rename from semantics/src/traversal/functions.rs rename to analyzer/src/traversal/functions.rs diff --git a/semantics/src/traversal/mod.rs b/analyzer/src/traversal/mod.rs similarity index 100% rename from semantics/src/traversal/mod.rs rename to analyzer/src/traversal/mod.rs diff --git a/semantics/src/traversal/module.rs b/analyzer/src/traversal/module.rs similarity index 100% rename from semantics/src/traversal/module.rs rename to analyzer/src/traversal/module.rs diff --git a/semantics/src/traversal/types.rs b/analyzer/src/traversal/types.rs similarity index 100% rename from semantics/src/traversal/types.rs rename to analyzer/src/traversal/types.rs diff --git a/semantics/tests/analysis.rs b/analyzer/tests/analysis.rs similarity index 94% rename from semantics/tests/analysis.rs rename to analyzer/tests/analysis.rs index 7a1f0e6fc5..99e4769fb5 100644 --- a/semantics/tests/analysis.rs +++ b/analyzer/tests/analysis.rs @@ -1,19 +1,19 @@ -use fe_parser::ast as fe; -use fe_parser::span::{ - Span, - Spanned, -}; -use fe_semantics; -use fe_semantics::namespace::types::{ +use fe_analyzer; +use fe_analyzer::namespace::types::{ Array, Base, Map, Type, }; -use fe_semantics::{ +use fe_analyzer::{ ExpressionAttributes, Location, }; +use fe_parser::ast as fe; +use fe_parser::span::{ + Span, + Spanned, +}; const GUEST_BOOK: &str = include_str!("fixtures/guest_book.fe"); @@ -91,7 +91,7 @@ fn guest_book_analysis() { .1 .node; - let context = fe_semantics::analysis(&fe_module).expect("failed to perform semantic analysis"); + let context = fe_analyzer::analyze(&fe_module).expect("failed to perform semantic analysis"); for (start, end, expected) in &[ (196, 206, &addr_val()), diff --git a/semantics/tests/fixtures/guest_book.fe b/analyzer/tests/fixtures/guest_book.fe similarity index 100% rename from semantics/tests/fixtures/guest_book.fe rename to analyzer/tests/fixtures/guest_book.fe diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 9d73b01fea..89e8121bdf 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -14,7 +14,7 @@ solc-backend = ["solc"] [dependencies] fe-common = {path = "../common", version = "^0.1.0-alpha"} fe-parser = {path = "../parser", version = "^0.1.0-alpha"} -fe-semantics = {path = "../semantics", version = "^0.1.0-alpha"} +fe-analyzer = {path = "../analyzer", version = "^0.1.0-alpha"} serde_json = "1.0" serde = "1.0" hex = "0.4" diff --git a/compiler/src/lib.rs b/compiler/src/lib.rs index 620a99762f..7d0163d7f9 100644 --- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs @@ -33,7 +33,7 @@ pub fn compile(src: FeSrc, with_bytecode: bool) -> Result Result #[cfg(test)] mod tests { use crate::yul::mappers::assignments::assign; - use fe_parser as parser; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ Array, Type, U256, }; - use fe_semantics::test_utils::ContextHarness; - use fe_semantics::{ + use fe_analyzer::test_utils::ContextHarness; + use fe_analyzer::{ Context, ExpressionAttributes, Location, }; + use fe_parser as parser; use rstest::rstest; fn map(context: &Context, src: &str) -> String { diff --git a/compiler/src/yul/mappers/contracts.rs b/compiler/src/yul/mappers/contracts.rs index 234aff27a8..a04c65737c 100644 --- a/compiler/src/yul/mappers/contracts.rs +++ b/compiler/src/yul/mappers/contracts.rs @@ -2,10 +2,10 @@ use crate::errors::CompileError; use crate::yul::constructor; use crate::yul::mappers::functions; use crate::yul::runtime; +use fe_analyzer::Context; use fe_common::utils::keccak::get_full_signature; use fe_parser::ast as fe; use fe_parser::span::Spanned; -use fe_semantics::Context; use yultsur::*; /// Builds a Yul object from a Fe contract. diff --git a/compiler/src/yul/mappers/declarations.rs b/compiler/src/yul/mappers/declarations.rs index ea325703b1..4de36f93e3 100644 --- a/compiler/src/yul/mappers/declarations.rs +++ b/compiler/src/yul/mappers/declarations.rs @@ -1,14 +1,14 @@ use crate::errors::CompileError; use crate::yul::mappers::expressions; use crate::yul::names; -use fe_parser::ast as fe; -use fe_parser::span::Spanned; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ Array, FeSized, FixedSize, }; -use fe_semantics::Context; +use fe_analyzer::Context; +use fe_parser::ast as fe; +use fe_parser::span::Spanned; use yultsur::*; /// Builds a Yul statement from a Fe variable declaration @@ -80,20 +80,20 @@ fn var_decl_array( #[cfg(test)] mod tests { use crate::yul::mappers::declarations::var_decl; - use fe_parser as parser; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ Array, Base, FixedSize, Type, U256, }; - use fe_semantics::test_utils::ContextHarness; - use fe_semantics::{ + use fe_analyzer::test_utils::ContextHarness; + use fe_analyzer::{ Context, ExpressionAttributes, Location, }; + use fe_parser as parser; fn map(context: &Context, src: &str) -> String { let tokens = parser::get_parse_tokens(src).expect("Couldn't parse declaration"); diff --git a/compiler/src/yul/mappers/expressions.rs b/compiler/src/yul/mappers/expressions.rs index d95077aa1d..3f60948cf5 100644 --- a/compiler/src/yul/mappers/expressions.rs +++ b/compiler/src/yul/mappers/expressions.rs @@ -2,19 +2,19 @@ use crate::errors::CompileError; use crate::yul::names; use crate::yul::operations::data as data_operations; use crate::yul::utils; -use fe_common::utils::keccak::get_full_signature; -use fe_parser::ast as fe; -use fe_parser::span::Spanned; -use fe_semantics::builtins; -use fe_semantics::namespace::types::{ +use fe_analyzer::builtins; +use fe_analyzer::namespace::types::{ FixedSize, Type, }; -use fe_semantics::{ +use fe_analyzer::{ CallType, Context, Location, }; +use fe_common::utils::keccak::get_full_signature; +use fe_parser::ast as fe; +use fe_parser::span::Spanned; use std::convert::TryFrom; use yultsur::*; @@ -378,19 +378,19 @@ mod tests { expr, Location, }; - use fe_parser as parser; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ Array, Base, Map, Type, U256, }; - use fe_semantics::test_utils::ContextHarness; - use fe_semantics::{ + use fe_analyzer::test_utils::ContextHarness; + use fe_analyzer::{ Context, ExpressionAttributes, }; + use fe_parser as parser; use rstest::rstest; fn map(context: &Context, src: &str) -> String { diff --git a/compiler/src/yul/mappers/functions.rs b/compiler/src/yul/mappers/functions.rs index 6a363633d3..618bcb48d9 100644 --- a/compiler/src/yul/mappers/functions.rs +++ b/compiler/src/yul/mappers/functions.rs @@ -7,16 +7,16 @@ use crate::yul::mappers::{ use crate::yul::names; use crate::yul::operations::data as data_operations; use crate::yul::utils; -use fe_parser::ast as fe; -use fe_parser::span::Spanned; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ FeSized, Type, }; -use fe_semantics::{ +use fe_analyzer::{ Context, ExpressionAttributes, }; +use fe_parser::ast as fe; +use fe_parser::span::Spanned; use yultsur::*; pub fn multiple_func_stmt( diff --git a/compiler/src/yul/mappers/module.rs b/compiler/src/yul/mappers/module.rs index b16ab3754d..f5cc1d4966 100644 --- a/compiler/src/yul/mappers/module.rs +++ b/compiler/src/yul/mappers/module.rs @@ -1,7 +1,7 @@ use crate::errors::CompileError; use crate::yul::mappers::contracts; +use fe_analyzer::Context; use fe_parser::ast as fe; -use fe_semantics::Context; use std::collections::HashMap; use yultsur::yul; diff --git a/compiler/src/yul/mod.rs b/compiler/src/yul/mod.rs index 128c92262b..ff5260b39e 100644 --- a/compiler/src/yul/mod.rs +++ b/compiler/src/yul/mod.rs @@ -5,7 +5,7 @@ use crate::types::{ FeModuleAst, NamedYulContracts, }; -use fe_semantics::Context; +use fe_analyzer::Context; mod constructor; mod mappers; diff --git a/compiler/src/yul/names.rs b/compiler/src/yul/names.rs index 2d1bf53573..9766139b28 100644 --- a/compiler/src/yul/names.rs +++ b/compiler/src/yul/names.rs @@ -1,4 +1,4 @@ -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ AbiDecodeLocation, AbiEncoding, }; @@ -45,7 +45,7 @@ mod tests { decode_name, encode_name, }; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ AbiDecodeLocation, Array, Base, diff --git a/compiler/src/yul/operations/abi.rs b/compiler/src/yul/operations/abi.rs index e80b4b5809..fecda64357 100644 --- a/compiler/src/yul/operations/abi.rs +++ b/compiler/src/yul/operations/abi.rs @@ -1,7 +1,7 @@ use crate::yul::names; use crate::yul::operations::data as data_operations; use crate::yul::utils; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ AbiArraySize, AbiDecodeLocation, AbiEncoding, @@ -82,7 +82,7 @@ mod tests { encode, encode_size, }; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ AbiDecodeLocation, FeString, U256, diff --git a/compiler/src/yul/operations/data.rs b/compiler/src/yul/operations/data.rs index de659f188a..48f6801b1b 100644 --- a/compiler/src/yul/operations/data.rs +++ b/compiler/src/yul/operations/data.rs @@ -1,6 +1,6 @@ use crate::yul::operations::abi as abi_operations; -use fe_semantics::namespace::events::Event; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::events::Event; +use fe_analyzer::namespace::types::{ Array, FeSized, FixedSize, @@ -128,8 +128,8 @@ mod tests { emit_event, sum, }; - use fe_semantics::namespace::events::Event; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::events::Event; + use fe_analyzer::namespace::types::{ Base, FixedSize, U256, diff --git a/compiler/src/yul/runtime/abi_dispatcher.rs b/compiler/src/yul/runtime/abi_dispatcher.rs index 787d9e4ee5..279c19390e 100644 --- a/compiler/src/yul/runtime/abi_dispatcher.rs +++ b/compiler/src/yul/runtime/abi_dispatcher.rs @@ -1,12 +1,12 @@ use crate::abi::utils as abi_utils; use crate::yul::names; use crate::yul::operations::abi as abi_operations; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ AbiDecodeLocation, AbiEncoding, FixedSize, }; -use fe_semantics::FunctionAttributes; +use fe_analyzer::FunctionAttributes; use yultsur::*; /// Builds a switch statement that dispatches calls to the contract. @@ -80,7 +80,7 @@ fn selection_as_statement(name: String, params: &[FixedSize]) -> yul::Statement #[cfg(test)] mod tests { use crate::yul::runtime::abi_dispatcher::selector; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ FixedSize, U256, }; diff --git a/compiler/src/yul/runtime/functions/abi.rs b/compiler/src/yul/runtime/functions/abi.rs index 5e9f466fce..2b1c9aa483 100644 --- a/compiler/src/yul/runtime/functions/abi.rs +++ b/compiler/src/yul/runtime/functions/abi.rs @@ -1,7 +1,7 @@ use crate::yul::names; use crate::yul::operations::data as data_operations; use crate::yul::utils; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ AbiArraySize, AbiDecodeLocation, AbiEncoding, @@ -337,7 +337,7 @@ mod tests { decode, encode, }; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ AbiDecodeLocation, Base, FeString, diff --git a/compiler/src/yul/runtime/functions/mod.rs b/compiler/src/yul/runtime/functions/mod.rs index cc15d8793a..f0f2364279 100644 --- a/compiler/src/yul/runtime/functions/mod.rs +++ b/compiler/src/yul/runtime/functions/mod.rs @@ -1,4 +1,4 @@ -use fe_semantics::namespace::types::AbiDecodeLocation; +use fe_analyzer::namespace::types::AbiDecodeLocation; use yultsur::*; pub mod abi; diff --git a/compiler/src/yul/runtime/mod.rs b/compiler/src/yul/runtime/mod.rs index f91e62bc4e..6aaefd4c3b 100644 --- a/compiler/src/yul/runtime/mod.rs +++ b/compiler/src/yul/runtime/mod.rs @@ -1,13 +1,13 @@ mod abi_dispatcher; mod functions; -use fe_parser::ast as fe; -use fe_parser::span::Spanned; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ AbiDecodeLocation, FixedSize, }; -use fe_semantics::Context; +use fe_analyzer::Context; +use fe_parser::ast as fe; +use fe_parser::span::Spanned; use yultsur::*; /// Builds the set of function statements that are needed during runtime. diff --git a/compiler/src/yul/utils.rs b/compiler/src/yul/utils.rs index 0b5b46589e..ee24cd4725 100644 --- a/compiler/src/yul/utils.rs +++ b/compiler/src/yul/utils.rs @@ -1,14 +1,14 @@ -use fe_parser::ast as fe; -use fe_parser::span::{ - Span, - Spanned, -}; -use fe_semantics::namespace::types::{ +use fe_analyzer::namespace::types::{ AbiArraySize, AbiEncoding, AbiType, AbiUintSize, }; +use fe_parser::ast as fe; +use fe_parser::span::{ + Span, + Spanned, +}; /// Creates a new spanned expression. Useful in cases where an `Expr` is nested /// within the node of a `Spanned` object. @@ -59,7 +59,7 @@ pub fn ceil_32(n: usize) -> usize { #[cfg(test)] mod tests { use crate::yul::utils::abi_head_offsets; - use fe_semantics::namespace::types::{ + use fe_analyzer::namespace::types::{ Array, Base, FeString, diff --git a/newsfragments/207.internal.md b/newsfragments/207.internal.md new file mode 100644 index 0000000000..1d356141a9 --- /dev/null +++ b/newsfragments/207.internal.md @@ -0,0 +1 @@ +Renamed the fe-semantics library to fe-analyzer. \ No newline at end of file