diff --git a/crates/pyrometer/src/analyzer.rs b/crates/pyrometer/src/analyzer.rs index 364130d0..6a3cb304 100644 --- a/crates/pyrometer/src/analyzer.rs +++ b/crates/pyrometer/src/analyzer.rs @@ -3,7 +3,7 @@ use crate::builtin_fns; use analyzers::LocStrSpan; use graph::{nodes::*, ContextEdge, Edge, Node, VarType}; use shared::{AnalyzerLike, GraphLike, NodeIdx, Search}; -use solc_expressions::{StatementParser, ExprErr, IntoExprErr}; +use solc_expressions::{ExprErr, IntoExprErr, StatementParser}; use ariadne::{Cache, Color, Config, Fmt, Label, Report, ReportKind, Source, Span}; use petgraph::{graph::*, Directed}; diff --git a/crates/solc-expressions/src/array.rs b/crates/solc-expressions/src/array.rs index 616d4722..26f9480a 100644 --- a/crates/solc-expressions/src/array.rs +++ b/crates/solc-expressions/src/array.rs @@ -1,4 +1,7 @@ -use crate::{ExpressionParser, variable::Variable, require::Require, ContextBuilder, ExprErr, IntoExprErr, ListAccess}; +use crate::{ + require::Require, variable::Variable, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, + ListAccess, +}; use graph::{ elem::RangeOp, diff --git a/crates/solc-expressions/src/assign.rs b/crates/solc-expressions/src/assign.rs index a95280e4..a103a503 100644 --- a/crates/solc-expressions/src/assign.rs +++ b/crates/solc-expressions/src/assign.rs @@ -1,9 +1,9 @@ -use crate::{variable::Variable, ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{variable::Variable, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ - elem::Elem, GraphError, Range, + elem::Elem, nodes::{Concrete, ContextNode, ContextVarNode, ExprRet}, - AnalyzerBackend, ContextEdge, Edge, + AnalyzerBackend, ContextEdge, Edge, GraphError, Range, }; use solang_parser::pt::{Expression, Loc}; @@ -11,7 +11,7 @@ use solang_parser::pt::{Expression, Loc}; impl Assign for T where T: AnalyzerBackend + Sized {} /// Handles assignments pub trait Assign: AnalyzerBackend + Sized { -#[tracing::instrument(level = "trace", skip_all)] + #[tracing::instrument(level = "trace", skip_all)] /// Parse an assignment expression fn assign_exprs( &mut self, @@ -239,4 +239,3 @@ pub trait Assign: AnalyzerBackend + Sized Ok(ExprRet::Single(new_lhs.into())) } } - \ No newline at end of file diff --git a/crates/solc-expressions/src/bin_op.rs b/crates/solc-expressions/src/bin_op.rs index da328dea..86ff6d67 100644 --- a/crates/solc-expressions/src/bin_op.rs +++ b/crates/solc-expressions/src/bin_op.rs @@ -1,4 +1,6 @@ -use crate::{variable::Variable, require::Require, ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{ + require::Require, variable::Variable, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, +}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/cmp.rs b/crates/solc-expressions/src/cmp.rs index bd3fe7f8..ed67222d 100644 --- a/crates/solc-expressions/src/cmp.rs +++ b/crates/solc-expressions/src/cmp.rs @@ -1,4 +1,4 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/cond_op.rs b/crates/solc-expressions/src/cond_op.rs index df688f58..999e2489 100644 --- a/crates/solc-expressions/src/cond_op.rs +++ b/crates/solc-expressions/src/cond_op.rs @@ -1,4 +1,6 @@ -use crate::{require::Require, ContextBuilder, ExprErr, IntoExprErr, StatementParser, ExpressionParser}; +use crate::{ + require::Require, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, StatementParser, +}; use graph::{ nodes::{Context, ContextNode}, diff --git a/crates/solc-expressions/src/context_builder/expr.rs b/crates/solc-expressions/src/context_builder/expr.rs index 407f2c5c..3a551e69 100644 --- a/crates/solc-expressions/src/context_builder/expr.rs +++ b/crates/solc-expressions/src/context_builder/expr.rs @@ -1,24 +1,20 @@ use crate::{ - context_builder::ContextBuilder, - variable::Variable, - func_call::{func_caller::FuncCaller}, ExprErr, ExprTyParser, IntoExprErr, + context_builder::ContextBuilder, func_call::func_caller::FuncCaller, variable::Variable, + ExprErr, ExprTyParser, IntoExprErr, }; use graph::{ elem::*, - nodes::{ - Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet, - }, + nodes::{Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet}, AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, }; -use ethers_core::types::{I256}; +use ethers_core::types::I256; use solang_parser::{ helpers::CodeLocation, pt::{Expression, Loc}, }; - impl ExpressionParser for T where T: AnalyzerBackend + Sized + ExprTyParser { @@ -28,7 +24,7 @@ impl ExpressionParser for T where pub trait ExpressionParser: AnalyzerBackend + Sized + ExprTyParser { - /// Perform setup for parsing an expression + /// Perform setup for parsing an expression fn parse_ctx_expr(&mut self, expr: &Expression, ctx: ContextNode) -> Result<(), ExprErr> { if !ctx.killed_or_ret(self).unwrap() { let edges = ctx.live_edges(self).into_expr_err(expr.loc())?; @@ -390,4 +386,4 @@ pub trait ExpressionParser: Parenthesis(_loc, expr) => self.parse_ctx_expr(expr, ctx), } } -} \ No newline at end of file +} diff --git a/crates/solc-expressions/src/context_builder/mod.rs b/crates/solc-expressions/src/context_builder/mod.rs index a26a7a87..35b58142 100644 --- a/crates/solc-expressions/src/context_builder/mod.rs +++ b/crates/solc-expressions/src/context_builder/mod.rs @@ -1,12 +1,8 @@ //! Trait and blanket implementation for the core parsing loop -use crate::{ - ExprErr, IntoExprErr, -}; +use crate::{ExprErr, IntoExprErr}; use graph::{ - nodes::{ - ContextNode, ContextVarNode, ExprRet, KilledKind, - }, + nodes::{ContextNode, ContextVarNode, ExprRet, KilledKind}, AnalyzerBackend, ContextEdge, Edge, GraphError, }; @@ -17,17 +13,16 @@ impl ContextBuilder for T where { } -mod stmt; mod expr; +mod stmt; -pub use stmt::*; pub use expr::*; +pub use stmt::*; /// Dispatcher for building up a context of a function pub trait ContextBuilder: AnalyzerBackend + Sized + StatementParser { - /// TODO: rename this. Sometimes we dont want to kill a context if we hit an error fn widen_if_limit_hit(&mut self, ctx: ContextNode, maybe_err: Result<(), ExprErr>) -> bool { match maybe_err { diff --git a/crates/solc-expressions/src/context_builder/stmt.rs b/crates/solc-expressions/src/context_builder/stmt.rs index 526b6ae4..50a1d6b6 100644 --- a/crates/solc-expressions/src/context_builder/stmt.rs +++ b/crates/solc-expressions/src/context_builder/stmt.rs @@ -1,27 +1,26 @@ - use crate::{ - context_builder::ContextBuilder, - ExpressionParser, - func_call::{func_caller::FuncCaller, modifier::ModifierCaller}, loops::Looper, yul::YulBuilder, ExprErr, IntoExprErr, + context_builder::ContextBuilder, + func_call::{func_caller::FuncCaller, modifier::ModifierCaller}, + loops::Looper, + yul::YulBuilder, + ExprErr, ExpressionParser, IntoExprErr, }; use graph::{ nodes::{ - Context, ContextNode, ContextVar, ContextVarNode, ExprRet, FunctionNode, - FunctionParamNode, FunctionReturnNode, KilledKind, + Context, ContextNode, ContextVar, ContextVarNode, ExprRet, FunctionNode, FunctionParamNode, + FunctionReturnNode, KilledKind, }, AnalyzerBackend, ContextEdge, Edge, Node, }; use shared::NodeIdx; - use petgraph::{visit::EdgeRef, Direction}; use solang_parser::{ helpers::CodeLocation, pt::{Expression, Statement, YulStatement}, }; - impl StatementParser for T where T: AnalyzerBackend + Sized + ExpressionParser { @@ -525,4 +524,4 @@ pub trait StatementParser: Error(_loc) => {} } } -} \ No newline at end of file +} diff --git a/crates/solc-expressions/src/env.rs b/crates/solc-expressions/src/env.rs index 54060832..17c73755 100644 --- a/crates/solc-expressions/src/env.rs +++ b/crates/solc-expressions/src/env.rs @@ -1,4 +1,6 @@ -use crate::{func_call::helper::CallerHelper, func_call::modifier::ModifierCaller, ExprErr, IntoExprErr}; +use crate::{ + func_call::helper::CallerHelper, func_call::modifier::ModifierCaller, ExprErr, IntoExprErr, +}; use graph::{ nodes::{Builtin, Concrete, ContextNode, ContextVar, ExprRet}, diff --git a/crates/solc-expressions/src/func_call/func_caller.rs b/crates/solc-expressions/src/func_call/func_caller.rs index 39f859ca..7418cd60 100644 --- a/crates/solc-expressions/src/func_call/func_caller.rs +++ b/crates/solc-expressions/src/func_call/func_caller.rs @@ -1,20 +1,19 @@ //! Traits & blanket implementations that facilitate performing various forms of function calls. use crate::{ - func_call::modifier::ModifierCaller, - internal_call::InternalFuncCaller, intrinsic_call::IntrinsicFuncCaller, - namespaced_call::NameSpaceFuncCaller, ContextBuilder, ExprErr, IntoExprErr, - helper::CallerHelper, ExpressionParser, StatementParser, + func_call::modifier::ModifierCaller, helper::CallerHelper, internal_call::InternalFuncCaller, + intrinsic_call::IntrinsicFuncCaller, namespaced_call::NameSpaceFuncCaller, ContextBuilder, + ExprErr, ExpressionParser, IntoExprErr, StatementParser, }; use graph::{ nodes::{ - Context, ContextNode, ContextVar, ContextVarNode, ExprRet, FunctionNode, - FunctionParamNode, ModifierState, + Context, ContextNode, ContextVar, ContextVarNode, ExprRet, FunctionNode, FunctionParamNode, + ModifierState, }, AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, }; -use shared::{NodeIdx}; +use shared::NodeIdx; use solang_parser::pt::{Expression, Loc, NamedArgument}; @@ -296,7 +295,6 @@ pub trait FuncCaller: }) } - /// Actually executes the function #[tracing::instrument(level = "trace", skip_all)] fn execute_call_inner( diff --git a/crates/solc-expressions/src/func_call/helper.rs b/crates/solc-expressions/src/func_call/helper.rs index 732f9b0c..62446fd3 100644 --- a/crates/solc-expressions/src/func_call/helper.rs +++ b/crates/solc-expressions/src/func_call/helper.rs @@ -1,7 +1,5 @@ //! Helper traits & blanket implementations that help facilitate performing function calls. -use crate::{ - ContextBuilder, ExprErr, IntoExprErr, variable::Variable, ExpressionParser -}; +use crate::{variable::Variable, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ nodes::{ @@ -14,11 +12,7 @@ use shared::{NodeIdx, StorageLocation}; use solang_parser::pt::{Expression, Loc}; -use std::{ - cell::RefCell, - collections::BTreeMap, - rc::Rc -}; +use std::{cell::RefCell, collections::BTreeMap, rc::Rc}; impl CallerHelper for T where T: AnalyzerBackend + Sized {} /// Helper trait for performing function calls @@ -582,4 +576,4 @@ pub trait CallerHelper: AnalyzerBackend + } Ok(()) } -} \ No newline at end of file +} diff --git a/crates/solc-expressions/src/func_call/internal_call.rs b/crates/solc-expressions/src/func_call/internal_call.rs index 5200c111..c053b4e3 100644 --- a/crates/solc-expressions/src/func_call/internal_call.rs +++ b/crates/solc-expressions/src/func_call/internal_call.rs @@ -1,6 +1,9 @@ //! Traits & blanket implementations that facilitate performing locally scoped function calls. -use crate::{func_call::func_caller::FuncCaller, helper::CallerHelper, ContextBuilder, ExprErr, IntoExprErr, ExpressionParser, assign::Assign}; +use crate::{ + assign::Assign, func_call::func_caller::FuncCaller, helper::CallerHelper, ContextBuilder, + ExprErr, ExpressionParser, IntoExprErr, +}; use graph::{ nodes::{Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet}, @@ -232,7 +235,13 @@ pub trait InternalFuncCaller: ctx.push_expr(inputs, analyzer).into_expr_err(loc)?; return Ok(()); } - analyzer.setup_fn_call(&ident.loc, &inputs, (possible_funcs[0]).into(), ctx, None) + analyzer.setup_fn_call( + &ident.loc, + &inputs, + (possible_funcs[0]).into(), + ctx, + None, + ) }) } _ => { diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/abi.rs b/crates/solc-expressions/src/func_call/intrinsic_call/abi.rs index f85c060f..84e7befb 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/abi.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/abi.rs @@ -1,4 +1,4 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ nodes::{Builtin, ContextNode, ContextVar, ExprRet}, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/array.rs b/crates/solc-expressions/src/func_call/intrinsic_call/array.rs index f3a14803..059b0fcd 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/array.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/array.rs @@ -1,4 +1,7 @@ -use crate::{array::Array, ContextBuilder, ExprErr, IntoExprErr, ListAccess, ExpressionParser, assign::Assign, variable::Variable}; +use crate::{ + array::Array, assign::Assign, variable::Variable, ContextBuilder, ExprErr, ExpressionParser, + IntoExprErr, ListAccess, +}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/block.rs b/crates/solc-expressions/src/func_call/intrinsic_call/block.rs index 53ede044..edb12ead 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/block.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/block.rs @@ -1,4 +1,4 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ nodes::{Builtin, ContextNode, ContextVar, ExprRet}, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/constructors.rs b/crates/solc-expressions/src/func_call/intrinsic_call/constructors.rs index 61859472..a6f4717a 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/constructors.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/constructors.rs @@ -1,4 +1,7 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, func_call::helper::CallerHelper, ExpressionParser, assign::Assign}; +use crate::{ + assign::Assign, func_call::helper::CallerHelper, ContextBuilder, ExprErr, ExpressionParser, + IntoExprErr, +}; use graph::{ elem::*, @@ -15,7 +18,9 @@ impl ConstructorCaller for T where } /// Trait for constructing compound types like contracts, structs and arrays -pub trait ConstructorCaller: AnalyzerBackend + Sized + CallerHelper { +pub trait ConstructorCaller: + AnalyzerBackend + Sized + CallerHelper +{ /// Construct an array fn construct_array( &mut self, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/dyn_builtin.rs b/crates/solc-expressions/src/func_call/intrinsic_call/dyn_builtin.rs index f06e7421..ef7a610e 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/dyn_builtin.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/dyn_builtin.rs @@ -1,4 +1,4 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ nodes::{Builtin, Concrete, ContextNode, ContextVarNode, ExprRet}, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/intrinsic_caller.rs b/crates/solc-expressions/src/func_call/intrinsic_call/intrinsic_caller.rs index 21b83e57..a6126edf 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/intrinsic_caller.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/intrinsic_caller.rs @@ -1,9 +1,10 @@ use crate::{ + func_call::helper::CallerHelper, intrinsic_call::{ AbiCaller, AddressCaller, ArrayCaller, BlockCaller, ConstructorCaller, DynBuiltinCaller, MsgCaller, PrecompileCaller, SolidityCaller, TypesCaller, }, - ContextBuilder, ExprErr, IntoExprErr, func_call::helper::CallerHelper + ContextBuilder, ExprErr, IntoExprErr, }; use graph::{ diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/precompile.rs b/crates/solc-expressions/src/func_call/intrinsic_call/precompile.rs index ec0616fc..9bcb866c 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/precompile.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/precompile.rs @@ -1,4 +1,6 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, func_call::helper::CallerHelper, ExpressionParser}; +use crate::{ + func_call::helper::CallerHelper, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, +}; use graph::{ nodes::{Builtin, Context, ContextNode, ContextVar, ContextVarNode, ExprRet}, @@ -8,11 +10,15 @@ use shared::NodeIdx; use solang_parser::pt::{Expression, Loc}; -impl PrecompileCaller for T where T: AnalyzerBackend + Sized + CallerHelper -{} +impl PrecompileCaller for T where + T: AnalyzerBackend + Sized + CallerHelper +{ +} /// Trait for calling precompile intrinsic functions, like `ecrecover` -pub trait PrecompileCaller: AnalyzerBackend + Sized + CallerHelper { +pub trait PrecompileCaller: + AnalyzerBackend + Sized + CallerHelper +{ /// Perform a precompile's function call, like `ecrecover` fn precompile_call( &mut self, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/solidity.rs b/crates/solc-expressions/src/func_call/intrinsic_call/solidity.rs index 7614d827..70b5e76d 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/solidity.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/solidity.rs @@ -1,4 +1,7 @@ -use crate::{require::Require, ContextBuilder, ExprErr, func_call::helper::CallerHelper, IntoExprErr, ExpressionParser}; +use crate::{ + func_call::helper::CallerHelper, require::Require, ContextBuilder, ExprErr, ExpressionParser, + IntoExprErr, +}; use graph::{ nodes::{Builtin, ContextNode, ContextVar, ExprRet}, @@ -7,10 +10,15 @@ use graph::{ use solang_parser::pt::{Expression, Loc}; -impl SolidityCaller for T where T: AnalyzerBackend + Sized + CallerHelper {} +impl SolidityCaller for T where + T: AnalyzerBackend + Sized + CallerHelper +{ +} /// Trait for calling solidity's intrinsic functions, like `keccak256` -pub trait SolidityCaller: AnalyzerBackend + Sized + CallerHelper { +pub trait SolidityCaller: + AnalyzerBackend + Sized + CallerHelper +{ /// Perform a solidity intrinsic function call, like `keccak256` fn solidity_call( &mut self, diff --git a/crates/solc-expressions/src/func_call/intrinsic_call/types.rs b/crates/solc-expressions/src/func_call/intrinsic_call/types.rs index 5d1d5a7f..a0379fbc 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call/types.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call/types.rs @@ -1,4 +1,7 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, func_call::helper::CallerHelper, ExpressionParser, variable::Variable}; +use crate::{ + func_call::helper::CallerHelper, variable::Variable, ContextBuilder, ExprErr, ExpressionParser, + IntoExprErr, +}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/func_call/mod.rs b/crates/solc-expressions/src/func_call/mod.rs index a4ea9278..ac6bd0c2 100644 --- a/crates/solc-expressions/src/func_call/mod.rs +++ b/crates/solc-expressions/src/func_call/mod.rs @@ -1,6 +1,6 @@ +pub mod func_caller; pub mod helper; pub mod internal_call; pub mod intrinsic_call; pub mod modifier; pub mod namespaced_call; -pub mod func_caller; diff --git a/crates/solc-expressions/src/func_call/modifier.rs b/crates/solc-expressions/src/func_call/modifier.rs index 5d32c98b..321781ef 100644 --- a/crates/solc-expressions/src/func_call/modifier.rs +++ b/crates/solc-expressions/src/func_call/modifier.rs @@ -1,25 +1,32 @@ //! Traits & blanket implementations that facilitate performing modifier function calls. use crate::{ - helper::CallerHelper, ContextBuilder, ExprErr, IntoExprErr, func_caller::FuncCaller, ExpressionParser + func_caller::FuncCaller, helper::CallerHelper, ContextBuilder, ExprErr, ExpressionParser, + IntoExprErr, }; use graph::{ - nodes::{ - Context, ContextNode, ExprRet, FunctionNode, ModifierState, - }, + nodes::{Context, ContextNode, ExprRet, FunctionNode, ModifierState}, AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, }; -use solang_parser::pt::{Expression, Loc, CodeLocation}; +use solang_parser::pt::{CodeLocation, Expression, Loc}; impl ModifierCaller for T where - T: AnalyzerBackend + Sized + GraphBackend + FuncCaller + CallerHelper + T: AnalyzerBackend + + Sized + + GraphBackend + + FuncCaller + + CallerHelper { } /// A trait for dealing with modifier calls pub trait ModifierCaller: - GraphBackend + AnalyzerBackend + Sized + FuncCaller + CallerHelper + GraphBackend + + AnalyzerBackend + + Sized + + FuncCaller + + CallerHelper { /// Calls a modifier for a function #[tracing::instrument(level = "trace", skip_all)] diff --git a/crates/solc-expressions/src/func_call/namespaced_call.rs b/crates/solc-expressions/src/func_call/namespaced_call.rs index e123f644..b6079862 100644 --- a/crates/solc-expressions/src/func_call/namespaced_call.rs +++ b/crates/solc-expressions/src/func_call/namespaced_call.rs @@ -1,10 +1,9 @@ //! Traits & blanket implementations that facilitate performing namespaced function calls. use crate::{ - func_call::helper::CallerHelper, - func_call::func_caller::FuncCaller, - intrinsic_call::IntrinsicFuncCaller, member_access::MemberAccess, ContextBuilder, ExprErr, IntoExprErr, - ExpressionParser + func_call::func_caller::FuncCaller, func_call::helper::CallerHelper, + intrinsic_call::IntrinsicFuncCaller, member_access::MemberAccess, ContextBuilder, ExprErr, + ExpressionParser, IntoExprErr, }; use graph::{ diff --git a/crates/solc-expressions/src/lib.rs b/crates/solc-expressions/src/lib.rs index 46f202cc..95fe792b 100644 --- a/crates/solc-expressions/src/lib.rs +++ b/crates/solc-expressions/src/lib.rs @@ -12,9 +12,9 @@ mod list; mod literal; mod loops; mod member_access; +mod pre_post_in_decrement; mod require; mod variable; -mod pre_post_in_decrement; pub mod yul; pub use array::*; @@ -29,17 +29,39 @@ pub use list::*; pub use literal::*; pub use loops::*; pub use member_access::*; +pub use pre_post_in_decrement::*; pub use require::*; pub use variable::*; -pub use pre_post_in_decrement::*; /// Supertrait for parsing expressions pub trait ExprTyParser: - BinOp + Require + Variable + Literal + Array + MemberAccess + Cmp + CondOp + List + Env + PrePostIncDecrement + Assign + BinOp + + Require + + Variable + + Literal + + Array + + MemberAccess + + Cmp + + CondOp + + List + + Env + + PrePostIncDecrement + + Assign { } impl ExprTyParser for T where - T: BinOp + Require + Variable + Literal + Array + MemberAccess + Cmp + CondOp + List + Env + PrePostIncDecrement + Assign + T: BinOp + + Require + + Variable + + Literal + + Array + + MemberAccess + + Cmp + + CondOp + + List + + Env + + PrePostIncDecrement + + Assign { } diff --git a/crates/solc-expressions/src/list.rs b/crates/solc-expressions/src/list.rs index 1846d1a5..332f451f 100644 --- a/crates/solc-expressions/src/list.rs +++ b/crates/solc-expressions/src/list.rs @@ -1,4 +1,4 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, ExpressionParser}; +use crate::{ContextBuilder, ExprErr, ExpressionParser, IntoExprErr}; use graph::{ nodes::{ContextNode, ContextVar, ExprRet}, diff --git a/crates/solc-expressions/src/member_access/list_access.rs b/crates/solc-expressions/src/member_access/list_access.rs index 0b28f68d..354f971c 100644 --- a/crates/solc-expressions/src/member_access/list_access.rs +++ b/crates/solc-expressions/src/member_access/list_access.rs @@ -1,4 +1,4 @@ -use crate::{ContextBuilder, ExprErr, IntoExprErr, Variable, ExpressionParser}; +use crate::{ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, Variable}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/member_access/member_trait.rs b/crates/solc-expressions/src/member_access/member_trait.rs index 8395c539..893db13d 100644 --- a/crates/solc-expressions/src/member_access/member_trait.rs +++ b/crates/solc-expressions/src/member_access/member_trait.rs @@ -1,6 +1,6 @@ use crate::{ - BuiltinAccess, ContextBuilder, ContractAccess, EnumAccess, Env, ExprErr, IntoExprErr, - ListAccess, StructAccess, ExpressionParser + BuiltinAccess, ContextBuilder, ContractAccess, EnumAccess, Env, ExprErr, ExpressionParser, + IntoExprErr, ListAccess, StructAccess, }; use graph::{ diff --git a/crates/solc-expressions/src/pre_post_in_decrement.rs b/crates/solc-expressions/src/pre_post_in_decrement.rs index 6886b2fa..48417121 100644 --- a/crates/solc-expressions/src/pre_post_in_decrement.rs +++ b/crates/solc-expressions/src/pre_post_in_decrement.rs @@ -1,27 +1,32 @@ use crate::{ - context_builder::ContextBuilder, - variable::Variable, ExprErr, IntoExprErr, ExpressionParser + context_builder::ContextBuilder, variable::Variable, ExprErr, ExpressionParser, IntoExprErr, }; use graph::{ elem::*, - nodes::{ - Concrete, ContextNode, ContextVarNode, ExprRet, - }, + nodes::{Concrete, ContextNode, ContextVarNode, ExprRet}, AnalyzerBackend, }; -use ethers_core::types::{U256}; -use solang_parser::{ - pt::{Expression, Loc}, -}; +use ethers_core::types::U256; +use solang_parser::pt::{Expression, Loc}; -impl PrePostIncDecrement for T where T: AnalyzerBackend + Sized {} +impl PrePostIncDecrement for T where + T: AnalyzerBackend + Sized +{ +} /// Handles pre and post increment and decrement -pub trait PrePostIncDecrement: AnalyzerBackend + Sized { - /// Handle a preincrement - fn pre_increment(&mut self, expr: &Expression, loc: Loc, ctx: ContextNode) -> Result<(), ExprErr> { - self.parse_ctx_expr(expr, ctx)?; +pub trait PrePostIncDecrement: + AnalyzerBackend + Sized +{ + /// Handle a preincrement + fn pre_increment( + &mut self, + expr: &Expression, + loc: Loc, + ctx: ContextNode, + ) -> Result<(), ExprErr> { + self.parse_ctx_expr(expr, ctx)?; self.apply_to_edges(ctx, loc, &|analyzer, ctx, loc| { tracing::trace!("PreIncrement variable pop"); let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else { @@ -37,11 +42,16 @@ pub trait PrePostIncDecrement: AnalyzerBackend Result<(), ExprErr> { - self.parse_ctx_expr(expr, ctx)?; + /// Handle a postincrement + fn post_increment( + &mut self, + expr: &Expression, + loc: Loc, + ctx: ContextNode, + ) -> Result<(), ExprErr> { + self.parse_ctx_expr(expr, ctx)?; self.apply_to_edges(ctx, loc, &|analyzer, ctx, loc| { tracing::trace!("PostIncrement variable pop"); let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else { @@ -56,11 +66,16 @@ pub trait PrePostIncDecrement: AnalyzerBackend Result<(), ExprErr> { - self.parse_ctx_expr(expr, ctx)?; + /// Handle a predecrement + fn pre_decrement( + &mut self, + expr: &Expression, + loc: Loc, + ctx: ContextNode, + ) -> Result<(), ExprErr> { + self.parse_ctx_expr(expr, ctx)?; self.apply_to_edges(ctx, loc, &|analyzer, ctx, loc| { tracing::trace!("PreDecrement variable pop"); let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else { @@ -75,11 +90,16 @@ pub trait PrePostIncDecrement: AnalyzerBackend Result<(), ExprErr> { - self.parse_ctx_expr(expr, ctx)?; + /// Handle a postdecrement + fn post_decrement( + &mut self, + expr: &Expression, + loc: Loc, + ctx: ContextNode, + ) -> Result<(), ExprErr> { + self.parse_ctx_expr(expr, ctx)?; self.apply_to_edges(ctx, loc, &|analyzer, ctx, loc| { tracing::trace!("PostDecrement variable pop"); let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else { @@ -94,9 +114,9 @@ pub trait PrePostIncDecrement: AnalyzerBackend Ok(()), } } -} \ No newline at end of file +} diff --git a/crates/solc-expressions/src/require.rs b/crates/solc-expressions/src/require.rs index b490bbd6..f37318bb 100644 --- a/crates/solc-expressions/src/require.rs +++ b/crates/solc-expressions/src/require.rs @@ -1,4 +1,4 @@ -use crate::{ExpressionParser, BinOp, ContextBuilder, ExprErr, IntoExprErr, Variable}; +use crate::{BinOp, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, Variable}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/variable.rs b/crates/solc-expressions/src/variable.rs index 59607d76..fb713c49 100644 --- a/crates/solc-expressions/src/variable.rs +++ b/crates/solc-expressions/src/variable.rs @@ -1,11 +1,11 @@ use crate::{assign::Assign, env::Env, ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - nodes::{ContextVarNode, ContextNode, ContextVar, ExprRet, VarNode}, - GraphError, AnalyzerBackend, ContextEdge, Edge, Node, VarType, + nodes::{ContextNode, ContextVar, ContextVarNode, ExprRet, VarNode}, + AnalyzerBackend, ContextEdge, Edge, GraphError, Node, VarType, }; -use solang_parser::pt::{VariableDeclaration, Loc, Expression, Identifier}; +use solang_parser::pt::{Expression, Identifier, Loc, VariableDeclaration}; impl Variable for T where T: AnalyzerBackend + Sized {} /// Deals with variable retrieval, parsing, and versioning diff --git a/crates/solc-expressions/src/yul/mod.rs b/crates/solc-expressions/src/yul/mod.rs index aa6f8d1a..d7a4fd29 100644 --- a/crates/solc-expressions/src/yul/mod.rs +++ b/crates/solc-expressions/src/yul/mod.rs @@ -5,4 +5,4 @@ mod yul_cond_op; mod yul_funcs; pub use yul_builder::*; pub use yul_cond_op::*; -pub use yul_funcs::*; \ No newline at end of file +pub use yul_funcs::*; diff --git a/crates/solc-expressions/src/yul/yul_builder.rs b/crates/solc-expressions/src/yul/yul_builder.rs index 02b798c0..f3f43c53 100644 --- a/crates/solc-expressions/src/yul/yul_builder.rs +++ b/crates/solc-expressions/src/yul/yul_builder.rs @@ -1,9 +1,7 @@ //! Trait and blanket implementation for parsing yul-based statements and expressions use crate::{ - ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, - yul::YulFuncCaller, - yul::YulCondOp + yul::YulCondOp, yul::YulFuncCaller, ContextBuilder, ExprErr, ExpressionParser, IntoExprErr, }; use graph::{ @@ -16,7 +14,6 @@ use solang_parser::{ pt::{Expression, Loc, YulExpression, YulFor, YulStatement, YulSwitch}, }; - impl YulBuilder for T where T: AnalyzerBackend + Sized + ExpressionParser { diff --git a/crates/solc-expressions/src/yul/yul_cond_op.rs b/crates/solc-expressions/src/yul/yul_cond_op.rs index 7f5f74a2..f7bc1737 100644 --- a/crates/solc-expressions/src/yul/yul_cond_op.rs +++ b/crates/solc-expressions/src/yul/yul_cond_op.rs @@ -1,4 +1,4 @@ -use crate::{require::Require, ContextBuilder, ExprErr, IntoExprErr, yul::YulBuilder}; +use crate::{require::Require, yul::YulBuilder, ContextBuilder, ExprErr, IntoExprErr}; use graph::{ elem::*, diff --git a/crates/solc-expressions/src/yul/yul_funcs.rs b/crates/solc-expressions/src/yul/yul_funcs.rs index f67454f5..c725e930 100644 --- a/crates/solc-expressions/src/yul/yul_funcs.rs +++ b/crates/solc-expressions/src/yul/yul_funcs.rs @@ -1,4 +1,6 @@ -use crate::{variable::Variable, BinOp, Cmp, ContextBuilder, Env, ExprErr, IntoExprErr, yul::YulBuilder}; +use crate::{ + variable::Variable, yul::YulBuilder, BinOp, Cmp, ContextBuilder, Env, ExprErr, IntoExprErr, +}; use graph::{ elem::*,