diff --git a/crates/metaslang/bindings/generated/public_api.txt b/crates/metaslang/bindings/generated/public_api.txt index f98a7e4582..59b63d67ae 100644 --- a/crates/metaslang/bindings/generated/public_api.txt +++ b/crates/metaslang/bindings/generated/public_api.txt @@ -22,7 +22,6 @@ pub fn metaslang_bindings::Bindings::all_references(&self) -> impl core::ite pub fn metaslang_bindings::Bindings::create(version: semver::Version, binding_rules: &str, path_resolver: alloc::sync::Arc<(dyn metaslang_bindings::PathResolver + core::marker::Sync + core::marker::Send)>) -> Self pub fn metaslang_bindings::Bindings::definition_at(&self, cursor: &metaslang_cst::cursor::Cursor) -> core::option::Option> pub fn metaslang_bindings::Bindings::get_context(&self) -> core::option::Option> -pub fn metaslang_bindings::Bindings::lookup_definition_by_name(&self, name: &str) -> core::option::Option> pub fn metaslang_bindings::Bindings::reference_at(&self, cursor: &metaslang_cst::cursor::Cursor) -> core::option::Option> pub fn metaslang_bindings::Bindings::set_context(&mut self, context: &metaslang_bindings::DefinitionHandle) pub struct metaslang_bindings::Definition<'a, KT: metaslang_cst::kinds::KindTypes + 'static> @@ -48,7 +47,7 @@ impl<'a, KT: metaslang_cst::kinds::KindTypes + 'static> metaslang_bindings::Refe pub fn metaslang_bindings::Reference<'a, KT>::definitions(&self) -> alloc::vec::Vec> pub fn metaslang_bindings::Reference<'a, KT>::get_cursor(&self) -> core::option::Option> pub fn metaslang_bindings::Reference<'a, KT>::get_file(&self) -> metaslang_bindings::FileDescriptor -pub fn metaslang_bindings::Reference<'a, KT>::jump_to_definition(&self) -> core::result::Result, metaslang_bindings::ResolutionError<'a, KT>> +pub fn metaslang_bindings::Reference<'a, KT>::resolve_definition(&self) -> core::result::Result, metaslang_bindings::ResolutionError<'a, KT>> impl<'a, KT: core::clone::Clone + metaslang_cst::kinds::KindTypes + 'static> core::clone::Clone for metaslang_bindings::Reference<'a, KT> pub fn metaslang_bindings::Reference<'a, KT>::clone(&self) -> metaslang_bindings::Reference<'a, KT> impl core::cmp::PartialEq for metaslang_bindings::Reference<'_, KT> diff --git a/crates/metaslang/bindings/src/builder/mod.rs b/crates/metaslang/bindings/src/builder/mod.rs index 3a27e9b1cc..f768302d52 100644 --- a/crates/metaslang/bindings/src/builder/mod.rs +++ b/crates/metaslang/bindings/src/builder/mod.rs @@ -130,7 +130,7 @@ //! To do this, add a `source_node` attribute, whose value is a syntax node capture: //! //! ``` skip -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]]] { //! node def //! attr (def) type = "pop_symbol", symbol = (source-text @id), source_node = @func, is_definition //! } @@ -161,7 +161,7 @@ //! `syntax_type` attribute, whose value is a string indicating the syntax type. //! //! ``` skip -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]]] { //! node def //! ; ... //! attr (def) syntax_type = "function" @@ -175,7 +175,7 @@ //! `definiens_node` attribute, whose value is a syntax node that spans the definiens. //! //! ``` skip -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ... @body [FunctionBody] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]] @body [FunctionBody]] { //! node def //! ; ... //! attr (def) definiens_node = @body @@ -189,7 +189,7 @@ //! To connect two stack graph nodes, use the `edge` statement to add an edge between them: //! //! ``` skip -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]]] { //! node def //! attr (def) type = "pop_symbol", symbol = (source-text @id), source_node = @func, is_definition //! node body @@ -201,7 +201,7 @@ //! you can add a `precedence` attribute to each edge to indicate which paths are prioritized: //! //! ``` skip -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]]] { //! node def //! attr (def) type = "pop_symbol", symbol = (source-text @id), source_node = @func, is_definition //! node body @@ -220,7 +220,7 @@ //! ``` skip //! global ROOT_NODE //! -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]]] { //! node def //! attr (def) type = "pop_symbol", symbol = (source-text @id), source_node = @func, is_definition //! edge ROOT_NODE -> def @@ -235,7 +235,7 @@ //! a scope node with a kind as follows: //! //! ``` skip -//! @func [FunctionDefinition ... [FunctionName @id [Identifier]] ...] { +//! @func [FunctionDefinition [FunctionName @id [Identifier]]] { //! ; ... //! node param_scope //! attr (param_scope) debug_kind = "param_scope" @@ -243,6 +243,72 @@ //! } //! ``` //! +//! ### Other node attributes introduced in Slang's usage of stack-graphs +//! +//! #### `tag` attribute +//! +//! This is used to attach a specific meaning to the node, to alter the ranking +//! algorithm used when attempting to disambiguate between multiple definitions +//! found for a reference. This is an optional string attribute. +//! +//! Possible values: +//! +//! - "alias": marks a definition node as a semantic alias of another definition +//! (eg. an import alias) +//! +//! - "c3": used to mark a function/method definition to be a candidate in +//! disambiguation using the C3 linearisation algorithm. In order for C3 +//! linearisation to be possible, type hierarchy attributes need to be provided +//! as well (see `parents` attribute below). +//! +//! - "super": marks a reference as a call to super virtual call. This modifies +//! the C3 linearisation algorithm by eliminating the candidates that are at +//! or further down the hierarchy of where the reference occurs. To determine +//! where the reference occurs, we also use the `parents` attribute. +//! +//! #### `parents` attribute +//! +//! Is used to convey semantic hierarchy. Can be applied to both definitions and +//! references. It's an optional, list of graph nodes attribute. +//! +//! For references it can indicate in which language context the reference +//! occurs (eg. in which method or class). For definitions it can indicate the +//! enclosing type of the definition, or parent classes in a class hierarchy. +//! The parent handles themselves can refer to definitions or references. In the +//! later case, generally speaking they will need to be resolved at resolution +//! time in order to be useful. +//! +//! #### `export_node` and `import_nodes` +//! +//! These are used to define static fixed edges to add via `set_context()`. +//! Using `set_context()` will modify the underlying stack graph by inserting +//! edges from the `import_nodes` of all parents (resolved recursively) of the +//! given context, to the `export_node` associated with the context. +//! +//! This can be used to inject virtual method implementations defined in +//! subclasses in the scope of their parent classes, which are otherwise +//! lexically inaccessible. +//! +//! `export_node` is an optional graph node attribute, and `import_nodes` is an +//! optional list of graph nodes. Both apply only to definition nodes. +//! +//! #### `extension_hook`, `extension_scope` and `inherit_extensions` +//! +//! These attributes enable the bindings API to resolve extension methods by +//! injecting specific scopes at potentially unrelated (lexically speaking) +//! nodes in the stack graph. Availability and application of extension scopes +//! depend on the call site (ie. the reference node). Thus, the extension scope +//! to (potentially) apply when resolving a reference is computed by looking up +//! the `parents` of the reference and then querying those parent nodes for +//! their `extension_scope` (an optional scope node). Any extension providing +//! node can also have the `inherit_extensions` attribute (a boolean) which +//! indicates that the algorithm should recurse and resolve its parents to +//! further look for other extensions scopes. +//! +//! Finally, the attribute `extension_hook` defines where in the graph should +//! these extension scopes be injected. This is typically the root lexical +//! scope. This attribute applies to any scope node and is boolean. +//! mod cancellation; mod functions; @@ -282,6 +348,9 @@ static IS_DEFINITION_ATTR: &str = "is_definition"; static IS_ENDPOINT_ATTR: &str = "is_endpoint"; static IS_EXPORTED_ATTR: &str = "is_exported"; static IS_REFERENCE_ATTR: &str = "is_reference"; +static EXTENSION_HOOK_ATTR: &str = "extension_hook"; +static EXTENSION_SCOPE_ATTR: &str = "extension_scope"; +static INHERIT_EXTENSIONS_ATTR: &str = "inherit_extensions"; static PARENTS_ATTR: &str = "parents"; static SCOPE_ATTR: &str = "scope"; static SOURCE_NODE_ATTR: &str = "source_node"; @@ -302,6 +371,8 @@ static POP_SCOPED_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { EXPORT_NODE_ATTR, IMPORT_NODES_ATTR, SYNTAX_TYPE_ATTR, + EXTENSION_SCOPE_ATTR, + INHERIT_EXTENSIONS_ATTR, ]) }); static POP_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { @@ -315,6 +386,8 @@ static POP_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { EXPORT_NODE_ATTR, IMPORT_NODES_ATTR, SYNTAX_TYPE_ATTR, + EXTENSION_SCOPE_ATTR, + INHERIT_EXTENSIONS_ATTR, ]) }); static PUSH_SCOPED_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { @@ -336,8 +409,14 @@ static PUSH_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { PARENTS_ATTR, ]) }); -static SCOPE_ATTRS: Lazy> = - Lazy::new(|| HashSet::from([TYPE_ATTR, IS_EXPORTED_ATTR, IS_ENDPOINT_ATTR])); +static SCOPE_ATTRS: Lazy> = Lazy::new(|| { + HashSet::from([ + TYPE_ATTR, + IS_EXPORTED_ATTR, + IS_ENDPOINT_ATTR, + EXTENSION_HOOK_ATTR, + ]) +}); // Edge attribute names static PRECEDENCE_ATTR: &str = "precedence"; @@ -362,6 +441,7 @@ pub(crate) struct Builder<'a, KT: KindTypes + 'static> { cursors: HashMap, Cursor>, definitions_info: HashMap, DefinitionBindingInfo>, references_info: HashMap, ReferenceBindingInfo>, + extension_hooks: HashSet>, } pub(crate) struct BuildResult { @@ -370,6 +450,8 @@ pub(crate) struct BuildResult { pub cursors: HashMap, Cursor>, pub definitions_info: HashMap, DefinitionBindingInfo>, pub references_info: HashMap, ReferenceBindingInfo>, + // Nodes where we want to inject extensions + pub extension_hooks: HashSet>, } impl<'a, KT: KindTypes + 'static> Builder<'a, KT> { @@ -392,6 +474,7 @@ impl<'a, KT: KindTypes + 'static> Builder<'a, KT> { cursors: HashMap::new(), definitions_info: HashMap::new(), references_info: HashMap::new(), + extension_hooks: HashSet::new(), } } @@ -480,6 +563,7 @@ impl<'a, KT: KindTypes + 'static> Builder<'a, KT> { cursors: self.cursors, definitions_info: self.definitions_info, references_info: self.references_info, + extension_hooks: self.extension_hooks, }) } @@ -896,6 +980,15 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { None => Vec::new(), }; + let extension_scope = match node.attributes.get(EXTENSION_SCOPE_ATTR) { + Some(extension_scope) => { + Some(self.node_handle_for_graph_node(extension_scope.as_graph_node_ref()?)) + } + None => None, + }; + + let inherit_extensions = Self::load_flag(node, INHERIT_EXTENSIONS_ATTR)?; + self.definitions_info.insert( node_handle, DefinitionBindingInfo { @@ -904,6 +997,8 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { parents, export_node, import_nodes, + extension_scope, + inherit_extensions, }, ); } else if stack_graph_node.is_reference() { @@ -911,6 +1006,10 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { .insert(node_handle, ReferenceBindingInfo { tag, parents }); } + if Self::load_flag(node, EXTENSION_HOOK_ATTR)? { + self.extension_hooks.insert(node_handle); + } + Ok(()) } diff --git a/crates/metaslang/bindings/src/lib.rs b/crates/metaslang/bindings/src/lib.rs index ccc855fca5..af852723b5 100644 --- a/crates/metaslang/bindings/src/lib.rs +++ b/crates/metaslang/bindings/src/lib.rs @@ -11,7 +11,7 @@ use metaslang_cst::cursor::Cursor; use metaslang_cst::kinds::KindTypes; use metaslang_graph_builder::ast::File; use metaslang_graph_builder::functions::Functions; -use resolver::Resolver; +use resolver::{ResolveOptions, Resolver}; use semver::Version; use stack_graphs::graph::StackGraph; @@ -32,10 +32,10 @@ pub(crate) struct DefinitionBindingInfo { definiens: Option>, tag: Option, parents: Vec, - #[allow(dead_code)] export_node: Option, - #[allow(dead_code)] import_nodes: Vec, + extension_scope: Option, + inherit_extensions: bool, } pub(crate) struct ReferenceBindingInfo { @@ -53,6 +53,7 @@ pub struct Bindings { cursor_to_definitions: HashMap, cursor_to_references: HashMap, context: Option, + extension_hooks: HashSet, } pub enum FileDescriptor { @@ -136,6 +137,7 @@ impl Bindings { cursor_to_definitions: HashMap::new(), cursor_to_references: HashMap::new(), context: None, + extension_hooks: HashSet::new(), } } @@ -187,6 +189,7 @@ impl Bindings { self.definitions_info .extend(result.definitions_info.drain()); self.references_info.extend(result.references_info.drain()); + self.extension_hooks.extend(result.extension_hooks.drain()); result } @@ -258,18 +261,13 @@ impl Bindings { // cannot be resolved at this point? self.to_reference(*handle) .unwrap() - .jump_to_definition() + .non_recursive_resolve() .ok() } }) .collect() } - pub fn lookup_definition_by_name(&self, name: &str) -> Option> { - self.all_definitions() - .find(|definition| definition.get_cursor().unwrap().node().unparse() == name) - } - pub fn get_context(&self) -> Option> { self.context.and_then(|handle| self.to_definition(handle)) } @@ -338,6 +336,10 @@ impl Bindings { } results } + + pub(crate) fn is_extension_hook(&self, node_handle: GraphHandle) -> bool { + self.extension_hooks.contains(&node_handle) + } } struct DisplayCursor<'a, KT: KindTypes + 'static> { @@ -401,6 +403,20 @@ impl<'a, KT: KindTypes + 'static> Definition<'a, KT> { .unwrap_or_default() } + pub(crate) fn get_extension_scope(&self) -> Option { + self.owner + .definitions_info + .get(&self.handle) + .and_then(|info| info.extension_scope) + } + + pub(crate) fn inherit_extensions(&self) -> bool { + self.owner + .definitions_info + .get(&self.handle) + .map_or(false, |info| info.inherit_extensions) + } + pub fn to_handle(self) -> DefinitionHandle { DefinitionHandle(self.handle) } @@ -471,12 +487,20 @@ impl<'a, KT: KindTypes + 'static> Reference<'a, KT> { .expect("Reference does not have a valid file descriptor") } - pub fn jump_to_definition(&self) -> Result, ResolutionError<'a, KT>> { - Resolver::build_for(self).first() + pub fn resolve_definition(&self) -> Result, ResolutionError<'a, KT>> { + Resolver::build_for(self, ResolveOptions::Full).first() } pub fn definitions(&self) -> Vec> { - Resolver::build_for(self).all() + Resolver::build_for(self, ResolveOptions::Full).all() + } + + pub(crate) fn non_recursive_resolve( + &self, + ) -> Result, ResolutionError<'a, KT>> { + // This was likely originated from a full resolution call, so cut + // recursion here by restricting the resolution algorithm. + Resolver::build_for(self, ResolveOptions::NonRecursive).first() } pub(crate) fn has_tag(&self, tag: Tag) -> bool { diff --git a/crates/metaslang/bindings/src/resolver/mod.rs b/crates/metaslang/bindings/src/resolver/mod.rs index 46a92cdc0f..f9b425a5c6 100644 --- a/crates/metaslang/bindings/src/resolver/mod.rs +++ b/crates/metaslang/bindings/src/resolver/mod.rs @@ -1,11 +1,15 @@ -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::iter::once; use metaslang_cst::kinds::KindTypes; +use stack_graphs::graph::{Degree, Edge, StackGraph}; use stack_graphs::partial::{PartialPath, PartialPaths}; -use stack_graphs::stitching::{ForwardPartialPathStitcher, GraphEdgeCandidates, StitcherConfig}; +use stack_graphs::stitching::{ + ForwardCandidates, ForwardPartialPathStitcher, GraphEdgeCandidates, GraphEdges, StitcherConfig, +}; +use stack_graphs::CancellationError; -use crate::{Bindings, Definition, Reference, ResolutionError, Tag}; +use crate::{Bindings, Definition, FileHandle, GraphHandle, Reference, ResolutionError, Tag}; mod c3; @@ -37,6 +41,13 @@ pub(crate) struct Resolver<'a, KT: KindTypes + 'static> { reference: Reference<'a, KT>, partials: PartialPaths, results: Vec>, + options: ResolveOptions, +} + +#[derive(Copy, Clone, Eq, PartialEq)] +pub(crate) enum ResolveOptions { + Full, + NonRecursive, } struct ResolvedPath<'a, KT: KindTypes + 'static> { @@ -51,13 +62,79 @@ impl<'a, KT: KindTypes + 'static> ResolvedPath<'a, KT> { } } +/// Candidates for the forward stitching resolution process. This will inject +/// edges to the the given extensions scopes at extension hook nodes when asked +/// for forward candidates (ie. `get_forward_candidates`) by the resolution +/// algorithm. Other than that, it's exactly the same as `GraphEdgeCandidates`. +struct ResolverCandidates<'a, KT: KindTypes + 'static> { + owner: &'a Bindings, + partials: &'a mut PartialPaths, + file: Option, + edges: GraphEdges, + extensions: &'a [GraphHandle], +} + +impl<'a, KT: KindTypes + 'static> ResolverCandidates<'a, KT> { + pub fn new( + owner: &'a Bindings, + partials: &'a mut PartialPaths, + file: Option, + extensions: &'a [GraphHandle], + ) -> Self { + Self { + owner, + partials, + file, + edges: GraphEdges, + extensions, + } + } +} + +impl ForwardCandidates + for ResolverCandidates<'_, KT> +{ + fn get_forward_candidates(&mut self, path: &PartialPath, result: &mut R) + where + R: std::iter::Extend, + { + let node = path.end_node; + result.extend(self.owner.stack_graph.outgoing_edges(node).filter(|e| { + self.file + .map_or(true, |file| self.owner.stack_graph[e.sink].is_in_file(file)) + })); + + if self.owner.is_extension_hook(node) { + // Inject edges from the extension hook node to each extension scope + let mut extension_edges = Vec::new(); + for extension in self.extensions { + extension_edges.push(Edge { + source: node, + sink: *extension, + precedence: 0, + }); + } + result.extend(extension_edges); + } + } + + fn get_joining_candidate_degree(&self, path: &PartialPath) -> Degree { + self.owner.stack_graph.incoming_edge_degree(path.end_node) + } + + fn get_graph_partials_and_db(&mut self) -> (&StackGraph, &mut PartialPaths, &GraphEdges) { + (&self.owner.stack_graph, self.partials, &self.edges) + } +} + impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> { - pub fn build_for(reference: &Reference<'a, KT>) -> Self { + pub fn build_for(reference: &Reference<'a, KT>, options: ResolveOptions) -> Self { let mut resolver = Self { owner: reference.owner, reference: reference.clone(), partials: PartialPaths::new(), results: Vec::new(), + options, }; resolver.resolve(); resolver @@ -65,30 +142,70 @@ impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> { fn resolve(&mut self) { let mut reference_paths = Vec::new(); - ForwardPartialPathStitcher::find_all_complete_partial_paths( - &mut GraphEdgeCandidates::new(&self.owner.stack_graph, &mut self.partials, None), - once(self.reference.handle), - StitcherConfig::default(), - &stack_graphs::NoCancellation, - |_graph, _paths, path| { - reference_paths.push(path.clone()); - }, - ) - .expect("should never be cancelled"); + if self.options == ResolveOptions::Full { + let ref_parents = self.reference.resolve_parents(); + let mut extensions = HashSet::new(); + for parent in &ref_parents { + if let Some(extension_scope) = parent.get_extension_scope() { + extensions.insert(extension_scope); + } + if parent.inherit_extensions() { + #[allow(clippy::mutable_key_type)] + let grand_parents = Self::resolve_parents_all(parent.clone()); + for grand_parent in grand_parents.values().flatten() { + if let Some(extension_scope) = grand_parent.get_extension_scope() { + extensions.insert(extension_scope); + } + } + } + } + let extensions = extensions.drain().collect::>(); + + ForwardPartialPathStitcher::find_all_complete_partial_paths( + &mut ResolverCandidates::new(self.owner, &mut self.partials, None, &extensions), + once(self.reference.handle), + StitcherConfig::default(), + &stack_graphs::NoCancellation, + |_graph, _paths, path| { + reference_paths.push(path.clone()); + }, + ) + .expect("Should never be cancelled"); + } else { + ForwardPartialPathStitcher::find_all_complete_partial_paths( + &mut GraphEdgeCandidates::new(&self.owner.stack_graph, &mut self.partials, None), + once(self.reference.handle), + StitcherConfig::default(), + &stack_graphs::NoCancellation, + |_graph, _paths, path| { + reference_paths.push(path.clone()); + }, + ) + .expect("Should never be cancelled"); + }; + + let mut added_nodes = HashSet::new(); for reference_path in &reference_paths { - if reference_paths - .iter() - .all(|other| !other.shadows(&mut self.partials, reference_path)) + let end_node = reference_path.end_node; + + // There may be duplicate ending nodes with different + // post-conditions in the scope stack, but we only care about the + // definition itself. Hence we need to check for uniqueness. + if !added_nodes.contains(&end_node) + && reference_paths + .iter() + .all(|other| !other.shadows(&mut self.partials, reference_path)) { self.results.push(ResolvedPath { definition: self .owner - .to_definition(reference_path.end_node) + .to_definition(end_node) .expect("path to end in a definition node"), partial_path: reference_path.clone(), score: 0.0, }); + added_nodes.insert(end_node); } } } @@ -130,7 +247,9 @@ impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> { } self.mark_down_aliases(); self.mark_down_built_ins(); - self.rank_c3_methods(); + if self.options == ResolveOptions::Full { + self.rank_c3_methods(); + } self.results.sort_by(|a, b| b.score.total_cmp(&a.score)); } diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 0e341a683b..68c8c2708c 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -22,6 +22,11 @@ inherit .enclosing_def inherit .parent_scope inherit .lexical_scope +; Used to resolve extension methods for `using for *` directives +; This is used as a minor optimization to avoid introducing new possible paths +; when there are no `using for *` directives in the contract. +inherit .star_extension + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Source unit (aka .sol file) @@ -62,14 +67,22 @@ inherit .lexical_scope ;; inherited) for contracts to resolve bases (both in inheritance lists and ;; override specifiers) let @source_unit.parent_scope = @source_unit.lexical_scope + + ; This is used to indicate the resolution algorithm that here's where it + ; should inject any possible extension scopes + attr (@source_unit.lexical_scope) extension_hook + + ; Provide a default star extension sink node that gets inherited. This is + ; connected to from expressions, and those can potentially happen anywhere. + node @source_unit.star_extension } ;; Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( [ContractDefinition] - | [InterfaceDefinition] | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -79,9 +92,12 @@ inherit .lexical_scope | [EventDefinition] )] ]] { - edge @unit_member.lexical_scope -> @source_unit.lexical_scope edge @source_unit.lexical_scope -> @unit_member.def edge @source_unit.defs -> @unit_member.def + + ; In the general case, the lexical scope of the definition connects directly + ; to the source unit's + edge @unit_member.lexical_scope -> @source_unit.lexical_scope } ;; Special case for built-ins: we want to export all symbols in the contract: @@ -94,13 +110,14 @@ inherit .lexical_scope [SourceUnitMember @contract [ContractDefinition name: ["%BuiltIns%"]]] ]] { if (is-system-file FILE_PATH) { - edge @source_unit.defs -> @contract.members - edge @source_unit.defs -> @contract.type_members - edge @source_unit.defs -> @contract.state_vars + edge @source_unit.defs -> @contract.instance } } @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @using [UsingDirective]]]] { + ; TODO: this is the hook for top-level extensions, but this should connect to + ; an extensions scope that gets pushed to the scope stack, as in the case of + ; contracts/libraries (defined further down below). edge @source_unit.lexical_scope -> @using.def } @@ -111,7 +128,7 @@ inherit .lexical_scope edge @source_unit.defs -> @using.def } -;; ... and imports +;; Import connections to the source unit @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember [ImportDirective [ImportClause @import ( @@ -250,28 +267,32 @@ inherit .lexical_scope ;; interface), aka the source unit edge @type_name.push_end -> heir.parent_scope - ;; Make base members accesible as our own members - node member - attr (member) push_symbol = "." + ; Access instance members of the inherited contract/interface, from the + ; instance scope of the inheriting contract/interface + node instance + attr (instance) push_symbol = "@instance" + edge heir.instance -> instance + edge instance -> @type_name.push_begin - node typeof - attr (typeof) push_symbol = "@typeof" - - edge heir.members -> member - edge member -> typeof - edge typeof -> @type_name.push_begin - - ;; Make base defs (eg. enums and structs) accessible as our own - node type_member - attr (type_member) push_symbol = "." - - edge heir.type_members -> type_member - edge type_member -> @type_name.push_begin + ; Base members can also be accessed (from the instance scope) qualified with + ; the base name (eg. `Base.something`) + node member_pop + attr (member_pop) pop_symbol = "." + edge heir.instance -> @type_name.pop_begin + edge @type_name.pop_end -> member_pop + edge member_pop -> instance - ; Resolve the "super" keyword to the inherited type - edge heir.super -> @type_name.push_begin + ; Base namespace-like members (ie. enums, structs, etc) are also accessible as + ; our own namespace members + node ns_member + attr (ns_member) push_symbol = "." + edge heir.ns -> ns_member + edge ns_member -> @type_name.push_begin } +;; The next couple of rules setup a `.parent_refs` attribute to use in the +;; resolution algorithm to perform linearisation of a contract hierarchy. + ;; NOTE: we use anchors here to prevent the query engine from returning all the ;; sublists of possible parents @specifier [InheritanceSpecifier [InheritanceTypes . @parents [_]+ .]] { @@ -294,38 +315,35 @@ inherit .lexical_scope ;;; Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@contract [ContractDefinition] { +@contract [ContractDefinition @name name: [Identifier]] { node @contract.lexical_scope - node @contract.super_scope + node @contract.extensions node @contract.def node @contract.members - node @contract.type_members + node @contract.ns node @contract.modifiers - node @contract.state_vars + node @contract.instance - edge @contract.lexical_scope -> @contract.members - edge @contract.lexical_scope -> @contract.type_members - edge @contract.lexical_scope -> @contract.state_vars + attr (@contract.def) node_definition = @name + attr (@contract.def) definiens_node = @contract + ; The .extensions node is where `using` directives will hook the definitions + attr (@contract.def) extension_scope = @contract.extensions - ;; Modifiers are available as a contract type members through a special '@modifier' symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @contract.type_members -> modifier - edge modifier -> @contract.modifiers + edge @contract.lexical_scope -> @contract.instance - let @contract.enclosing_def = @contract.def -} + ; Instance scope can also see members and our namespace definitions + edge @contract.instance -> @contract.members + edge @contract.instance -> @contract.ns -@contract [ContractDefinition @name name: [Identifier]] { - attr (@contract.def) node_definition = @name - attr (@contract.def) definiens_node = @contract + let @contract.enclosing_def = @contract.def - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + ;; External "instance" scope access: either member access through a variable + ;; of the contract's type, or through calling (which happens on `new` + ;; invocations or casting). These should access only externally accessible + ;; members, such as functions and public variables. node member attr (member) pop_symbol = "." - edge member -> @contract.members + edge member -> @contract.instance node type_def attr (type_def) pop_symbol = "@typeof" @@ -337,81 +355,148 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member - ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @contract.def -> type_member - edge type_member -> @contract.type_members - - ;; Define "this" and connect it to the contract definition + ;; "namespace" scope access + node ns_member + attr (ns_member) pop_symbol = "." + edge @contract.def -> ns_member + edge ns_member -> @contract.ns + + ; Finally there's an @instance guarded path used by derived contracts to + ; access instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @contract.def -> instance + edge instance -> @contract.instance + + ; "this" keyword is available in our lexical scope and can access any + ; externally available member node this attr (this) pop_symbol = "this" - edge this -> member - - ;; ... and make it available in the contract's lexical scope edge @contract.lexical_scope -> this + edge this -> member - ; Resolve the "this" keyword to the contract itself - node name_push - attr (name_push) push_symbol = (source-text @name) - edge this -> name_push - edge name_push -> @contract.lexical_scope - - ;; Define "super" effectively as if it was a state variable of a type connected by our super_scope - ;; super_scope will later connect to the base contract defs directly - node @contract.super - attr (@contract.super) pop_symbol = "super" - - node super_typeof - attr (super_typeof) push_symbol = "@typeof" - - edge @contract.super -> super_typeof - edge super_typeof -> @contract.super_scope - - ;; Finally make "super" available in the contract's lexical scope for function bodies to use - edge @contract.lexical_scope -> @contract.super + ;; Modifiers are available as a contract type members through a special '@modifier' guard + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @contract.ns -> modifier + edge modifier -> @contract.modifiers - ; NOTE: The keyword "super" itself resolves to each of its parent contracts. - ; See the related rules in the InheritanceSpecifier section above. + ; There may be attached functions to our type. For the general case of + ; variables of our type, that's already handled via normal lexical scope + ; resolution. But for casting/`new` invocations that we resolve through the + ; `()` guard above, we need to explicitly jump to the extension scope from + ; here to attempt resolving the attached function. We cannot jump back to the + ; parent scope because that would create a cycle in the graph. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + node hook + attr (hook) extension_hook + + edge call -> push_typeof + edge push_typeof -> push_name + edge push_name -> hook - ;; This defines the sink of edges added from base contracts when setting this - ;; contract as the compilation context - attr (@contract.def) export_node = @contract.members + if (version-matches "< 0.5.0") { + ; For Solidity < 0.5.0 `this` also acts like an `address` + node address_ref + attr (address_ref) push_symbol = "%address" + node address_typeof + attr (address_typeof) push_symbol = "@typeof" + edge this -> address_typeof + edge address_typeof -> address_ref + edge address_ref -> @contract.lexical_scope + } - ;; This node will eventually connect to the contract's members being compiled - ;; and grants access to definitions in that contract and all its parents - ;; (recursively) - node super_import - attr (super_import) pop_symbol = "." - edge @contract.super -> super_import + ; This is the connection point to resolve attached functions by `using for *` + node @contract.star_extension + attr (@contract.star_extension) push_symbol = "@*" - ;; This defines the source side of edges added to base contracts when setting - ;; a contract as compilation context; this allows this contract (a base) to - ;; access virtual methods in any sub-contract defined in the hierarchy - attr (@contract.def) import_nodes = [@contract.lexical_scope, super_import] + if (version-matches "< 0.7.0") { + ; For Solidity < 0.7.0 using directives are inherited, so we need to connect + ; always For newer versions, this connection only happens when there is a + ; `using for *` directive in the contract (see rule below) + edge @contract.star_extension -> @contract.lexical_scope + } ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" + attr (type_contract_type) push_symbol = "%ContractTypeType" edge @contract.def -> type edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope + edge type_contract_type -> @contract.parent_scope + + ; The following defines the connection nodes the resolution algorithm uses + ; *only when setting a compilation context/target*. + + ; This attribute defines the sink of edges added from base contracts when + ; setting this contract as the compilation context, and should provide access + ; to anything that can be reached through `super`. The instance scope is a bit + ; too broad, but `.members` is too narrow as it doesn't allow navigation to + ; parent contracts (and from the base we need to be able to reach all + ; contracts in the hierarchy). + attr (@contract.def) export_node = @contract.instance + + ; This node will eventually connect to the contract's members being compiled + ; and grants access to definitions in that contract and all its parents + ; (recursively). It only makes sense if `super` is defined (ie. if we have + ; parents), but we define it here to be able to use it in the declaration of + ; import nodes. This is the dual of the export_node above. + node @contract.super_import + attr (@contract.super_import) pop_symbol = "." + + ; This defines the source side of edges added to base contracts when setting + ; a contract as compilation context; this allows this contract (a base) to + ; access virtual methods in any sub-contract defined in the hierarchy (both + ; with and without `super`, hence the two connection points). + attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] } @contract [ContractDefinition @specifier [InheritanceSpecifier]] { + ; The `.heir` scoped variable allows the rules for `InheritanceSpecifier` + ; above to connect the instance scope of this contract to the parents. let @specifier.heir = @contract attr (@contract.def) parents = @specifier.parent_refs + if (version-matches "< 0.7.0") { + attr (@contract.def) inherit_extensions + } + + ; The rest of these statements deal with defining and connecting the `super` + ; keyword path. + + ; `super_scope` is where we hook all references to our parent contracts + node @contract.super_scope + + ; Define "super" in the lexical scope + node @contract.super + attr (@contract.super) pop_symbol = "super" + edge @contract.lexical_scope -> @contract.super + + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target (see more detailed description + ; above on the definition of the `super_import` node). + edge @contract.super -> @contract.super_import + + ; Then connect it through an `@instance` guard to the parent contracts through + ; `super_scope`. This allows "instance"-like access to members of parents + ; through `super`. + node super_instance + attr (super_instance) push_symbol = "@instance" + edge @contract.super_import -> super_instance + edge super_instance -> @contract.super_scope } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes [InheritanceType @type_name [IdentifierPath]] ]]] { - ;; The base contract defs are directly accesible through our special super scope + ;; The base contract defs are directly accesible through our super scope edge @contract.super_scope -> @type_name.push_begin } +; Pure definitions that cannot contain expressions @contract [ContractDefinition [ContractMembers [ContractMember @member ( [EnumDefinition] @@ -419,12 +504,23 @@ inherit .lexical_scope | [EventDefinition] | [ErrorDefinition] | [UserDefinedValueTypeDefinition] - | [FunctionDefinition] + )] +]] { + edge @member.lexical_scope -> @contract.lexical_scope +} + +; Definitions that can contain expressions need two scopes: +; - normal lexical scope for resolving types +; - extended scope (extended by using directives) for resolving expressions +@contract [ContractDefinition [ContractMembers + [ContractMember @member ( + [FunctionDefinition] | [ConstructorDefinition] - | [StateVariableDefinition] | [ModifierDefinition] | [FallbackFunctionDefinition] | [ReceiveFunctionDefinition] + | [UnnamedFunctionDefinition] + | [StateVariableDefinition] )] ]] { edge @member.lexical_scope -> @contract.lexical_scope @@ -433,7 +529,8 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - edge @contract.lexical_scope -> @using.def + ; Hook the using definition in the extensions scope + edge @contract.extensions -> @using.def } @contract [ContractDefinition [ContractMembers @@ -445,13 +542,20 @@ inherit .lexical_scope | [UserDefinedValueTypeDefinition] )] ]] { - edge @contract.type_members -> @member.def + ; These definition go into the "namespace" scope and are accessible externally + ; via qualified naming (eg. `Contract.MyStruct`) + edge @contract.ns -> @member.def } @contract [ContractDefinition [ContractMembers [ContractMember @state_var [StateVariableDefinition]] ]] { - edge @contract.state_vars -> @state_var.def + ; State variables are available to derived contracts. + ; TODO: this also exposes private state variables to derived contracts, but we + ; can't easily filter them because we don't have negative assertions in our + ; query language (we would need to modify this query for anything *not* + ; containing a `PrivateKeyword` node) + edge @contract.instance -> @state_var.def } ;; Public state variables are also exposed as external member functions @@ -480,13 +584,15 @@ inherit .lexical_scope [FunctionAttributes [FunctionAttribute ([ExternalKeyword] | [PublicKeyword])]] ]] ]] { - ; public or external functions are also accessible through the contract type - edge @contract.type_members -> @function.def + ; Public or external functions are also accessible through the contract type + ; (to retrieve their `.selector` for example) + edge @contract.ns -> @function.def } @contract [ContractDefinition members: [ContractMembers [ContractMember @modifier [ModifierDefinition]] ]] { + ; Modifiers live in their own special scope edge @contract.modifiers -> @modifier.def ;; This may prioritize this definition (when there are multiple options) @@ -495,6 +601,15 @@ inherit .lexical_scope attr (@modifier.def) parents = [@contract.def] } +@contract [ContractDefinition [ContractMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the contract + edge @contract.star_extension -> @contract.lexical_scope +} + +; This applies to both state variables and function definitions @override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths @base_ident [IdentifierPath] ]]] { @@ -507,26 +622,29 @@ inherit .lexical_scope ;;; Interfaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@interface [InterfaceDefinition] { +@interface [InterfaceDefinition @name name: [Identifier]] { node @interface.lexical_scope node @interface.def node @interface.members - node @interface.type_members - - edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.type_members -} + node @interface.ns + node @interface.instance -@interface [InterfaceDefinition @name name: [Identifier]] { attr (@interface.def) node_definition = @name attr (@interface.def) definiens_node = @interface - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + edge @interface.lexical_scope -> @interface.instance + + ; The extensions node is required for the inheritance rules, but not used in interfaces + let @interface.extensions = (node) + + edge @interface.instance -> @interface.members + edge @interface.instance -> @interface.ns + + ;; External "instance" like access path, to access members of a variable of + ;; the interface's type or through a casting call. node member attr (member) pop_symbol = "." - edge member -> @interface.members + edge member -> @interface.instance node typeof attr (typeof) pop_symbol = "@typeof" @@ -538,28 +656,46 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member + ; From a call we may need to resolve using the extensions scope, in case there's + ; a `using` directive on our type. This path ends up jumping to scope just to + ; handle that case. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + edge call -> push_typeof + edge push_typeof -> push_name + node hook + attr (hook) extension_hook + edge push_name -> hook + ; edge push_name -> JUMP_TO_SCOPE_NODE + ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @interface.def -> type_member - edge type_member -> @interface.type_members + node ns_member + attr (ns_member) pop_symbol = "." + edge @interface.def -> ns_member + edge ns_member -> @interface.ns + + ; Finally there's guarded `@instance` path used by derived contracts to access + ; instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @interface.def -> instance + edge instance -> @interface.instance ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" + attr (type_interface_type) push_symbol = "%InterfaceTypeType" edge @interface.def -> type edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope + edge type_interface_type -> @interface.parent_scope } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { let @specifier.heir = @interface attr (@interface.def) parents = @specifier.parent_refs - - ; Define a dummy "super" node required by the rules for InheritanceSpecifier - node @interface.super } @interface [InterfaceDefinition [InterfaceMembers @@ -573,7 +709,7 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @interface.lexical_scope - edge @interface.type_members -> @member.def + edge @interface.ns -> @member.def } ;; Allow references (eg. variables of the interface type) to the interface to @@ -581,14 +717,13 @@ inherit .lexical_scope @interface [InterfaceDefinition members: [InterfaceMembers item: [ContractMember @function variant: [FunctionDefinition]] ]] { - edge @function.lexical_scope -> @interface.lexical_scope edge @interface.members -> @function.def } [InterfaceDefinition [InterfaceMembers [ContractMember @using [UsingDirective]]]] { ; using directives are not allowed in interfaces, but the grammar allows them ; so we need to create an artificial node here to connect to created edges from - ; the internal nodes + ; the instance nodes let @using.lexical_scope = (node) } @@ -597,38 +732,50 @@ inherit .lexical_scope ;;; Libraries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@library [LibraryDefinition] { +@library [LibraryDefinition @name name: [Identifier]] { node @library.lexical_scope + node @library.extensions node @library.def - node @library.members + node @library.ns + node @library.modifiers - edge @library.lexical_scope -> @library.members -} - -@library [LibraryDefinition @name name: [Identifier]] { attr (@library.def) node_definition = @name attr (@library.def) definiens_node = @library + ; The .extensions node is where `using` directives will hook the definitions + attr (@library.def) extension_scope = @library.extensions + + edge @library.lexical_scope -> @library.ns + + let @library.enclosing_def = @library.def node member attr (member) pop_symbol = "." edge @library.def -> member + edge member -> @library.ns - edge member -> @library.members + ; Access to modifiers is guarded by a @modifier symbol + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @library.ns -> modifier + edge modifier -> @library.modifiers ; Path to resolve the built-in type for type() expressions (same as contracts) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_library_type - attr (type_library_type) push_symbol = "%typeContractType" + attr (type_library_type) push_symbol = "%ContractTypeType" edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; This is the connection point to resolve attached functions by `using for *` + node @library.star_extension + attr (@library.star_extension) push_symbol = "@*" } @library [LibraryDefinition [LibraryMembers [ContractMember @member ( - [FunctionDefinition] - | [EnumDefinition] + [EnumDefinition] | [StructDefinition] | [EventDefinition] | [ErrorDefinition] @@ -636,31 +783,54 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @library.lexical_scope - edge @library.members -> @member.def + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @member ( + [FunctionDefinition] + | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] + )] +]] { + edge @member.lexical_scope -> @library.lexical_scope + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @modifier [ModifierDefinition]] +]] { + edge @library.modifiers -> @modifier.def + edge @modifier.lexical_scope -> @library.lexical_scope } @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - edge @library.lexical_scope -> @using.def + ; Expose the using directive from the extensions scope + edge @library.extensions -> @using.def } +@library [LibraryDefinition [LibraryMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the library + edge @library.star_extension -> @library.lexical_scope +} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Using directives ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; The UsingDirective node requires the enclosing context to setup a -;; .lexical_scope scoped variable for it to resolve both targets and subjects. - @using [UsingDirective] { ; This node acts as a definition in the sense that provides an entry point ; that pops the target type and pushes the library/functions to attach to the ; target type node @using.def - ; This internal node connects the other end of the popping path starting at - ; .def and resolves for the library/functions in the directive + ; This internal node connects the definition side of the clause to the target + ; for resolution, and allows handling the multiple cases of `using` syntax + ; easily node @using.clause } @@ -704,12 +874,18 @@ inherit .lexical_scope ; pop the type symbols to connect to the attached function (via @using.clause) node typeof attr (typeof) pop_symbol = "@typeof" + node cast + attr (cast) pop_symbol = "()" - edge @using.def -> @type_name.pop_begin + ; We connect to all_pop_begin to be able to resolve both qualified and + ; unqualified instances of the target type + edge @using.def -> @type_name.all_pop_begin edge @type_name.pop_end -> typeof edge typeof -> @using.clause + edge @type_name.pop_end -> cast + edge cast -> @using.clause - ; resolve the target type of the directive + ; resolve the target type of the directive on the lexical scope edge @type_name.type_ref -> @using.lexical_scope } @@ -726,7 +902,7 @@ inherit .lexical_scope ;;; Type names ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TypeName nodes should define two scoped variables: +;; TypeName nodes should define these scoped variables: ;; ;; - @type_name.type_ref represents the node in the graph where we're ready to ;; resolve the type, and thus should generally be connected to a (lexical) @@ -735,12 +911,19 @@ inherit .lexical_scope ;; - @type_name.output represents the other end of the type and corresponds to a ;; state where the type has already been resolved so we can, for example ;; resolve its members (sink node, outside edges connect *to* here). +;; +;; - @type_name.pop_begin, @type_name.pop_end are used in a definition context, +;; ie. when we need to pop the type name symbol(s) from the symbol stack. +;; Additionally, @type_name.all_pop_begin links to each symbol in a typename +;; (ie. in an identifier path typename), which allows referring to a type both +;; qualified and unqualified. @type_name [TypeName @elementary [ElementaryType]] { let @type_name.type_ref = @elementary.ref let @type_name.output = @elementary.ref let @type_name.pop_begin = @elementary.pop let @type_name.pop_end = @elementary.pop + let @type_name.all_pop_begin = @elementary.pop } @type_name [TypeName @id_path [IdentifierPath]] { @@ -755,6 +938,7 @@ inherit .lexical_scope let @type_name.pop_begin = @id_path.pop_begin let @type_name.pop_end = @id_path.pop_end + let @type_name.all_pop_begin = @id_path.all_pop_begin } @type_name [TypeName @type_variant ([ArrayTypeName] | [FunctionType])] { @@ -762,6 +946,7 @@ inherit .lexical_scope let @type_name.output = @type_variant.output let @type_name.pop_begin = @type_variant.pop_begin let @type_name.pop_end = @type_variant.pop_end + let @type_name.all_pop_begin = @type_variant.pop_begin } @type_name [TypeName @mapping [MappingType]] { @@ -769,6 +954,7 @@ inherit .lexical_scope let @type_name.output = @mapping.output let @type_name.pop_begin = @mapping.pop_begin let @type_name.pop_end = @mapping.pop_end + let @type_name.all_pop_begin = @mapping.pop_begin } @@ -783,76 +969,130 @@ inherit .lexical_scope node @elementary.pop attr (@elementary.pop) pop_symbol = @elementary.symbol + + ; These variables are a bit redundant, but necessary to easily use elementary + ; types as mapping keys + let @elementary.pop_begin = @elementary.pop + let @elementary.pop_end = @elementary.pop + let @elementary.all_pop_begin = @elementary.pop + + let @elementary.push_begin = @elementary.ref + let @elementary.push_end = @elementary.ref +} + +@elementary [ElementaryType [AddressType]] { + let @elementary.symbol = "%address" +} + +@elementary [ElementaryType [BoolKeyword]] { + let @elementary.symbol = "%bool" } -@elementary [ElementaryType variant: [AddressType @address [AddressKeyword]]] { - let @elementary.symbol = (format "%{}" (source-text @address)) +@elementary [ElementaryType [ByteKeyword]] { + let @elementary.symbol = "%byte" } -@elementary [ElementaryType @keyword ( - [BoolKeyword] - | [ByteKeyword] - | [BytesKeyword] - | [StringKeyword] - | [IntKeyword] - | [UintKeyword] - | [FixedKeyword] - | [UfixedKeyword] -)] { +@elementary [ElementaryType @keyword [BytesKeyword]] { let @elementary.symbol = (format "%{}" (source-text @keyword)) } +@elementary [ElementaryType [StringKeyword]] { + let @elementary.symbol = "%string" +} + +@elementary [ElementaryType @keyword [IntKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "int") { + let @elementary.symbol = "%int256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UintKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "uint") { + let @elementary.symbol = "%uint256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [FixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "fixed") { + let @elementary.symbol = "%fixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UfixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "ufixed") { + let @elementary.symbol = "%ufixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@mapping [MappingType] { +@mapping [MappingType + [MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]] + [MappingValue @value_type [TypeName]] +] { node @mapping.lexical_scope node @mapping.output -} - -@mapping [MappingType [MappingKey [MappingKeyType @key_ident [IdentifierPath]]]] { - ; resolve key type - edge @key_ident.push_end -> @mapping.lexical_scope -} -@mapping [MappingType [MappingValue @value_type [TypeName]]] { - ; for mapping types we don't need to push the type itself, because we don't need it (yet) - ; ditto for the pop path, because a mapping type cannot be the target of a using directive + ; Define the pushing path of the mapping type + ; ValueType <- top of the symbol stack + ; KeyType + ; %mapping <- bottom of the symbol stack + node mapping + attr (mapping) push_symbol = "%Mapping" + edge @mapping.output -> mapping + edge mapping -> @key_type.push_begin + edge @key_type.push_end -> @value_type.output + + ; Both key and value types need to be resolved + edge @value_type.type_ref -> @mapping.lexical_scope + edge @key_type.push_end -> @mapping.lexical_scope - ; The mapping's type exposes the `%index` (ie. `[]`) operator that returns the value type - ; This is similar to arrays, only in that case we have a built-in type where - ; we can define an index function. For mappings we hard-code in the rules directly. + ; The mapping's type exposes the `[]` operator that returns the value type. node typeof_input attr (typeof_input) pop_symbol = "@typeof" - - node index_member - attr (index_member) pop_symbol = "." - node index - attr (index) pop_symbol = "%index" - node index_call - attr (index_call) pop_symbol = "()" + edge @mapping.output -> typeof_input node typeof_output attr (typeof_output) push_symbol = "@typeof" - - edge @mapping.output -> typeof_input - edge typeof_input -> index_member - edge index_member -> index - edge index -> index_call - edge index_call -> typeof_output edge typeof_output -> @value_type.output - ; resolve the value type through our scope - edge @value_type.type_ref -> @mapping.lexical_scope + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for mapping public state variables: they can be called + ; like a function with a key, and it's effectively the same as indexing it. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only + ; This is the reverse of the pushing path above (to the `.output` node) + node pop_mapping + attr (pop_mapping) pop_symbol = "%Mapping" - ; We use the value_type's definition path as our own because it's needed when - ; a mapping is the target of a `using` directive. It's not correct, but we - ; don't have the analog referencing path either. let @mapping.pop_begin = @value_type.pop_begin - let @mapping.pop_end = @value_type.pop_end + edge @value_type.pop_end -> @key_type.pop_begin + edge @key_type.pop_end -> pop_mapping + let @mapping.pop_end = pop_mapping } @@ -866,47 +1106,69 @@ inherit .lexical_scope } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type = "%arrayFixed" + let @array.type_symbol = "%FixedArray" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type = "%array" + let @array.type_symbol = "%Array" } @array [ArrayTypeName @type_name [TypeName]] { - ; First define the normal, reference route: - - ; We first push the array type `%array`, which should connect to two distinct paths: - ; 1. the typed path, which will use a jump scope entry to resolve the element type - ; 2. the hard-coded path to connect to any `using` directive + ; Define the pushing path of the array type + ; ValueType <- top of the symbol stack + ; %array / %arrayFixed <- bottom of the symbol stack node array - attr (array) push_symbol = @array.type + attr (array) push_symbol = @array.type_symbol edge @array.output -> array + edge array -> @type_name.output - ; For the first path, we need to define a scope jump entry for resolving the element type of the array - node entry - attr (entry) is_exported - node element - attr (element) pop_symbol = "%element" - edge entry -> element - edge element -> @type_name.output + ; Resolve the value type itself + edge @type_name.type_ref -> @array.lexical_scope + ; And also the "type erased" array type so we can resolve built-in members + edge array -> @array.lexical_scope - ; And then the path itself - node params - attr (params) push_scoped_symbol = "<>", scope = entry - edge array -> params + ; Define the path to resolve index access (aka the `[]` operator) - ; Second path, for `using` directives - edge array -> @type_name.output + node typeof_input + attr (typeof_input) pop_symbol = "@typeof" + edge @array.output -> typeof_input - ; Finally, both ends connect to our lexical scope - edge params -> @array.lexical_scope - edge @type_name.type_ref -> @array.lexical_scope + node typeof_output + attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @type_name.output + + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for public state variables of type array: they can be called + ; like a function with an index, and it's effectively the same as indexing the + ; array. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Define the special `.push()` built-in that returns the element type (for Solidity >= 0.6.0) + if (version-matches ">= 0.6.0") { + node built_in_member + attr (built_in_member) pop_symbol = "." + node push_built_in + attr (push_built_in) pop_symbol = "push" + node built_in_call + attr (built_in_call) pop_symbol = "()" + + edge typeof_input -> built_in_member + edge built_in_member -> push_built_in + edge push_built_in -> built_in_call + edge built_in_call -> typeof_output + } ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only ; This is essentially the reverse of the second path above node pop_array - attr (pop_array) pop_symbol = @array.type + attr (pop_array) pop_symbol = @array.type_symbol let @array.pop_begin = @type_name.pop_begin edge @type_name.pop_end -> pop_array @@ -921,10 +1183,10 @@ inherit .lexical_scope @ftype [FunctionType @attrs [FunctionTypeAttributes]] { ; Compute the built-in type of the function ; %functionExternal provides access to .selector and .address - var type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "external" { - set type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -934,14 +1196,14 @@ inherit .lexical_scope ; This path pushes the function type to the symbol stack ; TODO: add parameter and return types to distinguish between different function types node function_type - attr (function_type) push_symbol = type + attr (function_type) push_symbol = type_symbol edge @ftype.output -> function_type edge function_type -> @ftype.lexical_scope ; the pop path for the using directive node pop_function_type - attr (pop_function_type) pop_symbol = type + attr (pop_function_type) pop_symbol = type_symbol let @ftype.pop_begin = pop_function_type let @ftype.pop_end = pop_function_type @@ -958,8 +1220,9 @@ inherit .lexical_scope @ftype [FunctionType [ReturnsDeclaration [ParametersDeclaration [Parameters . @param [Parameter] .]] ]] { - ; variables of a function type type can be "called" and resolve to the type of - ; the return parameter + ; Variables of a function type type can be "called" and resolve to the type of + ; the return parameter. This is only valid if the function returns a single + ; value. node typeof attr (typeof) pop_symbol = "@typeof" @@ -986,14 +1249,22 @@ inherit .lexical_scope ;; @id_path.pop_end. ;; ;; NOTE: most of the time, and unless this identifier path is the target of a -;; using directive this path will not be used and will form a disconnected -;; graph component. We currently have no way of determining when this path is -;; necessary, so we always construct it. +;; using directive this second path will not be used and will form a +;; disconnected graph component. We currently have no way of determining when +;; this path is necessary, so we always construct it. ;; ;; Additionally the IdentifierPath defines another scoped variable ;; @id_path.rightmost_identifier which corresponds to the identifier in the last -;; position in the path, from left to right. Useful for the using directive to -;; be able to pop the name of the attached function. +;; position in the path, from left to right. This is used in the using directive +;; rules to be able to pop the name of the attached function. + +@id_path [IdentifierPath] { + ; This node connects to all parts of the path, for popping. This allows to + ; connect at any point of the path. Useful for `using` directives when the + ; target type is fully qualified but we want to resolve for the unqualified + ; name. + node @id_path.all_pop_begin +} @id_path [IdentifierPath @name [Identifier]] { node @name.ref @@ -1002,6 +1273,8 @@ inherit .lexical_scope node @name.pop attr (@name.pop) pop_symbol = (source-text @name) + + edge @id_path.all_pop_begin -> @name.pop } @id_path [IdentifierPath @name [Identifier] .] { @@ -1069,10 +1342,10 @@ inherit .lexical_scope } @function [FunctionDefinition @attrs [FunctionAttributes]] { - var function_type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "\\b(public|external)\\b" { - set function_type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -1084,7 +1357,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type_function - attr (type_function) push_symbol = function_type + attr (type_function) push_symbol = type_symbol edge @function.def -> typeof edge typeof -> type_function edge type_function -> @function.lexical_scope @@ -1149,12 +1422,39 @@ inherit .lexical_scope edge @name.push_end -> modifier edge modifier -> @modifier.lexical_scope + + ; This allows resolving @name in the more general scope in constructors (since + ; calling a parent constructor is parsed as a modifier invocation) + let @modifier.identifier = @name.push_end } @modifier [ModifierInvocation @args [ArgumentsDeclaration]] { edge @args.lexical_scope -> @modifier.lexical_scope } +;;; Unnamed functions (deprecated) +@unnamed_function [UnnamedFunctionDefinition] { + node @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition @params parameters: [ParametersDeclaration]] { + edge @params.lexical_scope -> @unnamed_function.lexical_scope + + edge @unnamed_function.lexical_scope -> @params.defs + attr (@unnamed_function.lexical_scope -> @params.defs) precedence = 1 +} + +@unnamed_function [UnnamedFunctionDefinition [FunctionBody @block [Block]]] { + edge @block.lexical_scope -> @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition + [UnnamedFunctionAttributes [UnnamedFunctionAttribute @modifier [ModifierInvocation]]] +] { + edge @modifier.lexical_scope -> @unnamed_function.lexical_scope +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Constructors @@ -1186,6 +1486,7 @@ inherit .lexical_scope @modifier [ModifierInvocation] ]]] { edge @modifier.lexical_scope -> @constructor.lexical_scope + edge @modifier.identifier -> @constructor.lexical_scope } @contract [ContractDefinition [ContractMembers [ContractMember @@ -1195,7 +1496,9 @@ inherit .lexical_scope edge @contract.def -> @constructor.def } -;; Solidity < 0.5.0 constructors were declared as functions of the contract's name +;; Solidity < 0.5.0 constructors +;; They were declared as functions of the contract's name + @contract [ContractDefinition @contract_name [Identifier] [ContractMembers [ContractMember [FunctionDefinition @@ -1211,6 +1514,21 @@ inherit .lexical_scope } } +[ContractDefinition + @contract_name [Identifier] + [ContractMembers [ContractMember @function [FunctionDefinition + [FunctionName @function_name [Identifier]] + [FunctionAttributes [FunctionAttribute @modifier [ModifierInvocation]]] + ]]] +] { + if (version-matches "< 0.5.0") { + if (eq (source-text @contract_name) (source-text @function_name)) { + ; Parent constructor calls are parsed as modifier invocations + edge @modifier.identifier -> @function.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Fallback and receive functions @@ -1386,7 +1704,6 @@ inherit .lexical_scope @expr_stmt [ExpressionStatement] { node @expr_stmt.lexical_scope - node @expr_stmt.defs } @@ -1394,32 +1711,46 @@ inherit .lexical_scope @stmt [Statement @var_decl [VariableDeclarationStatement]] { edge @var_decl.lexical_scope -> @stmt.lexical_scope - edge @stmt.defs -> @var_decl.defs + edge @stmt.defs -> @var_decl.def } @var_decl [VariableDeclarationStatement] { node @var_decl.lexical_scope - node @var_decl.defs + node @var_decl.def } @var_decl [VariableDeclarationStatement [VariableDeclarationType @var_type [TypeName]] @name name: [Identifier] ] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @var_decl + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl - edge @var_decl.defs -> def edge @var_type.type_ref -> @var_decl.lexical_scope node typeof attr (typeof) push_symbol = "@typeof" - edge def -> typeof + edge @var_decl.def -> typeof edge typeof -> @var_type.output } +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + @name name: [Identifier] +] { + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl +} + +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + [VariableDeclarationValue @value [Expression]] +] { + edge @var_decl.def -> @value.output +} + + ;;; Tuple deconstruction statements @@ -1493,11 +1824,20 @@ inherit .lexical_scope ;; For loops @stmt [Statement [ForStatement - initialization: [ForStatementInitialization - @init_stmt ([ExpressionStatement] - | [VariableDeclarationStatement] - | [TupleDeconstructionStatement]) - ] + initialization: [ForStatementInitialization @init_stmt [ExpressionStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [VariableDeclarationStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope + edge @stmt.init_defs -> @init_stmt.def +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [TupleDeconstructionStatement]] ]] { edge @init_stmt.lexical_scope -> @stmt.lexical_scope edge @stmt.init_defs -> @init_stmt.defs @@ -1647,11 +1987,36 @@ inherit .lexical_scope edge @type_name.type_ref -> @state_var.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @state_var.typeof + attr (@state_var.typeof) push_symbol = "@typeof" + + edge @state_var.def -> @state_var.typeof + edge @state_var.typeof -> @type_name.output +} + +@state_var [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [PublicKeyword]]] +] { + ; Public state variables are used as functions when invoked from an external contract + node call + attr (call) pop_symbol = "()" + + ; In the general case using the getter can bind to the state variable's type + edge @state_var.def -> call + edge call -> @state_var.typeof - edge @state_var.def -> typeof - edge typeof -> @type_name.output + ; Some complex types generate special getters (ie. arrays and mappings index + ; their contents, structs flatten most of their fields and return a tuple) + node getter + attr (getter) push_symbol = "@as_getter" + edge call -> getter + edge getter -> @state_var.typeof +} + +@state_var [StateVariableDefinition + [StateVariableDefinitionValue @value [Expression]] +] { + let @value.lexical_scope = @state_var.lexical_scope } @@ -1659,13 +2024,11 @@ inherit .lexical_scope ;;; Enum definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@enum [EnumDefinition] { +@enum [EnumDefinition @name name: [Identifier]] { node @enum.lexical_scope node @enum.def node @enum.members -} -@enum [EnumDefinition @name name: [Identifier]] { attr (@enum.def) node_definition = @name attr (@enum.def) definiens_node = @enum @@ -1677,9 +2040,9 @@ inherit .lexical_scope ; Path to resolve the built-in type for enums (which is the same as for integer types) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_enum_type - attr (type_enum_type) push_symbol = "%typeIntType" + attr (type_enum_type) push_symbol = "%IntTypeType" edge @enum.def -> type edge type -> type_enum_type edge type_enum_type -> @enum.lexical_scope @@ -1700,73 +2063,61 @@ inherit .lexical_scope ;;; Structure definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@struct [StructDefinition] { +@struct [StructDefinition @name name: [Identifier]] { node @struct.lexical_scope node @struct.def node @struct.members -} - -@struct [StructDefinition @name name: [Identifier]] { - ; Since we use structs to define built-in types and some of them (ie. array) - ; have have a parametric type, we define two distinct paths to define a - ; struct: - ; 1. the normal, non parametric path, should drop scopes in the scope stack first of all - ; 2. the parametric path, that pops a scope to resolve the parametric type - ; Both of these connect to the node that pops the struct identifier symbol - - ; First the normal path - node struct_drop - attr (struct_drop) type = "drop_scopes" - edge @struct.def -> struct_drop - - ; Second path, pops the scope - node typed_params - attr (typed_params) pop_scoped_symbol = "<>" - edge @struct.def -> typed_params - - ; Connect both to the struct identifier - node def - attr (def) node_definition = @name - attr (def) definiens_node = @struct - edge struct_drop -> def - edge typed_params -> def - ; On the other end, to properly close the second path we need to jump to the popped scope - ; (this is why on the other path we drop scopes) - edge @struct.lexical_scope -> JUMP_TO_SCOPE_NODE + attr (@struct.def) node_definition = @name + attr (@struct.def) definiens_node = @struct ; Now connect normally to the struct members - node type_def - attr (type_def) pop_symbol = "@typeof" + node @struct.typeof + attr (@struct.typeof) pop_symbol = "@typeof" node member attr (member) pop_symbol = "." - edge def -> type_def - edge type_def -> member + edge @struct.def -> @struct.typeof + edge @struct.typeof -> member edge member -> @struct.members ; Bind member names when using construction with named arguments node param_names attr (param_names) pop_symbol = "@param_names" - edge def -> param_names + edge @struct.def -> param_names edge param_names -> @struct.members + + ; Used as a function call (ie. casting), should bind to itself + node call + attr (call) pop_symbol = "()" + edge @struct.def -> call + edge call -> member } @struct [StructDefinition [StructMembers @member item: [StructMember @type_name [TypeName] @name name: [Identifier]] ]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @member + node @member.def + attr (@member.def) node_definition = @name + attr (@member.def) definiens_node = @member - edge @struct.members -> def + edge @struct.members -> @member.def edge @type_name.type_ref -> @struct.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @member.typeof + attr (@member.typeof) push_symbol = "@typeof" - edge def -> typeof - edge typeof -> @type_name.output + edge @member.def -> @member.typeof + edge @member.typeof -> @type_name.output +} + +@struct [StructDefinition [StructMembers . @first_member [StructMember]]] { + ; As a public getter result, the value returned is a tuple with all our fields flattened + ; We only care about the first member for name binding, since tuples are not real types + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge @struct.typeof -> getter_call + edge getter_call -> @first_member.typeof } @@ -1819,6 +2170,15 @@ inherit .lexical_scope node @error.params attr (@error.params) pop_symbol = "@param_names" edge @error.def -> @error.params + + ; Bind to built-in errorType for accessing built-in member `.selector` + node typeof + attr (typeof) push_symbol = "@typeof" + node error_type + attr (error_type) push_symbol = "%ErrorType" + edge @error.def -> typeof + edge typeof -> error_type + edge error_type -> @error.lexical_scope } @error [ErrorDefinition [ErrorParametersDeclaration [ErrorParameters @@ -1862,17 +2222,59 @@ inherit .lexical_scope edge @type_name.type_ref -> @constant.lexical_scope } -@user_type [UserDefinedValueTypeDefinition] { +@user_type [UserDefinedValueTypeDefinition @name [Identifier] @value_type [ElementaryType]] { node @user_type.lexical_scope node @user_type.def -} -@user_type [UserDefinedValueTypeDefinition @name [Identifier]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @user_type + attr (@user_type.def) node_definition = @name + attr (@user_type.def) definiens_node = @user_type + + ; Provide member resolution through the built-in `%userTypeType` + ; Because the built-in is defined as a struct, we need to push an extra `@typeof` + node member_guard + attr (member_guard) pop_symbol = "." + node member + attr (member) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node user_type_type + attr (user_type_type) push_symbol = "%UserDefinedValueType" - edge @user_type.def -> def + edge @user_type.def -> member_guard + edge member_guard -> member + edge member -> typeof + edge typeof -> user_type_type + edge user_type_type -> @user_type.lexical_scope + + ; Hard-code built-in functions `wrap` and `unwrap` in order to be able to + ; resolve their return types + node wrap + attr (wrap) pop_symbol = "wrap" + node wrap_call + attr (wrap_call) pop_symbol = "()" + node wrap_typeof + attr (wrap_typeof) push_symbol = "@typeof" + + edge member_guard -> wrap + edge wrap -> wrap_call + edge wrap_call -> wrap_typeof + edge wrap_typeof -> @value_type.ref + edge @value_type.ref -> @user_type.lexical_scope + + node unwrap + attr (unwrap) pop_symbol = "unwrap" + node unwrap_call + attr (unwrap_call) pop_symbol = "()" + node unwrap_typeof + attr (unwrap_typeof) push_symbol = "@typeof" + node type_ref + attr (type_ref) push_symbol = (source-text @name) + + edge member_guard -> unwrap + edge unwrap -> unwrap_call + edge unwrap_call -> unwrap_typeof + edge unwrap_typeof -> type_ref + edge type_ref -> @user_type.lexical_scope } @@ -1892,9 +2294,7 @@ inherit .lexical_scope } ;; Identifier expressions -@expr [Expression @name ( - variant: [Identifier] | variant: [SuperKeyword] | variant: [ThisKeyword] -)] { +@expr [Expression @name [Identifier]] { node ref attr (ref) node_reference = @name attr (ref) parents = [@expr.enclosing_def] @@ -1903,6 +2303,14 @@ inherit .lexical_scope edge @expr.output -> ref } +@expr [Expression @keyword ([ThisKeyword] | [SuperKeyword])] { + ; This is almost equivalent to the above rule, except it doesn't generate a reference + node keyword + attr (keyword) push_symbol = (source-text @keyword) + edge keyword -> @expr.lexical_scope + edge @expr.output -> keyword +} + ;; Member access expressions @expr [Expression [MemberAccessExpression @operand operand: [Expression] @@ -1921,10 +2329,7 @@ inherit .lexical_scope edge @expr.output -> @name.ref ; Shortcut path for expressions inside contracts with using X for * directives - node star - attr (star) push_symbol = "@*" - edge member -> star - edge star -> @expr.lexical_scope + edge member -> @expr.star_extension } ;; Special case: member accesses to `super` are tagged with "super" to rank @@ -1936,21 +2341,31 @@ inherit .lexical_scope attr (@name.ref) tag = "super" } +;; Elementary types used as expressions (eg. for type casting, or for built-ins like `string.concat`) +@expr [Expression @type [ElementaryType]] { + edge @expr.output -> @type.ref + edge @type.ref -> @expr.lexical_scope + + ; Elementary types can also be used for casting; instead of defining built-in + ; struct for each available elementary type, we define a special path here + node call + attr (call) pop_symbol = "()" + node typeof + attr (typeof) push_symbol = "@typeof" + edge @expr.output -> call + edge call -> typeof + edge typeof -> @type.ref +} + ;; Index access expressions @expr [Expression [IndexAccessExpression @operand operand: [Expression] ]] { - node index_call - attr (index_call) push_symbol = "()" node index - attr (index) push_symbol = "%index" - node index_member - attr (index_member) push_symbol = "." + attr (index) push_symbol = "[]" - edge @expr.output -> index_call - edge index_call -> index - edge index -> index_member - edge index_member -> @operand.output + edge @expr.output -> index + edge index -> @operand.output } ;; Type expressions @@ -1963,7 +2378,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%typeIntType" + attr (type) push_symbol = "%IntTypeType" edge @type_expr.output -> typeof edge typeof -> type @@ -1975,7 +2390,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%type" + attr (type) push_symbol = "@type" edge @type_expr.output -> typeof edge typeof -> type @@ -2039,7 +2454,7 @@ inherit .lexical_scope attr (@options.refs) push_symbol = "@param_names" node call_options - attr (call_options) push_symbol = "%callOptions" + attr (call_options) push_symbol = "%CallOptions" edge @options.refs -> call_options edge call_options -> @expr.lexical_scope @@ -2053,6 +2468,137 @@ inherit .lexical_scope } +;;; Payable +; These work like `address`, should they should bind to `%address` +@expr [Expression [PayableKeyword]] { + node ref + attr (ref) push_symbol = "%address" + + edge ref -> @expr.lexical_scope + edge @expr.output -> ref +} + + +;;; Tuple expressions + +; Parenthesized expressions are parsed as tuples of a single value +@expr [Expression [TupleExpression [TupleValues . [TupleValue @operand [Expression]] .]]] { + edge @expr.output -> @operand.output +} + +;;; Arithmetic, bitwise & logical operators, etc + +; Bind to the left operand only: assignment expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [Equal] + | [BarEqual] + | [PlusEqual] + | [MinusEqual] + | [CaretEqual] + | [SlashEqual] + | [PercentEqual] + | [AsteriskEqual] + | [AmpersandEqual] + | [LessThanLessThanEqual] + | [GreaterThanGreaterThanEqual] + | [GreaterThanGreaterThanGreaterThanEqual] + ) +]] { + edge @expr.output -> @left_operand.output +} + +; Unary operators postfix +@expr [Expression [_ + @operand operand: [Expression] + ([PlusPlus] | [MinusMinus]) +]] { + edge @expr.output -> @operand.output +} + +; Unary operators prefix +@expr [Expression [_ + ([PlusPlus] | [MinusMinus] | [Tilde] | [Bang] | [Minus] | [Plus]) + @operand operand: [Expression] +]] { + edge @expr.output -> @operand.output +} + +; Bind to both operands: logical and/or, arithmetic, bit-wise expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [BarBar] + | [AmpersandAmpersand] + + | [Plus] + | [Minus] + | [Asterisk] + | [Slash] + | [Percent] + | [AsteriskAsterisk] + + | [Bar] + | [Caret] + | [Ampersand] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] + ) + @right_operand right_operand: [Expression] +]] { + edge @expr.output -> @left_operand.output + edge @expr.output -> @right_operand.output +} + +; Comparison operators bind to bool type +@expr [Expression [_ + ( + [EqualEqual] + | [BangEqual] + | [LessThan] + | [GreaterThan] + | [LessThanEqual] + | [GreaterThanEqual] + ) +]] { + node typeof + attr (typeof) push_symbol = "@typeof" + node bool + attr (bool) push_symbol = "%bool" + edge @expr.output -> typeof + edge typeof -> bool + edge bool -> @expr.lexical_scope +} + +; Ternary conditional expression binds to both branches +@expr [Expression [ConditionalExpression + @true_expression true_expression: [Expression] + @false_expression false_expression: [Expression] +]] { + edge @expr.output -> @true_expression.output + edge @expr.output -> @false_expression.output +} + + +;;; Literal Address Expressions +@expr [Expression [HexNumberExpression @hex_literal [HexLiteral]]] { + scan (source-text @hex_literal) { + "0x[0-9a-fA-F]{40}" { + ; Treat it as a valid address + node typeof + attr (typeof) push_symbol = "@typeof" + node address + attr (address) push_symbol = "%address" + edge @expr.output -> typeof + edge typeof -> address + edge address -> @expr.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul @@ -2162,6 +2708,38 @@ inherit .lexical_scope ;; parameters) are functions (ie. the body of the function doesn't have access ;; to any outside variables) edge @fundef.lexical_scope -> @block.function_defs + ; Exception: but outside constants *are* available, so we provide a guarded + ; access to the parent lexical scope. This guard will be popped to link to + ; available constants. + node yul_function_guard + attr (yul_function_guard) push_symbol = "@in_yul_function" + edge @fundef.lexical_scope -> yul_function_guard + edge yul_function_guard -> @block.lexical_scope +} + +;; Constants need to be available inside Yul functions. This is an exception +;; since no other external identifiers are, so the path is guarded. We create a +;; scope in the source unit, contracts and libraries, and guard it from the +;; lexical scope, so we can link constant definitions here. See the dual path in +;; the rule above. +@constant_container ([SourceUnit] | [ContractDefinition] | [LibraryDefinition]) { + node @constant_container.yul_functions_guarded_scope + attr (@constant_container.yul_functions_guarded_scope) pop_symbol = "@in_yul_function" + edge @constant_container.lexical_scope -> @constant_container.yul_functions_guarded_scope +} + +;; Make top-level constants available inside Yul functions +@source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @constant [ConstantDefinition]]]] { + edge @source_unit.yul_functions_guarded_scope -> @constant.def +} + +;; Ditto for contracts, interfaces and libraries +@contract [_ members: [_ [ContractMember + @constant [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]] + ] +]]] { + edge @contract.yul_functions_guarded_scope -> @constant.def } @fundef [YulFunctionDefinition @@ -2277,11 +2855,60 @@ inherit .lexical_scope node @path.lexical_scope } -@path [YulPath @name [YulIdentifier]] { +@path [YulPath . @name [YulIdentifier]] { node ref attr (ref) node_reference = @name edge ref -> @path.lexical_scope + + if (version-matches "< 0.7.0") { + ; Before Solidity 0.7.0 storage variables' `.offset` and `.slot` were + ; accessed by suffixing the name with `_offset` and `_slot` + scan (source-text @name) { + "^(.*)_(slot|offset|length)$" { + let symbol = $0 + let without_suffix = $1 + let suffix = $2 + + ; We bind the whole symbol to the built-in field for the known cases + node pop_ref + attr (pop_ref) pop_symbol = symbol + node push_suffixless + attr (push_suffixless) push_symbol = suffix + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> pop_ref + edge pop_ref -> push_suffixless + edge push_suffixless -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope + } + } + } +} + +@path [YulPath [Period] @member [YulIdentifier] .] { + ; Yul variable members only apply to external variables and hence are + ; automatically bound to a special %YulExternal built-in + node ref + attr (ref) node_reference = @member + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } @expr [YulExpression @funcall [YulFunctionCallExpression]] { diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 73648c1145..8944573116 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6751,42 +6751,45 @@ codegen_language_macros::compile!(Language( enabled = Till("0.5.0") ), BuiltInType( - name = "$abiType", + name = "$AbiType", fields = [], functions = [ BuiltInFunction( name = "decode", - parameters = ["bytes memory", "$args"], - return_type = "$args", + parameters = ["bytes memory encodedData", "$Type[] encodedTypesTuple"], + return_type = "$Any[]", enabled = From("0.5.0") ), BuiltInFunction( name = "encode", - parameters = ["$args"], + parameters = ["$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeCall", - parameters = ["function()", "$args"], + parameters = [ + "function() functionPointer", + "$Any[] functionArgumentsTuple" + ], return_type = "bytes memory", enabled = From("0.8.11") ), BuiltInFunction( name = "encodePacked", - parameters = ["$args"], + parameters = ["$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSelector", - parameters = ["bytes4 selector", "$args"], + parameters = ["bytes4 selector", "$Any[] functionArgumentsTuple"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSignature", - parameters = ["string memory", "$args"], + parameters = ["string memory signature", "$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ) @@ -6832,7 +6835,7 @@ codegen_language_macros::compile!(Language( ), BuiltInFunction( name = "send", - parameters = ["uint256"], + parameters = ["uint256 amount"], return_type = "bool" ), BuiltInFunction( @@ -6841,49 +6844,40 @@ codegen_language_macros::compile!(Language( return_type = "bool, bytes memory", enabled = From("0.5.0") ), - BuiltInFunction(name = "transfer", parameters = ["uint256"]) + BuiltInFunction(name = "transfer", parameters = ["uint256 amount"]) ] ), BuiltInType( - name = "$array", + name = "$Array", fields = [BuiltInField(definition = "uint length")], functions = [ - BuiltInFunction( - name = "$index", - parameters = ["uint"], - return_type = "$element" - ), BuiltInFunction( name = "push", parameters = [], - return_type = "$element", + return_type = "$ValueType", enabled = From("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$element"], + parameters = ["$ValueType element"], return_type = "uint", enabled = Till("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$element"], + parameters = ["$ValueType element"], enabled = From("0.6.0") ), BuiltInFunction(name = "pop", parameters = []) ] ), BuiltInType( - name = "$arrayFixed", + name = "$FixedArray", fields = [BuiltInField(definition = "uint length")], - functions = [BuiltInFunction( - name = "$index", - parameters = ["uint"], - return_type = "$element" - )] + functions = [] ), BuiltInType( - name = "$blockType", + name = "$BlockType", fields = [ BuiltInField(definition = "uint basefee", enabled = From("0.8.7")), BuiltInField(definition = "uint blobbasefee", enabled = From("0.8.24")), @@ -6904,15 +6898,20 @@ codegen_language_macros::compile!(Language( ), BuiltInType( name = "$bytes", + fields = [BuiltInField(definition = "uint length")], + functions = [] + ), + BuiltInType( + name = "$BytesType", fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$args"], + parameters = ["bytes[] bytesToConcatenate"], return_type = "bytes memory" )] ), BuiltInType( - name = "$callOptions", + name = "$CallOptions", fields = [ BuiltInField(definition = "uint gas"), BuiltInField(definition = "uint salt"), @@ -6922,28 +6921,52 @@ codegen_language_macros::compile!(Language( enabled = From("0.6.2") ), BuiltInType( - name = "$functionExternal", + name = "$ErrorType", + fields = [BuiltInField(definition = "bytes4 selector")], + functions = [], + enabled = From("0.8.4") + ), + BuiltInType( + name = "$Function", + fields = [], + functions = [ + BuiltInFunction( + name = "gas", + parameters = ["uint amount"], + return_type = "function()", + enabled = Till("0.7.0") + ), + BuiltInFunction( + name = "value", + parameters = ["uint amount"], + return_type = "function()", + enabled = Till("0.7.0") + ) + ] + ), + BuiltInType( + name = "$ExternalFunction", fields = [ - BuiltInField(definition = "$address address", enabled = From("0.8.2")), - BuiltInField(definition = "$selector selector", enabled = From("0.4.17")) + BuiltInField(definition = "address address", enabled = From("0.8.2")), + BuiltInField(definition = "bytes4 selector", enabled = From("0.4.17")) ], functions = [ BuiltInFunction( name = "gas", - parameters = ["uint"], - return_type = "$function", + parameters = ["uint amount"], + return_type = "function()", enabled = Till("0.7.0") ), BuiltInFunction( name = "value", - parameters = ["uint"], - return_type = "$function", + parameters = ["uint amount"], + return_type = "function()", enabled = Till("0.7.0") ) ] ), BuiltInType( - name = "$msgType", + name = "$MessageType", fields = [ BuiltInField(definition = "bytes data"), BuiltInField(definition = "uint256 gas", enabled = Till("0.5.0")), @@ -6958,16 +6981,16 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$string", + name = "$StringType", fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$args"], + parameters = ["string[] stringsToConcatenate"], return_type = "string memory" )] ), BuiltInType( - name = "$txType", + name = "$TransactionType", fields = [ BuiltInField(definition = "uint gasprice"), BuiltInField( @@ -6979,7 +7002,7 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$typeContractType", + name = "$ContractTypeType", fields = [ BuiltInField(definition = "string name"), BuiltInField(definition = "bytes creationCode", enabled = From("0.5.3")), @@ -6989,7 +7012,7 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$typeInterfaceType", + name = "$InterfaceTypeType", fields = [ BuiltInField(definition = "string name"), BuiltInField(definition = "bytes4 interfaceId", enabled = From("0.6.7")) @@ -6997,18 +7020,48 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$typeIntType", + name = "$IntTypeType", fields = [ BuiltInField(definition = "int min", enabled = From("0.6.8")), BuiltInField(definition = "int max", enabled = From("0.6.8")) ], functions = [] ), - BuiltInVariable(definition = "$function $placeholder"), - BuiltInVariable(definition = "$abiType abi"), - BuiltInVariable(definition = "$blockType block"), - BuiltInVariable(definition = "$msgType msg"), + BuiltInType( + name = "$UserDefinedValueType", + fields = [], + functions = [ + BuiltInFunction( + name = "wrap", + parameters = ["$WrappedType elementaryType"], + return_type = "$UserType" + ), + BuiltInFunction( + name = "unwrap", + parameters = ["$UserType userType"], + return_type = "$WrappedType" + ) + ], + enabled = From("0.8.8") + ), + BuiltInType( + name = "$YulExternal", + fields = [ + // These apply to state and storage variables + BuiltInField(definition = "uint slot"), + BuiltInField(definition = "uint offset"), + // Dynamic calldata arrays also have a length + BuiltInField(definition = "uint length") + ], + functions = [] + ), + BuiltInVariable(definition = "$Function $placeholder"), + BuiltInVariable(definition = "$AbiType abi"), + BuiltInVariable(definition = "$BlockType block"), + BuiltInVariable(definition = "$BytesType $bytes"), + BuiltInVariable(definition = "$MessageType msg"), BuiltInVariable(definition = "uint now", enabled = Till("0.7.0")), - BuiltInVariable(definition = "$txType tx") + BuiltInVariable(definition = "$StringType $string"), + BuiltInVariable(definition = "$TransactionType tx") ] )); diff --git a/crates/solidity/outputs/cargo/crate/generated/public_api.txt b/crates/solidity/outputs/cargo/crate/generated/public_api.txt index 5fa1c4d0eb..160b08e248 100644 --- a/crates/solidity/outputs/cargo/crate/generated/public_api.txt +++ b/crates/solidity/outputs/cargo/crate/generated/public_api.txt @@ -2,6 +2,7 @@ pub mod slang_solidity pub mod slang_solidity::bindings +pub fn slang_solidity::bindings::add_built_ins(bindings: &mut slang_solidity::bindings::Bindings, version: &semver::Version) -> core::result::Result<(), slang_solidity::parser::ParserInitializationError> pub fn slang_solidity::bindings::create_with_resolver(version: semver::Version, resolver: alloc::sync::Arc<(dyn metaslang_bindings::PathResolver + core::marker::Sync + core::marker::Send)>) -> slang_solidity::bindings::Bindings pub fn slang_solidity::bindings::get_binding_rules() -> &'static str pub fn slang_solidity::bindings::get_built_ins(version: &semver::Version) -> &'static str @@ -930,4 +931,3 @@ pub fn slang_solidity::parser::Parser::parse(&self, kind: slang_solidity::cst::N pub fn slang_solidity::parser::Parser::version(&self) -> &semver::Version impl core::fmt::Debug for slang_solidity::parser::Parser pub fn slang_solidity::parser::Parser::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result -pub fn slang_solidity::transform_built_ins_node(node: &slang_solidity::cst::Node) -> slang_solidity::cst::Node diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs index 63e0862896..579c433711 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs @@ -27,6 +27,11 @@ inherit .enclosing_def inherit .parent_scope inherit .lexical_scope +; Used to resolve extension methods for `using for *` directives +; This is used as a minor optimization to avoid introducing new possible paths +; when there are no `using for *` directives in the contract. +inherit .star_extension + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Source unit (aka .sol file) @@ -67,14 +72,22 @@ inherit .lexical_scope ;; inherited) for contracts to resolve bases (both in inheritance lists and ;; override specifiers) let @source_unit.parent_scope = @source_unit.lexical_scope + + ; This is used to indicate the resolution algorithm that here's where it + ; should inject any possible extension scopes + attr (@source_unit.lexical_scope) extension_hook + + ; Provide a default star extension sink node that gets inherited. This is + ; connected to from expressions, and those can potentially happen anywhere. + node @source_unit.star_extension } ;; Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( [ContractDefinition] - | [InterfaceDefinition] | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -84,9 +97,12 @@ inherit .lexical_scope | [EventDefinition] )] ]] { - edge @unit_member.lexical_scope -> @source_unit.lexical_scope edge @source_unit.lexical_scope -> @unit_member.def edge @source_unit.defs -> @unit_member.def + + ; In the general case, the lexical scope of the definition connects directly + ; to the source unit's + edge @unit_member.lexical_scope -> @source_unit.lexical_scope } ;; Special case for built-ins: we want to export all symbols in the contract: @@ -99,13 +115,14 @@ inherit .lexical_scope [SourceUnitMember @contract [ContractDefinition name: ["%BuiltIns%"]]] ]] { if (is-system-file FILE_PATH) { - edge @source_unit.defs -> @contract.members - edge @source_unit.defs -> @contract.type_members - edge @source_unit.defs -> @contract.state_vars + edge @source_unit.defs -> @contract.instance } } @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @using [UsingDirective]]]] { + ; TODO: this is the hook for top-level extensions, but this should connect to + ; an extensions scope that gets pushed to the scope stack, as in the case of + ; contracts/libraries (defined further down below). edge @source_unit.lexical_scope -> @using.def } @@ -116,7 +133,7 @@ inherit .lexical_scope edge @source_unit.defs -> @using.def } -;; ... and imports +;; Import connections to the source unit @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember [ImportDirective [ImportClause @import ( @@ -255,28 +272,32 @@ inherit .lexical_scope ;; interface), aka the source unit edge @type_name.push_end -> heir.parent_scope - ;; Make base members accesible as our own members - node member - attr (member) push_symbol = "." + ; Access instance members of the inherited contract/interface, from the + ; instance scope of the inheriting contract/interface + node instance + attr (instance) push_symbol = "@instance" + edge heir.instance -> instance + edge instance -> @type_name.push_begin - node typeof - attr (typeof) push_symbol = "@typeof" - - edge heir.members -> member - edge member -> typeof - edge typeof -> @type_name.push_begin - - ;; Make base defs (eg. enums and structs) accessible as our own - node type_member - attr (type_member) push_symbol = "." - - edge heir.type_members -> type_member - edge type_member -> @type_name.push_begin + ; Base members can also be accessed (from the instance scope) qualified with + ; the base name (eg. `Base.something`) + node member_pop + attr (member_pop) pop_symbol = "." + edge heir.instance -> @type_name.pop_begin + edge @type_name.pop_end -> member_pop + edge member_pop -> instance - ; Resolve the "super" keyword to the inherited type - edge heir.super -> @type_name.push_begin + ; Base namespace-like members (ie. enums, structs, etc) are also accessible as + ; our own namespace members + node ns_member + attr (ns_member) push_symbol = "." + edge heir.ns -> ns_member + edge ns_member -> @type_name.push_begin } +;; The next couple of rules setup a `.parent_refs` attribute to use in the +;; resolution algorithm to perform linearisation of a contract hierarchy. + ;; NOTE: we use anchors here to prevent the query engine from returning all the ;; sublists of possible parents @specifier [InheritanceSpecifier [InheritanceTypes . @parents [_]+ .]] { @@ -299,38 +320,35 @@ inherit .lexical_scope ;;; Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@contract [ContractDefinition] { +@contract [ContractDefinition @name name: [Identifier]] { node @contract.lexical_scope - node @contract.super_scope + node @contract.extensions node @contract.def node @contract.members - node @contract.type_members + node @contract.ns node @contract.modifiers - node @contract.state_vars + node @contract.instance - edge @contract.lexical_scope -> @contract.members - edge @contract.lexical_scope -> @contract.type_members - edge @contract.lexical_scope -> @contract.state_vars + attr (@contract.def) node_definition = @name + attr (@contract.def) definiens_node = @contract + ; The .extensions node is where `using` directives will hook the definitions + attr (@contract.def) extension_scope = @contract.extensions - ;; Modifiers are available as a contract type members through a special '@modifier' symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @contract.type_members -> modifier - edge modifier -> @contract.modifiers + edge @contract.lexical_scope -> @contract.instance - let @contract.enclosing_def = @contract.def -} + ; Instance scope can also see members and our namespace definitions + edge @contract.instance -> @contract.members + edge @contract.instance -> @contract.ns -@contract [ContractDefinition @name name: [Identifier]] { - attr (@contract.def) node_definition = @name - attr (@contract.def) definiens_node = @contract + let @contract.enclosing_def = @contract.def - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + ;; External "instance" scope access: either member access through a variable + ;; of the contract's type, or through calling (which happens on `new` + ;; invocations or casting). These should access only externally accessible + ;; members, such as functions and public variables. node member attr (member) pop_symbol = "." - edge member -> @contract.members + edge member -> @contract.instance node type_def attr (type_def) pop_symbol = "@typeof" @@ -342,81 +360,148 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member - ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @contract.def -> type_member - edge type_member -> @contract.type_members - - ;; Define "this" and connect it to the contract definition + ;; "namespace" scope access + node ns_member + attr (ns_member) pop_symbol = "." + edge @contract.def -> ns_member + edge ns_member -> @contract.ns + + ; Finally there's an @instance guarded path used by derived contracts to + ; access instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @contract.def -> instance + edge instance -> @contract.instance + + ; "this" keyword is available in our lexical scope and can access any + ; externally available member node this attr (this) pop_symbol = "this" - edge this -> member - - ;; ... and make it available in the contract's lexical scope edge @contract.lexical_scope -> this + edge this -> member - ; Resolve the "this" keyword to the contract itself - node name_push - attr (name_push) push_symbol = (source-text @name) - edge this -> name_push - edge name_push -> @contract.lexical_scope - - ;; Define "super" effectively as if it was a state variable of a type connected by our super_scope - ;; super_scope will later connect to the base contract defs directly - node @contract.super - attr (@contract.super) pop_symbol = "super" - - node super_typeof - attr (super_typeof) push_symbol = "@typeof" - - edge @contract.super -> super_typeof - edge super_typeof -> @contract.super_scope - - ;; Finally make "super" available in the contract's lexical scope for function bodies to use - edge @contract.lexical_scope -> @contract.super + ;; Modifiers are available as a contract type members through a special '@modifier' guard + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @contract.ns -> modifier + edge modifier -> @contract.modifiers - ; NOTE: The keyword "super" itself resolves to each of its parent contracts. - ; See the related rules in the InheritanceSpecifier section above. + ; There may be attached functions to our type. For the general case of + ; variables of our type, that's already handled via normal lexical scope + ; resolution. But for casting/`new` invocations that we resolve through the + ; `()` guard above, we need to explicitly jump to the extension scope from + ; here to attempt resolving the attached function. We cannot jump back to the + ; parent scope because that would create a cycle in the graph. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + node hook + attr (hook) extension_hook + + edge call -> push_typeof + edge push_typeof -> push_name + edge push_name -> hook - ;; This defines the sink of edges added from base contracts when setting this - ;; contract as the compilation context - attr (@contract.def) export_node = @contract.members + if (version-matches "< 0.5.0") { + ; For Solidity < 0.5.0 `this` also acts like an `address` + node address_ref + attr (address_ref) push_symbol = "%address" + node address_typeof + attr (address_typeof) push_symbol = "@typeof" + edge this -> address_typeof + edge address_typeof -> address_ref + edge address_ref -> @contract.lexical_scope + } - ;; This node will eventually connect to the contract's members being compiled - ;; and grants access to definitions in that contract and all its parents - ;; (recursively) - node super_import - attr (super_import) pop_symbol = "." - edge @contract.super -> super_import + ; This is the connection point to resolve attached functions by `using for *` + node @contract.star_extension + attr (@contract.star_extension) push_symbol = "@*" - ;; This defines the source side of edges added to base contracts when setting - ;; a contract as compilation context; this allows this contract (a base) to - ;; access virtual methods in any sub-contract defined in the hierarchy - attr (@contract.def) import_nodes = [@contract.lexical_scope, super_import] + if (version-matches "< 0.7.0") { + ; For Solidity < 0.7.0 using directives are inherited, so we need to connect + ; always For newer versions, this connection only happens when there is a + ; `using for *` directive in the contract (see rule below) + edge @contract.star_extension -> @contract.lexical_scope + } ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" + attr (type_contract_type) push_symbol = "%ContractTypeType" edge @contract.def -> type edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope + edge type_contract_type -> @contract.parent_scope + + ; The following defines the connection nodes the resolution algorithm uses + ; *only when setting a compilation context/target*. + + ; This attribute defines the sink of edges added from base contracts when + ; setting this contract as the compilation context, and should provide access + ; to anything that can be reached through `super`. The instance scope is a bit + ; too broad, but `.members` is too narrow as it doesn't allow navigation to + ; parent contracts (and from the base we need to be able to reach all + ; contracts in the hierarchy). + attr (@contract.def) export_node = @contract.instance + + ; This node will eventually connect to the contract's members being compiled + ; and grants access to definitions in that contract and all its parents + ; (recursively). It only makes sense if `super` is defined (ie. if we have + ; parents), but we define it here to be able to use it in the declaration of + ; import nodes. This is the dual of the export_node above. + node @contract.super_import + attr (@contract.super_import) pop_symbol = "." + + ; This defines the source side of edges added to base contracts when setting + ; a contract as compilation context; this allows this contract (a base) to + ; access virtual methods in any sub-contract defined in the hierarchy (both + ; with and without `super`, hence the two connection points). + attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] } @contract [ContractDefinition @specifier [InheritanceSpecifier]] { + ; The `.heir` scoped variable allows the rules for `InheritanceSpecifier` + ; above to connect the instance scope of this contract to the parents. let @specifier.heir = @contract attr (@contract.def) parents = @specifier.parent_refs + if (version-matches "< 0.7.0") { + attr (@contract.def) inherit_extensions + } + + ; The rest of these statements deal with defining and connecting the `super` + ; keyword path. + + ; `super_scope` is where we hook all references to our parent contracts + node @contract.super_scope + + ; Define "super" in the lexical scope + node @contract.super + attr (@contract.super) pop_symbol = "super" + edge @contract.lexical_scope -> @contract.super + + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target (see more detailed description + ; above on the definition of the `super_import` node). + edge @contract.super -> @contract.super_import + + ; Then connect it through an `@instance` guard to the parent contracts through + ; `super_scope`. This allows "instance"-like access to members of parents + ; through `super`. + node super_instance + attr (super_instance) push_symbol = "@instance" + edge @contract.super_import -> super_instance + edge super_instance -> @contract.super_scope } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes [InheritanceType @type_name [IdentifierPath]] ]]] { - ;; The base contract defs are directly accesible through our special super scope + ;; The base contract defs are directly accesible through our super scope edge @contract.super_scope -> @type_name.push_begin } +; Pure definitions that cannot contain expressions @contract [ContractDefinition [ContractMembers [ContractMember @member ( [EnumDefinition] @@ -424,12 +509,23 @@ inherit .lexical_scope | [EventDefinition] | [ErrorDefinition] | [UserDefinedValueTypeDefinition] - | [FunctionDefinition] + )] +]] { + edge @member.lexical_scope -> @contract.lexical_scope +} + +; Definitions that can contain expressions need two scopes: +; - normal lexical scope for resolving types +; - extended scope (extended by using directives) for resolving expressions +@contract [ContractDefinition [ContractMembers + [ContractMember @member ( + [FunctionDefinition] | [ConstructorDefinition] - | [StateVariableDefinition] | [ModifierDefinition] | [FallbackFunctionDefinition] | [ReceiveFunctionDefinition] + | [UnnamedFunctionDefinition] + | [StateVariableDefinition] )] ]] { edge @member.lexical_scope -> @contract.lexical_scope @@ -438,7 +534,8 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - edge @contract.lexical_scope -> @using.def + ; Hook the using definition in the extensions scope + edge @contract.extensions -> @using.def } @contract [ContractDefinition [ContractMembers @@ -450,13 +547,20 @@ inherit .lexical_scope | [UserDefinedValueTypeDefinition] )] ]] { - edge @contract.type_members -> @member.def + ; These definition go into the "namespace" scope and are accessible externally + ; via qualified naming (eg. `Contract.MyStruct`) + edge @contract.ns -> @member.def } @contract [ContractDefinition [ContractMembers [ContractMember @state_var [StateVariableDefinition]] ]] { - edge @contract.state_vars -> @state_var.def + ; State variables are available to derived contracts. + ; TODO: this also exposes private state variables to derived contracts, but we + ; can't easily filter them because we don't have negative assertions in our + ; query language (we would need to modify this query for anything *not* + ; containing a `PrivateKeyword` node) + edge @contract.instance -> @state_var.def } ;; Public state variables are also exposed as external member functions @@ -485,13 +589,15 @@ inherit .lexical_scope [FunctionAttributes [FunctionAttribute ([ExternalKeyword] | [PublicKeyword])]] ]] ]] { - ; public or external functions are also accessible through the contract type - edge @contract.type_members -> @function.def + ; Public or external functions are also accessible through the contract type + ; (to retrieve their `.selector` for example) + edge @contract.ns -> @function.def } @contract [ContractDefinition members: [ContractMembers [ContractMember @modifier [ModifierDefinition]] ]] { + ; Modifiers live in their own special scope edge @contract.modifiers -> @modifier.def ;; This may prioritize this definition (when there are multiple options) @@ -500,6 +606,15 @@ inherit .lexical_scope attr (@modifier.def) parents = [@contract.def] } +@contract [ContractDefinition [ContractMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the contract + edge @contract.star_extension -> @contract.lexical_scope +} + +; This applies to both state variables and function definitions @override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths @base_ident [IdentifierPath] ]]] { @@ -512,26 +627,29 @@ inherit .lexical_scope ;;; Interfaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@interface [InterfaceDefinition] { +@interface [InterfaceDefinition @name name: [Identifier]] { node @interface.lexical_scope node @interface.def node @interface.members - node @interface.type_members - - edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.type_members -} + node @interface.ns + node @interface.instance -@interface [InterfaceDefinition @name name: [Identifier]] { attr (@interface.def) node_definition = @name attr (@interface.def) definiens_node = @interface - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + edge @interface.lexical_scope -> @interface.instance + + ; The extensions node is required for the inheritance rules, but not used in interfaces + let @interface.extensions = (node) + + edge @interface.instance -> @interface.members + edge @interface.instance -> @interface.ns + + ;; External "instance" like access path, to access members of a variable of + ;; the interface's type or through a casting call. node member attr (member) pop_symbol = "." - edge member -> @interface.members + edge member -> @interface.instance node typeof attr (typeof) pop_symbol = "@typeof" @@ -543,28 +661,46 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member + ; From a call we may need to resolve using the extensions scope, in case there's + ; a `using` directive on our type. This path ends up jumping to scope just to + ; handle that case. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + edge call -> push_typeof + edge push_typeof -> push_name + node hook + attr (hook) extension_hook + edge push_name -> hook + ; edge push_name -> JUMP_TO_SCOPE_NODE + ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @interface.def -> type_member - edge type_member -> @interface.type_members + node ns_member + attr (ns_member) pop_symbol = "." + edge @interface.def -> ns_member + edge ns_member -> @interface.ns + + ; Finally there's guarded `@instance` path used by derived contracts to access + ; instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @interface.def -> instance + edge instance -> @interface.instance ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" + attr (type_interface_type) push_symbol = "%InterfaceTypeType" edge @interface.def -> type edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope + edge type_interface_type -> @interface.parent_scope } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { let @specifier.heir = @interface attr (@interface.def) parents = @specifier.parent_refs - - ; Define a dummy "super" node required by the rules for InheritanceSpecifier - node @interface.super } @interface [InterfaceDefinition [InterfaceMembers @@ -578,7 +714,7 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @interface.lexical_scope - edge @interface.type_members -> @member.def + edge @interface.ns -> @member.def } ;; Allow references (eg. variables of the interface type) to the interface to @@ -586,14 +722,13 @@ inherit .lexical_scope @interface [InterfaceDefinition members: [InterfaceMembers item: [ContractMember @function variant: [FunctionDefinition]] ]] { - edge @function.lexical_scope -> @interface.lexical_scope edge @interface.members -> @function.def } [InterfaceDefinition [InterfaceMembers [ContractMember @using [UsingDirective]]]] { ; using directives are not allowed in interfaces, but the grammar allows them ; so we need to create an artificial node here to connect to created edges from - ; the internal nodes + ; the instance nodes let @using.lexical_scope = (node) } @@ -602,38 +737,50 @@ inherit .lexical_scope ;;; Libraries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@library [LibraryDefinition] { +@library [LibraryDefinition @name name: [Identifier]] { node @library.lexical_scope + node @library.extensions node @library.def - node @library.members + node @library.ns + node @library.modifiers - edge @library.lexical_scope -> @library.members -} - -@library [LibraryDefinition @name name: [Identifier]] { attr (@library.def) node_definition = @name attr (@library.def) definiens_node = @library + ; The .extensions node is where `using` directives will hook the definitions + attr (@library.def) extension_scope = @library.extensions + + edge @library.lexical_scope -> @library.ns + + let @library.enclosing_def = @library.def node member attr (member) pop_symbol = "." edge @library.def -> member + edge member -> @library.ns - edge member -> @library.members + ; Access to modifiers is guarded by a @modifier symbol + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @library.ns -> modifier + edge modifier -> @library.modifiers ; Path to resolve the built-in type for type() expressions (same as contracts) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_library_type - attr (type_library_type) push_symbol = "%typeContractType" + attr (type_library_type) push_symbol = "%ContractTypeType" edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; This is the connection point to resolve attached functions by `using for *` + node @library.star_extension + attr (@library.star_extension) push_symbol = "@*" } @library [LibraryDefinition [LibraryMembers [ContractMember @member ( - [FunctionDefinition] - | [EnumDefinition] + [EnumDefinition] | [StructDefinition] | [EventDefinition] | [ErrorDefinition] @@ -641,31 +788,54 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @library.lexical_scope - edge @library.members -> @member.def + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @member ( + [FunctionDefinition] + | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] + )] +]] { + edge @member.lexical_scope -> @library.lexical_scope + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @modifier [ModifierDefinition]] +]] { + edge @library.modifiers -> @modifier.def + edge @modifier.lexical_scope -> @library.lexical_scope } @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - edge @library.lexical_scope -> @using.def + ; Expose the using directive from the extensions scope + edge @library.extensions -> @using.def } +@library [LibraryDefinition [LibraryMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the library + edge @library.star_extension -> @library.lexical_scope +} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Using directives ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; The UsingDirective node requires the enclosing context to setup a -;; .lexical_scope scoped variable for it to resolve both targets and subjects. - @using [UsingDirective] { ; This node acts as a definition in the sense that provides an entry point ; that pops the target type and pushes the library/functions to attach to the ; target type node @using.def - ; This internal node connects the other end of the popping path starting at - ; .def and resolves for the library/functions in the directive + ; This internal node connects the definition side of the clause to the target + ; for resolution, and allows handling the multiple cases of `using` syntax + ; easily node @using.clause } @@ -709,12 +879,18 @@ inherit .lexical_scope ; pop the type symbols to connect to the attached function (via @using.clause) node typeof attr (typeof) pop_symbol = "@typeof" + node cast + attr (cast) pop_symbol = "()" - edge @using.def -> @type_name.pop_begin + ; We connect to all_pop_begin to be able to resolve both qualified and + ; unqualified instances of the target type + edge @using.def -> @type_name.all_pop_begin edge @type_name.pop_end -> typeof edge typeof -> @using.clause + edge @type_name.pop_end -> cast + edge cast -> @using.clause - ; resolve the target type of the directive + ; resolve the target type of the directive on the lexical scope edge @type_name.type_ref -> @using.lexical_scope } @@ -731,7 +907,7 @@ inherit .lexical_scope ;;; Type names ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TypeName nodes should define two scoped variables: +;; TypeName nodes should define these scoped variables: ;; ;; - @type_name.type_ref represents the node in the graph where we're ready to ;; resolve the type, and thus should generally be connected to a (lexical) @@ -740,12 +916,19 @@ inherit .lexical_scope ;; - @type_name.output represents the other end of the type and corresponds to a ;; state where the type has already been resolved so we can, for example ;; resolve its members (sink node, outside edges connect *to* here). +;; +;; - @type_name.pop_begin, @type_name.pop_end are used in a definition context, +;; ie. when we need to pop the type name symbol(s) from the symbol stack. +;; Additionally, @type_name.all_pop_begin links to each symbol in a typename +;; (ie. in an identifier path typename), which allows referring to a type both +;; qualified and unqualified. @type_name [TypeName @elementary [ElementaryType]] { let @type_name.type_ref = @elementary.ref let @type_name.output = @elementary.ref let @type_name.pop_begin = @elementary.pop let @type_name.pop_end = @elementary.pop + let @type_name.all_pop_begin = @elementary.pop } @type_name [TypeName @id_path [IdentifierPath]] { @@ -760,6 +943,7 @@ inherit .lexical_scope let @type_name.pop_begin = @id_path.pop_begin let @type_name.pop_end = @id_path.pop_end + let @type_name.all_pop_begin = @id_path.all_pop_begin } @type_name [TypeName @type_variant ([ArrayTypeName] | [FunctionType])] { @@ -767,6 +951,7 @@ inherit .lexical_scope let @type_name.output = @type_variant.output let @type_name.pop_begin = @type_variant.pop_begin let @type_name.pop_end = @type_variant.pop_end + let @type_name.all_pop_begin = @type_variant.pop_begin } @type_name [TypeName @mapping [MappingType]] { @@ -774,6 +959,7 @@ inherit .lexical_scope let @type_name.output = @mapping.output let @type_name.pop_begin = @mapping.pop_begin let @type_name.pop_end = @mapping.pop_end + let @type_name.all_pop_begin = @mapping.pop_begin } @@ -788,76 +974,130 @@ inherit .lexical_scope node @elementary.pop attr (@elementary.pop) pop_symbol = @elementary.symbol + + ; These variables are a bit redundant, but necessary to easily use elementary + ; types as mapping keys + let @elementary.pop_begin = @elementary.pop + let @elementary.pop_end = @elementary.pop + let @elementary.all_pop_begin = @elementary.pop + + let @elementary.push_begin = @elementary.ref + let @elementary.push_end = @elementary.ref +} + +@elementary [ElementaryType [AddressType]] { + let @elementary.symbol = "%address" +} + +@elementary [ElementaryType [BoolKeyword]] { + let @elementary.symbol = "%bool" } -@elementary [ElementaryType variant: [AddressType @address [AddressKeyword]]] { - let @elementary.symbol = (format "%{}" (source-text @address)) +@elementary [ElementaryType [ByteKeyword]] { + let @elementary.symbol = "%byte" } -@elementary [ElementaryType @keyword ( - [BoolKeyword] - | [ByteKeyword] - | [BytesKeyword] - | [StringKeyword] - | [IntKeyword] - | [UintKeyword] - | [FixedKeyword] - | [UfixedKeyword] -)] { +@elementary [ElementaryType @keyword [BytesKeyword]] { let @elementary.symbol = (format "%{}" (source-text @keyword)) } +@elementary [ElementaryType [StringKeyword]] { + let @elementary.symbol = "%string" +} + +@elementary [ElementaryType @keyword [IntKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "int") { + let @elementary.symbol = "%int256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UintKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "uint") { + let @elementary.symbol = "%uint256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [FixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "fixed") { + let @elementary.symbol = "%fixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UfixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "ufixed") { + let @elementary.symbol = "%ufixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@mapping [MappingType] { +@mapping [MappingType + [MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]] + [MappingValue @value_type [TypeName]] +] { node @mapping.lexical_scope node @mapping.output -} - -@mapping [MappingType [MappingKey [MappingKeyType @key_ident [IdentifierPath]]]] { - ; resolve key type - edge @key_ident.push_end -> @mapping.lexical_scope -} -@mapping [MappingType [MappingValue @value_type [TypeName]]] { - ; for mapping types we don't need to push the type itself, because we don't need it (yet) - ; ditto for the pop path, because a mapping type cannot be the target of a using directive + ; Define the pushing path of the mapping type + ; ValueType <- top of the symbol stack + ; KeyType + ; %mapping <- bottom of the symbol stack + node mapping + attr (mapping) push_symbol = "%Mapping" + edge @mapping.output -> mapping + edge mapping -> @key_type.push_begin + edge @key_type.push_end -> @value_type.output + + ; Both key and value types need to be resolved + edge @value_type.type_ref -> @mapping.lexical_scope + edge @key_type.push_end -> @mapping.lexical_scope - ; The mapping's type exposes the `%index` (ie. `[]`) operator that returns the value type - ; This is similar to arrays, only in that case we have a built-in type where - ; we can define an index function. For mappings we hard-code in the rules directly. + ; The mapping's type exposes the `[]` operator that returns the value type. node typeof_input attr (typeof_input) pop_symbol = "@typeof" - - node index_member - attr (index_member) pop_symbol = "." - node index - attr (index) pop_symbol = "%index" - node index_call - attr (index_call) pop_symbol = "()" + edge @mapping.output -> typeof_input node typeof_output attr (typeof_output) push_symbol = "@typeof" - - edge @mapping.output -> typeof_input - edge typeof_input -> index_member - edge index_member -> index - edge index -> index_call - edge index_call -> typeof_output edge typeof_output -> @value_type.output - ; resolve the value type through our scope - edge @value_type.type_ref -> @mapping.lexical_scope + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for mapping public state variables: they can be called + ; like a function with a key, and it's effectively the same as indexing it. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only + ; This is the reverse of the pushing path above (to the `.output` node) + node pop_mapping + attr (pop_mapping) pop_symbol = "%Mapping" - ; We use the value_type's definition path as our own because it's needed when - ; a mapping is the target of a `using` directive. It's not correct, but we - ; don't have the analog referencing path either. let @mapping.pop_begin = @value_type.pop_begin - let @mapping.pop_end = @value_type.pop_end + edge @value_type.pop_end -> @key_type.pop_begin + edge @key_type.pop_end -> pop_mapping + let @mapping.pop_end = pop_mapping } @@ -871,47 +1111,69 @@ inherit .lexical_scope } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type = "%arrayFixed" + let @array.type_symbol = "%FixedArray" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type = "%array" + let @array.type_symbol = "%Array" } @array [ArrayTypeName @type_name [TypeName]] { - ; First define the normal, reference route: - - ; We first push the array type `%array`, which should connect to two distinct paths: - ; 1. the typed path, which will use a jump scope entry to resolve the element type - ; 2. the hard-coded path to connect to any `using` directive + ; Define the pushing path of the array type + ; ValueType <- top of the symbol stack + ; %array / %arrayFixed <- bottom of the symbol stack node array - attr (array) push_symbol = @array.type + attr (array) push_symbol = @array.type_symbol edge @array.output -> array + edge array -> @type_name.output - ; For the first path, we need to define a scope jump entry for resolving the element type of the array - node entry - attr (entry) is_exported - node element - attr (element) pop_symbol = "%element" - edge entry -> element - edge element -> @type_name.output + ; Resolve the value type itself + edge @type_name.type_ref -> @array.lexical_scope + ; And also the "type erased" array type so we can resolve built-in members + edge array -> @array.lexical_scope - ; And then the path itself - node params - attr (params) push_scoped_symbol = "<>", scope = entry - edge array -> params + ; Define the path to resolve index access (aka the `[]` operator) - ; Second path, for `using` directives - edge array -> @type_name.output + node typeof_input + attr (typeof_input) pop_symbol = "@typeof" + edge @array.output -> typeof_input - ; Finally, both ends connect to our lexical scope - edge params -> @array.lexical_scope - edge @type_name.type_ref -> @array.lexical_scope + node typeof_output + attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @type_name.output + + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for public state variables of type array: they can be called + ; like a function with an index, and it's effectively the same as indexing the + ; array. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Define the special `.push()` built-in that returns the element type (for Solidity >= 0.6.0) + if (version-matches ">= 0.6.0") { + node built_in_member + attr (built_in_member) pop_symbol = "." + node push_built_in + attr (push_built_in) pop_symbol = "push" + node built_in_call + attr (built_in_call) pop_symbol = "()" + + edge typeof_input -> built_in_member + edge built_in_member -> push_built_in + edge push_built_in -> built_in_call + edge built_in_call -> typeof_output + } ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only ; This is essentially the reverse of the second path above node pop_array - attr (pop_array) pop_symbol = @array.type + attr (pop_array) pop_symbol = @array.type_symbol let @array.pop_begin = @type_name.pop_begin edge @type_name.pop_end -> pop_array @@ -926,10 +1188,10 @@ inherit .lexical_scope @ftype [FunctionType @attrs [FunctionTypeAttributes]] { ; Compute the built-in type of the function ; %functionExternal provides access to .selector and .address - var type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "external" { - set type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -939,14 +1201,14 @@ inherit .lexical_scope ; This path pushes the function type to the symbol stack ; TODO: add parameter and return types to distinguish between different function types node function_type - attr (function_type) push_symbol = type + attr (function_type) push_symbol = type_symbol edge @ftype.output -> function_type edge function_type -> @ftype.lexical_scope ; the pop path for the using directive node pop_function_type - attr (pop_function_type) pop_symbol = type + attr (pop_function_type) pop_symbol = type_symbol let @ftype.pop_begin = pop_function_type let @ftype.pop_end = pop_function_type @@ -963,8 +1225,9 @@ inherit .lexical_scope @ftype [FunctionType [ReturnsDeclaration [ParametersDeclaration [Parameters . @param [Parameter] .]] ]] { - ; variables of a function type type can be "called" and resolve to the type of - ; the return parameter + ; Variables of a function type type can be "called" and resolve to the type of + ; the return parameter. This is only valid if the function returns a single + ; value. node typeof attr (typeof) pop_symbol = "@typeof" @@ -991,14 +1254,22 @@ inherit .lexical_scope ;; @id_path.pop_end. ;; ;; NOTE: most of the time, and unless this identifier path is the target of a -;; using directive this path will not be used and will form a disconnected -;; graph component. We currently have no way of determining when this path is -;; necessary, so we always construct it. +;; using directive this second path will not be used and will form a +;; disconnected graph component. We currently have no way of determining when +;; this path is necessary, so we always construct it. ;; ;; Additionally the IdentifierPath defines another scoped variable ;; @id_path.rightmost_identifier which corresponds to the identifier in the last -;; position in the path, from left to right. Useful for the using directive to -;; be able to pop the name of the attached function. +;; position in the path, from left to right. This is used in the using directive +;; rules to be able to pop the name of the attached function. + +@id_path [IdentifierPath] { + ; This node connects to all parts of the path, for popping. This allows to + ; connect at any point of the path. Useful for `using` directives when the + ; target type is fully qualified but we want to resolve for the unqualified + ; name. + node @id_path.all_pop_begin +} @id_path [IdentifierPath @name [Identifier]] { node @name.ref @@ -1007,6 +1278,8 @@ inherit .lexical_scope node @name.pop attr (@name.pop) pop_symbol = (source-text @name) + + edge @id_path.all_pop_begin -> @name.pop } @id_path [IdentifierPath @name [Identifier] .] { @@ -1074,10 +1347,10 @@ inherit .lexical_scope } @function [FunctionDefinition @attrs [FunctionAttributes]] { - var function_type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "\\b(public|external)\\b" { - set function_type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -1089,7 +1362,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type_function - attr (type_function) push_symbol = function_type + attr (type_function) push_symbol = type_symbol edge @function.def -> typeof edge typeof -> type_function edge type_function -> @function.lexical_scope @@ -1154,12 +1427,39 @@ inherit .lexical_scope edge @name.push_end -> modifier edge modifier -> @modifier.lexical_scope + + ; This allows resolving @name in the more general scope in constructors (since + ; calling a parent constructor is parsed as a modifier invocation) + let @modifier.identifier = @name.push_end } @modifier [ModifierInvocation @args [ArgumentsDeclaration]] { edge @args.lexical_scope -> @modifier.lexical_scope } +;;; Unnamed functions (deprecated) +@unnamed_function [UnnamedFunctionDefinition] { + node @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition @params parameters: [ParametersDeclaration]] { + edge @params.lexical_scope -> @unnamed_function.lexical_scope + + edge @unnamed_function.lexical_scope -> @params.defs + attr (@unnamed_function.lexical_scope -> @params.defs) precedence = 1 +} + +@unnamed_function [UnnamedFunctionDefinition [FunctionBody @block [Block]]] { + edge @block.lexical_scope -> @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition + [UnnamedFunctionAttributes [UnnamedFunctionAttribute @modifier [ModifierInvocation]]] +] { + edge @modifier.lexical_scope -> @unnamed_function.lexical_scope +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Constructors @@ -1191,6 +1491,7 @@ inherit .lexical_scope @modifier [ModifierInvocation] ]]] { edge @modifier.lexical_scope -> @constructor.lexical_scope + edge @modifier.identifier -> @constructor.lexical_scope } @contract [ContractDefinition [ContractMembers [ContractMember @@ -1200,7 +1501,9 @@ inherit .lexical_scope edge @contract.def -> @constructor.def } -;; Solidity < 0.5.0 constructors were declared as functions of the contract's name +;; Solidity < 0.5.0 constructors +;; They were declared as functions of the contract's name + @contract [ContractDefinition @contract_name [Identifier] [ContractMembers [ContractMember [FunctionDefinition @@ -1216,6 +1519,21 @@ inherit .lexical_scope } } +[ContractDefinition + @contract_name [Identifier] + [ContractMembers [ContractMember @function [FunctionDefinition + [FunctionName @function_name [Identifier]] + [FunctionAttributes [FunctionAttribute @modifier [ModifierInvocation]]] + ]]] +] { + if (version-matches "< 0.5.0") { + if (eq (source-text @contract_name) (source-text @function_name)) { + ; Parent constructor calls are parsed as modifier invocations + edge @modifier.identifier -> @function.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Fallback and receive functions @@ -1391,7 +1709,6 @@ inherit .lexical_scope @expr_stmt [ExpressionStatement] { node @expr_stmt.lexical_scope - node @expr_stmt.defs } @@ -1399,32 +1716,46 @@ inherit .lexical_scope @stmt [Statement @var_decl [VariableDeclarationStatement]] { edge @var_decl.lexical_scope -> @stmt.lexical_scope - edge @stmt.defs -> @var_decl.defs + edge @stmt.defs -> @var_decl.def } @var_decl [VariableDeclarationStatement] { node @var_decl.lexical_scope - node @var_decl.defs + node @var_decl.def } @var_decl [VariableDeclarationStatement [VariableDeclarationType @var_type [TypeName]] @name name: [Identifier] ] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @var_decl + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl - edge @var_decl.defs -> def edge @var_type.type_ref -> @var_decl.lexical_scope node typeof attr (typeof) push_symbol = "@typeof" - edge def -> typeof + edge @var_decl.def -> typeof edge typeof -> @var_type.output } +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + @name name: [Identifier] +] { + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl +} + +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + [VariableDeclarationValue @value [Expression]] +] { + edge @var_decl.def -> @value.output +} + + ;;; Tuple deconstruction statements @@ -1498,11 +1829,20 @@ inherit .lexical_scope ;; For loops @stmt [Statement [ForStatement - initialization: [ForStatementInitialization - @init_stmt ([ExpressionStatement] - | [VariableDeclarationStatement] - | [TupleDeconstructionStatement]) - ] + initialization: [ForStatementInitialization @init_stmt [ExpressionStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [VariableDeclarationStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope + edge @stmt.init_defs -> @init_stmt.def +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [TupleDeconstructionStatement]] ]] { edge @init_stmt.lexical_scope -> @stmt.lexical_scope edge @stmt.init_defs -> @init_stmt.defs @@ -1652,11 +1992,36 @@ inherit .lexical_scope edge @type_name.type_ref -> @state_var.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @state_var.typeof + attr (@state_var.typeof) push_symbol = "@typeof" + + edge @state_var.def -> @state_var.typeof + edge @state_var.typeof -> @type_name.output +} + +@state_var [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [PublicKeyword]]] +] { + ; Public state variables are used as functions when invoked from an external contract + node call + attr (call) pop_symbol = "()" + + ; In the general case using the getter can bind to the state variable's type + edge @state_var.def -> call + edge call -> @state_var.typeof - edge @state_var.def -> typeof - edge typeof -> @type_name.output + ; Some complex types generate special getters (ie. arrays and mappings index + ; their contents, structs flatten most of their fields and return a tuple) + node getter + attr (getter) push_symbol = "@as_getter" + edge call -> getter + edge getter -> @state_var.typeof +} + +@state_var [StateVariableDefinition + [StateVariableDefinitionValue @value [Expression]] +] { + let @value.lexical_scope = @state_var.lexical_scope } @@ -1664,13 +2029,11 @@ inherit .lexical_scope ;;; Enum definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@enum [EnumDefinition] { +@enum [EnumDefinition @name name: [Identifier]] { node @enum.lexical_scope node @enum.def node @enum.members -} -@enum [EnumDefinition @name name: [Identifier]] { attr (@enum.def) node_definition = @name attr (@enum.def) definiens_node = @enum @@ -1682,9 +2045,9 @@ inherit .lexical_scope ; Path to resolve the built-in type for enums (which is the same as for integer types) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_enum_type - attr (type_enum_type) push_symbol = "%typeIntType" + attr (type_enum_type) push_symbol = "%IntTypeType" edge @enum.def -> type edge type -> type_enum_type edge type_enum_type -> @enum.lexical_scope @@ -1705,73 +2068,61 @@ inherit .lexical_scope ;;; Structure definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@struct [StructDefinition] { +@struct [StructDefinition @name name: [Identifier]] { node @struct.lexical_scope node @struct.def node @struct.members -} - -@struct [StructDefinition @name name: [Identifier]] { - ; Since we use structs to define built-in types and some of them (ie. array) - ; have have a parametric type, we define two distinct paths to define a - ; struct: - ; 1. the normal, non parametric path, should drop scopes in the scope stack first of all - ; 2. the parametric path, that pops a scope to resolve the parametric type - ; Both of these connect to the node that pops the struct identifier symbol - - ; First the normal path - node struct_drop - attr (struct_drop) type = "drop_scopes" - edge @struct.def -> struct_drop - - ; Second path, pops the scope - node typed_params - attr (typed_params) pop_scoped_symbol = "<>" - edge @struct.def -> typed_params - - ; Connect both to the struct identifier - node def - attr (def) node_definition = @name - attr (def) definiens_node = @struct - edge struct_drop -> def - edge typed_params -> def - ; On the other end, to properly close the second path we need to jump to the popped scope - ; (this is why on the other path we drop scopes) - edge @struct.lexical_scope -> JUMP_TO_SCOPE_NODE + attr (@struct.def) node_definition = @name + attr (@struct.def) definiens_node = @struct ; Now connect normally to the struct members - node type_def - attr (type_def) pop_symbol = "@typeof" + node @struct.typeof + attr (@struct.typeof) pop_symbol = "@typeof" node member attr (member) pop_symbol = "." - edge def -> type_def - edge type_def -> member + edge @struct.def -> @struct.typeof + edge @struct.typeof -> member edge member -> @struct.members ; Bind member names when using construction with named arguments node param_names attr (param_names) pop_symbol = "@param_names" - edge def -> param_names + edge @struct.def -> param_names edge param_names -> @struct.members + + ; Used as a function call (ie. casting), should bind to itself + node call + attr (call) pop_symbol = "()" + edge @struct.def -> call + edge call -> member } @struct [StructDefinition [StructMembers @member item: [StructMember @type_name [TypeName] @name name: [Identifier]] ]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @member + node @member.def + attr (@member.def) node_definition = @name + attr (@member.def) definiens_node = @member - edge @struct.members -> def + edge @struct.members -> @member.def edge @type_name.type_ref -> @struct.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @member.typeof + attr (@member.typeof) push_symbol = "@typeof" - edge def -> typeof - edge typeof -> @type_name.output + edge @member.def -> @member.typeof + edge @member.typeof -> @type_name.output +} + +@struct [StructDefinition [StructMembers . @first_member [StructMember]]] { + ; As a public getter result, the value returned is a tuple with all our fields flattened + ; We only care about the first member for name binding, since tuples are not real types + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge @struct.typeof -> getter_call + edge getter_call -> @first_member.typeof } @@ -1824,6 +2175,15 @@ inherit .lexical_scope node @error.params attr (@error.params) pop_symbol = "@param_names" edge @error.def -> @error.params + + ; Bind to built-in errorType for accessing built-in member `.selector` + node typeof + attr (typeof) push_symbol = "@typeof" + node error_type + attr (error_type) push_symbol = "%ErrorType" + edge @error.def -> typeof + edge typeof -> error_type + edge error_type -> @error.lexical_scope } @error [ErrorDefinition [ErrorParametersDeclaration [ErrorParameters @@ -1867,17 +2227,59 @@ inherit .lexical_scope edge @type_name.type_ref -> @constant.lexical_scope } -@user_type [UserDefinedValueTypeDefinition] { +@user_type [UserDefinedValueTypeDefinition @name [Identifier] @value_type [ElementaryType]] { node @user_type.lexical_scope node @user_type.def -} -@user_type [UserDefinedValueTypeDefinition @name [Identifier]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @user_type + attr (@user_type.def) node_definition = @name + attr (@user_type.def) definiens_node = @user_type + + ; Provide member resolution through the built-in `%userTypeType` + ; Because the built-in is defined as a struct, we need to push an extra `@typeof` + node member_guard + attr (member_guard) pop_symbol = "." + node member + attr (member) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node user_type_type + attr (user_type_type) push_symbol = "%UserDefinedValueType" - edge @user_type.def -> def + edge @user_type.def -> member_guard + edge member_guard -> member + edge member -> typeof + edge typeof -> user_type_type + edge user_type_type -> @user_type.lexical_scope + + ; Hard-code built-in functions `wrap` and `unwrap` in order to be able to + ; resolve their return types + node wrap + attr (wrap) pop_symbol = "wrap" + node wrap_call + attr (wrap_call) pop_symbol = "()" + node wrap_typeof + attr (wrap_typeof) push_symbol = "@typeof" + + edge member_guard -> wrap + edge wrap -> wrap_call + edge wrap_call -> wrap_typeof + edge wrap_typeof -> @value_type.ref + edge @value_type.ref -> @user_type.lexical_scope + + node unwrap + attr (unwrap) pop_symbol = "unwrap" + node unwrap_call + attr (unwrap_call) pop_symbol = "()" + node unwrap_typeof + attr (unwrap_typeof) push_symbol = "@typeof" + node type_ref + attr (type_ref) push_symbol = (source-text @name) + + edge member_guard -> unwrap + edge unwrap -> unwrap_call + edge unwrap_call -> unwrap_typeof + edge unwrap_typeof -> type_ref + edge type_ref -> @user_type.lexical_scope } @@ -1897,9 +2299,7 @@ inherit .lexical_scope } ;; Identifier expressions -@expr [Expression @name ( - variant: [Identifier] | variant: [SuperKeyword] | variant: [ThisKeyword] -)] { +@expr [Expression @name [Identifier]] { node ref attr (ref) node_reference = @name attr (ref) parents = [@expr.enclosing_def] @@ -1908,6 +2308,14 @@ inherit .lexical_scope edge @expr.output -> ref } +@expr [Expression @keyword ([ThisKeyword] | [SuperKeyword])] { + ; This is almost equivalent to the above rule, except it doesn't generate a reference + node keyword + attr (keyword) push_symbol = (source-text @keyword) + edge keyword -> @expr.lexical_scope + edge @expr.output -> keyword +} + ;; Member access expressions @expr [Expression [MemberAccessExpression @operand operand: [Expression] @@ -1926,10 +2334,7 @@ inherit .lexical_scope edge @expr.output -> @name.ref ; Shortcut path for expressions inside contracts with using X for * directives - node star - attr (star) push_symbol = "@*" - edge member -> star - edge star -> @expr.lexical_scope + edge member -> @expr.star_extension } ;; Special case: member accesses to `super` are tagged with "super" to rank @@ -1941,21 +2346,31 @@ inherit .lexical_scope attr (@name.ref) tag = "super" } +;; Elementary types used as expressions (eg. for type casting, or for built-ins like `string.concat`) +@expr [Expression @type [ElementaryType]] { + edge @expr.output -> @type.ref + edge @type.ref -> @expr.lexical_scope + + ; Elementary types can also be used for casting; instead of defining built-in + ; struct for each available elementary type, we define a special path here + node call + attr (call) pop_symbol = "()" + node typeof + attr (typeof) push_symbol = "@typeof" + edge @expr.output -> call + edge call -> typeof + edge typeof -> @type.ref +} + ;; Index access expressions @expr [Expression [IndexAccessExpression @operand operand: [Expression] ]] { - node index_call - attr (index_call) push_symbol = "()" node index - attr (index) push_symbol = "%index" - node index_member - attr (index_member) push_symbol = "." + attr (index) push_symbol = "[]" - edge @expr.output -> index_call - edge index_call -> index - edge index -> index_member - edge index_member -> @operand.output + edge @expr.output -> index + edge index -> @operand.output } ;; Type expressions @@ -1968,7 +2383,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%typeIntType" + attr (type) push_symbol = "%IntTypeType" edge @type_expr.output -> typeof edge typeof -> type @@ -1980,7 +2395,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%type" + attr (type) push_symbol = "@type" edge @type_expr.output -> typeof edge typeof -> type @@ -2044,7 +2459,7 @@ inherit .lexical_scope attr (@options.refs) push_symbol = "@param_names" node call_options - attr (call_options) push_symbol = "%callOptions" + attr (call_options) push_symbol = "%CallOptions" edge @options.refs -> call_options edge call_options -> @expr.lexical_scope @@ -2058,6 +2473,137 @@ inherit .lexical_scope } +;;; Payable +; These work like `address`, should they should bind to `%address` +@expr [Expression [PayableKeyword]] { + node ref + attr (ref) push_symbol = "%address" + + edge ref -> @expr.lexical_scope + edge @expr.output -> ref +} + + +;;; Tuple expressions + +; Parenthesized expressions are parsed as tuples of a single value +@expr [Expression [TupleExpression [TupleValues . [TupleValue @operand [Expression]] .]]] { + edge @expr.output -> @operand.output +} + +;;; Arithmetic, bitwise & logical operators, etc + +; Bind to the left operand only: assignment expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [Equal] + | [BarEqual] + | [PlusEqual] + | [MinusEqual] + | [CaretEqual] + | [SlashEqual] + | [PercentEqual] + | [AsteriskEqual] + | [AmpersandEqual] + | [LessThanLessThanEqual] + | [GreaterThanGreaterThanEqual] + | [GreaterThanGreaterThanGreaterThanEqual] + ) +]] { + edge @expr.output -> @left_operand.output +} + +; Unary operators postfix +@expr [Expression [_ + @operand operand: [Expression] + ([PlusPlus] | [MinusMinus]) +]] { + edge @expr.output -> @operand.output +} + +; Unary operators prefix +@expr [Expression [_ + ([PlusPlus] | [MinusMinus] | [Tilde] | [Bang] | [Minus] | [Plus]) + @operand operand: [Expression] +]] { + edge @expr.output -> @operand.output +} + +; Bind to both operands: logical and/or, arithmetic, bit-wise expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [BarBar] + | [AmpersandAmpersand] + + | [Plus] + | [Minus] + | [Asterisk] + | [Slash] + | [Percent] + | [AsteriskAsterisk] + + | [Bar] + | [Caret] + | [Ampersand] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] + ) + @right_operand right_operand: [Expression] +]] { + edge @expr.output -> @left_operand.output + edge @expr.output -> @right_operand.output +} + +; Comparison operators bind to bool type +@expr [Expression [_ + ( + [EqualEqual] + | [BangEqual] + | [LessThan] + | [GreaterThan] + | [LessThanEqual] + | [GreaterThanEqual] + ) +]] { + node typeof + attr (typeof) push_symbol = "@typeof" + node bool + attr (bool) push_symbol = "%bool" + edge @expr.output -> typeof + edge typeof -> bool + edge bool -> @expr.lexical_scope +} + +; Ternary conditional expression binds to both branches +@expr [Expression [ConditionalExpression + @true_expression true_expression: [Expression] + @false_expression false_expression: [Expression] +]] { + edge @expr.output -> @true_expression.output + edge @expr.output -> @false_expression.output +} + + +;;; Literal Address Expressions +@expr [Expression [HexNumberExpression @hex_literal [HexLiteral]]] { + scan (source-text @hex_literal) { + "0x[0-9a-fA-F]{40}" { + ; Treat it as a valid address + node typeof + attr (typeof) push_symbol = "@typeof" + node address + attr (address) push_symbol = "%address" + edge @expr.output -> typeof + edge typeof -> address + edge address -> @expr.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul @@ -2167,6 +2713,38 @@ inherit .lexical_scope ;; parameters) are functions (ie. the body of the function doesn't have access ;; to any outside variables) edge @fundef.lexical_scope -> @block.function_defs + ; Exception: but outside constants *are* available, so we provide a guarded + ; access to the parent lexical scope. This guard will be popped to link to + ; available constants. + node yul_function_guard + attr (yul_function_guard) push_symbol = "@in_yul_function" + edge @fundef.lexical_scope -> yul_function_guard + edge yul_function_guard -> @block.lexical_scope +} + +;; Constants need to be available inside Yul functions. This is an exception +;; since no other external identifiers are, so the path is guarded. We create a +;; scope in the source unit, contracts and libraries, and guard it from the +;; lexical scope, so we can link constant definitions here. See the dual path in +;; the rule above. +@constant_container ([SourceUnit] | [ContractDefinition] | [LibraryDefinition]) { + node @constant_container.yul_functions_guarded_scope + attr (@constant_container.yul_functions_guarded_scope) pop_symbol = "@in_yul_function" + edge @constant_container.lexical_scope -> @constant_container.yul_functions_guarded_scope +} + +;; Make top-level constants available inside Yul functions +@source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @constant [ConstantDefinition]]]] { + edge @source_unit.yul_functions_guarded_scope -> @constant.def +} + +;; Ditto for contracts, interfaces and libraries +@contract [_ members: [_ [ContractMember + @constant [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]] + ] +]]] { + edge @contract.yul_functions_guarded_scope -> @constant.def } @fundef [YulFunctionDefinition @@ -2282,11 +2860,60 @@ inherit .lexical_scope node @path.lexical_scope } -@path [YulPath @name [YulIdentifier]] { +@path [YulPath . @name [YulIdentifier]] { node ref attr (ref) node_reference = @name edge ref -> @path.lexical_scope + + if (version-matches "< 0.7.0") { + ; Before Solidity 0.7.0 storage variables' `.offset` and `.slot` were + ; accessed by suffixing the name with `_offset` and `_slot` + scan (source-text @name) { + "^(.*)_(slot|offset|length)$" { + let symbol = $0 + let without_suffix = $1 + let suffix = $2 + + ; We bind the whole symbol to the built-in field for the known cases + node pop_ref + attr (pop_ref) pop_symbol = symbol + node push_suffixless + attr (push_suffixless) push_symbol = suffix + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> pop_ref + edge pop_ref -> push_suffixless + edge push_suffixless -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope + } + } + } +} + +@path [YulPath [Period] @member [YulIdentifier] .] { + ; Yul variable members only apply to external variables and hence are + ; automatically bound to a special %YulExternal built-in + node ref + attr (ref) node_reference = @member + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } @expr [YulExpression @funcall [YulFunctionCallExpression]] { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs index 492dbe0f36..ac045e03e6 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs @@ -26,10 +26,14 @@ pub fn get_contents(version: &Version) -> &'static str { include_str!("./built_ins/0.7.0.sol") } else if *version < Version::new(0, 8, 2) { include_str!("./built_ins/0.8.0.sol") - } else if *version < Version::new(0, 8, 7) { + } else if *version < Version::new(0, 8, 4) { include_str!("./built_ins/0.8.2.sol") - } else if *version < Version::new(0, 8, 11) { + } else if *version < Version::new(0, 8, 7) { + include_str!("./built_ins/0.8.4.sol") + } else if *version < Version::new(0, 8, 8) { include_str!("./built_ins/0.8.7.sol") + } else if *version < Version::new(0, 8, 11) { + include_str!("./built_ins/0.8.8.sol") } else if *version < Version::new(0, 8, 18) { include_str!("./built_ins/0.8.11.sol") } else if *version < Version::new(0, 8, 24) { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol index 282a1cb7e5..a012478422 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol @@ -18,27 +18,25 @@ contract $BuiltIns$ { function sha256(bytes memory) public returns (bytes32); function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; - struct $abiType { + struct $AbiType { } struct $address { uint256 balance; function(bytes memory) returns (bool) call; function(bytes memory) returns (bool, bytes memory) callcode; function(bytes memory) returns (bool) delegatecall; - function(uint256) returns (bool) send; - function(uint256) transfer; + function(uint256 amount) returns (bool) send; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -47,38 +45,52 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol index 453f95ccf2..3ad1ac662a 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol @@ -18,27 +18,25 @@ contract $BuiltIns$ { function sha256(bytes memory) public returns (bytes32); function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; - struct $abiType { + struct $AbiType { } struct $address { uint256 balance; function(bytes memory) returns (bool) call; function(bytes memory) returns (bool, bytes memory) callcode; function(bytes memory) returns (bool) delegatecall; - function(uint256) returns (bool) send; - function(uint256) transfer; + function(uint256 amount) returns (bool) send; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -47,39 +45,53 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol index 49d650431a..e0928e5bb4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol @@ -22,31 +22,29 @@ contract $BuiltIns$ { function sha256(bytes memory) public returns (bytes32); function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; - struct $abiType { - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool) call; function(bytes memory) returns (bool, bytes memory) callcode; function(bytes memory) returns (bool) delegatecall; - function(uint256) returns (bool) send; - function(uint256) transfer; + function(uint256 amount) returns (bool) send; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -55,39 +53,53 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol index c722b7c163..18996d2bb1 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol @@ -20,32 +20,30 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -53,38 +51,52 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol index 49de4c27d9..5dd4bb0750 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol @@ -20,32 +20,30 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -53,40 +51,54 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol index 706f342a98..2fcabbc92e 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,40 +52,54 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol index bbedd35ca0..dc00818947 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,45 +52,59 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; + } + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol index 1bb40d1749..4a57dfa48f 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,47 +52,61 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; + } + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol index 51bc2829fd..a20e478f50 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,49 +52,63 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; + } + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol index ce5c90338a..6c4e69b5d9 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,46 +52,58 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; + struct $Function { + } + struct $ExternalFunction { + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol index 67a4546951..4626514db5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol @@ -15,12 +15,12 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,22 +28,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,46 +50,58 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; + struct $Function { + } + struct $ExternalFunction { + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol index a5a050182f..4fd057bb07 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol @@ -15,13 +15,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -29,22 +29,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -54,47 +52,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol index 8fd9b32c01..edf82c7c7d 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol @@ -15,13 +15,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -29,22 +29,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -55,47 +53,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol index c3be365f51..be45a8cbf4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol @@ -15,12 +15,12 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,22 +28,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,47 +50,59 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol index d461e13b67..5b537bd6f5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol @@ -16,13 +16,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -30,22 +30,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint blobbasefee; uint chainid; @@ -57,47 +55,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol index 51b4ea13a5..b27eff44b4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol @@ -17,13 +17,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -31,22 +31,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint blobbasefee; uint chainid; @@ -58,47 +56,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol new file mode 100644 index 0000000000..4ac08e94dd --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol @@ -0,0 +1,111 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +contract $BuiltIns$ { + function addmod(uint x, uint y, uint k) public returns (uint); + function assert(bool condition) public; + function blockhash(uint blockNumber) public returns (bytes32); + function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); + function gasleft() public returns (uint256); + function keccak256(bytes memory) public returns (bytes32); + function mulmod(uint x, uint y, uint k) public returns (uint); + function require(bool condition) public; + function require(bool condition, string memory message) public; + function revert() public; + function revert(string memory reason) public; + function ripemd160(bytes memory) public returns (bytes20); + function selfdestruct(address payable recipient) public; + function sha256(bytes memory) public returns (bytes32); + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; + } + struct $address { + uint256 balance; + bytes code; + bytes32 codehash; + function(bytes memory) returns (bool, bytes memory) call; + function(bytes memory) returns (bool, bytes memory) delegatecall; + function(uint256 amount) returns (bool) send; + function(bytes memory) returns (bool, bytes memory) staticcall; + function(uint256 amount) transfer; + } + struct $Array { + uint length; + function() returns ($ValueType) push; + function($ValueType element) push; + function() pop; + } + struct $FixedArray { + uint length; + } + struct $BlockType { + uint chainid; + address payable coinbase; + uint difficulty; + uint gaslimit; + uint number; + uint timestamp; + } + struct $bytes { + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $CallOptions { + uint gas; + uint salt; + uint value; + } + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; + } + struct $MessageType { + bytes data; + address sender; + bytes4 sig; + uint value; + } + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; + } + struct $TransactionType { + uint gasprice; + address origin; + } + struct $ContractTypeType { + string name; + bytes creationCode; + bytes runtimeCode; + bytes4 interfaceId; + } + struct $InterfaceTypeType { + string name; + bytes4 interfaceId; + } + struct $IntTypeType { + int min; + int max; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; +} diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol index 0ca8106588..503367efb7 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol @@ -15,12 +15,12 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,22 +28,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -53,47 +51,62 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { } - struct $msgType { + struct $ExternalFunction { + address address; + bytes4 selector; + } + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol new file mode 100644 index 0000000000..ec34656dbc --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol @@ -0,0 +1,116 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +contract $BuiltIns$ { + function addmod(uint x, uint y, uint k) public returns (uint); + function assert(bool condition) public; + function blockhash(uint blockNumber) public returns (bytes32); + function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); + function gasleft() public returns (uint256); + function keccak256(bytes memory) public returns (bytes32); + function mulmod(uint x, uint y, uint k) public returns (uint); + function require(bool condition) public; + function require(bool condition, string memory message) public; + function revert() public; + function revert(string memory reason) public; + function ripemd160(bytes memory) public returns (bytes20); + function selfdestruct(address payable recipient) public; + function sha256(bytes memory) public returns (bytes32); + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; + } + struct $address { + uint256 balance; + bytes code; + bytes32 codehash; + function(bytes memory) returns (bool, bytes memory) call; + function(bytes memory) returns (bool, bytes memory) delegatecall; + function(uint256 amount) returns (bool) send; + function(bytes memory) returns (bool, bytes memory) staticcall; + function(uint256 amount) transfer; + } + struct $Array { + uint length; + function() returns ($ValueType) push; + function($ValueType element) push; + function() pop; + } + struct $FixedArray { + uint length; + } + struct $BlockType { + uint basefee; + uint chainid; + address payable coinbase; + uint difficulty; + uint gaslimit; + uint number; + uint timestamp; + } + struct $bytes { + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $CallOptions { + uint gas; + uint salt; + uint value; + } + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; + } + struct $MessageType { + bytes data; + address sender; + bytes4 sig; + uint value; + } + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; + } + struct $TransactionType { + uint gasprice; + address origin; + } + struct $ContractTypeType { + string name; + bytes creationCode; + bytes runtimeCode; + bytes4 interfaceId; + } + struct $InterfaceTypeType { + string name; + bytes4 interfaceId; + } + struct $IntTypeType { + int min; + int max; + } + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; +} diff --git a/crates/solidity/outputs/cargo/crate/src/lib.rs b/crates/solidity/outputs/cargo/crate/src/lib.rs index 515f523f68..80f15d2e43 100644 --- a/crates/solidity/outputs/cargo/crate/src/lib.rs +++ b/crates/solidity/outputs/cargo/crate/src/lib.rs @@ -3,44 +3,68 @@ mod generated; pub use generated::*; #[cfg(feature = "__experimental_bindings_api")] -pub fn transform_built_ins_node(node: &generated::cst::Node) -> generated::cst::Node { - use std::rc::Rc; - - use generated::cst::{Edge, Node, NonterminalNode, TerminalNode}; - - use crate::cst::TerminalKind; - - match node { - Node::Nonterminal(nonterminal) => { - let NonterminalNode { - kind, - text_len, - children, - } = nonterminal.as_ref(); - let children = children - .iter() - .map(|edge| Edge { - label: edge.label, - node: transform_built_ins_node(&edge.node), - }) - .collect(); - let nonterminal = Rc::new(NonterminalNode { - kind: *kind, - text_len: *text_len, - children, - }); - Node::Nonterminal(nonterminal) - } - Node::Terminal(terminal) => { - let TerminalNode { kind, text } = terminal.as_ref(); - let terminal = match terminal.as_ref().kind { - TerminalKind::Identifier => Rc::new(TerminalNode { +pub mod bindings { + use semver::Version; + + pub use super::generated::bindings::*; + use crate::cst::TextIndex; + use crate::parser::{Parser, ParserInitializationError}; + + pub fn add_built_ins( + bindings: &mut Bindings, + version: &Version, + ) -> Result<(), ParserInitializationError> { + let parser = Parser::create(version.clone())?; + let built_ins_parse_output = parser.parse(Parser::ROOT_KIND, get_built_ins(version)); + assert!( + built_ins_parse_output.is_valid(), + "built-ins parse without errors" + ); + + let built_ins_cursor = transform_built_ins_node(&built_ins_parse_output.tree()) + .cursor_with_offset(TextIndex::ZERO); + + bindings.add_system_file("built_ins.sol", built_ins_cursor); + Ok(()) + } + + pub fn transform_built_ins_node(node: &crate::cst::Node) -> crate::cst::Node { + use std::rc::Rc; + + use crate::cst::{Edge, Node, NonterminalNode, TerminalKind, TerminalNode}; + + match node { + Node::Nonterminal(nonterminal) => { + let NonterminalNode { + kind, + text_len, + children, + } = nonterminal.as_ref(); + let children = children + .iter() + .map(|edge| Edge { + label: edge.label, + node: transform_built_ins_node(&edge.node), + }) + .collect(); + let nonterminal = Rc::new(NonterminalNode { kind: *kind, - text: text.replace('$', "%"), - }), - _ => Rc::clone(terminal), - }; - Node::Terminal(terminal) + text_len: *text_len, + children, + }); + Node::Nonterminal(nonterminal) + } + Node::Terminal(terminal) => { + let TerminalNode { kind, text } = terminal.as_ref(); + let terminal = match terminal.as_ref().kind { + TerminalKind::Identifier => Rc::new(TerminalNode { + kind: *kind, + text: text.replace('$', "%"), + }), + _ => Rc::clone(terminal), + }; + Node::Terminal(terminal) + } } } } diff --git a/crates/solidity/outputs/cargo/tests/src/bindings.rs b/crates/solidity/outputs/cargo/tests/src/bindings.rs index c346ab6afb..aab85d9bad 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings.rs @@ -2,27 +2,20 @@ use std::sync::Arc; use anyhow::Result; use semver::Version; -use slang_solidity::bindings::{self, Bindings}; -use slang_solidity::cst::TextIndex; -use slang_solidity::parser::Parser; -use slang_solidity::transform_built_ins_node; +use slang_solidity::bindings::{self, add_built_ins, Bindings, Definition}; use crate::resolver::TestsPathResolver; pub fn create_bindings(version: &Version) -> Result { - let parser = Parser::create(version.clone())?; let mut bindings = bindings::create_with_resolver(version.clone(), Arc::new(TestsPathResolver {})); + add_built_ins(&mut bindings, version)?; - let built_ins_parse_output = parser.parse(Parser::ROOT_KIND, bindings::get_built_ins(version)); - assert!( - built_ins_parse_output.is_valid(), - "built-ins parse without errors" - ); - - let built_ins_cursor = transform_built_ins_node(&built_ins_parse_output.tree()) - .cursor_with_offset(TextIndex::ZERO); - - bindings.add_system_file("built_ins.sol", built_ins_cursor); Ok(bindings) } + +pub fn lookup_definition_by_name<'a>(bindings: &'a Bindings, name: &str) -> Option> { + bindings + .all_definitions() + .find(|definition| definition.get_cursor().unwrap().node().unparse() == name) +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs index 42d533ed5d..52e242cda8 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs @@ -475,7 +475,7 @@ fn find_and_resolve_reference<'a>( // For the purpose of binding assertions, any failure to resolve to a single // definition will be treated as if it was unresolved - Ok(reference.jump_to_definition().ok()) + Ok(reference.resolve_definition().ok()) } fn lookup_referenced_definition<'a>( diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs index f50520d789..e61b9a8f6b 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs @@ -16,5 +16,6 @@ mod mappings; mod modifiers; mod scoping; mod user_types; +mod using; mod variables; mod yul; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs new file mode 100644 index 0000000000..58420ec02b --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::bindings_assertions::runner::run; + +#[test] +fn inherited() -> Result<()> { + run("using", "inherited") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs index fc009f9a68..1c92493c10 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs @@ -6,7 +6,7 @@ use semver::Version; use slang_solidity::diagnostic; use slang_solidity::parser::Parser; -use crate::bindings::create_bindings; +use crate::bindings::{create_bindings, lookup_definition_by_name}; use crate::bindings_assertions::assertions::{ check_assertions, collect_assertions_into, Assertions, }; @@ -63,8 +63,7 @@ fn check_assertions_with_version(version: &Version, contents: &str) -> Result<() } if let Some(context) = multi_part.context { - let context_definition = bindings - .lookup_definition_by_name(context) + let context_definition = lookup_definition_by_name(&bindings, context) .expect("context definition to be found") .to_handle(); bindings.set_context(&context_definition); diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs index 63fdbbc1cb..80d84f86d5 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs @@ -8,3 +8,8 @@ use crate::bindings_output::runner::run; fn indexing() -> Result<()> { run("arrays", "indexing") } + +#[test] +fn length() -> Result<()> { + run("arrays", "length") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs index 328c698ec2..a28a9b2670 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs @@ -19,6 +19,11 @@ fn arrays() -> Result<()> { run("built_ins", "arrays") } +#[test] +fn bytes() -> Result<()> { + run("built_ins", "bytes") +} + #[test] fn function_type() -> Result<()> { run("built_ins", "function_type") @@ -39,6 +44,16 @@ fn shadowing() -> Result<()> { run("built_ins", "shadowing") } +#[test] +fn this() -> Result<()> { + run("built_ins", "this") +} + +#[test] +fn this_as_address() -> Result<()> { + run("built_ins", "this_as_address") +} + #[test] fn type_expr() -> Result<()> { run("built_ins", "type_expr") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs index c89e406696..a08b136dd9 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn constructor_call_parent() -> Result<()> { + run("contracts", "constructor_call_parent") +} + #[test] fn constructor_invocation() -> Result<()> { run("contracts", "constructor_invocation") @@ -29,11 +34,76 @@ fn inheritance() -> Result<()> { run("contracts", "inheritance") } +#[test] +fn inherited_state_vars() -> Result<()> { + run("contracts", "inherited_state_vars") +} + +#[test] +fn internal_visibility() -> Result<()> { + run("contracts", "internal_visibility") +} + +#[test] +fn legacy_constructors() -> Result<()> { + run("contracts", "legacy_constructors") +} + +#[test] +fn legacy_function_options() -> Result<()> { + run("contracts", "legacy_function_options") +} + +#[test] +fn multi_inheritance() -> Result<()> { + run("contracts", "multi_inheritance") +} + +#[test] +fn public_array_getters() -> Result<()> { + run("contracts", "public_array_getters") +} + +#[test] +fn public_getter_members() -> Result<()> { + run("contracts", "public_getter_members") +} + #[test] fn public_getters() -> Result<()> { run("contracts", "public_getters") } +#[test] +fn public_inherited_getter() -> Result<()> { + run("contracts", "public_inherited_getter") +} + +#[test] +fn public_mapping_getters() -> Result<()> { + run("contracts", "public_mapping_getters") +} + +#[test] +fn public_struct_getter() -> Result<()> { + run("contracts", "public_struct_getter") +} + +#[test] +fn qualified_inherited() -> Result<()> { + run("contracts", "qualified_inherited") +} + +#[test] +fn qualified_parent_call() -> Result<()> { + run("contracts", "qualified_parent_call") +} + +#[test] +fn super_deep() -> Result<()> { + run("contracts", "super_deep") +} + #[test] fn super_linearisation() -> Result<()> { run("contracts", "super_linearisation") @@ -49,6 +119,11 @@ fn this_scope() -> Result<()> { run("contracts", "this_scope") } +#[test] +fn unnamed_function() -> Result<()> { + run("contracts", "unnamed_function") +} + #[test] fn virtual_lookup() -> Result<()> { run("contracts", "virtual_lookup") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs index 7725da2d61..dc6cfdeec4 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs @@ -8,3 +8,8 @@ use crate::bindings_output::runner::run; fn custom_types() -> Result<()> { run("errors", "custom_types") } + +#[test] +fn selector() -> Result<()> { + run("errors", "selector") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs index a23eba4c12..d4e1b6730d 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs @@ -4,11 +4,21 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn binary_operators() -> Result<()> { + run("expressions", "binary_operators") +} + #[test] fn call_options() -> Result<()> { run("expressions", "call_options") } +#[test] +fn elementary_casting() -> Result<()> { + run("expressions", "elementary_casting") +} + #[test] fn emit_named_args() -> Result<()> { run("expressions", "emit_named_args") @@ -29,6 +39,21 @@ fn funcalls_output() -> Result<()> { run("expressions", "funcalls_output") } +#[test] +fn legacy_call_options() -> Result<()> { + run("expressions", "legacy_call_options") +} + +#[test] +fn literal_address() -> Result<()> { + run("expressions", "literal_address") +} + +#[test] +fn literal_integers() -> Result<()> { + run("expressions", "literal_integers") +} + #[test] fn new_output() -> Result<()> { run("expressions", "new_output") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs index 360bf638c1..541e9aa52b 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs @@ -9,6 +9,11 @@ fn inheritance() -> Result<()> { run("interfaces", "inheritance") } +#[test] +fn own_types_access() -> Result<()> { + run("interfaces", "own_types_access") +} + #[test] fn simple() -> Result<()> { run("interfaces", "simple") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs index 6e61f22c32..8a84aabbdd 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs @@ -4,6 +4,26 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn constants() -> Result<()> { + run("libraries", "constants") +} + +#[test] +fn modifiers() -> Result<()> { + run("libraries", "modifiers") +} + +#[test] +fn modifiers_scope() -> Result<()> { + run("libraries", "modifiers_scope") +} + +#[test] +fn propagate_dynamic_scope() -> Result<()> { + run("libraries", "propagate_dynamic_scope") +} + #[test] fn visibility() -> Result<()> { run("libraries", "visibility") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs index ba2bdc21a4..ebe2bbe3a0 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs @@ -15,6 +15,7 @@ mod libraries; mod mappings; mod modifiers; mod structs; +mod user_types; mod using; mod variables; mod yul; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs index 407534d917..9fb31f96dc 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs @@ -9,6 +9,11 @@ fn declaration() -> Result<()> { run("structs", "declaration") } +#[test] +fn function_call() -> Result<()> { + run("structs", "function_call") +} + #[test] fn named_params_construction() -> Result<()> { run("structs", "named_params_construction") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs new file mode 100644 index 0000000000..889783f382 --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::bindings_output::runner::run; + +#[test] +fn wrap_unwrap() -> Result<()> { + run("user_types", "wrap_unwrap") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs index 2019c4c6d1..7b8a7d7bff 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs @@ -4,6 +4,21 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn address() -> Result<()> { + run("using", "address") +} + +#[test] +fn casting() -> Result<()> { + run("using", "casting") +} + +#[test] +fn chained_calls() -> Result<()> { + run("using", "chained_calls") +} + #[test] fn deconstruction() -> Result<()> { run("using", "deconstruction") @@ -39,12 +54,72 @@ fn in_library() -> Result<()> { run("using", "in_library") } +#[test] +fn inherit_extension() -> Result<()> { + run("using", "inherit_extension") +} + +#[test] +fn inherited_types() -> Result<()> { + run("using", "inherited_types") +} + +#[test] +fn mappings() -> Result<()> { + run("using", "mappings") +} + +#[test] +fn on_interfaces_inherited() -> Result<()> { + run("using", "on_interfaces_inherited") +} + +#[test] +fn on_parameters() -> Result<()> { + run("using", "on_parameters") +} + +#[test] +fn on_state_var_initialization() -> Result<()> { + run("using", "on_state_var_initialization") +} + +#[test] +fn on_super_calls() -> Result<()> { + run("using", "on_super_calls") +} + +#[test] +fn qualified_type() -> Result<()> { + run("using", "qualified_type") +} + #[test] fn star() -> Result<()> { run("using", "star") } +#[test] +fn star_in_library() -> Result<()> { + run("using", "star_in_library") +} + +#[test] +fn star_inherited() -> Result<()> { + run("using", "star_inherited") +} + #[test] fn top_level() -> Result<()> { run("using", "top_level") } + +#[test] +fn uint_alias() -> Result<()> { + run("using", "uint_alias") +} + +#[test] +fn user_types() -> Result<()> { + run("using", "user_types") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs index c15dc0378f..b820477fa7 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs @@ -18,3 +18,8 @@ fn params() -> Result<()> { fn state_vars() -> Result<()> { run("variables", "state_vars") } + +#[test] +fn var_declaration() -> Result<()> { + run("variables", "var_declaration") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs index be4e184986..f16d3cda70 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs @@ -9,16 +9,36 @@ fn conditionals() -> Result<()> { run("yul", "conditionals") } +#[test] +fn constant_access_from_functions() -> Result<()> { + run("yul", "constant_access_from_functions") +} + #[test] fn functions() -> Result<()> { run("yul", "functions") } +#[test] +fn identifiers_with_dots() -> Result<()> { + run("yul", "identifiers_with_dots") +} + #[test] fn loops() -> Result<()> { run("yul", "loops") } +#[test] +fn slot_offset_members() -> Result<()> { + run("yul", "slot_offset_members") +} + +#[test] +fn slot_suffix() -> Result<()> { + run("yul", "slot_suffix") +} + #[test] fn variables() -> Result<()> { run("yul", "variables") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs index 7298d965d5..13c7035452 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs @@ -118,7 +118,7 @@ fn build_report_for_part<'a>( start..end }; - let definition = reference.jump_to_definition(); + let definition = reference.resolve_definition(); let message = match definition { Ok(definition) => { if definition.get_file().is_system() { diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs index 4d7217163f..2870d5ae7c 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs @@ -11,7 +11,7 @@ use slang_solidity::parser::{ParseOutput, Parser}; use super::graph::graphviz::render as render_graphviz_graph; use super::graph::mermaid::render as render_mermaid_graph; use super::renderer::render_bindings; -use crate::bindings::create_bindings; +use crate::bindings::{create_bindings, lookup_definition_by_name}; use crate::generated::VERSION_BREAKS; use crate::multi_part_file::{split_multi_file, Part}; @@ -63,8 +63,7 @@ pub fn run(group_name: &str, test_name: &str) -> Result<()> { } if let Some(context) = multi_part.context { - let context_definition = bindings - .lookup_definition_by_name(context) + let context_definition = lookup_definition_by_name(&bindings, context) .expect("context definition to be found") .to_handle(); bindings.set_context(&context_definition); diff --git a/crates/solidity/testing/perf/benches/iai/main.rs b/crates/solidity/testing/perf/benches/iai/main.rs index 1957df012e..0db0eae29d 100644 --- a/crates/solidity/testing/perf/benches/iai/main.rs +++ b/crates/solidity/testing/perf/benches/iai/main.rs @@ -8,7 +8,6 @@ use iai_callgrind::{ LibraryBenchmarkConfig, Tool, ValgrindTool, }; use slang_solidity::bindings::Bindings; -use slang_solidity::parser::ParseOutput; use solidity_testing_perf::dataset::SourceFile; use solidity_testing_perf::tests::definitions::Dependencies; use solidity_testing_perf::tests::parser::ParsedFile; @@ -18,6 +17,12 @@ mod __dependencies_used_in_lib__ { } macro_rules! define_benchmark { + ($name:ident) => { + #[library_benchmark()] + fn $name() { + black_box(solidity_testing_perf::tests::$name::run()); + } + }; ($name:ident, $payload:ty) => { #[library_benchmark(setup = solidity_testing_perf::tests::$name::setup)] fn $name(payload: $payload) { @@ -36,7 +41,7 @@ macro_rules! define_benchmark { define_benchmark!(parser, Vec); define_benchmark!(cursor, Vec); define_benchmark!(query, Vec); -define_benchmark!(init_bindings, ParseOutput); +define_benchmark!(init_bindings); define_benchmark!(definitions, Dependencies); define_benchmark!(references, Bindings); diff --git a/crates/solidity/testing/perf/src/lib.rs b/crates/solidity/testing/perf/src/lib.rs index 7819ab9ea0..2ed1851441 100644 --- a/crates/solidity/testing/perf/src/lib.rs +++ b/crates/solidity/testing/perf/src/lib.rs @@ -19,6 +19,12 @@ mod unit_tests { crate::tests::$name::run(payload); } }; + ($name:ident, empty_payload) => { + #[test] + fn $name() { + crate::tests::$name::run(); + } + }; } /* @@ -27,7 +33,7 @@ mod unit_tests { define_test!(parser); define_test!(cursor); define_test!(query); - define_test!(init_bindings); + define_test!(init_bindings, empty_payload); define_test!(definitions); define_test!(references); } diff --git a/crates/solidity/testing/perf/src/tests/definitions.rs b/crates/solidity/testing/perf/src/tests/definitions.rs index 047651d0f6..7c5e0805f3 100644 --- a/crates/solidity/testing/perf/src/tests/definitions.rs +++ b/crates/solidity/testing/perf/src/tests/definitions.rs @@ -8,7 +8,7 @@ pub struct Dependencies { } pub fn setup() -> Dependencies { - let bindings = super::init_bindings::run(super::init_bindings::setup()); + let bindings = super::init_bindings::run(); let files = super::parser::run(super::parser::setup()); Dependencies { bindings, files } @@ -31,7 +31,7 @@ pub fn run(dependencies: Dependencies) -> Bindings { definition_count += bindings.all_definitions().count(); } - assert_eq!(definition_count, 2832, "Failed to fetch all definitions"); + assert_eq!(definition_count, 2322, "Failed to fetch all definitions"); bindings } diff --git a/crates/solidity/testing/perf/src/tests/init_bindings.rs b/crates/solidity/testing/perf/src/tests/init_bindings.rs index 78119d2533..f14b539fc4 100644 --- a/crates/solidity/testing/perf/src/tests/init_bindings.rs +++ b/crates/solidity/testing/perf/src/tests/init_bindings.rs @@ -1,25 +1,13 @@ use std::sync::Arc; use metaslang_bindings::PathResolver; -use slang_solidity::bindings::{create_with_resolver, get_built_ins, Bindings}; -use slang_solidity::parser::{ParseOutput, Parser}; +use slang_solidity::bindings::{add_built_ins, create_with_resolver, Bindings}; use crate::dataset::SOLC_VERSION; -pub fn setup() -> ParseOutput { - let parser = Parser::create(SOLC_VERSION).unwrap(); - - let built_ins = parser.parse(Parser::ROOT_KIND, get_built_ins(&SOLC_VERSION)); - - assert!(built_ins.is_valid(), "built-ins parse without errors"); - - built_ins -} - -pub fn run(built_ins: ParseOutput) -> Bindings { +pub fn run() -> Bindings { let mut bindings = create_with_resolver(SOLC_VERSION, Arc::new(NoOpResolver {})); - - bindings.add_system_file("built_ins.sol", built_ins.create_tree_cursor()); + add_built_ins(&mut bindings, &SOLC_VERSION).unwrap(); bindings } diff --git a/crates/solidity/testing/perf/src/tests/references.rs b/crates/solidity/testing/perf/src/tests/references.rs index 5e237e2d69..98fb8bbf9d 100644 --- a/crates/solidity/testing/perf/src/tests/references.rs +++ b/crates/solidity/testing/perf/src/tests/references.rs @@ -11,18 +11,22 @@ pub fn run(bindings: Bindings) { let mut resolved_references = 0_usize; for reference in bindings.all_references() { + if reference.get_file().is_system() { + // skip built-ins + continue; + } reference_count += 1; - let resolution = reference.jump_to_definition(); + let resolution = reference.resolve_definition(); if resolution.is_ok() { resolved_references += 1; } } - assert_eq!(reference_count, 1686, "Failed to fetch all references"); + assert_eq!(reference_count, 1652, "Failed to fetch all references"); assert_eq!( - resolved_references, 1353, + resolved_references, 1409, "Failed to resolve all references" ); } diff --git a/crates/solidity/testing/sanctuary/Cargo.toml b/crates/solidity/testing/sanctuary/Cargo.toml index af8812c946..21d65774d1 100644 --- a/crates/solidity/testing/sanctuary/Cargo.toml +++ b/crates/solidity/testing/sanctuary/Cargo.toml @@ -5,6 +5,9 @@ rust-version.workspace = true edition.workspace = true publish = false +[features] +mem_profiler = [] + [dependencies] anyhow = { workspace = true } clap = { workspace = true } diff --git a/crates/solidity/testing/sanctuary/src/counting_allocator.rs b/crates/solidity/testing/sanctuary/src/counting_allocator.rs new file mode 100644 index 0000000000..4f99b8f0b5 --- /dev/null +++ b/crates/solidity/testing/sanctuary/src/counting_allocator.rs @@ -0,0 +1,43 @@ +use std::alloc::{GlobalAlloc, Layout, System}; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::Relaxed; +pub struct CountingAlloc; + +#[cfg_attr(feature = "mem_profiler", global_allocator)] +#[allow(dead_code)] +static COUNTING_ALLOCATOR: CountingAlloc = CountingAlloc; + +static ALLOCATED: AtomicUsize = AtomicUsize::new(0); +static DEALLOCATED: AtomicUsize = AtomicUsize::new(0); + +unsafe impl GlobalAlloc for CountingAlloc { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + let ret = System.alloc(layout); + if !ret.is_null() { + ALLOCATED.fetch_add(layout.size(), Relaxed); + } + ret + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + System.dealloc(ptr, layout); + DEALLOCATED.fetch_add(layout.size(), Relaxed); + } +} + +impl CountingAlloc { + #[allow(dead_code)] + pub fn reset() { + DEALLOCATED.store(0, Relaxed); + ALLOCATED.store(0, Relaxed); + } + + pub fn allocated() -> usize { + ALLOCATED.load(Relaxed) + } + + #[allow(dead_code)] + pub fn deallocated() -> usize { + DEALLOCATED.load(Relaxed) + } +} diff --git a/crates/solidity/testing/sanctuary/src/events.rs b/crates/solidity/testing/sanctuary/src/events.rs index d74bb8445c..b75fc4f166 100644 --- a/crates/solidity/testing/sanctuary/src/events.rs +++ b/crates/solidity/testing/sanctuary/src/events.rs @@ -1,4 +1,7 @@ -use std::cmp; +use std::fs::File; +use std::io::Write; +use std::sync::Mutex; +use std::{cmp, io}; use console::Color; use indicatif::ProgressBar; @@ -16,6 +19,44 @@ pub enum TestOutcome { NotFound, } +#[derive(Clone)] +pub(crate) struct Metric { + pub file: String, + pub bytes: usize, + pub locs: usize, + pub number_of_contracts: usize, + pub total_inheritance_count: usize, + pub inheritance_tree_height: usize, + pub cst_height: usize, + pub number_of_using_fors: usize, + pub number_of_nodes: usize, + pub without_trivia: usize, + pub number_of_refs: usize, + pub parsing_time: u128, + pub bindings_time: u128, + pub memory_usage: usize, +} + +impl Metric { + pub fn new() -> Self { + Metric { + file: String::new(), + bytes: 0, + locs: 0, + number_of_contracts: 0, + total_inheritance_count: 0, + inheritance_tree_height: 0, + cst_height: 0, + number_of_using_fors: 0, + number_of_nodes: 0, + without_trivia: 0, + number_of_refs: 0, + parsing_time: 0, + bindings_time: 0, + memory_usage: 0, + } + } +} pub struct Events { reporter: Reporter, @@ -28,6 +69,8 @@ pub struct Events { failed: ProgressBar, incompatible: ProgressBar, not_found: ProgressBar, + + metrics: Mutex>, } impl Events { @@ -52,6 +95,8 @@ impl Events { reporter.add_blank(); + let metrics = Mutex::new(vec![]); + Self { reporter, @@ -64,6 +109,8 @@ impl Events { failed, incompatible, not_found, + + metrics, } } @@ -133,4 +180,45 @@ impl Events { pub fn trace(&self, message: impl AsRef) { self.reporter.println(message); } + + pub fn register_metric(&self, metric: Metric) { + let mut metrics = self.metrics.lock().unwrap(); + metrics.push(metric); + } + + pub fn print_metrics(&self, metrics_file: Option) -> std::io::Result<()> { + let writer: &mut dyn Write = if let Some(file_name) = metrics_file { + &mut File::create(file_name.clone())? + } else { + &mut io::stdout() + }; + writeln!( + writer, + "file,bytes,locs,number_of_contracts,total_inheritance_count,inheritance_tree_height,cst_height,using_fors,number_of_nodes,without_trivia,number_of_refs,parsing_time,bindings_time,memory_usage" + )?; + + let metrics_guard = self.metrics.lock().unwrap(); + let metrics = metrics_guard.as_slice(); + for metric in metrics { + writeln!( + writer, + "{},{},{},{},{},{},{},{},{},{},{},{},{},{}", + metric.file, + metric.bytes, + metric.locs, + metric.number_of_contracts, + metric.total_inheritance_count, + metric.inheritance_tree_height, + metric.cst_height, + metric.number_of_using_fors, + metric.number_of_nodes, + metric.without_trivia, + metric.number_of_refs, + metric.parsing_time, + metric.bindings_time, + metric.memory_usage + )?; + } + Ok(()) + } } diff --git a/crates/solidity/testing/sanctuary/src/main.rs b/crates/solidity/testing/sanctuary/src/main.rs index 80f39766d6..64e49de571 100644 --- a/crates/solidity/testing/sanctuary/src/main.rs +++ b/crates/solidity/testing/sanctuary/src/main.rs @@ -1,4 +1,5 @@ mod chains; +mod counting_allocator; mod datasets; mod events; mod reporting; @@ -31,6 +32,14 @@ struct Cli { /// Enables checking bindings for each contract, failing if any symbol cannot be resolved. #[arg(long, default_value_t = false)] check_bindings: bool, + + /// Enables logging of times + #[arg(long, default_value_t = false)] + collect_metrics: bool, + + /// Metrics are stored in file instead of stdout + #[arg(long, requires = "collect_metrics")] + metrics_file: Option, } #[derive(Debug, Parser)] @@ -50,6 +59,8 @@ fn main() -> Result<()> { sharding_options, trace, check_bindings, + collect_metrics, + metrics_file, } = Cli::parse(); Terminal::step(format!( @@ -85,14 +96,18 @@ fn main() -> Result<()> { events.start_directory(files.len()); if trace { - run_with_traces(files, &events, check_bindings)?; + run_with_traces(files, &events, check_bindings, collect_metrics)?; } else { - run_in_parallel(files, &events, check_bindings)?; + run_in_parallel(files, &events, check_bindings, collect_metrics)?; } events.finish_directory(); } + if collect_metrics { + events.print_metrics(metrics_file)?; + } + let failure_count = events.failure_count(); if failure_count > 0 { println!(); @@ -105,18 +120,22 @@ fn main() -> Result<()> { #[allow(clippy::exit)] std::process::exit(1); } - Ok(()) } -fn run_with_traces(files: &Vec, events: &Events, check_bindings: bool) -> Result<()> { +fn run_with_traces( + files: &Vec, + events: &Events, + check_bindings: bool, + collect_metrics: bool, +) -> Result<()> { for file in files { let compiler = &file.compiler; let path = file.path.strip_repo_root()?; events.trace(format!("[{compiler}] Starting: {path:?}")); - run_test(file, events, check_bindings)?; + run_test(file, events, check_bindings, collect_metrics)?; events.trace(format!("[{compiler}] Finished: {path:?}")); } @@ -124,11 +143,16 @@ fn run_with_traces(files: &Vec, events: &Events, check_bindings: boo Ok(()) } -fn run_in_parallel(files: &Vec, events: &Events, check_bindings: bool) -> Result<()> { +fn run_in_parallel( + files: &Vec, + events: &Events, + check_bindings: bool, + collect_metrics: bool, +) -> Result<()> { files .par_iter() .panic_fuse(/* Halt as soon as possible if a child panics */) - .try_for_each(|file| run_test(file, events, check_bindings)) + .try_for_each(|file| run_test(file, events, check_bindings, collect_metrics)) } #[test] diff --git a/crates/solidity/testing/sanctuary/src/tests.rs b/crates/solidity/testing/sanctuary/src/tests.rs index 6571da0b11..683c79a5a8 100644 --- a/crates/solidity/testing/sanctuary/src/tests.rs +++ b/crates/solidity/testing/sanctuary/src/tests.rs @@ -1,20 +1,22 @@ use std::cmp::min; +use std::collections::HashMap; use std::path::Path; use std::sync::Arc; +use std::time::Instant; use anyhow::Result; use infra_utils::paths::PathExtensions; use itertools::Itertools; use metaslang_bindings::PathResolver; use semver::Version; -use slang_solidity::bindings::Bindings; -use slang_solidity::cst::{Cursor, NonterminalKind, TextIndex, TextRange}; +use slang_solidity::bindings::{self, transform_built_ins_node, Bindings}; +use slang_solidity::cst::{Cursor, Edge, NonterminalKind, Query, TextIndex, TextRange}; use slang_solidity::diagnostic::{Diagnostic, Severity}; use slang_solidity::parser::{ParseOutput, Parser}; -use slang_solidity::{bindings, transform_built_ins_node}; +use crate::counting_allocator::CountingAlloc; use crate::datasets::{DataSet, SourceFile}; -use crate::events::{Events, TestOutcome}; +use crate::events::{Events, Metric, TestOutcome}; use crate::ShardingOptions; pub struct TestSelection<'d> { @@ -64,7 +66,114 @@ pub(crate) fn select_tests<'d>( } } -pub fn run_test(file: &SourceFile, events: &Events, check_bindings: bool) -> Result<()> { +fn height(edges: &[Edge]) -> usize { + let mut max = 0; + for edge in edges { + max = max.max(height(edge.children()) + 1); + } + max +} + +fn nodes(edges: &[Edge]) -> (usize, usize) { + let mut nodes_count = 1; + let mut without_trivia = 1; + + for edge in edges { + let (partial_nodes, partial_without_trivia) = nodes(edge.children()); + nodes_count += partial_nodes; + if !edge.is_trivia() { + without_trivia += partial_without_trivia; + } + } + (nodes_count, without_trivia) +} + +fn locs(source: &str) -> usize { + source.split('\n').count() +} + +#[derive(Debug)] +struct HeritageGraphNode { + parents: Vec, + using_fors: usize, +} +struct MetricsGraph { + graph: HashMap, +} + +impl HeritageGraphNode { + pub fn new() -> Self { + HeritageGraphNode { + parents: vec![], + using_fors: 0, + } + } + + pub fn push_parent(&mut self, parent: String) { + self.parents.push(parent); + } + + pub fn parents(&self) -> &Vec { + &self.parents + } +} +impl MetricsGraph { + pub(crate) fn new() -> MetricsGraph { + MetricsGraph { + graph: HashMap::new(), + } + } + + pub(crate) fn add_contract(&mut self, name: String) { + self.graph.entry(name).or_insert(HeritageGraphNode::new()); + } + + pub(crate) fn add_link(&mut self, name: String, parent: String) { + self.add_contract(parent.clone()); + self.graph.entry(name).and_modify(|v| v.push_parent(parent)); + } + + pub(crate) fn add_using_for(&mut self, name: String) { + self.graph.entry(name).and_modify(|v| v.using_fors += 1); + } + + pub(crate) fn number_of_contracts(&self) -> usize { + self.graph.keys().count() + } + + pub(crate) fn inheritance_count(&self) -> usize { + self.graph.values().map(|v| v.parents().len()).sum() + } + + pub(crate) fn number_of_using_fors(&self) -> usize { + self.graph.values().map(|v| v.using_fors).sum() + } + + fn node_height(&self, name: &String) -> usize { + let node = self.graph.get(name).unwrap(); + let mut height = 0; + for parent in node.parents() { + let parent_height = self.node_height(parent); + height = height.max(parent_height + 1); + } + height + } + + pub(crate) fn inheritance_height(&self) -> usize { + self.graph + .keys() + .map(|contract| self.node_height(contract)) + .max() + .unwrap_or(0) + } +} + +pub fn run_test( + file: &SourceFile, + events: &Events, + check_bindings: bool, + collect_metrics: bool, +) -> Result<()> { if !file.path.exists() { // Index can be out of date: events.test(TestOutcome::NotFound); @@ -103,9 +212,18 @@ pub fn run_test(file: &SourceFile, events: &Events, check_bindings: bool) -> Res // https://github.com/tintinweb/smart-contract-sanctuary/issues/32 .replace("'", "\""); + let mut metric = Metric::new(); + + let parsing_time = Instant::now(); let parser = Parser::create(version.clone())?; let output = parser.parse(NonterminalKind::SourceUnit, &source); - let source_id = file.path.strip_repo_root()?.unwrap_str(); + metric.parsing_time = parsing_time.elapsed().as_micros(); + + let source_id = file + .path + .strip_repo_root() + .unwrap_or(Path::new("none")) + .unwrap_str(); let with_color = true; @@ -120,8 +238,31 @@ pub fn run_test(file: &SourceFile, events: &Events, check_bindings: bool) -> Res return Ok(()); } + if collect_metrics { + let file_name = file.path.to_str().unwrap_or("unknown"); + metric.file = file_name.to_string(); + metric.bytes = source.len(); + metric.locs = locs(&source); + + let graph = build_graph(&output); + + metric.number_of_contracts = graph.number_of_contracts(); + metric.total_inheritance_count = graph.inheritance_count(); + metric.inheritance_tree_height = graph.inheritance_height(); + metric.number_of_using_fors = graph.number_of_using_fors(); + + metric.cst_height = height(output.tree().children()); + let (nodes, without_trivia) = nodes(output.tree().children()); + metric.number_of_nodes = nodes; + metric.without_trivia = without_trivia; + } + if check_bindings { - let unresolved_references = run_bindings_check(&version, source_id, &output)?; + CountingAlloc::reset(); + let bindings_time = Instant::now(); + let (ref_count, unresolved_references) = run_bindings_check(&version, source_id, &output)?; + metric.bindings_time = bindings_time.elapsed().as_micros(); + metric.memory_usage = CountingAlloc::allocated(); if !unresolved_references.is_empty() { for unresolved in &unresolved_references { let report = @@ -132,12 +273,50 @@ pub fn run_test(file: &SourceFile, events: &Events, check_bindings: bool) -> Res events.test(TestOutcome::Failed); return Ok(()); } + metric.number_of_refs = ref_count; + } + + if collect_metrics { + events.register_metric(metric); } events.test(TestOutcome::Passed); Ok(()) } +fn build_graph(output: &ParseOutput) -> MetricsGraph { + let mut graph = MetricsGraph::new(); + let query1 = Query::parse("[ContractDefinition @contract_name name:[Identifier]]").unwrap(); + let query2 = Query::parse("[InterfaceDefinition @contract_name name:[Identifier]]").unwrap(); + let query3 = Query::parse("[ContractDefinition @contract_name name:[Identifier] inheritance:[InheritanceSpecifier types:[InheritanceTypes @types (item:[InheritanceType])+]]]").unwrap(); + let query4 = Query::parse("[InterfaceDefinition @contract_name name:[Identifier] inheritance:[InheritanceSpecifier types:[InheritanceTypes @types (item:[InheritanceType])+]]]").unwrap(); + let query5 = Query::parse("[ContractDefinition @contract_name name:[Identifier] [ContractMembers item:[ContractMember @using (variant:[UsingDirective])+]]]").unwrap(); + let query_match = output + .create_tree_cursor() + .query(vec![query1, query2, query3, query4, query5]); + + for q in query_match { + let (_, mut it) = q.capture("contract_name").unwrap(); + let contract_name = it.next().unwrap().node().unparse(); + graph.add_contract(contract_name.clone()); + if let Some((_, mut it)) = q.capture("types") { + let is_type = it.next().unwrap().node(); + let mut is_type = is_type.children().iter().filter(|p| !p.is_trivia()); + let next = is_type.next().unwrap(); + let remaining = next + .children() + .iter() + .filter(|n| !n.is_trivia()) + .collect_vec(); + assert_eq!(remaining.len(), 1); + graph.add_link(contract_name, remaining.first().unwrap().unparse()); + } else if q.capture("using").is_some() { + graph.add_using_for(contract_name); + } + } + graph +} + fn extract_compiler_version(compiler: &str) -> Option { if compiler.starts_with("vyper:") { // Ignore contracts not compiled by "solc": @@ -184,15 +363,17 @@ fn run_bindings_check( version: &Version, source_id: &str, output: &ParseOutput, -) -> Result> { +) -> Result<(usize, Vec)> { let mut unresolved = Vec::new(); let bindings = create_bindings(version, source_id, output)?; + let mut ref_count: usize = 0; for reference in bindings.all_references() { if reference.get_file().is_system() { // skip built-ins continue; } + ref_count += 1; // We're not interested in the exact definition a reference resolves // to, so we lookup all of them and fail if we find none. if reference.definitions().is_empty() { @@ -201,7 +382,7 @@ fn run_bindings_check( } } - Ok(unresolved) + Ok((ref_count, unresolved)) } fn create_bindings(version: &Version, source_id: &str, output: &ParseOutput) -> Result { diff --git a/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol b/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol new file mode 100644 index 0000000000..6bcd410801 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol @@ -0,0 +1,16 @@ +library Lib { + function squared(int x) public returns (int) { return x * x; } + // ^def:1 +} + +contract Base { + using Lib for int; +} + +contract Test is Base { + function test(int x) public returns (int) { + return x.squared(); + // ^ref:1 (< 0.7.0) + // ^ref:! (>= 0.7.0) + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt new file mode 100644 index 0000000000..2e3248e35d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint x) internal {} + │ ─┬─ ┬ + │ ╰────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test(uint256[] memory data) public { + │ ──┬─ ──┬─ + │ ╰───────────────────────── def: 5 + │ │ + │ ╰─── def: 6 + 7 │ data.length.nop(); + │ ──┬─ ───┬── ─┬─ + │ ╰────────────── ref: 6 + │ │ │ + │ ╰──────── ref: built-in + │ │ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol b/crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol new file mode 100644 index 0000000000..10925efe89 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol @@ -0,0 +1,9 @@ +library Lib { + function nop(uint x) internal {} +} +contract Test { + using Lib for uint; + function test(uint256[] memory data) public { + data.length.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt index 1f202ff321..9ff8c9567f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt @@ -59,4 +59,9 @@ References and definitions: │ ╰─────────── ref: 3 │ │ │ ╰─── ref: built-in + 9 │ uint256 v10 = address(this).balance; + │ ─┬─ ───┬─── + │ ╰─────────────────────────── def: 12 + │ │ + │ ╰───── ref: built-in ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt index c51e30477e..d5f0a1db53 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt @@ -59,4 +59,9 @@ References and definitions: │ ╰─────────── ref: 3 │ │ │ ╰─── ref: built-in + 9 │ uint256 v10 = address(this).balance; + │ ─┬─ ───┬─── + │ ╰─────────────────────────── def: 12 + │ │ + │ ╰───── ref: built-in ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol index 7c97254b4d..769a5d8cc4 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol @@ -6,5 +6,6 @@ contract Test { (bool v7, bytes memory v8) = recipient.staticcall(x1); recipient.transfer(1); bool v9 = recipient.send(1); + uint256 v10 = address(this).balance; } } diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt index 4f2a748f2f..7d6647ad22 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt @@ -1,76 +1,41 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ contract Test { - │ ──┬─ - │ ╰─── def: 1 - 2 │ uint[] a; - │ ┬ - │ ╰── def: 2 - 3 │ function testArray() public { - │ ────┬──── - │ ╰────── def: 3 - 4 │ uint[] storage b = new uint[](5); - │ ┬ - │ ╰── def: 4 - 5 │ assert(b.length == 5); - │ ───┬── ┬ ───┬── - │ ╰───────────── ref: built-in - │ │ │ - │ ╰───────── ref: 4 - │ │ - │ ╰──── ref: built-in - │ - 7 │ a.push(); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── ref: built-in - 8 │ a.push(1); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── ref: built-in - 9 │ a.pop(); - │ ┬ ─┬─ - │ ╰────── ref: 2 - │ │ - │ ╰─── ref: built-in - │ - 12 │ function testConcat() public { - │ ─────┬──── - │ ╰────── def: 5 - 13 │ bytes memory b1; - │ ─┬ - │ ╰── def: 6 - 14 │ bytes memory b2; - │ ─┬ - │ ╰── def: 7 - 15 │ bytes memory b3 = b1.concat(b2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 8 - │ │ │ │ - │ ╰──────────── ref: 6 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 7 - │ - 17 │ string memory s1; - │ ─┬ - │ ╰── def: 9 - 18 │ string memory s2; - │ ─┬ - │ ╰── def: 10 - 19 │ string memory s3 = s1.concat(s2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 11 - │ │ │ │ - │ ╰──────────── ref: 9 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 10 -────╯ + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ uint[] a; + │ ┬ + │ ╰── def: 2 + 3 │ function testArray() public { + │ ────┬──── + │ ╰────── def: 3 + 4 │ uint[] storage b = new uint[](5); + │ ┬ + │ ╰── def: 4 + 5 │ assert(b.length == 5); + │ ───┬── ┬ ───┬── + │ ╰───────────── ref: built-in + │ │ │ + │ ╰───────── ref: 4 + │ │ + │ ╰──── ref: built-in + │ + 7 │ a.push(); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── ref: built-in + 8 │ a.push(1); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── ref: built-in + 9 │ a.pop(); + │ ┬ ─┬─ + │ ╰────── ref: 2 + │ │ + │ ╰─── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt index 1253ccf796..c8f4c1481f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt @@ -1,76 +1,41 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ contract Test { - │ ──┬─ - │ ╰─── def: 1 - 2 │ uint[] a; - │ ┬ - │ ╰── def: 2 - 3 │ function testArray() public { - │ ────┬──── - │ ╰────── def: 3 - 4 │ uint[] storage b = new uint[](5); - │ ┬ - │ ╰── def: 4 - 5 │ assert(b.length == 5); - │ ───┬── ┬ ───┬── - │ ╰───────────── ref: built-in - │ │ │ - │ ╰───────── ref: 4 - │ │ - │ ╰──── ref: built-in - │ - 7 │ a.push(); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── refs: built-in, built-in - 8 │ a.push(1); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── refs: built-in, built-in - 9 │ a.pop(); - │ ┬ ─┬─ - │ ╰────── ref: 2 - │ │ - │ ╰─── ref: built-in - │ - 12 │ function testConcat() public { - │ ─────┬──── - │ ╰────── def: 5 - 13 │ bytes memory b1; - │ ─┬ - │ ╰── def: 6 - 14 │ bytes memory b2; - │ ─┬ - │ ╰── def: 7 - 15 │ bytes memory b3 = b1.concat(b2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 8 - │ │ │ │ - │ ╰──────────── ref: 6 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 7 - │ - 17 │ string memory s1; - │ ─┬ - │ ╰── def: 9 - 18 │ string memory s2; - │ ─┬ - │ ╰── def: 10 - 19 │ string memory s3 = s1.concat(s2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 11 - │ │ │ │ - │ ╰──────────── ref: 9 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 10 -────╯ + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ uint[] a; + │ ┬ + │ ╰── def: 2 + 3 │ function testArray() public { + │ ────┬──── + │ ╰────── def: 3 + 4 │ uint[] storage b = new uint[](5); + │ ┬ + │ ╰── def: 4 + 5 │ assert(b.length == 5); + │ ───┬── ┬ ───┬── + │ ╰───────────── ref: built-in + │ │ │ + │ ╰───────── ref: 4 + │ │ + │ ╰──── ref: built-in + │ + 7 │ a.push(); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── refs: built-in, built-in + 8 │ a.push(1); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── refs: built-in, built-in + 9 │ a.pop(); + │ ┬ ─┬─ + │ ╰────── ref: 2 + │ │ + │ ╰─── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol index 619d86dbb8..1646154c42 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol @@ -8,14 +8,4 @@ contract Test { a.push(1); a.pop(); } - - function testConcat() public { - bytes memory b1; - bytes memory b2; - bytes memory b3 = b1.concat(b2); - - string memory s1; - string memory s2; - string memory s3 = s1.concat(s2); - } } diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt new file mode 100644 index 0000000000..01319e37d0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt @@ -0,0 +1,51 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function testBytes() public { + │ ────┬──── + │ ╰────── def: 2 + 3 │ bytes memory b1; + │ ─┬ + │ ╰── def: 3 + 4 │ bytes memory b2; + │ ─┬ + │ ╰── def: 4 + 5 │ bytes memory b3 = bytes.concat(b1, b2); + │ ─┬ ───┬── ─┬ ─┬ + │ ╰──────────────────────── def: 5 + │ │ │ │ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰────── ref: 3 + │ │ + │ ╰── ref: 4 + 6 │ b1.length; + │ ─┬ ───┬── + │ ╰───────── ref: 3 + │ │ + │ ╰──── ref: built-in + │ + 9 │ function testString() public { + │ ─────┬──── + │ ╰────── def: 6 + 10 │ string memory s1; + │ ─┬ + │ ╰── def: 7 + 11 │ string memory s2; + │ ─┬ + │ ╰── def: 8 + 12 │ string memory s3 = string.concat(s1, s2); + │ ─┬ ───┬── ─┬ ─┬ + │ ╰───────────────────────── def: 9 + │ │ │ │ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰────── ref: 7 + │ │ + │ ╰── ref: 8 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol new file mode 100644 index 0000000000..d6da9002a3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol @@ -0,0 +1,14 @@ +contract Test { + function testBytes() public { + bytes memory b1; + bytes memory b2; + bytes memory b3 = bytes.concat(b1, b2); + b1.length; + } + + function testString() public { + string memory s1; + string memory s2; + string memory s3 = string.concat(s1, s2); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt index b90ecb72e9..8164d93dfd 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt @@ -10,19 +10,15 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ bytes4 v1 = this.test.selector; - │ ─┬ ──┬─ ──┬─ ────┬─── + │ ─┬ ──┬─ ────┬─── │ ╰─────────────────────── def: 3 - │ │ │ │ - │ ╰───────────────── ref: 1 │ │ │ │ ╰──────────── ref: 2 │ │ │ ╰───── unresolved 4 │ address v2 = this.test.address; - │ ─┬ ──┬─ ──┬─ ───┬─── + │ ─┬ ──┬─ ───┬─── │ ╰────────────────────── def: 4 - │ │ │ │ - │ ╰──────────────── ref: 1 │ │ │ │ ╰─────────── ref: 2 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt index 0d92e4506b..ec1fe46b15 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt @@ -10,19 +10,15 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ bytes4 v1 = this.test.selector; - │ ─┬ ──┬─ ──┬─ ────┬─── + │ ─┬ ──┬─ ────┬─── │ ╰─────────────────────── def: 3 - │ │ │ │ - │ ╰───────────────── ref: 1 │ │ │ │ ╰──────────── ref: 2 │ │ │ ╰───── ref: built-in 4 │ address v2 = this.test.address; - │ ─┬ ──┬─ ──┬─ ───┬─── + │ ─┬ ──┬─ ───┬─── │ ╰────────────────────── def: 4 - │ │ │ │ - │ ╰──────────────── ref: 1 │ │ │ │ ╰─────────── ref: 2 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt index 4e5d5be407..1b10c554b8 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt @@ -10,19 +10,15 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ bytes4 v1 = this.test.selector; - │ ─┬ ──┬─ ──┬─ ────┬─── + │ ─┬ ──┬─ ────┬─── │ ╰─────────────────────── def: 3 - │ │ │ │ - │ ╰───────────────── ref: 1 │ │ │ │ ╰──────────── ref: 2 │ │ │ ╰───── ref: built-in 4 │ address v2 = this.test.address; - │ ─┬ ──┬─ ──┬─ ───┬─── + │ ─┬ ──┬─ ───┬─── │ ╰────────────────────── def: 4 - │ │ │ │ - │ ╰──────────────── ref: 1 │ │ │ │ ╰─────────── ref: 2 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt index 012ad3172e..1968dc3495 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── unresolved 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── unresolved - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt index 4ff6d6c42c..54e971d730 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── unresolved 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── unresolved - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt index 1282f7841d..fc3aaa04ce 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt index f901dcb995..3a79b59191 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt index 690910c0a7..43b3aa3a88 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── ref: built-in - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt index cda93f689d..4134c68526 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── ref: built-in - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt index 5b04719552..1d9544857a 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── ref: built-in - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt index 835dcf5dcc..3c898c3511 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt new file mode 100644 index 0000000000..c86bc2430b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt @@ -0,0 +1,15 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function test() internal returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol new file mode 100644 index 0000000000..ac4a90eeb0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol @@ -0,0 +1,5 @@ +library Lib { + function test() internal returns (uint) { + return address(this).balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e5572f9274 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt @@ -0,0 +1,16 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ this.balance; + │ ───┬─── + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..8d1ee729e4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt @@ -0,0 +1,16 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ this.balance; + │ ───┬─── + │ ╰───── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol new file mode 100644 index 0000000000..06d15f15bd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol @@ -0,0 +1,6 @@ +contract Test { + function test() public { + // This was valid before 0.5.0 + this.balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..fa35b69352 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt @@ -0,0 +1,27 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or InternalKeyword or PrivateKeyword or PublicKeyword. + ╭─[input.sol:4:16] + │ + 4 │ ╭─▶ constructor() Base() { + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base {} + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ constructor() Base() { + │ ─────┬───── + │ ╰─────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt new file mode 100644 index 0000000000..84795b192d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt @@ -0,0 +1,18 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base {} + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ constructor() Base() { + │ ──┬─ + │ ╰─── ref: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol new file mode 100644 index 0000000000..98fa43a3ea --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol @@ -0,0 +1,6 @@ +contract Base {} + +contract Test is Base { + constructor() Base() { + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt new file mode 100644 index 0000000000..64c83c5658 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt @@ -0,0 +1,36 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ int in_base; + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Middle is Base { + │ ───┬── ──┬─ + │ ╰──────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ int in_middle; + │ ────┬──── + │ ╰────── def: 4 + │ + 7 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 5 + │ │ + │ ╰──── ref: 3 + 8 │ function test() public { + │ ──┬─ + │ ╰─── def: 6 + 9 │ in_base; + │ ───┬─── + │ ╰───── ref: 2 + 10 │ in_middle; + │ ────┬──── + │ ╰────── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol new file mode 100644 index 0000000000..593a55a1c5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol @@ -0,0 +1,12 @@ +contract Base { + int in_base; +} +contract Middle is Base { + int in_middle; +} +contract Test is Middle { + function test() public { + in_base; + in_middle; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..507119f26e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ abstract contract Ownable { + ┆ ┆ + 13 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt new file mode 100644 index 0000000000..acd63c8cb7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt @@ -0,0 +1,41 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ abstract contract Ownable { + │ ───┬─── + │ ╰───── def: 1 + 2 │ address internal owner; + │ ──┬── + │ ╰──── def: 2 + 3 │ address default_visibility; + │ ─────────┬──────── + │ ╰────────── def: 3 + 4 │ function _internal_only() internal {} + │ ───────┬────── + │ ╰──────── def: 4 + │ + 6 │ contract Test is Ownable { + │ ──┬─ ───┬─── + │ ╰────────────── def: 5 + │ │ + │ ╰───── ref: 1 + 7 │ function test() public { + │ ──┬─ + │ ╰─── def: 6 + 8 │ owner; + │ ──┬── + │ ╰──── ref: 2 + 9 │ default_visibility; + │ ─────────┬──────── + │ ╰────────── ref: 3 + 10 │ _internal_only(); + │ ───────┬────── + │ ╰──────── ref: 4 + 11 │ Ownable._internal_only(); + │ ───┬─── ───────┬────── + │ ╰──────────────────── ref: 1 + │ │ + │ ╰──────── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol new file mode 100644 index 0000000000..48bd9c2fda --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol @@ -0,0 +1,13 @@ +abstract contract Ownable { + address internal owner; + address default_visibility; + function _internal_only() internal {} +} +contract Test is Ownable { + function test() public { + owner; + default_visibility; + _internal_only(); + Ownable._internal_only(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt new file mode 100644 index 0000000000..33d044032f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt @@ -0,0 +1,20 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ function Test() public Base() {} + │ ──┬─ ──┬─ + │ ╰───────────────── def: 3 + │ │ + │ ╰─── ref: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..24988498b8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt @@ -0,0 +1,20 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ function Test() public Base() {} + │ ──┬─ ──┬─ + │ ╰───────────────── def: 3 + │ │ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol new file mode 100644 index 0000000000..eba69e5203 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol @@ -0,0 +1,5 @@ +contract Base { +} +contract Test is Base { + function Test() public Base() {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e7f54749fd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract RefundVault { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ function deposit() public payable {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 3 + 5 │ RefundVault public vault; + │ ─────┬───── ──┬── + │ ╰──────────────────── ref: 1 + │ │ + │ ╰──── def: 4 + 6 │ function test() internal { + │ ──┬─ + │ ╰─── def: 5 + 7 │ vault.deposit.value(msg.value)(); + │ ──┬── ───┬─── ──┬── ─┬─ ──┬── + │ ╰──────────────────────────── ref: 4 + │ │ │ │ │ + │ ╰───────────────────── ref: 2 + │ │ │ │ + │ ╰────────────── ref: built-in + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..065ccbdfad --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract RefundVault { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ function deposit() public payable {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 3 + 5 │ RefundVault public vault; + │ ─────┬───── ──┬── + │ ╰──────────────────── ref: 1 + │ │ + │ ╰──── def: 4 + 6 │ function test() internal { + │ ──┬─ + │ ╰─── def: 5 + 7 │ vault.deposit.value(msg.value)(); + │ ──┬── ───┬─── ──┬── ─┬─ ──┬── + │ ╰──────────────────────────── ref: 4 + │ │ │ │ │ + │ ╰───────────────────── ref: 2 + │ │ │ │ + │ ╰────────────── unresolved + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol new file mode 100644 index 0000000000..d5fd938d05 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol @@ -0,0 +1,9 @@ +contract RefundVault { + function deposit() public payable {} +} +contract Test { + RefundVault public vault; + function test() internal { + vault.deposit.value(msg.value)(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt new file mode 100644 index 0000000000..280b52987b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base1 { + │ ──┬── + │ ╰──── def: 1 + 2 │ function base1() returns (int) { return 1; } + │ ──┬── + │ ╰──── def: 2 + │ + 5 │ contract Base2 { + │ ──┬── + │ ╰──── def: 3 + 6 │ function base2() returns (int) { return 2; } + │ ──┬── + │ ╰──── def: 4 + │ + 9 │ contract Derived is + │ ───┬─── + │ ╰───── def: 5 + 10 │ Base1, + │ ──┬── + │ ╰──── ref: 1 + 11 │ Base2 + │ ──┬── + │ ╰──── ref: 3 + │ + 13 │ function test() returns (int) { + │ ──┬─ + │ ╰─── def: 6 + 14 │ return base1() + base2(); + │ ──┬── ──┬── + │ ╰────────────── ref: 2 + │ │ + │ ╰──── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol new file mode 100644 index 0000000000..604fcfa794 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol @@ -0,0 +1,16 @@ +contract Base1 { + function base1() returns (int) { return 1; } +} + +contract Base2 { + function base2() returns (int) { return 2; } +} + +contract Derived is + Base1, + Base2 +{ + function test() returns (int) { + return base1() + base2(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt new file mode 100644 index 0000000000..3c4e526ae4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(TokenState tokenState) public { + │ ──┬─ ─────┬──── ─────┬──── + │ ╰───────────────────────── def: 2 + │ │ │ + │ ╰───────────────── ref: 4 + │ │ + │ ╰────── def: 3 + 3 │ tokenState.owners(1).balance; + │ ─────┬──── ───┬── ───┬─── + │ ╰──────────────────────── ref: 3 + │ │ │ + │ ╰─────────────── ref: 5 + │ │ + │ ╰───── ref: built-in + │ + 6 │ contract TokenState { + │ ─────┬──── + │ ╰────── def: 4 + 7 │ address[] public owners; + │ ───┬── + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol new file mode 100644 index 0000000000..1fd95e6a5e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test(TokenState tokenState) public { + tokenState.owners(1).balance; + } +} +contract TokenState { + address[] public owners; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt new file mode 100644 index 0000000000..503776d84b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ address public owner; + │ ──┬── + │ ╰──── def: 2 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 3 + 5 │ function test(Base base) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰───────────── def: 4 + │ │ │ + │ ╰──────── ref: 1 + │ │ + │ ╰─── def: 5 + 6 │ base.owner().balance; + │ ──┬─ ──┬── ───┬─── + │ ╰─────────────────── ref: 5 + │ │ │ + │ ╰────────────── ref: 2 + │ │ + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol new file mode 100644 index 0000000000..eca1760059 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol @@ -0,0 +1,8 @@ +contract Base { + address public owner; +} +contract Test { + function test(Base base) public { + base.owner().balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt index beb90fd893..7afdf26c48 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt @@ -26,10 +26,8 @@ References and definitions: │ ──┬─ │ ╰─── def: 6 10 │ return y + this.y() + f.x(); - │ ┬ ──┬─ ┬ ┬ ┬ + │ ┬ ┬ ┬ ┬ │ ╰─────────────────── ref: 4 - │ │ │ │ │ - │ ╰───────────── ref: 3 │ │ │ │ │ ╰────────── ref: 4 │ │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt new file mode 100644 index 0000000000..fab1b7434b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract RegistrarAccess { + │ ───────┬─────── + │ ╰───────── def: 1 + 2 │ Root root; + │ ──┬─ ──┬─ + │ ╰──────── ref: 4 + │ │ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 4 │ root.controllers; + │ ──┬─ ─────┬───── + │ ╰─────────────── ref: 2 + │ │ + │ ╰─────── ref: 6 + │ + 8 │ contract Root is Controllable {} + │ ──┬─ ──────┬───── + │ ╰─────────────────── def: 4 + │ │ + │ ╰─────── ref: 5 + │ + 10 │ contract Controllable { + │ ──────┬───── + │ ╰─────── def: 5 + 11 │ mapping (address => bool) public controllers; + │ ─────┬───── + │ ╰─────── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol new file mode 100644 index 0000000000..5388a5d254 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol @@ -0,0 +1,12 @@ +contract RegistrarAccess { + Root root; + function test() public { + root.controllers; + } +} + +contract Root is Controllable {} + +contract Controllable { + mapping (address => bool) public controllers; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt new file mode 100644 index 0000000000..84dff71c3f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(TokenState tokenState) public { + │ ──┬─ ─────┬──── ─────┬──── + │ ╰───────────────────────── def: 2 + │ │ │ + │ ╰───────────────── ref: 4 + │ │ + │ ╰────── def: 3 + 3 │ tokenState.owners(1).balance; + │ ─────┬──── ───┬── ───┬─── + │ ╰──────────────────────── ref: 3 + │ │ │ + │ ╰─────────────── ref: 5 + │ │ + │ ╰───── ref: built-in + │ + 6 │ contract TokenState { + │ ─────┬──── + │ ╰────── def: 4 + 7 │ mapping(uint => address) public owners; + │ ───┬── + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol new file mode 100644 index 0000000000..69efebff11 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test(TokenState tokenState) public { + tokenState.owners(1).balance; + } +} +contract TokenState { + mapping(uint => address) public owners; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt new file mode 100644 index 0000000000..28722902e6 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt @@ -0,0 +1,37 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Owner { address owner; } + │ ──┬── ──┬── + │ ╰──────────────────── def: 2 + │ │ + │ ╰──── def: 3 + 3 │ Owner public owner; + │ ──┬── ──┬── + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 4 + │ + 5 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 6 │ function test(Base base) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰───────────── def: 6 + │ │ │ + │ ╰──────── ref: 1 + │ │ + │ ╰─── def: 7 + 7 │ base.owner().balance; + │ ──┬─ ──┬── ───┬─── + │ ╰─────────────────── ref: 7 + │ │ │ + │ ╰────────────── ref: 4 + │ │ + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol new file mode 100644 index 0000000000..3c85bc3911 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol @@ -0,0 +1,9 @@ +contract Base { + struct Owner { address owner; } + Owner public owner; +} +contract Test { + function test(Base base) public { + base.owner().balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt new file mode 100644 index 0000000000..da81507f48 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bool renounced; + │ ────┬──── + │ ╰────── def: 2 + │ + 4 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ function test() public { + │ ──┬─ + │ ╰─── def: 4 + 6 │ Base.renounced = true; + │ ──┬─ ────┬──── + │ ╰───────────── ref: 1 + │ │ + │ ╰────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol new file mode 100644 index 0000000000..bc9b730d79 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol @@ -0,0 +1,8 @@ +contract Base { + bool renounced; +} +contract Test is Base { + function test() public { + Base.renounced = true; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e0763a81c8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function in_base() internal {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Middle is Base {} + │ ───┬── ──┬─ + │ ╰──────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 4 + │ │ + │ ╰──── ref: 3 + 6 │ function test() public { + │ ──┬─ + │ ╰─── def: 5 + 7 │ Base.in_base(); + │ ──┬─ ───┬─── + │ ╰─────────── ref: 1 + │ │ + │ ╰───── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol new file mode 100644 index 0000000000..3e23b1b8b9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol @@ -0,0 +1,9 @@ +contract Base { + function in_base() internal {} +} +contract Middle is Base {} +contract Test is Middle { + function test() public { + Base.in_base(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt new file mode 100644 index 0000000000..66779a28d1 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt @@ -0,0 +1,29 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function in_base() {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Middle is Base {} + │ ───┬── ──┬─ + │ ╰──────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 4 + │ │ + │ ╰──── ref: 3 + 6 │ function in_base() { + │ ───┬─── + │ ╰───── def: 5 + 7 │ super.in_base(); + │ ───┬─── + │ ╰───── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol new file mode 100644 index 0000000000..0a933e7431 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol @@ -0,0 +1,9 @@ +contract Base { + function in_base() {} +} +contract Middle is Base {} +contract Test is Middle { + function in_base() { + super.in_base(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt index e5d4bc6d71..5819b34073 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt @@ -19,9 +19,7 @@ References and definitions: │ ─┬─ │ ╰─── def: 4 6 │ super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 │ 9 │ contract C is A { @@ -33,9 +31,7 @@ References and definitions: │ ─┬─ │ ╰─── def: 6 11 │ super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 4 │ 14 │ contract D is B, C { @@ -49,8 +45,6 @@ References and definitions: │ ─┬─ │ ╰─── def: 8 16 │ super.foo(); - │ ──┬── ─┬─ - │ ╰──────── refs: 3, 5 - │ │ + │ ─┬─ │ ╰─── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt index 1e7b1003b1..1e0d62fb2d 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt @@ -28,8 +28,6 @@ References and definitions: │ │ │ ╰── ref: 1 13 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt index c3f150295d..7feb70120a 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt @@ -22,8 +22,6 @@ References and definitions: │ │ │ ╰── ref: 1 13 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt index 2f9f1eb37e..ac355a829c 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt @@ -14,8 +14,6 @@ References and definitions: │ ─┬─ │ ╰─── def: 3 5 │ this.foo(); - │ ──┬─ ─┬─ - │ ╰─────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt new file mode 100644 index 0000000000..24a80f6855 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ revert(); + │ ───┬── + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt new file mode 100644 index 0000000000..165fe5e41d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ revert(); + │ ───┬── + │ ╰──── refs: built-in, built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..17e5d6e85e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or InternalKeyword or OverrideKeyword or PrivateKeyword or PublicKeyword. + ╭─[input.sol:2:25] + │ + 2 │ ╭─▶ function () payable { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt new file mode 100644 index 0000000000..1dda92db7e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or ImmutableKeyword or InternalKeyword or OverrideKeyword or PrivateKeyword or PublicKeyword. + ╭─[input.sol:2:25] + │ + 2 │ ╭─▶ function () payable { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt new file mode 100644 index 0000000000..61ee40e68c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or ImmutableKeyword or InternalKeyword or OverrideKeyword or PrivateKeyword or PublicKeyword or TransientKeyword. + ╭─[input.sol:2:25] + │ + 2 │ ╭─▶ function () payable { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol new file mode 100644 index 0000000000..e69d46f688 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol @@ -0,0 +1,5 @@ +contract Test { + function () payable { + revert(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt index 99eacf7c99..1a4864098f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt @@ -58,8 +58,6 @@ References and definitions: │ │ │ ╰── ref: 5 25 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── refs: 3, 5 - │ │ + │ ─┬─ │ ╰─── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt index 78ee0e6e94..c5f1386460 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt @@ -46,8 +46,6 @@ References and definitions: │ │ │ ╰── ref: 5 25 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── refs: 3, 5 - │ │ + │ ─┬─ │ ╰─── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5bc593e595 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:20] + │ + 2 │ error TestError(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error TestError(); + │ ──┬── ────┬──── + │ ╰────────────── unresolved + │ │ + │ ╰────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 5 │ TestError.selector; + │ ────┬──── ────┬─── + │ ╰─────────────── ref: 2 + │ │ + │ ╰───── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt new file mode 100644 index 0000000000..41e568485d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error TestError(); + │ ────┬──── + │ ╰────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 5 │ TestError.selector; + │ ────┬──── ────┬─── + │ ╰─────────────── ref: 2 + │ │ + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol b/crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol new file mode 100644 index 0000000000..1c9d61ed82 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol @@ -0,0 +1,7 @@ +contract Test { + error TestError(); + + function test() public { + TestError.selector; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt new file mode 100644 index 0000000000..69f5695dea --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt @@ -0,0 +1,100 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop_uint(uint x) public returns (uint) {} + │ ────┬─── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function nop_bool(bool x) public returns (bool) {} + │ ────┬─── ┬ + │ ╰──────────── def: 4 + │ │ + │ ╰── def: 5 + │ + 6 │ contract Test { + │ ──┬─ + │ ╰─── def: 6 + 7 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 1 + 8 │ using Lib for bool; + │ ─┬─ + │ ╰─── ref: 1 + 9 │ function test(uint a, uint b) public { + │ ──┬─ ┬ ┬ + │ ╰────────────────── def: 7 + │ │ │ + │ ╰────────── def: 8 + │ │ + │ ╰── def: 9 + 10 │ (a += b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰───────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 11 │ (true ? a : b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 12 │ (a == b).nop_bool(); + │ ┬ ┬ ────┬─── + │ ╰───────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 4 + 13 │ (a > b).nop_bool(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 4 + 14 │ (a | b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 15 │ (a << 1).nop_uint(); + │ ┬ ────┬─── + │ ╰───────────────── ref: 8 + │ │ + │ ╰───── ref: 2 + 16 │ (a + b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 17 │ (a * b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 18 │ (a++).nop_uint(); + │ ┬ ────┬─── + │ ╰────────────── ref: 8 + │ │ + │ ╰───── ref: 2 + 19 │ (++a).nop_uint(); + │ ┬ ────┬─── + │ ╰──────────── ref: 8 + │ │ + │ ╰───── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol new file mode 100644 index 0000000000..90d76c2564 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol @@ -0,0 +1,21 @@ +library Lib { + function nop_uint(uint x) public returns (uint) {} + function nop_bool(bool x) public returns (bool) {} +} + +contract Test { + using Lib for uint; + using Lib for bool; + function test(uint a, uint b) public { + (a += b).nop_uint(); + (true ? a : b).nop_uint(); + (a == b).nop_bool(); + (a > b).nop_bool(); + (a | b).nop_uint(); + (a << 1).nop_uint(); + (a + b).nop_uint(); + (a * b).nop_uint(); + (a++).nop_uint(); + (++a).nop_uint(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..f25c1ffe3c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt new file mode 100644 index 0000000000..bdf6d7ee03 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..8ee42cb4f3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..0563005915 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt new file mode 100644 index 0000000000..55ec33f7cd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + 6 │ payable(a).call(""); + │ ┬ ──┬─ + │ ╰──────── ref: 3 + │ │ + │ ╰─── ref: built-in + 7 │ uint(10).noop(); + │ ──┬─ + │ ╰─── ref: 5 + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol new file mode 100644 index 0000000000..db44f7978e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol @@ -0,0 +1,13 @@ +contract Test { + using Lib for uint; + + function test(address a) public { + address(this).balance; + payable(a).call(""); + uint(10).noop(); + } +} + +library Lib { + function noop(uint x) public returns (uint) {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt new file mode 100644 index 0000000000..4f39167043 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(address rcpt, bytes memory data) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰─────────────────────────────────── def: 2 + │ │ │ + │ ╰────────────────────── def: 3 + │ │ + │ ╰─── def: 4 + │ + 4 │ rcpt.call.value(1)(data); + │ ──┬─ ──┬─ ──┬── ──┬─ + │ ╰────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────── ref: built-in + │ │ │ + │ ╰──────────── ref: built-in + │ │ + │ ╰─── ref: 4 + 5 │ rcpt.call.gas(1)(data); + │ ──┬─ ──┬─ ─┬─ ──┬─ + │ ╰──────────────────── ref: 3 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰─────────── ref: built-in + │ │ + │ ╰─── ref: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..b15ce9308a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(address rcpt, bytes memory data) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰─────────────────────────────────── def: 2 + │ │ │ + │ ╰────────────────────── def: 3 + │ │ + │ ╰─── def: 4 + │ + 4 │ rcpt.call.value(1)(data); + │ ──┬─ ──┬─ ──┬── ──┬─ + │ ╰────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────── ref: built-in + │ │ │ + │ ╰──────────── unresolved + │ │ + │ ╰─── ref: 4 + 5 │ rcpt.call.gas(1)(data); + │ ──┬─ ──┬─ ─┬─ ──┬─ + │ ╰──────────────────── ref: 3 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰─────────── unresolved + │ │ + │ ╰─── ref: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol new file mode 100644 index 0000000000..cc5d1f69ce --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol @@ -0,0 +1,7 @@ +contract Test { + function test(address rcpt, bytes memory data) public { + // this is valid on Solidity < 0.7.0 + rcpt.call.value(1)(data); + rcpt.call.gas(1)(data); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt new file mode 100644 index 0000000000..31773815f8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(bytes memory data) public { + │ ──┬─ ──┬─ + │ ╰───────────────────── def: 2 + │ │ + │ ╰─── def: 3 + 3 │ 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1.delegatecall(data); + │ ──────┬───── ──┬─ + │ ╰──────────── ref: built-in + │ │ + │ ╰─── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol new file mode 100644 index 0000000000..2f58b86413 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol @@ -0,0 +1,5 @@ +contract Test { + function test(bytes memory data) public { + 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1.delegatecall(data); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e00ce09b33 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt @@ -0,0 +1,27 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint256 x) internal {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test() public { + │ ──┬─ + │ ╰─── def: 5 + 7 │ (50 * 10**uint(4)).nop(); + │ ─┬─ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol new file mode 100644 index 0000000000..3ffcec21df --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol @@ -0,0 +1,9 @@ +library Lib { + function nop(uint256 x) internal {} +} +contract Test { + using Lib for uint256; + function test() public { + (50 * 10**uint(4)).nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt new file mode 100644 index 0000000000..bfc96cf8da --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt @@ -0,0 +1,23 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IFoo { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Bar { + │ ─┬─ + │ ╰─── def: 2 + 3 │ int value; + │ ──┬── + │ ╰──── def: 3 + │ + 5 │ function test(Bar memory bar); + │ ──┬─ ─┬─ ─┬─ + │ ╰────────────────── def: 4 + │ │ │ + │ ╰────────────── ref: 2 + │ │ + │ ╰─── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol new file mode 100644 index 0000000000..23d18a2bd3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol @@ -0,0 +1,6 @@ +interface IFoo { + struct Bar { + int value; + } + function test(Bar memory bar); +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d83d224dfa --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt @@ -0,0 +1,34 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ uint private constant X = 1; + │ ┬ + │ ╰── def: 2 + 3 │ uint public constant Y = 2; + │ ┬ + │ ╰── def: 3 + │ + 5 │ function test() public returns (uint) { + │ ──┬─ + │ ╰─── def: 4 + 6 │ return X; + │ ┬ + │ ╰── ref: 2 + │ + 10 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 11 │ function test() public { + │ ──┬─ + │ ╰─── def: 6 + 12 │ Lib.Y; + │ ─┬─ ┬ + │ ╰───── ref: 1 + │ │ + │ ╰── ref: 3 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol new file mode 100644 index 0000000000..6990c22be9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol @@ -0,0 +1,14 @@ +library Lib { + uint private constant X = 1; + uint public constant Y = 2; + + function test() public returns (uint) { + return X; + } +} + +contract Test { + function test() public { + Lib.Y; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt new file mode 100644 index 0000000000..3fa6594466 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ modifier withinRange() { + │ ─────┬───── + │ ╰─────── def: 2 + 3 │ _; + │ ┬ + │ ╰── ref: built-in + │ + 5 │ function test() internal withinRange() {} + │ ──┬─ ─────┬───── + │ ╰────────────────────────── def: 3 + │ │ + │ ╰─────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol new file mode 100644 index 0000000000..72cebbcaf9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol @@ -0,0 +1,6 @@ +library Test { + modifier withinRange() { + _; + } + function test() internal withinRange() {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..6e61f4eb45 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:25] + │ + 2 │ error IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:5:28] + │ + 5 │ revert IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ error IndexOutOfBounds(); + │ ──┬── ────────┬─────── + │ ╰───────────────────── unresolved + │ │ + │ ╰───────── def: 2 + │ + 4 │ modifier test() { + │ ──┬─ + │ ╰─── def: 3 + 5 │ revert IndexOutOfBounds(); + │ ───┬── ────────┬─────── + │ ╰───────────────────── ref: built-in + │ │ + │ ╰───────── def: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..622f19db63 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:25] + │ + 2 │ error IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:5:28] + │ + 5 │ revert IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ error IndexOutOfBounds(); + │ ──┬── ────────┬─────── + │ ╰───────────────────── unresolved + │ │ + │ ╰───────── def: 2 + │ + 4 │ modifier test() { + │ ──┬─ + │ ╰─── def: 3 + 5 │ revert IndexOutOfBounds(); + │ ───┬── ────────┬─────── + │ ╰───────────────────── refs: built-in, built-in + │ │ + │ ╰───────── def: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt new file mode 100644 index 0000000000..ef7dba6b93 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ error IndexOutOfBounds(); + │ ────────┬─────── + │ ╰───────── def: 2 + │ + 4 │ modifier test() { + │ ──┬─ + │ ╰─── def: 3 + 5 │ revert IndexOutOfBounds(); + │ ────────┬─────── + │ ╰───────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol new file mode 100644 index 0000000000..066b231b3f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol @@ -0,0 +1,7 @@ +library Lib { + error IndexOutOfBounds(); + + modifier test() { + revert IndexOutOfBounds(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt new file mode 100644 index 0000000000..ce220baf55 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IERC20Upgradable { + │ ────────┬─────── + │ ╰───────── def: 1 + 2 │ function allowance(address owner) external returns (uint256); + │ ────┬──── ──┬── + │ ╰──────────────────── def: 2 + │ │ + │ ╰──── def: 3 + │ + 4 │ library Math { + │ ──┬─ + │ ╰─── def: 4 + 5 │ function nop(uint256 x) public {} + │ ─┬─ ┬ + │ ╰───────────── def: 5 + │ │ + │ ╰── def: 6 + │ + 7 │ library Test { + │ ──┬─ + │ ╰─── def: 7 + 8 │ using Math for uint256; + │ ──┬─ + │ ╰─── ref: 4 + │ + 10 │ function test(IERC20Upgradable token) internal { + │ ──┬─ ────────┬─────── ──┬── + │ ╰────────────────────────── def: 8 + │ │ │ + │ ╰─────────────── ref: 1 + │ │ + │ ╰──── def: 9 + 11 │ token.allowance(msg.sender).nop(); + │ ──┬── ────┬──── ─┬─ ───┬── ─┬─ + │ ╰────────────────────────────── ref: 9 + │ │ │ │ │ + │ ╰────────────────────── ref: 2 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol new file mode 100644 index 0000000000..2c12057eb3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol @@ -0,0 +1,13 @@ +interface IERC20Upgradable { + function allowance(address owner) external returns (uint256); +} +library Math { + function nop(uint256 x) public {} +} +library Test { + using Math for uint256; + + function test(IERC20Upgradable token) internal { + token.allowance(msg.sender).nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt new file mode 100644 index 0000000000..5e81f906d2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { + │ ──┬── + │ ╰──── def: 2 + 3 │ int x; + │ ┬ + │ ╰── def: 3 + │ + 5 │ function test() public { + │ ──┬─ + │ ╰─── def: 4 + 6 │ Value(10).x; + │ ──┬── ┬ + │ ╰────────── ref: 2 + │ │ + │ ╰── ref: 3 + 7 │ Value({x: 10}).x; + │ ──┬── ┬ ┬ + │ ╰─────────────── ref: 2 + │ │ │ + │ ╰────────── ref: 3 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol new file mode 100644 index 0000000000..48f1b04eb8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol @@ -0,0 +1,9 @@ +contract Test { + struct Value { + int x; + } + function test() public { + Value(10).x; + Value({x: 10}).x; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..b87a09cf85 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..cea0619d12 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..3505cedb20 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or FunctionKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt new file mode 100644 index 0000000000..bd4b20a86b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..619151156f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..f56435985e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or ErrorKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt new file mode 100644 index 0000000000..0563a6f694 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt @@ -0,0 +1,36 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ type ShortString is bytes32; + │ ─────┬───── + │ ╰─────── def: 1 + │ + 3 │ contract Test { + │ ──┬─ + │ ╰─── def: 2 + 4 │ function test(bytes32 data) public { + │ ──┬─ ──┬─ + │ ╰──────────────── def: 3 + │ │ + │ ╰─── def: 4 + 5 │ ShortString s = ShortString.wrap(data); + │ ─────┬───── ┬ ─────┬───── ──┬─ ──┬─ + │ ╰───────────────────────────────── ref: 1 + │ │ │ │ │ + │ ╰────────────────────────── def: 5 + │ │ │ │ + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰──────── ref: built-in + │ │ + │ ╰─── ref: 4 + 6 │ ShortString.unwrap(s); + │ ─────┬───── ───┬── ┬ + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰────── ref: built-in + │ │ + │ ╰── ref: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol new file mode 100644 index 0000000000..f6bc7b63b9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol @@ -0,0 +1,8 @@ +type ShortString is bytes32; + +contract Test { + function test(bytes32 data) public { + ShortString s = ShortString.wrap(data); + ShortString.unwrap(s); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..97aeb1b768 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt new file mode 100644 index 0000000000..d4bb34a55a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..d1ae8bf8e8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..05a55cb7be --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt new file mode 100644 index 0000000000..48d9b99f62 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 + 7 │ payable(_rcpt).sendValue(); + │ ──┬── ────┬──── + │ ╰─────────────── ref: 6 + │ │ + │ ╰────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/address/input.sol new file mode 100644 index 0000000000..06dcc8494d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/input.sol @@ -0,0 +1,9 @@ +library Address { + function sendValue(address payable recipient) internal {} +} +contract Test { + using Address for address payable; + function test(address _rcpt) public { + payable(_rcpt).sendValue(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt new file mode 100644 index 0000000000..7c63d30e2f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt @@ -0,0 +1,41 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IERC20 { + │ ───┬── + │ ╰──── def: 1 + │ + 3 │ library SafeERC20 { + │ ────┬──── + │ ╰────── def: 2 + 4 │ function safeApprove(IERC20 token) internal {} + │ ─────┬───── ───┬── ──┬── + │ ╰──────────────────── def: 3 + │ │ │ + │ ╰────────── ref: 1 + │ │ + │ ╰──── def: 4 + │ + 6 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 7 │ using SafeERC20 for IERC20; + │ ────┬──── ───┬── + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── ref: 1 + 8 │ function test(address token) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 6 + │ │ + │ ╰──── def: 7 + 9 │ IERC20(token).safeApprove(); + │ ───┬── ──┬── ─────┬───── + │ ╰─────────────────────── ref: 1 + │ │ │ + │ ╰───────────────── ref: 7 + │ │ + │ ╰─────── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol new file mode 100644 index 0000000000..2f6cf1f80c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol @@ -0,0 +1,11 @@ +interface IERC20 { +} +library SafeERC20 { + function safeApprove(IERC20 token) internal {} +} +contract Test { + using SafeERC20 for IERC20; + function test(address token) public { + IERC20(token).safeApprove(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt new file mode 100644 index 0000000000..180ec2bfde --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt @@ -0,0 +1,78 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Foo { + │ ─┬─ + │ ╰─── def: 1 + 2 │ struct Bar { + │ ─┬─ + │ ╰─── def: 2 + 3 │ uint value; + │ ──┬── + │ ╰──── def: 3 + │ + 5 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 4 + │ │ + │ ╰── def: 5 + 6 │ function bar(uint x) public returns (Bar) {} + │ ─┬─ ┬ ─┬─ + │ ╰─────────────────────────────── def: 6 + │ │ │ + │ ╰─────────────────────── def: 7 + │ │ + │ ╰─── ref: 2 + │ + 9 │ contract Test { + │ ──┬─ + │ ╰─── def: 8 + 10 │ using Foo for uint; + │ ─┬─ + │ ╰─── ref: 1 + 11 │ function test(uint a, Foo.Bar memory b) public { + │ ──┬─ ┬ ─┬─ ─┬─ ┬ + │ ╰──────────────────────────── def: 9 + │ │ │ │ │ + │ ╰──────────────────── def: 10 + │ │ │ │ + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰──────────── ref: 2 + │ │ + │ ╰── def: 11 + 12 │ uint[] memory xs; + │ ─┬ + │ ╰── def: 12 + 13 │ a.noop().noop().noop(); + │ ┬ ──┬─ ──┬─ ──┬─ + │ ╰───────────────────── ref: 10 + │ │ │ │ + │ ╰───────────────── ref: 4 + │ │ │ + │ ╰────────── ref: 4 + │ │ + │ ╰─── ref: 4 + 14 │ b.value.noop().bar().value.noop(); + │ ┬ ──┬── ──┬─ ─┬─ ──┬── ──┬─ + │ ╰──────────────────────────────── ref: 11 + │ │ │ │ │ │ + │ ╰──────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰────────────────────── ref: 4 + │ │ │ │ + │ ╰──────────────── ref: 6 + │ │ │ + │ ╰───────── ref: 3 + │ │ + │ ╰─── ref: 4 + 15 │ xs[5].noop().noop(); + │ ─┬ ──┬─ ──┬─ + │ ╰───────────────── ref: 12 + │ │ │ + │ ╰────────── ref: 4 + │ │ + │ ╰─── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol new file mode 100644 index 0000000000..0a0143ee1c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol @@ -0,0 +1,17 @@ +library Foo { + struct Bar { + uint value; + } + function noop(uint x) public returns (uint) {} + function bar(uint x) public returns (Bar) {} +} + +contract Test { + using Foo for uint; + function test(uint a, Foo.Bar memory b) public { + uint[] memory xs; + a.noop().noop().noop(); + b.value.noop().bar().value.noop(); + xs[5].noop().noop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d8aec265bc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt @@ -0,0 +1,44 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 2 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 3 │ function nop(uint256 x) {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ uint256 totalSupply; + │ ─────┬───── + │ ╰─────── def: 5 + │ + 8 │ contract Middle is Base { + │ ───┬── ──┬─ + │ ╰──────────── def: 6 + │ │ + │ ╰─── ref: 4 + 9 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + │ + 11 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 7 + │ │ + │ ╰──── ref: 6 + 12 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + 13 │ totalSupply.nop(); + │ ─────┬───── ─┬─ + │ ╰─────────── ref: 5 + │ │ + │ ╰─── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..3aa3f58fd1 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt @@ -0,0 +1,44 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 2 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 3 │ function nop(uint256 x) {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ uint256 totalSupply; + │ ─────┬───── + │ ╰─────── def: 5 + │ + 8 │ contract Middle is Base { + │ ───┬── ──┬─ + │ ╰──────────── def: 6 + │ │ + │ ╰─── ref: 4 + 9 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + │ + 11 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 7 + │ │ + │ ╰──── ref: 6 + 12 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + 13 │ totalSupply.nop(); + │ ─────┬───── ─┬─ + │ ╰─────────── ref: 5 + │ │ + │ ╰─── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol new file mode 100644 index 0000000000..6e5e05addb --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol @@ -0,0 +1,15 @@ +// In Solidity < 0.7.0 using directives are inherited in sub contracts +library Lib { + function nop(uint256 x) {} +} +contract Base { + uint256 totalSupply; +} +contract Middle is Base { + using Lib for uint256; +} +contract Test is Middle { + function test() public { + totalSupply.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e4adbece8d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt @@ -0,0 +1,52 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IPool { + │ ──┬── + │ ╰──── def: 1 + 2 │ struct Info { + │ ──┬─ + │ ╰─── def: 2 + 3 │ uint256 amount; + │ ───┬── + │ ╰──── def: 3 + │ + 6 │ library Math { + │ ──┬─ + │ ╰─── def: 4 + 7 │ function nop(uint256 x) public {} + │ ─┬─ ┬ + │ ╰───────────── def: 5 + │ │ + │ ╰── def: 6 + │ + 9 │ contract Test is IPool { + │ ──┬─ ──┬── + │ ╰──────────── def: 7 + │ │ + │ ╰──── ref: 1 + 10 │ mapping(uint256 => Info) infos; + │ ──┬─ ──┬── + │ ╰────────── ref: 2 + │ │ + │ ╰──── def: 8 + 11 │ using Math for uint256; + │ ──┬─ + │ ╰─── ref: 4 + 12 │ function test(uint256 x) public { + │ ──┬─ ┬ + │ ╰───────────── def: 9 + │ │ + │ ╰── def: 10 + 13 │ infos[x].amount.nop(); + │ ──┬── ┬ ───┬── ─┬─ + │ ╰────────────────── ref: 8 + │ │ │ │ + │ ╰────────────── ref: 10 + │ │ │ + │ ╰──────── ref: 3 + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol new file mode 100644 index 0000000000..d136d3833a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol @@ -0,0 +1,15 @@ +interface IPool { + struct Info { + uint256 amount; + } +} +library Math { + function nop(uint256 x) public {} +} +contract Test is IPool { + mapping(uint256 => Info) infos; + using Math for uint256; + function test(uint256 x) public { + infos[x].amount.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt new file mode 100644 index 0000000000..6094b2e72e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt @@ -0,0 +1,32 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for mapping(address => uint); + │ ─┬─ + │ ╰─── ref: 4 + 3 │ mapping(address => uint) balances; + │ ────┬─── + │ ╰───── def: 2 + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 5 │ balances.nop(); + │ ────┬─── ─┬─ + │ ╰───────── ref: 2 + │ │ + │ ╰─── ref: 5 + │ + 8 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 9 │ function nop(mapping(address => uint) storage m) internal {} + │ ─┬─ ┬ + │ ╰────────────────────────────────────── def: 5 + │ │ + │ ╰── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol new file mode 100644 index 0000000000..07c9130933 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol @@ -0,0 +1,10 @@ +contract Test { + using Lib for mapping(address => uint); + mapping(address => uint) balances; + function test() public { + balances.nop(); + } +} +library Lib { + function nop(mapping(address => uint) storage m) internal {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt new file mode 100644 index 0000000000..f11a068098 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt @@ -0,0 +1,48 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library LibFoo { + │ ───┬── + │ ╰──── def: 1 + 2 │ function use_foo(IFoo x) public returns (int) {} + │ ───┬─── ──┬─ ┬ + │ ╰──────────── def: 2 + │ │ │ + │ ╰───── ref: 4 + │ │ + │ ╰── def: 3 + │ + 4 │ interface IFoo { + │ ──┬─ + │ ╰─── def: 4 + │ + 6 │ contract Base { + │ ──┬─ + │ ╰─── def: 5 + 7 │ using LibFoo for IFoo; + │ ───┬── ──┬─ + │ ╰───────────── ref: 1 + │ │ + │ ╰─── ref: 4 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 6 + │ │ + │ ╰─── ref: 5 + 10 │ function test(address x) public { + │ ──┬─ ┬ + │ ╰───────────── def: 7 + │ │ + │ ╰── def: 8 + │ + 12 │ IFoo(x).use_foo(); + │ ──┬─ ┬ ───┬─── + │ ╰────────────── ref: 4 + │ │ │ + │ ╰─────────── ref: 8 + │ │ + │ ╰───── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..5afd65e4af --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt @@ -0,0 +1,48 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library LibFoo { + │ ───┬── + │ ╰──── def: 1 + 2 │ function use_foo(IFoo x) public returns (int) {} + │ ───┬─── ──┬─ ┬ + │ ╰──────────── def: 2 + │ │ │ + │ ╰───── ref: 4 + │ │ + │ ╰── def: 3 + │ + 4 │ interface IFoo { + │ ──┬─ + │ ╰─── def: 4 + │ + 6 │ contract Base { + │ ──┬─ + │ ╰─── def: 5 + 7 │ using LibFoo for IFoo; + │ ───┬── ──┬─ + │ ╰───────────── ref: 1 + │ │ + │ ╰─── ref: 4 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 6 + │ │ + │ ╰─── ref: 5 + 10 │ function test(address x) public { + │ ──┬─ ┬ + │ ╰───────────── def: 7 + │ │ + │ ╰── def: 8 + │ + 12 │ IFoo(x).use_foo(); + │ ──┬─ ┬ ───┬─── + │ ╰────────────── ref: 4 + │ │ │ + │ ╰─────────── ref: 8 + │ │ + │ ╰───── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol new file mode 100644 index 0000000000..c894206b75 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol @@ -0,0 +1,14 @@ +library LibFoo { + function use_foo(IFoo x) public returns (int) {} +} +interface IFoo { +} +contract Base { + using LibFoo for IFoo; +} +contract Test is Base { + function test(address x) public { + // should work for Solidity < 0.7.0 + IFoo(x).use_foo(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt new file mode 100644 index 0000000000..4753580729 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint256 x) internal {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test(uint256 x) public returns (uint256 y) { + │ ──┬─ ┬ ┬ + │ ╰──────────────────────────────────────── def: 5 + │ │ │ + │ ╰───────────────────────────── def: 6 + │ │ + │ ╰── def: 7 + 7 │ x.nop(); + │ ┬ ─┬─ + │ ╰────── ref: 6 + │ │ + │ ╰─── ref: 2 + 8 │ y.nop(); + │ ┬ ─┬─ + │ ╰────── ref: 7 + │ │ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol new file mode 100644 index 0000000000..135ab2423e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol @@ -0,0 +1,10 @@ +library Lib { + function nop(uint256 x) internal {} +} +contract Test { + using Lib for uint256; + function test(uint256 x) public returns (uint256 y) { + x.nop(); + y.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt new file mode 100644 index 0000000000..0dacde723a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint256 x) returns (uint256) { return x; } + │ ─┬─ ┬ ┬ + │ ╰─────────────────────────────────────────── def: 2 + │ │ │ + │ ╰──────────────────────────────── def: 3 + │ │ + │ ╰── ref: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ uint256 private v1 = 1; + │ ─┬ + │ ╰── def: 5 + 7 │ uint256 private v2 = v1.nop(); + │ ─┬ ─┬ ─┬─ + │ ╰─────────── def: 6 + │ │ │ + │ ╰────── ref: 5 + │ │ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol new file mode 100644 index 0000000000..ff41b32b6e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol @@ -0,0 +1,8 @@ +library Lib { + function nop(uint256 x) returns (uint256) { return x; } +} +contract Test { + using Lib for uint256; + uint256 private v1 = 1; + uint256 private v2 = v1.nop(); +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt new file mode 100644 index 0000000000..99cdf03840 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract A { + │ ┬ + │ ╰── def: 1 + 2 │ function total() public returns (uint256) {} + │ ──┬── + │ ╰──── def: 2 + │ + 4 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 5 + 6 │ function total() public returns (uint256) { + │ ──┬── + │ ╰──── def: 4 + 7 │ return super.total().nop(); + │ ──┬── ─┬─ + │ ╰────────── ref: 2 + │ │ + │ ╰─── ref: 6 + │ + 10 │ library Lib { + │ ─┬─ + │ ╰─── def: 5 + 11 │ function nop(uint256 x) internal returns (uint256) {} + │ ─┬─ ┬ + │ ╰───────────── def: 6 + │ │ + │ ╰── def: 7 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol new file mode 100644 index 0000000000..5fde21f3a5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol @@ -0,0 +1,12 @@ +contract A { + function total() public returns (uint256) {} +} +contract B is A { + using Lib for uint256; + function total() public returns (uint256) { + return super.total().nop(); + } +} +library Lib { + function nop(uint256 x) internal returns (uint256) {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d2c34aa894 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ struct Value { + │ ──┬── + │ ╰──── def: 2 + 3 │ int x; + │ ┬ + │ ╰── def: 3 + │ + 5 │ function getValue() external returns (Value memory) {} + │ ────┬─── ──┬── + │ ╰─────────────────────────────── def: 4 + │ │ + │ ╰──── ref: 2 + 6 │ function use(Value memory x) external {} + │ ─┬─ ──┬── ┬ + │ ╰────────────────── def: 5 + │ │ │ + │ ╰───────────── ref: 2 + │ │ + │ ╰── def: 6 + │ + 8 │ contract Test { + │ ──┬─ + │ ╰─── def: 7 + 9 │ using Lib for Lib.Value; + │ ─┬─ ─┬─ ──┬── + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + 10 │ function test() internal { + │ ──┬─ + │ ╰─── def: 8 + 11 │ Lib.getValue().use(); + │ ─┬─ ────┬─── ─┬─ + │ ╰────────────────── ref: 1 + │ │ │ + │ ╰─────────── ref: 4 + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol new file mode 100644 index 0000000000..b63cc756e5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol @@ -0,0 +1,13 @@ +library Lib { + struct Value { + int x; + } + function getValue() external returns (Value memory) {} + function use(Value memory x) external {} +} +contract Test { + using Lib for Lib.Value; + function test() internal { + Lib.getValue().use(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt index 63dd244363..f3c3ede787 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt @@ -1,45 +1,32 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ library Lib { - │ ─┬─ - │ ╰─── def: 1 - 2 │ struct Counter { - │ ───┬─── - │ ╰───── def: 2 - 3 │ uint value; - │ ──┬── - │ ╰──── def: 3 - │ - 6 │ function increment(Counter memory _counter) public {} - │ ────┬──── ───┬─── ────┬─── - │ ╰────────────────────────────── def: 4 - │ │ │ - │ ╰───────────────────── ref: 2 - │ │ - │ ╰───── def: 5 - │ - 9 │ contract Test { - │ ──┬─ - │ ╰─── def: 6 - 10 │ using Lib for *; - │ ─┬─ - │ ╰─── ref: 1 - │ - 12 │ function test(Lib.Counter memory c) public { - │ ──┬─ ─┬─ ───┬─── ┬ - │ ╰──────────────────────── def: 7 - │ │ │ │ - │ ╰──────────────────── ref: 1 - │ │ │ - │ ╰────────────── ref: 2 - │ │ - │ ╰── def: 8 - 13 │ c.increment(); - │ ┬ ────┬──── - │ ╰──────────── ref: 8 - │ │ - │ ╰────── ref: 4 -────╯ + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function increment(uint x) public {} + │ ────┬──── ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 6 │ using Lib for *; + │ ─┬─ + │ ╰─── ref: 1 + │ + 8 │ function test(uint x) public { + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 + 9 │ x.increment(); + │ ┬ ────┬──── + │ ╰──────────── ref: 6 + │ │ + │ ╰────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol index 90669136e3..af70c03cd9 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol @@ -1,15 +1,11 @@ library Lib { - struct Counter { - uint value; - } - - function increment(Counter memory _counter) public {} + function increment(uint x) public {} } contract Test { using Lib for *; - function test(Lib.Counter memory c) public { - c.increment(); + function test(uint x) public { + x.increment(); } } diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt new file mode 100644 index 0000000000..dfe2b1d565 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ using Math for *; + │ ──┬─ + │ ╰─── ref: 4 + 3 │ function test(uint x) internal { + │ ──┬─ ┬ + │ ╰────────── def: 2 + │ │ + │ ╰── def: 3 + 4 │ x.add(1); + │ ┬ ─┬─ + │ ╰────── ref: 3 + │ │ + │ ╰─── ref: 5 + │ + 7 │ library Math { + │ ──┬─ + │ ╰─── def: 4 + 8 │ function add(uint x, uint y) internal {} + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 5 + │ │ │ + │ ╰────────── def: 6 + │ │ + │ ╰── def: 7 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol new file mode 100644 index 0000000000..91fcfeaceb --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol @@ -0,0 +1,9 @@ +library Lib { + using Math for *; + function test(uint x) internal { + x.add(1); + } +} +library Math { + function add(uint x, uint y) internal {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt new file mode 100644 index 0000000000..0c749da6a4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function increment(uint x) public {} + │ ────┬──── ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ using Lib for *; + │ ─┬─ + │ ╰─── ref: 1 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 5 + │ │ + │ ╰─── ref: 4 + 10 │ function test(uint x) public { + │ ──┬─ ┬ + │ ╰────────── def: 6 + │ │ + │ ╰── def: 7 + │ + 12 │ x.increment(); + │ ┬ ────┬──── + │ ╰──────────── ref: 7 + │ │ + │ ╰────── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..d743ce1067 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function increment(uint x) public {} + │ ────┬──── ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ using Lib for *; + │ ─┬─ + │ ╰─── ref: 1 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 5 + │ │ + │ ╰─── ref: 4 + 10 │ function test(uint x) public { + │ ──┬─ ┬ + │ ╰────────── def: 6 + │ │ + │ ╰── def: 7 + │ + 12 │ x.increment(); + │ ┬ ────┬──── + │ ╰──────────── ref: 7 + │ │ + │ ╰────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol new file mode 100644 index 0000000000..1d77492bcd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol @@ -0,0 +1,14 @@ +library Lib { + function increment(uint x) public {} +} + +contract Base { + using Lib for *; +} + +contract Test is Base { + function test(uint x) public { + // should resolve for Solidity < 0.7.0 + x.increment(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d04e0ece4e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt @@ -0,0 +1,32 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 4 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 4 │ uint x; + │ ┬ + │ ╰── def: 3 + 5 │ x.nop(); + │ ┬ ─┬─ + │ ╰────── ref: 3 + │ │ + │ ╰─── ref: 5 + │ + 8 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 9 │ function nop(uint256 x) external {} + │ ─┬─ ┬ + │ ╰───────────── def: 5 + │ │ + │ ╰── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol new file mode 100644 index 0000000000..6785caf83f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol @@ -0,0 +1,10 @@ +contract Test { + using Lib for uint256; + function test() public { + uint x; + x.nop(); + } +} +library Lib { + function nop(uint256 x) external {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5b3351888a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..59217924c2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..d19bf6dfe0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or FunctionKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt new file mode 100644 index 0000000000..50dc41f2ab --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..205226995e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..c709a0526b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or ErrorKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt new file mode 100644 index 0000000000..2ec0bb8683 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ type ShortString is bytes32; + │ ─────┬───── + │ ╰─────── def: 1 + │ + 3 │ contract Test { + │ ──┬─ + │ ╰─── def: 2 + 4 │ using Lib for ShortString; + │ ─┬─ ─────┬───── + │ ╰─────────────────── ref: 6 + │ │ + │ ╰─────── ref: 1 + 5 │ using Lib for bytes32; + │ ─┬─ + │ ╰─── ref: 6 + │ + 7 │ function test(bytes32 data) public { + │ ──┬─ ──┬─ + │ ╰──────────────── def: 3 + │ │ + │ ╰─── def: 4 + 8 │ ShortString s; + │ ─────┬───── ┬ + │ ╰───────── ref: 1 + │ │ + │ ╰── def: 5 + │ + 10 │ ShortString.wrap(data).nop(); + │ ─────┬───── ──┬─ ──┬─ ─┬─ + │ ╰────────────────────── ref: 1 + │ │ │ │ + │ ╰───────────── ref: built-in + │ │ │ + │ ╰──────── ref: 4 + │ │ + │ ╰─── ref: 7 + 11 │ ShortString.unwrap(s).pon(); + │ ─────┬───── ───┬── ┬ ─┬─ + │ ╰───────────────────── ref: 1 + │ │ │ │ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰─────── ref: 5 + │ │ + │ ╰─── ref: 9 + │ + 15 │ library Lib { + │ ─┬─ + │ ╰─── def: 6 + 16 │ function nop(ShortString x) internal {} + │ ─┬─ ─────┬───── ┬ + │ ╰───────────────── def: 7 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰── def: 8 + 17 │ function pon(bytes32 x) internal {} + │ ─┬─ ┬ + │ ╰───────────── def: 9 + │ │ + │ ╰── def: 10 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol new file mode 100644 index 0000000000..2cd5524ea3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol @@ -0,0 +1,18 @@ +type ShortString is bytes32; + +contract Test { + using Lib for ShortString; + using Lib for bytes32; + + function test(bytes32 data) public { + ShortString s; + + ShortString.wrap(data).nop(); + ShortString.unwrap(s).pon(); + } +} + +library Lib { + function nop(ShortString x) internal {} + function pon(bytes32 x) internal {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt new file mode 100644 index 0000000000..49bae9ee2c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 + 4 │ var v = value; + │ ┬ ──┬── + │ ╰────────── def: 6 + │ │ + │ ╰──── ref: 5 + 5 │ v.x; + │ ┬ ┬ + │ ╰──── refs: 6, 5 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..b1aab5f30b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..916fc51d48 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..baeb9846cc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..d9a26d93af --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..4ab42efd3b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..bef3f48735 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or RevertKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol new file mode 100644 index 0000000000..2a03158592 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol @@ -0,0 +1,7 @@ +contract Test { + struct Value { int x; } + function test(Value memory value) public { + var v = value; + v.x; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..568d7b9b08 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:27:1] + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────────────────┬────────────────── + │ ╰──────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── unresolved + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..19b7c69fae --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:27:1] + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────────────────┬────────────────── + │ ╰──────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── unresolved + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..19d15d5248 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or FunctionKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:27:1] + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────────────────┬────────────────── + │ ╰──────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── unresolved + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt new file mode 100644 index 0000000000..38815261bc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt @@ -0,0 +1,63 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── ref: 11 + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── ref: 11 + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────┬─────── + │ ╰───────── def: 11 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol new file mode 100644 index 0000000000..2dcf1ca5ad --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol @@ -0,0 +1,27 @@ +contract InContracts { + uint256 private constant CONTRACT_CONST = 1; + + function test() public { + assembly { + function swap(emptyPtr) { + mstore(emptyPtr, CONTRACT_CONST) + mstore(emptyPtr, TOP_LEVEL_CONST) + } + } + } +} + +library InLibraries { + uint256 private constant LIB_CONST = 2; + + function test() public { + assembly { + function swap(emptyPtr) { + mstore(emptyPtr, LIB_CONST) + mstore(emptyPtr, TOP_LEVEL_CONST) + } + } + } +} + +uint256 constant TOP_LEVEL_CONST = 0; diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..d14a31e3bf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or Equal or EqualColon or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulJumpKeyword or YulJumpiKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulSha3Keyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStopKeyword or YulSubKeyword or YulSuicideKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt new file mode 100644 index 0000000000..d64f0a606b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or Equal or EqualColon or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulJumpKeyword or YulJumpiKeyword or YulKeccak256Keyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulSha3Keyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSuicideKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..a85be30fd2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt new file mode 100644 index 0000000000..a50ffd562b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ──┬── + │ ╰──── def: 3 + 5 │ let r := add(x.y.z, 20) + │ ┬ ──┬── + │ ╰─────────────── def: 4 + │ │ + │ ╰──── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..13ec567204 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt new file mode 100644 index 0000000000..ba89cdf44b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBaseFeeKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulPrevRandaoKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt new file mode 100644 index 0000000000..1a4a9715b3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBaseFeeKeyword or YulBlobBaseFeeKeyword or YulBlobHashKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMCopyKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulPrevRandaoKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTLoadKeyword or YulTStoreKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt new file mode 100644 index 0000000000..7572b37c42 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBaseFeeKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol new file mode 100644 index 0000000000..84beae31ee --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test() public { + assembly { + let x.y.z := 0 + let r := add(x.y.z, 20) + } + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt new file mode 100644 index 0000000000..6e244c0dcf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data.slot) + │ ┬ ──┬─ ──┬─ + │ ╰───────────────────── def: 4 + │ │ │ + │ ╰──────── ref: 2 + │ │ + │ ╰─── ref: built-in + 6 │ let o := sload(data.offset) + │ ┬ ──┬─ ───┬── + │ ╰─────────────────────── def: 5 + │ │ │ + │ ╰────────── ref: 2 + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt new file mode 100644 index 0000000000..6ec15facf8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data.slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── unresolved + 6 │ let o := sload(data.offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt new file mode 100644 index 0000000000..6e244c0dcf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data.slot) + │ ┬ ──┬─ ──┬─ + │ ╰───────────────────── def: 4 + │ │ │ + │ ╰──────── ref: 2 + │ │ + │ ╰─── ref: built-in + 6 │ let o := sload(data.offset) + │ ┬ ──┬─ ───┬── + │ ╰─────────────────────── def: 5 + │ │ │ + │ ╰────────── ref: 2 + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol new file mode 100644 index 0000000000..e35896c309 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol @@ -0,0 +1,9 @@ +contract Test { + bytes data; + function test() public { + assembly { + let s := sload(data.slot) + let o := sload(data.offset) + } + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt new file mode 100644 index 0000000000..bb7557764a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data_slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── ref: built-in + 6 │ let o := sload(data_offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..8745d145dd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data_slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── unresolved + 6 │ let o := sload(data_offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol new file mode 100644 index 0000000000..67caad33a2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol @@ -0,0 +1,9 @@ +contract Test { + bytes data; + function test() public { + assembly { + let s := sload(data_slot) + let o := sload(data_offset) + } + } +}