mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into HEAD
This commit is contained in:
commit
4d681fb16d
@ -52,7 +52,7 @@ configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/licens
|
|||||||
include(EthOptions)
|
include(EthOptions)
|
||||||
configure_project(TESTS)
|
configure_project(TESTS)
|
||||||
|
|
||||||
add_subdirectory(libdevcore)
|
add_subdirectory(libsolutil)
|
||||||
add_subdirectory(liblangutil)
|
add_subdirectory(liblangutil)
|
||||||
add_subdirectory(libevmasm)
|
add_subdirectory(libevmasm)
|
||||||
add_subdirectory(libyul)
|
add_subdirectory(libyul)
|
||||||
|
@ -211,7 +211,7 @@ for (map<ComplexTypeOne, ComplexTypeTwo>::iterator i = l.begin(); i != l.end();
|
|||||||
|
|
||||||
## 12. Include Headers
|
## 12. Include Headers
|
||||||
|
|
||||||
1. Includes should go in increasing order of generality (`libsolidity` -> `libevmasm` -> `libdevcore` -> `boost` -> `STL`).
|
1. Includes should go in increasing order of generality (`libsolidity` -> `libevmasm` -> `libsolutil` -> `boost` -> `STL`).
|
||||||
2. The corresponding `.h` file should be the first include in the respective `.cpp` file.
|
2. The corresponding `.h` file should be the first include in the respective `.cpp` file.
|
||||||
3. Insert empty lines between blocks of include files.
|
3. Insert empty lines between blocks of include files.
|
||||||
|
|
||||||
@ -226,8 +226,8 @@ Example:
|
|||||||
|
|
||||||
#include <libevmasm/GasMeter.h>
|
#include <libevmasm/GasMeter.h>
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/SHA3.h>
|
#include <libsolutil/SHA3.h>
|
||||||
|
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
25
Changelog.md
25
Changelog.md
@ -9,18 +9,28 @@ Compiler Features:
|
|||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
||||||
|
|
||||||
|
### 0.6.2 (unreleased)
|
||||||
### 0.6.1 (unreleased)
|
|
||||||
|
|
||||||
Language Features:
|
Language Features:
|
||||||
|
* Allow accessing external functions via contract and interface names to obtain their selector.
|
||||||
|
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
|
* General: Raise warning if runtime bytecode exceeds 24576 bytes (a limit introduced in Spurious Dragon).
|
||||||
|
* Yul Optimizer: Apply penalty when trying to rematerialize into loops.
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
||||||
|
|
||||||
|
Build System:
|
||||||
|
* Switch to building soljson.js with an embedded base64-encoded wasm binary.
|
||||||
|
|
||||||
|
|
||||||
|
### 0.6.1 (2020-01-02)
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements.
|
||||||
|
|
||||||
|
|
||||||
### 0.6.0 (2019-12-17)
|
### 0.6.0 (2019-12-17)
|
||||||
|
|
||||||
@ -57,6 +67,7 @@ Language Features:
|
|||||||
* Allow global enums and structs.
|
* Allow global enums and structs.
|
||||||
* Allow public variables to override external functions.
|
* Allow public variables to override external functions.
|
||||||
* Allow underscores as delimiters in hex strings.
|
* Allow underscores as delimiters in hex strings.
|
||||||
|
* Allow to react on failing external calls using ``try`` and ``catch``.
|
||||||
* Introduce syntax for array slices and implement them for dynamic calldata arrays.
|
* Introduce syntax for array slices and implement them for dynamic calldata arrays.
|
||||||
* Introduce ``push()`` for dynamic storage arrays. It returns a reference to the newly allocated element, if applicable.
|
* Introduce ``push()`` for dynamic storage arrays. It returns a reference to the newly allocated element, if applicable.
|
||||||
* Introduce ``virtual`` and ``override`` keywords.
|
* Introduce ``virtual`` and ``override`` keywords.
|
||||||
@ -69,6 +80,12 @@ Compiler Features:
|
|||||||
* ABIEncoderV2: Do not warn about enabled ABIEncoderV2 anymore (the pragma is still needed, though).
|
* ABIEncoderV2: Do not warn about enabled ABIEncoderV2 anymore (the pragma is still needed, though).
|
||||||
|
|
||||||
|
|
||||||
|
### 0.5.16 (2020-01-02)
|
||||||
|
|
||||||
|
Backported Bugfixes:
|
||||||
|
* Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements.
|
||||||
|
|
||||||
|
|
||||||
### 0.5.15 (2019-12-17)
|
### 0.5.15 (2019-12-17)
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
@ -911,7 +928,7 @@ Features:
|
|||||||
* ABI JSON: Include new field ``stateMutability`` with values ``pure``, ``view``,
|
* ABI JSON: Include new field ``stateMutability`` with values ``pure``, ``view``,
|
||||||
``nonpayable`` and ``payable``.
|
``nonpayable`` and ``payable``.
|
||||||
* Analyzer: Experimental partial support for Z3 SMT checker ("SMTChecker").
|
* Analyzer: Experimental partial support for Z3 SMT checker ("SMTChecker").
|
||||||
* Build System: Shared libraries (``libdevcore``, ``libevmasm``, ``libsolidity``
|
* Build System: Shared libraries (``libsolutil``, ``libevmasm``, ``libsolidity``
|
||||||
and ``liblll``) are no longer produced during the build process.
|
and ``liblll``) are no longer produced during the build process.
|
||||||
* Code generator: Experimental new implementation of ABI encoder that can
|
* Code generator: Experimental new implementation of ABI encoder that can
|
||||||
encode arbitrarily nested arrays ("ABIEncoderV2")
|
encode arbitrarily nested arrays ("ABIEncoderV2")
|
||||||
|
@ -110,9 +110,13 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s STRICT=1")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s STRICT=1")
|
||||||
# Export the Emscripten-generated auxiliary methods which are needed by solc-js.
|
# Export the Emscripten-generated auxiliary methods which are needed by solc-js.
|
||||||
# Which methods of libsolc itself are exported is specified in libsolc/CMakeLists.txt.
|
# Which methods of libsolc itself are exported is specified in libsolc/CMakeLists.txt.
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap','addFunction','removeFunction','UTF8ToString','lengthBytesUTF8','_malloc','stringToUTF8','setValue']")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap','addFunction','removeFunction','UTF8ToString','lengthBytesUTF8','stringToUTF8','setValue']")
|
||||||
# Do not build as a WebAssembly target - we need an asm.js output.
|
# Build for webassembly target.
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=0")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
|
||||||
|
# Set webassembly build to synchronous loading.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM_ASYNC_COMPILATION=0")
|
||||||
|
# Output a single js file with the wasm binary embedded as base64 string.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s SINGLE_FILE=1")
|
||||||
|
|
||||||
# Disable warnings about not being pure asm.js due to memory growth.
|
# Disable warnings about not being pure asm.js due to memory growth.
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-almost-asm")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-almost-asm")
|
||||||
|
@ -1,4 +1,26 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"name": "YulOptimizerRedundantAssignmentBreakContinue",
|
||||||
|
"summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.",
|
||||||
|
"description": "The Yul optimizer has a stage that removes assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.",
|
||||||
|
"introduced": "0.6.0",
|
||||||
|
"fixed": "0.6.1",
|
||||||
|
"severity": "medium",
|
||||||
|
"conditions": {
|
||||||
|
"yulOptimizer": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "YulOptimizerRedundantAssignmentBreakContinue0.5",
|
||||||
|
"summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.",
|
||||||
|
"description": "The Yul optimizer has a stage that removes assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.",
|
||||||
|
"introduced": "0.5.8",
|
||||||
|
"fixed": "0.5.16",
|
||||||
|
"severity": "low",
|
||||||
|
"conditions": {
|
||||||
|
"yulOptimizer": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ABIEncoderV2LoopYulOptimizer",
|
"name": "ABIEncoderV2LoopYulOptimizer",
|
||||||
"summary": "If both the experimental ABIEncoderV2 and the experimental Yul optimizer are activated, one component of the Yul optimizer may reuse data in memory that has been changed in the meantime.",
|
"summary": "If both the experimental ABIEncoderV2 and the experimental Yul optimizer are activated, one component of the Yul optimizer may reuse data in memory that has been changed in the meantime.",
|
||||||
|
@ -742,32 +742,46 @@
|
|||||||
},
|
},
|
||||||
"0.5.10": {
|
"0.5.10": {
|
||||||
"bugs": [
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5",
|
||||||
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers"
|
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers"
|
||||||
],
|
],
|
||||||
"released": "2019-06-25"
|
"released": "2019-06-25"
|
||||||
},
|
},
|
||||||
"0.5.11": {
|
"0.5.11": {
|
||||||
"bugs": [],
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5"
|
||||||
|
],
|
||||||
"released": "2019-08-12"
|
"released": "2019-08-12"
|
||||||
},
|
},
|
||||||
"0.5.12": {
|
"0.5.12": {
|
||||||
"bugs": [],
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5"
|
||||||
|
],
|
||||||
"released": "2019-10-01"
|
"released": "2019-10-01"
|
||||||
},
|
},
|
||||||
"0.5.13": {
|
"0.5.13": {
|
||||||
"bugs": [],
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5"
|
||||||
|
],
|
||||||
"released": "2019-11-14"
|
"released": "2019-11-14"
|
||||||
},
|
},
|
||||||
"0.5.14": {
|
"0.5.14": {
|
||||||
"bugs": [
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5",
|
||||||
"ABIEncoderV2LoopYulOptimizer"
|
"ABIEncoderV2LoopYulOptimizer"
|
||||||
],
|
],
|
||||||
"released": "2019-12-09"
|
"released": "2019-12-09"
|
||||||
},
|
},
|
||||||
"0.5.15": {
|
"0.5.15": {
|
||||||
"bugs": [],
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5"
|
||||||
|
],
|
||||||
"released": "2019-12-17"
|
"released": "2019-12-17"
|
||||||
},
|
},
|
||||||
|
"0.5.16": {
|
||||||
|
"bugs": [],
|
||||||
|
"released": "2020-01-02"
|
||||||
|
},
|
||||||
"0.5.2": {
|
"0.5.2": {
|
||||||
"bugs": [
|
"bugs": [
|
||||||
"SignedArrayStorageCopy",
|
"SignedArrayStorageCopy",
|
||||||
@ -840,6 +854,7 @@
|
|||||||
},
|
},
|
||||||
"0.5.8": {
|
"0.5.8": {
|
||||||
"bugs": [
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5",
|
||||||
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
|
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
|
||||||
"SignedArrayStorageCopy",
|
"SignedArrayStorageCopy",
|
||||||
"ABIEncoderV2StorageArrayWithMultiSlotElement",
|
"ABIEncoderV2StorageArrayWithMultiSlotElement",
|
||||||
@ -849,6 +864,7 @@
|
|||||||
},
|
},
|
||||||
"0.5.9": {
|
"0.5.9": {
|
||||||
"bugs": [
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue0.5",
|
||||||
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
|
"ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers",
|
||||||
"SignedArrayStorageCopy",
|
"SignedArrayStorageCopy",
|
||||||
"ABIEncoderV2StorageArrayWithMultiSlotElement"
|
"ABIEncoderV2StorageArrayWithMultiSlotElement"
|
||||||
@ -856,7 +872,13 @@
|
|||||||
"released": "2019-05-28"
|
"released": "2019-05-28"
|
||||||
},
|
},
|
||||||
"0.6.0": {
|
"0.6.0": {
|
||||||
"bugs": [],
|
"bugs": [
|
||||||
|
"YulOptimizerRedundantAssignmentBreakContinue"
|
||||||
|
],
|
||||||
"released": "2019-12-17"
|
"released": "2019-12-17"
|
||||||
|
},
|
||||||
|
"0.6.1": {
|
||||||
|
"bugs": [],
|
||||||
|
"released": "2020-01-02"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,12 +39,12 @@ if they are marked ``virtual``. For details, please see
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract mortal is owned {
|
contract destructible is owned {
|
||||||
// This contract inherits the `onlyOwner` modifier from
|
// This contract inherits the `onlyOwner` modifier from
|
||||||
// `owned` and applies it to the `close` function, which
|
// `owned` and applies it to the `destroy` function, which
|
||||||
// causes that calls to `close` only have an effect if
|
// causes that calls to `destroy` only have an effect if
|
||||||
// they are made by the stored owner.
|
// they are made by the stored owner.
|
||||||
function close() public onlyOwner {
|
function destroy() public onlyOwner {
|
||||||
selfdestruct(owner);
|
selfdestruct(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ if they are marked ``virtual``. For details, please see
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Register is priced, owned {
|
contract Register is priced, destructible {
|
||||||
mapping (address => bool) registeredAddresses;
|
mapping (address => bool) registeredAddresses;
|
||||||
uint price;
|
uint price;
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ Details are given in the following example.
|
|||||||
// contracts can access all non-private members including
|
// contracts can access all non-private members including
|
||||||
// internal functions and state variables. These cannot be
|
// internal functions and state variables. These cannot be
|
||||||
// accessed externally via `this`, though.
|
// accessed externally via `this`, though.
|
||||||
contract Mortal is Owned {
|
contract Destructible is Owned {
|
||||||
// The keyword `virtual` means that the function can change
|
// The keyword `virtual` means that the function can change
|
||||||
// its behaviour in derived classes ("overriding").
|
// its behaviour in derived classes ("overriding").
|
||||||
function kill() virtual public {
|
function destroy() virtual public {
|
||||||
if (msg.sender == owner) selfdestruct(owner);
|
if (msg.sender == owner) selfdestruct(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,9 +76,9 @@ Details are given in the following example.
|
|||||||
|
|
||||||
|
|
||||||
// Multiple inheritance is possible. Note that `owned` is
|
// Multiple inheritance is possible. Note that `owned` is
|
||||||
// also a base class of `mortal`, yet there is only a single
|
// also a base class of `Destructible`, yet there is only a single
|
||||||
// instance of `owned` (as for virtual inheritance in C++).
|
// instance of `owned` (as for virtual inheritance in C++).
|
||||||
contract Named is Owned, Mortal {
|
contract Named is Owned, Destructible {
|
||||||
constructor(bytes32 name) public {
|
constructor(bytes32 name) public {
|
||||||
Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
|
Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
|
||||||
NameReg(config.lookup(1)).register(name);
|
NameReg(config.lookup(1)).register(name);
|
||||||
@ -92,13 +92,13 @@ Details are given in the following example.
|
|||||||
// If you want the function to override, you need to use the
|
// If you want the function to override, you need to use the
|
||||||
// `override` keyword. You need to specify the `virtual` keyword again
|
// `override` keyword. You need to specify the `virtual` keyword again
|
||||||
// if you want this function to be overridden again.
|
// if you want this function to be overridden again.
|
||||||
function kill() public virtual override {
|
function destroy() public virtual override {
|
||||||
if (msg.sender == owner) {
|
if (msg.sender == owner) {
|
||||||
Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
|
Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
|
||||||
NameReg(config.lookup(1)).unregister();
|
NameReg(config.lookup(1)).unregister();
|
||||||
// It is still possible to call a specific
|
// It is still possible to call a specific
|
||||||
// overridden function.
|
// overridden function.
|
||||||
Mortal.kill();
|
Destructible.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,21 +107,21 @@ Details are given in the following example.
|
|||||||
// If a constructor takes an argument, it needs to be
|
// If a constructor takes an argument, it needs to be
|
||||||
// provided in the header (or modifier-invocation-style at
|
// provided in the header (or modifier-invocation-style at
|
||||||
// the constructor of the derived contract (see below)).
|
// the constructor of the derived contract (see below)).
|
||||||
contract PriceFeed is Owned, Mortal, Named("GoldFeed") {
|
contract PriceFeed is Owned, Destructible, Named("GoldFeed") {
|
||||||
function updateInfo(uint newInfo) public {
|
function updateInfo(uint newInfo) public {
|
||||||
if (msg.sender == owner) info = newInfo;
|
if (msg.sender == owner) info = newInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here, we only specify `override` and not `virtual`.
|
// Here, we only specify `override` and not `virtual`.
|
||||||
// This means that contracts deriving from `PriceFeed`
|
// This means that contracts deriving from `PriceFeed`
|
||||||
// cannot change the behaviour of `kill` anymore.
|
// cannot change the behaviour of `destroy` anymore.
|
||||||
function kill() public override(Mortal, Named) { Named.kill(); }
|
function destroy() public override(Destructible, Named) { Named.destroy(); }
|
||||||
function get() public view returns(uint r) { return info; }
|
function get() public view returns(uint r) { return info; }
|
||||||
|
|
||||||
uint info;
|
uint info;
|
||||||
}
|
}
|
||||||
|
|
||||||
Note that above, we call ``mortal.kill()`` to "forward" the
|
Note that above, we call ``Destructible.destroy()`` to "forward" the
|
||||||
destruction request. The way this is done is problematic, as
|
destruction request. The way this is done is problematic, as
|
||||||
seen in the following example::
|
seen in the following example::
|
||||||
|
|
||||||
@ -132,27 +132,27 @@ seen in the following example::
|
|||||||
address payable owner;
|
address payable owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
contract mortal is owned {
|
contract Destructible is owned {
|
||||||
function kill() public virtual {
|
function destroy() public virtual {
|
||||||
if (msg.sender == owner) selfdestruct(owner);
|
if (msg.sender == owner) selfdestruct(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Base1 is mortal {
|
contract Base1 is Destructible {
|
||||||
function kill() public virtual override { /* do cleanup 1 */ mortal.kill(); }
|
function destroy() public virtual override { /* do cleanup 1 */ Destructible.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Base2 is mortal {
|
contract Base2 is Destructible {
|
||||||
function kill() public virtual override { /* do cleanup 2 */ mortal.kill(); }
|
function destroy() public virtual override { /* do cleanup 2 */ Destructible.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Final is Base1, Base2 {
|
contract Final is Base1, Base2 {
|
||||||
function kill() public override(Base1, Base2) { Base2.kill(); }
|
function destroy() public override(Base1, Base2) { Base2.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
A call to ``Final.kill()`` will call ``Base2.kill`` because we specify it
|
A call to ``Final.destroy()`` will call ``Base2.destroy`` because we specify it
|
||||||
explicitly in the final override, but this function will bypass
|
explicitly in the final override, but this function will bypass
|
||||||
``Base1.kill``. The way around this is to use ``super``::
|
``Base1.destroy``. The way around this is to use ``super``::
|
||||||
|
|
||||||
pragma solidity >=0.4.22 <0.8.0;
|
pragma solidity >=0.4.22 <0.8.0;
|
||||||
|
|
||||||
@ -161,31 +161,31 @@ explicitly in the final override, but this function will bypass
|
|||||||
address payable owner;
|
address payable owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
contract mortal is owned {
|
contract Destructible is owned {
|
||||||
function kill() virtual public {
|
function destroy() virtual public {
|
||||||
if (msg.sender == owner) selfdestruct(owner);
|
if (msg.sender == owner) selfdestruct(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Base1 is mortal {
|
contract Base1 is Destructible {
|
||||||
function kill() public virtual override { /* do cleanup 1 */ super.kill(); }
|
function destroy() public virtual override { /* do cleanup 1 */ super.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Base2 is mortal {
|
contract Base2 is Destructible {
|
||||||
function kill() public virtual override { /* do cleanup 2 */ super.kill(); }
|
function destroy() public virtual override { /* do cleanup 2 */ super.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Final is Base1, Base2 {
|
contract Final is Base1, Base2 {
|
||||||
function kill() public override(Base1, Base2) { super.kill(); }
|
function destroy() public override(Base1, Base2) { super.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
If ``Base2`` calls a function of ``super``, it does not simply
|
If ``Base2`` calls a function of ``super``, it does not simply
|
||||||
call this function on one of its base contracts. Rather, it
|
call this function on one of its base contracts. Rather, it
|
||||||
calls this function on the next base contract in the final
|
calls this function on the next base contract in the final
|
||||||
inheritance graph, so it will call ``Base1.kill()`` (note that
|
inheritance graph, so it will call ``Base1.destroy()`` (note that
|
||||||
the final inheritance sequence is -- starting with the most
|
the final inheritance sequence is -- starting with the most
|
||||||
derived contract: Final, Base2, Base1, mortal, owned).
|
derived contract: Final, Base2, Base1, Destructible, owned).
|
||||||
The actual function that is called when using super is
|
The actual function that is called when using super is
|
||||||
not known in the context of the class where it is used,
|
not known in the context of the class where it is used,
|
||||||
although its type is known. This is similar for ordinary
|
although its type is known. This is similar for ordinary
|
||||||
|
@ -164,7 +164,7 @@ The full contract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// destroy the contract and reclaim the leftover funds.
|
/// destroy the contract and reclaim the leftover funds.
|
||||||
function kill() public {
|
function shutdown() public {
|
||||||
require(msg.sender == owner);
|
require(msg.sender == owner);
|
||||||
selfdestruct(msg.sender);
|
selfdestruct(msg.sender);
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,12 @@ StructDefinition = 'struct' Identifier '{'
|
|||||||
ModifierDefinition = 'modifier' Identifier ParameterList? ( 'virtual' | OverrideSpecifier )* Block
|
ModifierDefinition = 'modifier' Identifier ParameterList? ( 'virtual' | OverrideSpecifier )* Block
|
||||||
ModifierInvocation = Identifier ( '(' ExpressionList? ')' )?
|
ModifierInvocation = Identifier ( '(' ExpressionList? ')' )?
|
||||||
|
|
||||||
FunctionDefinition = 'function' Identifier? ParameterList
|
FunctionDefinition = FunctionDescriptor ParameterList
|
||||||
( ModifierInvocation | StateMutability | 'external' | 'public' | 'internal' | 'private' | 'virtual' | OverrideSpecifier )*
|
( ModifierInvocation | StateMutability | 'external' | 'public' | 'internal' | 'private' | 'virtual' | OverrideSpecifier )*
|
||||||
( 'returns' ParameterList )? ( ';' | Block )
|
( 'returns' ParameterList )? ( ';' | Block )
|
||||||
|
|
||||||
|
FunctionDescriptor = 'function' Identifier | 'constructor' | 'fallback' | 'receive'
|
||||||
|
|
||||||
OverrideSpecifier = 'override' ( '(' UserDefinedTypeName (',' UserDefinedTypeName)* ')' )?
|
OverrideSpecifier = 'override' ( '(' UserDefinedTypeName (',' UserDefinedTypeName)* ')' )?
|
||||||
|
|
||||||
EventDefinition = 'event' Identifier EventParameterList 'anonymous'? ';'
|
EventDefinition = 'event' Identifier EventParameterList 'anonymous'? ';'
|
||||||
@ -72,7 +74,7 @@ Statement = IfStatement | TryStatement | WhileStatement | ForStatement | Block |
|
|||||||
ExpressionStatement = Expression
|
ExpressionStatement = Expression
|
||||||
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
||||||
TryStatement = 'try' Expression ( 'returns' ParameterList )? Block CatchClause+
|
TryStatement = 'try' Expression ( 'returns' ParameterList )? Block CatchClause+
|
||||||
CatchClause = 'catch' Identifier? ParameterList Block
|
CatchClause = 'catch' ( Identifier? ParameterList )? Block
|
||||||
WhileStatement = 'while' '(' Expression ')' Statement
|
WhileStatement = 'while' '(' Expression ')' Statement
|
||||||
PlaceholderStatement = '_'
|
PlaceholderStatement = '_'
|
||||||
SimpleStatement = VariableDefinition | ExpressionStatement
|
SimpleStatement = VariableDefinition | ExpressionStatement
|
||||||
|
@ -56,11 +56,11 @@ explanatory purposes.
|
|||||||
// Swarm URL is recommended
|
// Swarm URL is recommended
|
||||||
"urls": [ "bzzr://56ab..." ]
|
"urls": [ "bzzr://56ab..." ]
|
||||||
},
|
},
|
||||||
"mortal": {
|
"destructible": {
|
||||||
// Required: keccak256 hash of the source file
|
// Required: keccak256 hash of the source file
|
||||||
"keccak256": "0x234...",
|
"keccak256": "0x234...",
|
||||||
// Required (unless "url" is used): literal contents of the source file
|
// Required (unless "url" is used): literal contents of the source file
|
||||||
"content": "contract mortal is owned { function kill() { if (msg.sender == owner) selfdestruct(owner); } }"
|
"content": "contract destructible is owned { function destroy() { if (msg.sender == owner) selfdestruct(owner); } }"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Required: Compiler settings
|
// Required: Compiler settings
|
||||||
|
@ -33,7 +33,7 @@ Solidity Integrations
|
|||||||
* `Solidity IDE <https://github.com/System-Glitch/Solidity-IDE>`_
|
* `Solidity IDE <https://github.com/System-Glitch/Solidity-IDE>`_
|
||||||
Browser-based IDE with integrated compiler, Ganache and local file system support.
|
Browser-based IDE with integrated compiler, Ganache and local file system support.
|
||||||
|
|
||||||
* `Solium <https://github.com/duaraghav8/Solium/>`_
|
* `Ethlint <https://github.com/duaraghav8/Ethlint>`_
|
||||||
Linter to identify and fix style and security issues in Solidity.
|
Linter to identify and fix style and security issues in Solidity.
|
||||||
|
|
||||||
* `Superblocks Lab <https://lab.superblocks.com/>`_
|
* `Superblocks Lab <https://lab.superblocks.com/>`_
|
||||||
@ -48,7 +48,7 @@ Solidity Integrations
|
|||||||
Plugin for the Atom editor that provides Solidity linting.
|
Plugin for the Atom editor that provides Solidity linting.
|
||||||
|
|
||||||
* `Atom Solium Linter <https://atom.io/packages/linter-solium>`_
|
* `Atom Solium Linter <https://atom.io/packages/linter-solium>`_
|
||||||
Configurable Solidty linter for Atom using Solium as a base.
|
Configurable Solidity linter for Atom using Solium (now Ethlint) as a base.
|
||||||
|
|
||||||
* Eclipse:
|
* Eclipse:
|
||||||
|
|
||||||
@ -97,23 +97,38 @@ Discontinued:
|
|||||||
Solidity Tools
|
Solidity Tools
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
* `ABI to Solidity interface converter <https://gist.github.com/chriseth/8f533d133fa0c15b0d6eaf3ec502c82b>`_
|
||||||
|
A script for generating contract interfaces from the ABI of a smart contract.
|
||||||
|
|
||||||
* `Dapp <https://dapp.tools/dapp/>`_
|
* `Dapp <https://dapp.tools/dapp/>`_
|
||||||
Build tool, package manager, and deployment assistant for Solidity.
|
Build tool, package manager, and deployment assistant for Solidity.
|
||||||
|
|
||||||
* `Solidity REPL <https://github.com/raineorshine/solidity-repl>`_
|
|
||||||
Try Solidity instantly with a command-line Solidity console.
|
|
||||||
|
|
||||||
* `solgraph <https://github.com/raineorshine/solgraph>`_
|
|
||||||
Visualize Solidity control flow and highlight potential security vulnerabilities.
|
|
||||||
|
|
||||||
* `Doxity <https://github.com/DigixGlobal/doxity>`_
|
* `Doxity <https://github.com/DigixGlobal/doxity>`_
|
||||||
Documentation Generator for Solidity.
|
Documentation Generator for Solidity.
|
||||||
|
|
||||||
* `evmdis <https://github.com/Arachnid/evmdis>`_
|
* `evmdis <https://github.com/Arachnid/evmdis>`_
|
||||||
EVM Disassembler that performs static analysis on the bytecode to provide a higher level of abstraction than raw EVM operations.
|
EVM Disassembler that performs static analysis on the bytecode to provide a higher level of abstraction than raw EVM operations.
|
||||||
|
|
||||||
* `ABI to solidity interface converter <https://gist.github.com/chriseth/8f533d133fa0c15b0d6eaf3ec502c82b>`_
|
* `EVM Lab <https://github.com/ethereum/evmlab/>`_
|
||||||
A script for generating contract interfaces from the ABI of a smart contract.
|
Rich tool package to interact with the EVM. Includes a VM, Etherchain API, and a trace-viewer with gas cost display.
|
||||||
|
|
||||||
|
* `leafleth <https://github.com/clemlak/leafleth>`_
|
||||||
|
A documentation generator for Solidity smart-contracts.
|
||||||
|
|
||||||
|
* `PIET <https://piet.slock.it/>`_
|
||||||
|
A tool to develop, audit and use Solidity smart contracts through a simple graphical interface.
|
||||||
|
|
||||||
|
* `solc-select <https://github.com/crytic/solc-select>`_
|
||||||
|
A script to quickly switch between Solidity compiler versions.
|
||||||
|
|
||||||
|
* `Solidity prettier plugin <https://github.com/prettier-solidity/prettier-plugin-solidity>`_
|
||||||
|
A Prettier Plugin for Solidity.
|
||||||
|
|
||||||
|
* `Solidity REPL <https://github.com/raineorshine/solidity-repl>`_
|
||||||
|
Try Solidity instantly with a command-line Solidity console.
|
||||||
|
|
||||||
|
* `solgraph <https://github.com/raineorshine/solgraph>`_
|
||||||
|
Visualize Solidity control flow and highlight potential security vulnerabilities.
|
||||||
|
|
||||||
* `Securify <https://securify.ch/>`_
|
* `Securify <https://securify.ch/>`_
|
||||||
Fully automated online static analyzer for smart contracts, providing a security report based on vulnerability patterns.
|
Fully automated online static analyzer for smart contracts, providing a security report based on vulnerability patterns.
|
||||||
@ -121,18 +136,9 @@ Solidity Tools
|
|||||||
* `Sūrya <https://github.com/ConsenSys/surya/>`_
|
* `Sūrya <https://github.com/ConsenSys/surya/>`_
|
||||||
Utility tool for smart contract systems, offering a number of visual outputs and information about the contracts' structure. Also supports querying the function call graph.
|
Utility tool for smart contract systems, offering a number of visual outputs and information about the contracts' structure. Also supports querying the function call graph.
|
||||||
|
|
||||||
* `EVM Lab <https://github.com/ethereum/evmlab/>`_
|
|
||||||
Rich tool package to interact with the EVM. Includes a VM, Etherchain API, and a trace-viewer with gas cost display.
|
|
||||||
|
|
||||||
* `Universal Mutator <https://github.com/agroce/universalmutator>`_
|
* `Universal Mutator <https://github.com/agroce/universalmutator>`_
|
||||||
A tool for mutation generation, with configurable rules and support for Solidity and Vyper.
|
A tool for mutation generation, with configurable rules and support for Solidity and Vyper.
|
||||||
|
|
||||||
* `PIET <https://piet.slock.it/>`_
|
|
||||||
A tool to develop, audit and use solidity smart contracts through a simple graphical interface.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
Information like variable names, comments, and source code formatting is lost in the compilation process and it is not possible to completely recover the original source code. Decompiling smart contracts to view the original source code might not be possible, or the end result that useful.
|
|
||||||
|
|
||||||
Third-Party Solidity Parsers and Grammars
|
Third-Party Solidity Parsers and Grammars
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ Yes::
|
|||||||
return balanceOf[from];
|
return balanceOf[from];
|
||||||
}
|
}
|
||||||
|
|
||||||
function kill() public onlyowner {
|
function shutdown() public onlyowner {
|
||||||
selfdestruct(owner);
|
selfdestruct(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,7 +594,7 @@ No::
|
|||||||
return balanceOf[from];
|
return balanceOf[from];
|
||||||
}
|
}
|
||||||
|
|
||||||
function kill() onlyowner public {
|
function shutdown() onlyowner public {
|
||||||
selfdestruct(owner);
|
selfdestruct(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,12 +180,12 @@ Input Description
|
|||||||
// `--allow-paths <path>`.
|
// `--allow-paths <path>`.
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mortal":
|
"destructible":
|
||||||
{
|
{
|
||||||
// Optional: keccak256 hash of the source file
|
// Optional: keccak256 hash of the source file
|
||||||
"keccak256": "0x234...",
|
"keccak256": "0x234...",
|
||||||
// Required (unless "urls" is used): literal contents of the source file
|
// Required (unless "urls" is used): literal contents of the source file
|
||||||
"content": "contract mortal is owned { function kill() { if (msg.sender == owner) selfdestruct(owner); } }"
|
"content": "contract destructible is owned { function shutdown() { if (msg.sender == owner) selfdestruct(owner); } }"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Optional
|
// Optional
|
||||||
@ -220,8 +220,11 @@ Input Description
|
|||||||
"cse": false,
|
"cse": false,
|
||||||
// Optimize representation of literal numbers and strings in code.
|
// Optimize representation of literal numbers and strings in code.
|
||||||
"constantOptimizer": false,
|
"constantOptimizer": false,
|
||||||
// The new Yul optimizer. Mostly operates on the code of ABIEncoderV2.
|
// The new Yul optimizer. Mostly operates on the code of ABIEncoderV2
|
||||||
// It can only be activated through the details here.
|
// and inline assembly.
|
||||||
|
// It is activated together with the global optimizer setting
|
||||||
|
// and can be deactivated here.
|
||||||
|
// Before Solidity 0.6.0 it had to be activated through this switch.
|
||||||
"yul": false,
|
"yul": false,
|
||||||
// Tuning options for the Yul optimizer.
|
// Tuning options for the Yul optimizer.
|
||||||
"yulDetails": {
|
"yulDetails": {
|
||||||
|
@ -33,9 +33,10 @@
|
|||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
using namespace solidity::util;
|
||||||
|
|
||||||
void Assembly::append(Assembly const& _a)
|
void Assembly::append(Assembly const& _a)
|
||||||
{
|
{
|
||||||
@ -105,7 +106,7 @@ unsigned Assembly::bytesRequired(unsigned subTagSize) const
|
|||||||
|
|
||||||
for (AssemblyItem const& i: m_items)
|
for (AssemblyItem const& i: m_items)
|
||||||
ret += i.bytesRequired(tagSize);
|
ret += i.bytesRequired(tagSize);
|
||||||
if (dev::bytesRequired(ret) <= tagSize)
|
if (util::bytesRequired(ret) <= tagSize)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,15 +291,15 @@ Json::Value Assembly::assemblyJSON(StringMap const& _sourceCodes) const
|
|||||||
createJsonValue("PUSH [ErrorTag]", i.location().start, i.location().end, ""));
|
createJsonValue("PUSH [ErrorTag]", i.location().start, i.location().end, ""));
|
||||||
else
|
else
|
||||||
collection.append(
|
collection.append(
|
||||||
createJsonValue("PUSH [tag]", i.location().start, i.location().end, dev::toString(i.data())));
|
createJsonValue("PUSH [tag]", i.location().start, i.location().end, toString(i.data())));
|
||||||
break;
|
break;
|
||||||
case PushSub:
|
case PushSub:
|
||||||
collection.append(
|
collection.append(
|
||||||
createJsonValue("PUSH [$]", i.location().start, i.location().end, dev::toString(h256(i.data()))));
|
createJsonValue("PUSH [$]", i.location().start, i.location().end, toString(h256(i.data()))));
|
||||||
break;
|
break;
|
||||||
case PushSubSize:
|
case PushSubSize:
|
||||||
collection.append(
|
collection.append(
|
||||||
createJsonValue("PUSH #[$]", i.location().start, i.location().end, dev::toString(h256(i.data()))));
|
createJsonValue("PUSH #[$]", i.location().start, i.location().end, toString(h256(i.data()))));
|
||||||
break;
|
break;
|
||||||
case PushProgramSize:
|
case PushProgramSize:
|
||||||
collection.append(
|
collection.append(
|
||||||
@ -316,7 +317,7 @@ Json::Value Assembly::assemblyJSON(StringMap const& _sourceCodes) const
|
|||||||
break;
|
break;
|
||||||
case Tag:
|
case Tag:
|
||||||
collection.append(
|
collection.append(
|
||||||
createJsonValue("tag", i.location().start, i.location().end, dev::toString(i.data())));
|
createJsonValue("tag", i.location().start, i.location().end, toString(i.data())));
|
||||||
collection.append(
|
collection.append(
|
||||||
createJsonValue("JUMPDEST", i.location().start, i.location().end));
|
createJsonValue("JUMPDEST", i.location().start, i.location().end));
|
||||||
break;
|
break;
|
||||||
@ -359,7 +360,7 @@ AssemblyItem Assembly::namedTag(string const& _name)
|
|||||||
|
|
||||||
AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier)
|
AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier)
|
||||||
{
|
{
|
||||||
h256 h(dev::keccak256(_identifier));
|
h256 h(util::keccak256(_identifier));
|
||||||
m_libraries[h] = _identifier;
|
m_libraries[h] = _identifier;
|
||||||
return AssemblyItem{PushLibraryAddress, h};
|
return AssemblyItem{PushLibraryAddress, h};
|
||||||
}
|
}
|
||||||
@ -543,14 +544,14 @@ LinkerObject const& Assembly::assemble() const
|
|||||||
multimap<h256, unsigned> dataRef;
|
multimap<h256, unsigned> dataRef;
|
||||||
multimap<size_t, size_t> subRef;
|
multimap<size_t, size_t> subRef;
|
||||||
vector<unsigned> sizeRef; ///< Pointers to code locations where the size of the program is inserted
|
vector<unsigned> sizeRef; ///< Pointers to code locations where the size of the program is inserted
|
||||||
unsigned bytesPerTag = dev::bytesRequired(bytesRequiredForCode);
|
unsigned bytesPerTag = util::bytesRequired(bytesRequiredForCode);
|
||||||
uint8_t tagPush = (uint8_t)Instruction::PUSH1 - 1 + bytesPerTag;
|
uint8_t tagPush = (uint8_t)Instruction::PUSH1 - 1 + bytesPerTag;
|
||||||
|
|
||||||
unsigned bytesRequiredIncludingData = bytesRequiredForCode + 1 + m_auxiliaryData.size();
|
unsigned bytesRequiredIncludingData = bytesRequiredForCode + 1 + m_auxiliaryData.size();
|
||||||
for (auto const& sub: m_subs)
|
for (auto const& sub: m_subs)
|
||||||
bytesRequiredIncludingData += sub->assemble().bytecode.size();
|
bytesRequiredIncludingData += sub->assemble().bytecode.size();
|
||||||
|
|
||||||
unsigned bytesPerDataRef = dev::bytesRequired(bytesRequiredIncludingData);
|
unsigned bytesPerDataRef = util::bytesRequired(bytesRequiredIncludingData);
|
||||||
uint8_t dataRefPush = (uint8_t)Instruction::PUSH1 - 1 + bytesPerDataRef;
|
uint8_t dataRefPush = (uint8_t)Instruction::PUSH1 - 1 + bytesPerDataRef;
|
||||||
ret.bytecode.reserve(bytesRequiredIncludingData);
|
ret.bytecode.reserve(bytesRequiredIncludingData);
|
||||||
|
|
||||||
@ -580,7 +581,7 @@ LinkerObject const& Assembly::assemble() const
|
|||||||
}
|
}
|
||||||
case Push:
|
case Push:
|
||||||
{
|
{
|
||||||
uint8_t b = max<unsigned>(1, dev::bytesRequired(i.data()));
|
uint8_t b = max<unsigned>(1, util::bytesRequired(i.data()));
|
||||||
ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b);
|
ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b);
|
||||||
ret.bytecode.resize(ret.bytecode.size() + b);
|
ret.bytecode.resize(ret.bytecode.size() + b);
|
||||||
bytesRef byr(&ret.bytecode.back() + 1 - b, b);
|
bytesRef byr(&ret.bytecode.back() + 1 - b, b);
|
||||||
@ -610,7 +611,7 @@ LinkerObject const& Assembly::assemble() const
|
|||||||
assertThrow(i.data() <= size_t(-1), AssemblyException, "");
|
assertThrow(i.data() <= size_t(-1), AssemblyException, "");
|
||||||
auto s = m_subs.at(size_t(i.data()))->assemble().bytecode.size();
|
auto s = m_subs.at(size_t(i.data()))->assemble().bytecode.size();
|
||||||
i.setPushedValue(u256(s));
|
i.setPushedValue(u256(s));
|
||||||
uint8_t b = max<unsigned>(1, dev::bytesRequired(s));
|
uint8_t b = max<unsigned>(1, util::bytesRequired(s));
|
||||||
ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b);
|
ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b);
|
||||||
ret.bytecode.resize(ret.bytecode.size() + b);
|
ret.bytecode.resize(ret.bytecode.size() + b);
|
||||||
bytesRef byr(&ret.bytecode.back() + 1 - b, b);
|
bytesRef byr(&ret.bytecode.back() + 1 - b, b);
|
||||||
@ -675,7 +676,7 @@ LinkerObject const& Assembly::assemble() const
|
|||||||
assertThrow(tagId < tagPositions.size(), AssemblyException, "Reference to non-existing tag.");
|
assertThrow(tagId < tagPositions.size(), AssemblyException, "Reference to non-existing tag.");
|
||||||
size_t pos = tagPositions[tagId];
|
size_t pos = tagPositions[tagId];
|
||||||
assertThrow(pos != size_t(-1), AssemblyException, "Reference to tag without position.");
|
assertThrow(pos != size_t(-1), AssemblyException, "Reference to tag without position.");
|
||||||
assertThrow(dev::bytesRequired(pos) <= bytesPerTag, AssemblyException, "Tag too large for reserved space.");
|
assertThrow(util::bytesRequired(pos) <= bytesPerTag, AssemblyException, "Tag too large for reserved space.");
|
||||||
bytesRef r(ret.bytecode.data() + i.first, bytesPerTag);
|
bytesRef r(ret.bytecode.data() + i.first, bytesPerTag);
|
||||||
toBigEndian(pos, r);
|
toBigEndian(pos, r);
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <libdevcore/Keccak256.h>
|
#include <libsolutil/Keccak256.h>
|
||||||
|
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
|
|
||||||
@ -35,9 +35,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
using AssemblyPointer = std::shared_ptr<Assembly>;
|
using AssemblyPointer = std::shared_ptr<Assembly>;
|
||||||
@ -49,8 +47,8 @@ public:
|
|||||||
AssemblyItem newPushTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(PushTag, m_usedTags++); }
|
AssemblyItem newPushTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(PushTag, m_usedTags++); }
|
||||||
/// Returns a tag identified by the given name. Creates it if it does not yet exist.
|
/// Returns a tag identified by the given name. Creates it if it does not yet exist.
|
||||||
AssemblyItem namedTag(std::string const& _name);
|
AssemblyItem namedTag(std::string const& _name);
|
||||||
AssemblyItem newData(bytes const& _data) { h256 h(dev::keccak256(asString(_data))); m_data[h] = _data; return AssemblyItem(PushData, h); }
|
AssemblyItem newData(bytes const& _data) { util::h256 h(util::keccak256(util::asString(_data))); m_data[h] = _data; return AssemblyItem(PushData, h); }
|
||||||
bytes const& data(h256 const& _i) const { return m_data.at(_i); }
|
bytes const& data(util::h256 const& _i) const { return m_data.at(_i); }
|
||||||
AssemblyItem newSub(AssemblyPointer const& _sub) { m_subs.push_back(_sub); return AssemblyItem(PushSub, m_subs.size() - 1); }
|
AssemblyItem newSub(AssemblyPointer const& _sub) { m_subs.push_back(_sub); return AssemblyItem(PushSub, m_subs.size() - 1); }
|
||||||
Assembly const& sub(size_t _sub) const { return *m_subs.at(_sub); }
|
Assembly const& sub(size_t _sub) const { return *m_subs.at(_sub); }
|
||||||
Assembly& sub(size_t _sub) { return *m_subs.at(_sub); }
|
Assembly& sub(size_t _sub) { return *m_subs.at(_sub); }
|
||||||
@ -141,7 +139,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// These features are only used by LLL
|
// These features are only used by LLL
|
||||||
AssemblyItem newPushString(std::string const& _data) { h256 h(dev::keccak256(_data)); m_strings[h] = _data; return AssemblyItem(PushString, h); }
|
AssemblyItem newPushString(std::string const& _data) { util::h256 h(util::keccak256(_data)); m_strings[h] = _data; return AssemblyItem(PushString, h); }
|
||||||
|
|
||||||
void append(Assembly const& _a);
|
void append(Assembly const& _a);
|
||||||
void append(Assembly const& _a, int _deposit);
|
void append(Assembly const& _a, int _deposit);
|
||||||
@ -149,7 +147,7 @@ public:
|
|||||||
void injectStart(AssemblyItem const& _i);
|
void injectStart(AssemblyItem const& _i);
|
||||||
|
|
||||||
AssemblyItem const& back() const { return m_items.back(); }
|
AssemblyItem const& back() const { return m_items.back(); }
|
||||||
std::string backString() const { return m_items.size() && m_items.back().type() == PushString ? m_strings.at((h256)m_items.back().data()) : std::string(); }
|
std::string backString() const { return m_items.size() && m_items.back().type() == PushString ? m_strings.at((util::h256)m_items.back().data()) : std::string(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Does the same operations as @a optimise, but should only be applied to a sub and
|
/// Does the same operations as @a optimise, but should only be applied to a sub and
|
||||||
@ -168,12 +166,12 @@ protected:
|
|||||||
unsigned m_usedTags = 1;
|
unsigned m_usedTags = 1;
|
||||||
std::map<std::string, size_t> m_namedTags;
|
std::map<std::string, size_t> m_namedTags;
|
||||||
AssemblyItems m_items;
|
AssemblyItems m_items;
|
||||||
std::map<h256, bytes> m_data;
|
std::map<util::h256, bytes> m_data;
|
||||||
/// Data that is appended to the very end of the contract.
|
/// Data that is appended to the very end of the contract.
|
||||||
bytes m_auxiliaryData;
|
bytes m_auxiliaryData;
|
||||||
std::vector<std::shared_ptr<Assembly>> m_subs;
|
std::vector<std::shared_ptr<Assembly>> m_subs;
|
||||||
std::map<h256, std::string> m_strings;
|
std::map<util::h256, std::string> m_strings;
|
||||||
std::map<h256, std::string> m_libraries; ///< Identifiers of libraries to be linked.
|
std::map<util::h256, std::string> m_libraries; ///< Identifiers of libraries to be linked.
|
||||||
|
|
||||||
mutable LinkerObject m_assembledObject;
|
mutable LinkerObject m_assembledObject;
|
||||||
mutable std::vector<size_t> m_tagPositionsInBytecode;
|
mutable std::vector<size_t> m_tagPositionsInBytecode;
|
||||||
@ -192,4 +190,3 @@ inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -17,21 +17,21 @@
|
|||||||
|
|
||||||
#include <libevmasm/AssemblyItem.h>
|
#include <libevmasm/AssemblyItem.h>
|
||||||
|
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
#include <libdevcore/FixedHash.h>
|
#include <libsolutil/FixedHash.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
static_assert(sizeof(size_t) <= 8, "size_t must be at most 64-bits wide");
|
static_assert(sizeof(size_t) <= 8, "size_t must be at most 64-bits wide");
|
||||||
|
|
||||||
AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const
|
AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const
|
||||||
{
|
{
|
||||||
assertThrow(data() < (u256(1) << 64), Exception, "Tag already has subassembly set.");
|
assertThrow(data() < (u256(1) << 64), util::Exception, "Tag already has subassembly set.");
|
||||||
assertThrow(m_type == PushTag || m_type == Tag, Exception, "");
|
assertThrow(m_type == PushTag || m_type == Tag, util::Exception, "");
|
||||||
size_t tag = size_t(u256(data()) & 0xffffffffffffffffULL);
|
size_t tag = size_t(u256(data()) & 0xffffffffffffffffULL);
|
||||||
AssemblyItem r = *this;
|
AssemblyItem r = *this;
|
||||||
r.m_type = PushTag;
|
r.m_type = PushTag;
|
||||||
@ -41,7 +41,7 @@ AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const
|
|||||||
|
|
||||||
pair<size_t, size_t> AssemblyItem::splitForeignPushTag() const
|
pair<size_t, size_t> AssemblyItem::splitForeignPushTag() const
|
||||||
{
|
{
|
||||||
assertThrow(m_type == PushTag || m_type == Tag, Exception, "");
|
assertThrow(m_type == PushTag || m_type == Tag, util::Exception, "");
|
||||||
u256 combined = u256(data());
|
u256 combined = u256(data());
|
||||||
size_t subId = size_t((combined >> 64) - 1);
|
size_t subId = size_t((combined >> 64) - 1);
|
||||||
size_t tag = size_t(combined & 0xffffffffffffffffULL);
|
size_t tag = size_t(combined & 0xffffffffffffffffULL);
|
||||||
@ -50,7 +50,7 @@ pair<size_t, size_t> AssemblyItem::splitForeignPushTag() const
|
|||||||
|
|
||||||
void AssemblyItem::setPushTagSubIdAndTag(size_t _subId, size_t _tag)
|
void AssemblyItem::setPushTagSubIdAndTag(size_t _subId, size_t _tag)
|
||||||
{
|
{
|
||||||
assertThrow(m_type == PushTag || m_type == Tag, Exception, "");
|
assertThrow(m_type == PushTag || m_type == Tag, util::Exception, "");
|
||||||
u256 data = _tag;
|
u256 data = _tag;
|
||||||
if (_subId != size_t(-1))
|
if (_subId != size_t(-1))
|
||||||
data |= (u256(_subId) + 1) << 64;
|
data |= (u256(_subId) + 1) << 64;
|
||||||
@ -67,7 +67,7 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const
|
|||||||
case PushString:
|
case PushString:
|
||||||
return 1 + 32;
|
return 1 + 32;
|
||||||
case Push:
|
case Push:
|
||||||
return 1 + max<unsigned>(1, dev::bytesRequired(data()));
|
return 1 + max<unsigned>(1, util::bytesRequired(data()));
|
||||||
case PushSubSize:
|
case PushSubSize:
|
||||||
case PushProgramSize:
|
case PushProgramSize:
|
||||||
return 1 + 4; // worst case: a 16MB program
|
return 1 + 4; // worst case: a 16MB program
|
||||||
@ -170,10 +170,10 @@ string AssemblyItem::toAssemblyText() const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Push:
|
case Push:
|
||||||
text = toHex(toCompactBigEndian(data(), 1), HexPrefix::Add);
|
text = toHex(util::toCompactBigEndian(data(), 1), util::HexPrefix::Add);
|
||||||
break;
|
break;
|
||||||
case PushString:
|
case PushString:
|
||||||
text = string("data_") + toHex(data());
|
text = string("data_") + util::toHex(data());
|
||||||
break;
|
break;
|
||||||
case PushTag:
|
case PushTag:
|
||||||
{
|
{
|
||||||
@ -191,7 +191,7 @@ string AssemblyItem::toAssemblyText() const
|
|||||||
text = string("tag_") + to_string(size_t(data())) + ":";
|
text = string("tag_") + to_string(size_t(data())) + ":";
|
||||||
break;
|
break;
|
||||||
case PushData:
|
case PushData:
|
||||||
text = string("data_") + toHex(data());
|
text = string("data_") + util::toHex(data());
|
||||||
break;
|
break;
|
||||||
case PushSub:
|
case PushSub:
|
||||||
text = string("dataOffset(sub_") + to_string(size_t(data())) + ")";
|
text = string("dataOffset(sub_") + to_string(size_t(data())) + ")";
|
||||||
@ -203,7 +203,7 @@ string AssemblyItem::toAssemblyText() const
|
|||||||
text = string("bytecodeSize");
|
text = string("bytecodeSize");
|
||||||
break;
|
break;
|
||||||
case PushLibraryAddress:
|
case PushLibraryAddress:
|
||||||
text = string("linkerSymbol(\"") + toHex(data()) + string("\")");
|
text = string("linkerSymbol(\"") + util::toHex(data()) + string("\")");
|
||||||
break;
|
break;
|
||||||
case PushDeployTimeAddress:
|
case PushDeployTimeAddress:
|
||||||
text = string("deployTimeAddress()");
|
text = string("deployTimeAddress()");
|
||||||
@ -225,7 +225,7 @@ string AssemblyItem::toAssemblyText() const
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
|
ostream& solidity::evmasm::operator<<(ostream& _out, AssemblyItem const& _item)
|
||||||
{
|
{
|
||||||
switch (_item.type())
|
switch (_item.type())
|
||||||
{
|
{
|
||||||
@ -266,7 +266,7 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
|
|||||||
break;
|
break;
|
||||||
case PushLibraryAddress:
|
case PushLibraryAddress:
|
||||||
{
|
{
|
||||||
string hash(h256((_item.data())).hex());
|
string hash(util::h256((_item.data())).hex());
|
||||||
_out << " PushLibraryAddress " << hash.substr(0, 8) + "..." + hash.substr(hash.length() - 8);
|
_out << " PushLibraryAddress " << hash.substr(0, 8) + "..." + hash.substr(hash.length() - 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,12 @@
|
|||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libevmasm/Exceptions.h>
|
#include <libevmasm/Exceptions.h>
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
enum AssemblyItemType {
|
enum AssemblyItemType {
|
||||||
@ -77,8 +75,8 @@ public:
|
|||||||
AssemblyItem& operator=(AssemblyItem const&) = default;
|
AssemblyItem& operator=(AssemblyItem const&) = default;
|
||||||
AssemblyItem& operator=(AssemblyItem&&) = default;
|
AssemblyItem& operator=(AssemblyItem&&) = default;
|
||||||
|
|
||||||
AssemblyItem tag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(Tag, data()); }
|
AssemblyItem tag() const { assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); return AssemblyItem(Tag, data()); }
|
||||||
AssemblyItem pushTag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(PushTag, data()); }
|
AssemblyItem pushTag() const { assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); return AssemblyItem(PushTag, data()); }
|
||||||
/// Converts the tag to a subassembly tag. This has to be called in order to move a tag across assemblies.
|
/// Converts the tag to a subassembly tag. This has to be called in order to move a tag across assemblies.
|
||||||
/// @param _subId the identifier of the subassembly the tag is taken from.
|
/// @param _subId the identifier of the subassembly the tag is taken from.
|
||||||
AssemblyItem toSubAssemblyTag(size_t _subId) const;
|
AssemblyItem toSubAssemblyTag(size_t _subId) const;
|
||||||
@ -89,11 +87,11 @@ public:
|
|||||||
void setPushTagSubIdAndTag(size_t _subId, size_t _tag);
|
void setPushTagSubIdAndTag(size_t _subId, size_t _tag);
|
||||||
|
|
||||||
AssemblyItemType type() const { return m_type; }
|
AssemblyItemType type() const { return m_type; }
|
||||||
u256 const& data() const { assertThrow(m_type != Operation, Exception, ""); return *m_data; }
|
u256 const& data() const { assertThrow(m_type != Operation, util::Exception, ""); return *m_data; }
|
||||||
void setData(u256 const& _data) { assertThrow(m_type != Operation, Exception, ""); m_data = std::make_shared<u256>(_data); }
|
void setData(u256 const& _data) { assertThrow(m_type != Operation, util::Exception, ""); m_data = std::make_shared<u256>(_data); }
|
||||||
|
|
||||||
/// @returns the instruction of this item (only valid if type() == Operation)
|
/// @returns the instruction of this item (only valid if type() == Operation)
|
||||||
Instruction instruction() const { assertThrow(m_type == Operation, Exception, ""); return m_instruction; }
|
Instruction instruction() const { assertThrow(m_type == Operation, util::Exception, ""); return m_instruction; }
|
||||||
|
|
||||||
/// @returns true if the type and data of the items are equal.
|
/// @returns true if the type and data of the items are equal.
|
||||||
bool operator==(AssemblyItem const& _other) const
|
bool operator==(AssemblyItem const& _other) const
|
||||||
@ -178,4 +176,3 @@ inline std::ostream& operator<<(std::ostream& _out, AssemblyItems const& _items)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
|
|
||||||
bool BlockDeduplicator::deduplicate()
|
bool BlockDeduplicator::deduplicate()
|
||||||
|
@ -23,16 +23,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
@ -90,4 +88,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -36,4 +36,4 @@ set(sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(evmasm ${sources})
|
add_library(evmasm ${sources})
|
||||||
target_link_libraries(evmasm PUBLIC devcore)
|
target_link_libraries(evmasm PUBLIC solutil)
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <libdevcore/Keccak256.h>
|
#include <libsolutil/Keccak256.h>
|
||||||
#include <libevmasm/CommonSubexpressionEliminator.h>
|
#include <libevmasm/CommonSubexpressionEliminator.h>
|
||||||
#include <libevmasm/AssemblyItem.h>
|
#include <libevmasm/AssemblyItem.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
vector<AssemblyItem> CommonSubexpressionEliminator::getOptimizedItems()
|
vector<AssemblyItem> CommonSubexpressionEliminator::getOptimizedItems()
|
||||||
{
|
{
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libsolutil/CommonIO.h>
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
#include <libevmasm/ExpressionClasses.h>
|
#include <libevmasm/ExpressionClasses.h>
|
||||||
#include <libevmasm/SemanticInformation.h>
|
#include <libevmasm/SemanticInformation.h>
|
||||||
#include <libevmasm/KnownState.h>
|
#include <libevmasm/KnownState.h>
|
||||||
@ -39,9 +39,7 @@ namespace langutil
|
|||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
@ -187,4 +185,3 @@ _AssemblyItemIterator CommonSubexpressionEliminator::feedItems(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -22,9 +22,11 @@
|
|||||||
#include <libevmasm/ConstantOptimiser.h>
|
#include <libevmasm/ConstantOptimiser.h>
|
||||||
#include <libevmasm/Assembly.h>
|
#include <libevmasm/Assembly.h>
|
||||||
#include <libevmasm/GasMeter.h>
|
#include <libevmasm/GasMeter.h>
|
||||||
|
#include <libsolutil/CommonData.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
unsigned ConstantOptimisationMethod::optimiseConstants(
|
unsigned ConstantOptimisationMethod::optimiseConstants(
|
||||||
bool _isCreation,
|
bool _isCreation,
|
||||||
@ -101,7 +103,7 @@ bigint ConstantOptimisationMethod::dataGas(bytes const& _data) const
|
|||||||
|
|
||||||
size_t ConstantOptimisationMethod::bytesRequired(AssemblyItems const& _items)
|
size_t ConstantOptimisationMethod::bytesRequired(AssemblyItems const& _items)
|
||||||
{
|
{
|
||||||
return eth::bytesRequired(_items, 3); // assume 3 byte addresses
|
return evmasm::bytesRequired(_items, 3); // assume 3 byte addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstantOptimisationMethod::replaceConstants(
|
void ConstantOptimisationMethod::replaceConstants(
|
||||||
@ -131,7 +133,7 @@ bigint LiteralMethod::gasNeeded() const
|
|||||||
return combineGas(
|
return combineGas(
|
||||||
simpleRunGas({Instruction::PUSH1}),
|
simpleRunGas({Instruction::PUSH1}),
|
||||||
// PUSHX plus data
|
// PUSHX plus data
|
||||||
(m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas) + dataGas(toCompactBigEndian(m_value, 1)),
|
(m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas) + dataGas(util::toCompactBigEndian(m_value, 1)),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -144,13 +146,13 @@ bigint CodeCopyMethod::gasNeeded() const
|
|||||||
// Data gas for copy routines: Some bytes are zero, but we ignore them.
|
// Data gas for copy routines: Some bytes are zero, but we ignore them.
|
||||||
bytesRequired(copyRoutine()) * (m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas),
|
bytesRequired(copyRoutine()) * (m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas),
|
||||||
// Data gas for data itself
|
// Data gas for data itself
|
||||||
dataGas(toBigEndian(m_value))
|
dataGas(util::toBigEndian(m_value))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const
|
AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const
|
||||||
{
|
{
|
||||||
bytes data = toBigEndian(m_value);
|
bytes data = util::toBigEndian(m_value);
|
||||||
assertThrow(data.size() == 32, OptimizerException, "Invalid number encoding.");
|
assertThrow(data.size() == 32, OptimizerException, "Invalid number encoding.");
|
||||||
AssemblyItems actualCopyRoutine = copyRoutine();
|
AssemblyItems actualCopyRoutine = copyRoutine();
|
||||||
actualCopyRoutine[4] = _assembly.newData(data);
|
actualCopyRoutine[4] = _assembly.newData(data);
|
||||||
@ -190,7 +192,7 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value)
|
|||||||
if (_value < 0x10000)
|
if (_value < 0x10000)
|
||||||
// Very small value, not worth computing
|
// Very small value, not worth computing
|
||||||
return AssemblyItems{_value};
|
return AssemblyItems{_value};
|
||||||
else if (dev::bytesRequired(~_value) < dev::bytesRequired(_value))
|
else if (util::bytesRequired(~_value) < util::bytesRequired(_value))
|
||||||
// Negated is shorter to represent
|
// Negated is shorter to represent
|
||||||
return findRepresentation(~_value) + AssemblyItems{Instruction::NOT};
|
return findRepresentation(~_value) + AssemblyItems{Instruction::NOT};
|
||||||
else
|
else
|
||||||
|
@ -25,15 +25,13 @@
|
|||||||
|
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libsolutil/CommonIO.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
@ -164,4 +162,3 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include <libevmasm/KnownState.h>
|
#include <libevmasm/KnownState.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
BlockId::BlockId(u256 const& _id):
|
BlockId::BlockId(u256 const& _id):
|
||||||
m_id(unsigned(_id))
|
m_id(unsigned(_id))
|
||||||
|
@ -25,13 +25,11 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <libevmasm/ExpressionClasses.h>
|
#include <libevmasm/ExpressionClasses.h>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class KnownState;
|
class KnownState;
|
||||||
@ -127,4 +125,3 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -21,14 +21,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
struct AssemblyException: virtual Exception {};
|
struct AssemblyException: virtual util::Exception {};
|
||||||
struct OptimizerException: virtual AssemblyException {};
|
struct OptimizerException: virtual AssemblyException {};
|
||||||
struct StackTooDeepException: virtual OptimizerException {};
|
struct StackTooDeepException: virtual OptimizerException {};
|
||||||
struct ItemNotAvailableException: virtual OptimizerException {};
|
struct ItemNotAvailableException: virtual OptimizerException {};
|
||||||
@ -37,4 +35,3 @@ DEV_SIMPLE_EXCEPTION(InvalidDeposit);
|
|||||||
DEV_SIMPLE_EXCEPTION(InvalidOpcode);
|
DEV_SIMPLE_EXCEPTION(InvalidOpcode);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
#include <libevmasm/SimplificationRules.h>
|
#include <libevmasm/SimplificationRules.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
bool ExpressionClasses::Expression::operator<(ExpressionClasses::Expression const& _other) const
|
bool ExpressionClasses::Expression::operator<(ExpressionClasses::Expression const& _other) const
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libevmasm/AssemblyItem.h>
|
#include <libevmasm/AssemblyItem.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -31,14 +31,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Pattern;
|
class Pattern;
|
||||||
@ -128,4 +126,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -19,11 +19,12 @@
|
|||||||
|
|
||||||
#include <libevmasm/KnownState.h>
|
#include <libevmasm/KnownState.h>
|
||||||
|
|
||||||
#include <libdevcore/FixedHash.h>
|
#include <libsolutil/FixedHash.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
GasMeter::GasConsumption& GasMeter::GasConsumption::operator+=(GasConsumption const& _other)
|
GasMeter::GasConsumption& GasMeter::GasConsumption::operator+=(GasConsumption const& _other)
|
||||||
{
|
{
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class KnownState;
|
class KnownState;
|
||||||
@ -180,4 +178,3 @@ inline std::ostream& operator<<(std::ostream& _str, GasMeter::GasConsumption con
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -21,16 +21,17 @@
|
|||||||
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libsolutil/CommonIO.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
std::map<std::string, Instruction> const dev::eth::c_instructions =
|
std::map<std::string, Instruction> const solidity::evmasm::c_instructions =
|
||||||
{
|
{
|
||||||
{ "STOP", Instruction::STOP },
|
{ "STOP", Instruction::STOP },
|
||||||
{ "ADD", Instruction::ADD },
|
{ "ADD", Instruction::ADD },
|
||||||
@ -322,7 +323,7 @@ static std::map<Instruction, InstructionInfo> const c_instructionInfo =
|
|||||||
{ Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Special } }
|
{ Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Special } }
|
||||||
};
|
};
|
||||||
|
|
||||||
void dev::eth::eachInstruction(
|
void solidity::evmasm::eachInstruction(
|
||||||
bytes const& _mem,
|
bytes const& _mem,
|
||||||
function<void(Instruction,u256 const&)> const& _onInstruction
|
function<void(Instruction,u256 const&)> const& _onInstruction
|
||||||
)
|
)
|
||||||
@ -351,7 +352,7 @@ void dev::eth::eachInstruction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string dev::eth::disassemble(bytes const& _mem)
|
string solidity::evmasm::disassemble(bytes const& _mem)
|
||||||
{
|
{
|
||||||
stringstream ret;
|
stringstream ret;
|
||||||
eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) {
|
eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) {
|
||||||
@ -368,7 +369,7 @@ string dev::eth::disassemble(bytes const& _mem)
|
|||||||
return ret.str();
|
return ret.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionInfo dev::eth::instructionInfo(Instruction _inst)
|
InstructionInfo solidity::evmasm::instructionInfo(Instruction _inst)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -380,7 +381,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dev::eth::isValidInstruction(Instruction _inst)
|
bool solidity::evmasm::isValidInstruction(Instruction _inst)
|
||||||
{
|
{
|
||||||
return !!c_instructionInfo.count(_inst);
|
return !!c_instructionInfo.count(_inst);
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libevmasm/Exceptions.h>
|
#include <libevmasm/Exceptions.h>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/// Virtual machine bytecode instruction.
|
/// Virtual machine bytecode instruction.
|
||||||
@ -318,4 +316,3 @@ void eachInstruction(bytes const& _mem, std::function<void(Instruction,u256 cons
|
|||||||
std::string disassemble(bytes const& _mem);
|
std::string disassemble(bytes const& _mem);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
#include <libevmasm/AssemblyItem.h>
|
#include <libevmasm/AssemblyItem.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev::eth;
|
using namespace solidity;
|
||||||
using namespace dev;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
bool JumpdestRemover::optimise(set<size_t> const& _tagsReferencedFromOutside)
|
bool JumpdestRemover::optimise(set<size_t> const& _tagsReferencedFromOutside)
|
||||||
{
|
{
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
using AssemblyItems = std::vector<AssemblyItem>;
|
using AssemblyItems = std::vector<AssemblyItem>;
|
||||||
@ -47,4 +45,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
|
|
||||||
#include <libevmasm/KnownState.h>
|
#include <libevmasm/KnownState.h>
|
||||||
#include <libevmasm/AssemblyItem.h>
|
#include <libevmasm/AssemblyItem.h>
|
||||||
#include <libdevcore/Keccak256.h>
|
#include <libsolutil/Keccak256.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
ostream& KnownState::stream(ostream& _out) const
|
ostream& KnownState::stream(ostream& _out) const
|
||||||
{
|
{
|
||||||
@ -383,9 +383,9 @@ KnownState::Id KnownState::applyKeccak256(
|
|||||||
{
|
{
|
||||||
bytes data;
|
bytes data;
|
||||||
for (Id a: arguments)
|
for (Id a: arguments)
|
||||||
data += toBigEndian(*m_expressionClasses->knownConstant(a));
|
data += util::toBigEndian(*m_expressionClasses->knownConstant(a));
|
||||||
data.resize(size_t(*l));
|
data.resize(size_t(*l));
|
||||||
v = m_expressionClasses->find(AssemblyItem(u256(dev::keccak256(data)), _location));
|
v = m_expressionClasses->find(AssemblyItem(u256(util::keccak256(data)), _location));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
v = m_expressionClasses->find(keccak256Item, {_start, _length}, true, m_sequenceNumber);
|
v = m_expressionClasses->find(keccak256Item, {_start, _length}, true, m_sequenceNumber);
|
||||||
|
@ -41,19 +41,17 @@
|
|||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif // defined(__clang__)
|
#endif // defined(__clang__)
|
||||||
|
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libsolutil/CommonIO.h>
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
#include <libevmasm/ExpressionClasses.h>
|
#include <libevmasm/ExpressionClasses.h>
|
||||||
#include <libevmasm/SemanticInformation.h>
|
#include <libevmasm/SemanticInformation.h>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
@ -182,4 +180,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -20,12 +20,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libevmasm/LinkerObject.h>
|
#include <libevmasm/LinkerObject.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
#include <libdevcore/Keccak256.h>
|
#include <libsolutil/Keccak256.h>
|
||||||
|
|
||||||
using namespace dev;
|
|
||||||
using namespace dev::eth;
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace solidity;
|
||||||
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
void LinkerObject::append(LinkerObject const& _other)
|
void LinkerObject::append(LinkerObject const& _other)
|
||||||
{
|
{
|
||||||
@ -47,7 +48,7 @@ void LinkerObject::link(map<string, h160> const& _libraryAddresses)
|
|||||||
|
|
||||||
string LinkerObject::toHex() const
|
string LinkerObject::toHex() const
|
||||||
{
|
{
|
||||||
string hex = dev::toHex(bytecode);
|
string hex = solidity::util::toHex(bytecode);
|
||||||
for (auto const& ref: linkReferences)
|
for (auto const& ref: linkReferences)
|
||||||
{
|
{
|
||||||
size_t pos = ref.first * 2;
|
size_t pos = ref.first * 2;
|
||||||
|
@ -21,12 +21,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/FixedHash.h>
|
#include <libsolutil/FixedHash.h>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +44,7 @@ struct LinkerObject
|
|||||||
void append(LinkerObject const& _other);
|
void append(LinkerObject const& _other);
|
||||||
|
|
||||||
/// Links the given libraries by replacing their uses in the code and removes them from the references.
|
/// Links the given libraries by replacing their uses in the code and removes them from the references.
|
||||||
void link(std::map<std::string, h160> const& _libraryAddresses);
|
void link(std::map<std::string, util::h160> const& _libraryAddresses);
|
||||||
|
|
||||||
/// @returns a hex representation of the bytecode of the given object, replacing unlinked
|
/// @returns a hex representation of the bytecode of the given object, replacing unlinked
|
||||||
/// addresses by placeholders. This output is lowercase.
|
/// addresses by placeholders. This output is lowercase.
|
||||||
@ -58,11 +56,10 @@ struct LinkerObject
|
|||||||
static std::string libraryPlaceholder(std::string const& _libraryName);
|
static std::string libraryPlaceholder(std::string const& _libraryName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static h160 const* matchLibrary(
|
static util::h160 const* matchLibrary(
|
||||||
std::string const& _linkRefName,
|
std::string const& _linkRefName,
|
||||||
std::map<std::string, h160> const& _libraryAddresses
|
std::map<std::string, util::h160> const& _libraryAddresses
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#include <libevmasm/SemanticInformation.h>
|
#include <libevmasm/SemanticInformation.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
PathGasMeter::PathGasMeter(AssemblyItems const& _items, langutil::EVMVersion _evmVersion):
|
PathGasMeter::PathGasMeter(AssemblyItems const& _items, langutil::EVMVersion _evmVersion):
|
||||||
m_items(_items), m_evmVersion(_evmVersion)
|
m_items(_items), m_evmVersion(_evmVersion)
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class KnownState;
|
class KnownState;
|
||||||
@ -85,4 +83,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
#include <libevmasm/SemanticInformation.h>
|
#include <libevmasm/SemanticInformation.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev::eth;
|
using namespace solidity;
|
||||||
using namespace dev;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
// TODO: Extend this to use the tools from ExpressionClasses.cpp
|
// TODO: Extend this to use the tools from ExpressionClasses.cpp
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ bool PeepholeOptimiser::optimise()
|
|||||||
);
|
);
|
||||||
if (m_optimisedItems.size() < m_items.size() || (
|
if (m_optimisedItems.size() < m_items.size() || (
|
||||||
m_optimisedItems.size() == m_items.size() && (
|
m_optimisedItems.size() == m_items.size() && (
|
||||||
eth::bytesRequired(m_optimisedItems, 3) < eth::bytesRequired(m_items, 3) ||
|
evmasm::bytesRequired(m_optimisedItems, 3) < evmasm::bytesRequired(m_items, 3) ||
|
||||||
numberOfPops(m_optimisedItems) > numberOfPops(m_items)
|
numberOfPops(m_optimisedItems) > numberOfPops(m_items)
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
using AssemblyItems = std::vector<AssemblyItem>;
|
using AssemblyItems = std::vector<AssemblyItem>;
|
||||||
@ -53,4 +51,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -25,16 +25,14 @@
|
|||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libevmasm/SimplificationRule.h>
|
#include <libevmasm/SimplificationRule.h>
|
||||||
|
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
|
|
||||||
#include <boost/multiprecision/detail/min_max.hpp>
|
#include <boost/multiprecision/detail/min_max.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
template <class S> S divWorkaround(S const& _a, S const& _b)
|
template <class S> S divWorkaround(S const& _a, S const& _b)
|
||||||
@ -674,4 +672,3 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
#include <libevmasm/AssemblyItem.h>
|
#include <libevmasm/AssemblyItem.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
|
||||||
bool SemanticInformation::breaksCSEAnalysisBlock(AssemblyItem const& _item, bool _msizeImportant)
|
bool SemanticInformation::breaksCSEAnalysisBlock(AssemblyItem const& _item, bool _msizeImportant)
|
||||||
{
|
{
|
||||||
@ -96,14 +96,14 @@ bool SemanticInformation::isDupInstruction(AssemblyItem const& _item)
|
|||||||
{
|
{
|
||||||
if (_item.type() != Operation)
|
if (_item.type() != Operation)
|
||||||
return false;
|
return false;
|
||||||
return dev::eth::isDupInstruction(_item.instruction());
|
return evmasm::isDupInstruction(_item.instruction());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticInformation::isSwapInstruction(AssemblyItem const& _item)
|
bool SemanticInformation::isSwapInstruction(AssemblyItem const& _item)
|
||||||
{
|
{
|
||||||
if (_item.type() != Operation)
|
if (_item.type() != Operation)
|
||||||
return false;
|
return false;
|
||||||
return dev::eth::isSwapInstruction(_item.instruction());
|
return evmasm::isSwapInstruction(_item.instruction());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticInformation::isJumpInstruction(AssemblyItem const& _item)
|
bool SemanticInformation::isJumpInstruction(AssemblyItem const& _item)
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class AssemblyItem;
|
class AssemblyItem;
|
||||||
@ -75,4 +73,3 @@ struct SemanticInformation
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -21,12 +21,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,4 +156,3 @@ struct EVMBuiltins
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <libevmasm/Assembly.h>
|
#include <libevmasm/Assembly.h>
|
||||||
#include <libevmasm/CommonSubexpressionEliminator.h>
|
#include <libevmasm/CommonSubexpressionEliminator.h>
|
||||||
#include <libevmasm/RuleList.h>
|
#include <libevmasm/RuleList.h>
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
|
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
@ -36,9 +36,9 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
SimplificationRule<Pattern> const* Rules::findFirstMatch(
|
SimplificationRule<Pattern> const* Rules::findFirstMatch(
|
||||||
Expression const& _expr,
|
Expression const& _expr,
|
||||||
|
@ -26,21 +26,19 @@
|
|||||||
#include <libevmasm/ExpressionClasses.h>
|
#include <libevmasm/ExpressionClasses.h>
|
||||||
#include <libevmasm/SimplificationRule.h>
|
#include <libevmasm/SimplificationRule.h>
|
||||||
|
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::evmasm
|
||||||
{
|
|
||||||
namespace eth
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Pattern;
|
class Pattern;
|
||||||
@ -89,7 +87,7 @@ public:
|
|||||||
using Expression = ExpressionClasses::Expression;
|
using Expression = ExpressionClasses::Expression;
|
||||||
using Id = ExpressionClasses::Id;
|
using Id = ExpressionClasses::Id;
|
||||||
|
|
||||||
using Builtins = dev::eth::EVMBuiltins<Pattern>;
|
using Builtins = evmasm::EVMBuiltins<Pattern>;
|
||||||
static constexpr size_t WordSize = 256;
|
static constexpr size_t WordSize = 256;
|
||||||
using Word = u256;
|
using Word = u256;
|
||||||
|
|
||||||
@ -159,4 +157,3 @@ struct ExpressionTemplate
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -28,4 +28,4 @@ set(sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(langutil ${sources})
|
add_library(langutil ${sources})
|
||||||
target_link_libraries(langutil PUBLIC devcore)
|
target_link_libraries(langutil PUBLIC solutil)
|
||||||
|
@ -54,7 +54,8 @@
|
|||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace langutil;
|
using namespace solidity;
|
||||||
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
char CharStream::advanceAndGet(size_t _chars)
|
char CharStream::advanceAndGet(size_t _chars)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
inline bool isDecimalDigit(char c)
|
inline bool isDecimalDigit(char c)
|
||||||
|
@ -20,8 +20,9 @@
|
|||||||
|
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
using namespace langutil;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::evmasm;
|
||||||
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
bool EVMVersion::hasOpcode(Instruction _opcode) const
|
bool EVMVersion::hasOpcode(Instruction _opcode) const
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +87,7 @@ public:
|
|||||||
bool hasChainID() const { return *this >= istanbul(); }
|
bool hasChainID() const { return *this >= istanbul(); }
|
||||||
bool hasSelfBalance() const { return *this >= istanbul(); }
|
bool hasSelfBalance() const { return *this >= istanbul(); }
|
||||||
|
|
||||||
bool hasOpcode(dev::eth::Instruction _opcode) const;
|
bool hasOpcode(evmasm::Instruction _opcode) const;
|
||||||
|
|
||||||
/// Whether we have to retain the costs for the call opcode itself (false),
|
/// Whether we have to retain the costs for the call opcode itself (false),
|
||||||
/// or whether we can just forward easily all remaining gas (true).
|
/// or whether we can just forward easily all remaining gas (true).
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
ErrorReporter& ErrorReporter::operator=(ErrorReporter const& _errorReporter)
|
ErrorReporter& ErrorReporter::operator=(ErrorReporter const& _errorReporter)
|
||||||
{
|
{
|
||||||
@ -67,7 +67,7 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, st
|
|||||||
auto err = make_shared<Error>(_type);
|
auto err = make_shared<Error>(_type);
|
||||||
*err <<
|
*err <<
|
||||||
errinfo_sourceLocation(_location) <<
|
errinfo_sourceLocation(_location) <<
|
||||||
errinfo_comment(_description);
|
util::errinfo_comment(_description);
|
||||||
|
|
||||||
m_errorList.push_back(err);
|
m_errorList.push_back(err);
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se
|
|||||||
*err <<
|
*err <<
|
||||||
errinfo_sourceLocation(_location) <<
|
errinfo_sourceLocation(_location) <<
|
||||||
errinfo_secondarySourceLocation(_secondaryLocation) <<
|
errinfo_secondarySourceLocation(_secondaryLocation) <<
|
||||||
errinfo_comment(_description);
|
util::errinfo_comment(_description);
|
||||||
|
|
||||||
m_errorList.push_back(err);
|
m_errorList.push_back(err);
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type)
|
|||||||
if (m_warningCount == c_maxWarningsAllowed)
|
if (m_warningCount == c_maxWarningsAllowed)
|
||||||
{
|
{
|
||||||
auto err = make_shared<Error>(Error::Type::Warning);
|
auto err = make_shared<Error>(Error::Type::Warning);
|
||||||
*err << errinfo_comment("There are more than 256 warnings. Ignoring the rest.");
|
*err << util::errinfo_comment("There are more than 256 warnings. Ignoring the rest.");
|
||||||
m_errorList.push_back(err);
|
m_errorList.push_back(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type)
|
|||||||
if (m_errorCount > c_maxErrorsAllowed)
|
if (m_errorCount > c_maxErrorsAllowed)
|
||||||
{
|
{
|
||||||
auto err = make_shared<Error>(Error::Type::Warning);
|
auto err = make_shared<Error>(Error::Type::Warning);
|
||||||
*err << errinfo_comment("There are more than 256 errors. Aborting.");
|
*err << util::errinfo_comment("There are more than 256 errors. Aborting.");
|
||||||
m_errorList.push_back(err);
|
m_errorList.push_back(err);
|
||||||
BOOST_THROW_EXCEPTION(FatalError());
|
BOOST_THROW_EXCEPTION(FatalError());
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
|
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
#include <libdevcore/StringUtils.h>
|
#include <libsolutil/StringUtils.h>
|
||||||
|
|
||||||
#include <boost/range/adaptor/filtered.hpp>
|
#include <boost/range/adaptor/filtered.hpp>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
class ErrorReporter
|
class ErrorReporter
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
|
|
||||||
auto filterEmpty = boost::adaptors::filtered([](std::string const& _s) { return !_s.empty(); });
|
auto filterEmpty = boost::adaptors::filtered([](std::string const& _s) { return !_s.empty(); });
|
||||||
|
|
||||||
std::string errorStr = dev::joinHumanReadable(descs | filterEmpty, " ");
|
std::string errorStr = util::joinHumanReadable(descs | filterEmpty, " ");
|
||||||
|
|
||||||
error(Error::Type::TypeError, _location, errorStr);
|
error(Error::Type::TypeError, _location, errorStr);
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
Error::Error(Type _type, SourceLocation const& _location, string const& _description):
|
Error::Error(Type _type, SourceLocation const& _location, string const& _description):
|
||||||
m_type(_type)
|
m_type(_type)
|
||||||
@ -54,7 +54,7 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip
|
|||||||
if (!_location.isEmpty())
|
if (!_location.isEmpty())
|
||||||
*this << errinfo_sourceLocation(_location);
|
*this << errinfo_sourceLocation(_location);
|
||||||
if (!_description.empty())
|
if (!_description.empty())
|
||||||
*this << errinfo_comment(_description);
|
*this << util::errinfo_comment(_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error::Error(Error::Type _type, std::string const& _description, SourceLocation const& _location):
|
Error::Error(Error::Type _type, std::string const& _description, SourceLocation const& _location):
|
||||||
@ -62,5 +62,5 @@ Error::Error(Error::Type _type, std::string const& _description, SourceLocation
|
|||||||
{
|
{
|
||||||
if (!_location.isEmpty())
|
if (!_location.isEmpty())
|
||||||
*this << errinfo_sourceLocation(_location);
|
*this << errinfo_sourceLocation(_location);
|
||||||
*this << errinfo_comment(_description);
|
*this << util::errinfo_comment(_description);
|
||||||
}
|
}
|
||||||
|
@ -26,32 +26,32 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
class Error;
|
class Error;
|
||||||
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
||||||
|
|
||||||
struct CompilerError: virtual dev::Exception {};
|
struct CompilerError: virtual util::Exception {};
|
||||||
struct InternalCompilerError: virtual dev::Exception {};
|
struct InternalCompilerError: virtual util::Exception {};
|
||||||
struct FatalError: virtual dev::Exception {};
|
struct FatalError: virtual util::Exception {};
|
||||||
struct UnimplementedFeatureError: virtual dev::Exception {};
|
struct UnimplementedFeatureError: virtual util::Exception {};
|
||||||
|
|
||||||
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
|
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
|
||||||
#define solAssert(CONDITION, DESCRIPTION) \
|
#define solAssert(CONDITION, DESCRIPTION) \
|
||||||
assertThrow(CONDITION, ::langutil::InternalCompilerError, DESCRIPTION)
|
assertThrow(CONDITION, ::solidity::langutil::InternalCompilerError, DESCRIPTION)
|
||||||
|
|
||||||
#define solUnimplementedAssert(CONDITION, DESCRIPTION) \
|
#define solUnimplementedAssert(CONDITION, DESCRIPTION) \
|
||||||
assertThrow(CONDITION, ::langutil::UnimplementedFeatureError, DESCRIPTION)
|
assertThrow(CONDITION, ::solidity::langutil::UnimplementedFeatureError, DESCRIPTION)
|
||||||
|
|
||||||
#define solUnimplemented(DESCRIPTION) \
|
#define solUnimplemented(DESCRIPTION) \
|
||||||
solUnimplementedAssert(false, DESCRIPTION)
|
solUnimplementedAssert(false, DESCRIPTION)
|
||||||
|
|
||||||
class Error: virtual public dev::Exception
|
class Error: virtual public util::Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Type
|
enum class Type
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace langutil;
|
using namespace solidity;
|
||||||
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
int ParserBase::position() const
|
int ParserBase::position() const
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
class ErrorReporter;
|
class ErrorReporter;
|
||||||
|
@ -60,9 +60,10 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace langutil;
|
|
||||||
|
|
||||||
string langutil::to_string(ScannerError _errorCode)
|
namespace solidity::langutil {
|
||||||
|
|
||||||
|
string to_string(ScannerError _errorCode)
|
||||||
{
|
{
|
||||||
switch (_errorCode)
|
switch (_errorCode)
|
||||||
{
|
{
|
||||||
@ -84,14 +85,11 @@ string langutil::to_string(ScannerError _errorCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ostream& langutil::operator<<(ostream& os, ScannerError _errorCode)
|
ostream& operator<<(ostream& os, ScannerError _errorCode)
|
||||||
{
|
{
|
||||||
return os << to_string(_errorCode);
|
return os << to_string(_errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace langutil
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Scoped helper for literal recording. Automatically drops the literal
|
/// Scoped helper for literal recording. Automatically drops the literal
|
||||||
/// if aborting the scanning before it's complete.
|
/// if aborting the scanning before it's complete.
|
||||||
enum LiteralType
|
enum LiteralType
|
||||||
@ -132,8 +130,6 @@ private:
|
|||||||
bool m_complete;
|
bool m_complete;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scanner::reset(CharStream _source)
|
void Scanner::reset(CharStream _source)
|
||||||
{
|
{
|
||||||
m_source = make_shared<CharStream>(std::move(_source));
|
m_source = make_shared<CharStream>(std::move(_source));
|
||||||
@ -933,3 +929,5 @@ tuple<Token, unsigned, unsigned> Scanner::scanIdentifierOrKeyword()
|
|||||||
literal.complete();
|
literal.complete();
|
||||||
return TokenTraits::fromIdentifierOrKeyword(m_nextToken.literal);
|
return TokenTraits::fromIdentifierOrKeyword(m_nextToken.literal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace solidity::langutil
|
||||||
|
@ -55,13 +55,13 @@
|
|||||||
#include <liblangutil/Token.h>
|
#include <liblangutil/Token.h>
|
||||||
#include <liblangutil/CharStream.h>
|
#include <liblangutil/CharStream.h>
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
class AstRawString;
|
class AstRawString;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
SemVerVersion::SemVerVersion(string const& _versionString)
|
SemVerVersion::SemVerVersion(string const& _versionString)
|
||||||
{
|
{
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
class SemVerError: dev::Exception
|
class SemVerError: util::Exception
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,18 +22,18 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <libdevcore/Common.h> // defines noexcept macro for MSVC
|
#include <libsolutil/Common.h> // defines noexcept macro for MSVC
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
#include <liblangutil/CharStream.h>
|
#include <liblangutil/CharStream.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
struct SourceLocationError: virtual dev::Exception {};
|
struct SourceLocationError: virtual util::Exception {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of an interval of source positions.
|
* Representation of an interval of source positions.
|
||||||
|
@ -22,14 +22,14 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
SourceReferenceExtractor::Message SourceReferenceExtractor::extract(Exception const& _exception, string _category)
|
SourceReferenceExtractor::Message SourceReferenceExtractor::extract(util::Exception const& _exception, string _category)
|
||||||
{
|
{
|
||||||
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception);
|
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception);
|
||||||
|
|
||||||
string const* message = boost::get_error_info<errinfo_comment>(_exception);
|
string const* message = boost::get_error_info<util::errinfo_comment>(_exception);
|
||||||
SourceReference primary = extract(location, message ? *message : "");
|
SourceReference primary = extract(location, message ? *message : "");
|
||||||
|
|
||||||
std::vector<SourceReference> secondary;
|
std::vector<SourceReference> secondary;
|
||||||
@ -46,6 +46,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio
|
|||||||
if (!_location || !_location->source.get()) // Nothing we can extract here
|
if (!_location || !_location->source.get()) // Nothing we can extract here
|
||||||
return SourceReference::MessageOnly(std::move(message));
|
return SourceReference::MessageOnly(std::move(message));
|
||||||
|
|
||||||
|
if (_location->source->source().empty()) // No source text, so we can only extract the source name
|
||||||
|
return SourceReference::MessageOnly(std::move(message), _location->source->name());
|
||||||
|
|
||||||
shared_ptr<CharStream> const& source = _location->source;
|
shared_ptr<CharStream> const& source = _location->source;
|
||||||
|
|
||||||
LineColumn const interest = source->translatePositionToLineColumn(_location->start);
|
LineColumn const interest = source->translatePositionToLineColumn(_location->start);
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::util
|
||||||
{
|
{
|
||||||
struct Exception;
|
struct Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
struct LineColumn
|
struct LineColumn
|
||||||
@ -49,10 +49,11 @@ struct SourceReference
|
|||||||
int endColumn = {-1}; ///< Highlighting range-end of text field.
|
int endColumn = {-1}; ///< Highlighting range-end of text field.
|
||||||
|
|
||||||
/// Constructs a SourceReference containing a message only.
|
/// Constructs a SourceReference containing a message only.
|
||||||
static SourceReference MessageOnly(std::string _msg)
|
static SourceReference MessageOnly(std::string _msg, std::string _sourceName = {})
|
||||||
{
|
{
|
||||||
SourceReference sref;
|
SourceReference sref;
|
||||||
sref.message = std::move(_msg);
|
sref.message = std::move(_msg);
|
||||||
|
sref.sourceName = std::move(_sourceName);
|
||||||
return sref;
|
return sref;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -68,7 +69,7 @@ namespace SourceReferenceExtractor
|
|||||||
std::vector<SourceReference> secondary;
|
std::vector<SourceReference> secondary;
|
||||||
};
|
};
|
||||||
|
|
||||||
Message extract(dev::Exception const& _exception, std::string _category);
|
Message extract(util::Exception const& _exception, std::string _category);
|
||||||
SourceReference extract(SourceLocation const* _location, std::string message = "");
|
SourceReference extract(SourceLocation const* _location, std::string message = "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,9 @@
|
|||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
void SourceReferenceFormatter::printSourceLocation(SourceLocation const* _location)
|
void SourceReferenceFormatter::printSourceLocation(SourceLocation const* _location)
|
||||||
{
|
{
|
||||||
@ -70,7 +71,7 @@ void SourceReferenceFormatter::printSourceName(SourceReference const& _ref)
|
|||||||
m_stream << _ref.sourceName << ":" << (_ref.position.line + 1) << ":" << (_ref.position.column + 1) << ": ";
|
m_stream << _ref.sourceName << ":" << (_ref.position.line + 1) << ":" << (_ref.position.column + 1) << ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceReferenceFormatter::printExceptionInformation(dev::Exception const& _exception, std::string const& _category)
|
void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _category)
|
||||||
{
|
{
|
||||||
printExceptionInformation(SourceReferenceExtractor::extract(_exception, _category));
|
printExceptionInformation(SourceReferenceExtractor::extract(_exception, _category));
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/SourceReferenceExtractor.h>
|
#include <liblangutil/SourceReferenceExtractor.h>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::util
|
||||||
{
|
{
|
||||||
struct Exception; // forward
|
struct Exception; // forward
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
class Scanner;
|
class Scanner;
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
virtual void printExceptionInformation(SourceReferenceExtractor::Message const& _msg);
|
virtual void printExceptionInformation(SourceReferenceExtractor::Message const& _msg);
|
||||||
|
|
||||||
virtual void printSourceLocation(SourceLocation const* _location);
|
virtual void printSourceLocation(SourceLocation const* _location);
|
||||||
virtual void printExceptionInformation(dev::Exception const& _exception, std::string const& _category);
|
virtual void printExceptionInformation(util::Exception const& _exception, std::string const& _category);
|
||||||
virtual void printErrorInformation(Error const& _error);
|
virtual void printErrorInformation(Error const& _error);
|
||||||
|
|
||||||
static std::string formatErrorInformation(Error const& _error)
|
static std::string formatErrorInformation(Error const& _error)
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::string formatExceptionInformation(
|
static std::string formatExceptionInformation(
|
||||||
dev::Exception const& _exception,
|
util::Exception const& _exception,
|
||||||
std::string const& _name
|
std::string const& _name
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -25,9 +25,10 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::formatting;
|
using namespace solidity::langutil;
|
||||||
using namespace langutil;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::util::formatting;
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatterHuman::normalColored() const
|
AnsiColorized SourceReferenceFormatterHuman::normalColored() const
|
||||||
{
|
{
|
||||||
|
@ -23,18 +23,18 @@
|
|||||||
#include <liblangutil/SourceReferenceExtractor.h>
|
#include <liblangutil/SourceReferenceExtractor.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h> // SourceReferenceFormatterBase
|
#include <liblangutil/SourceReferenceFormatter.h> // SourceReferenceFormatterBase
|
||||||
|
|
||||||
#include <libdevcore/AnsiColorized.h>
|
#include <libsolutil/AnsiColorized.h>
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::util
|
||||||
{
|
{
|
||||||
struct Exception; // forward
|
struct Exception; // forward
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
using SourceReferenceFormatter::printExceptionInformation;
|
using SourceReferenceFormatter::printExceptionInformation;
|
||||||
|
|
||||||
static std::string formatExceptionInformation(
|
static std::string formatExceptionInformation(
|
||||||
dev::Exception const& _exception,
|
util::Exception const& _exception,
|
||||||
std::string const& _name,
|
std::string const& _name,
|
||||||
bool colored = false
|
bool colored = false
|
||||||
)
|
)
|
||||||
@ -65,13 +65,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dev::AnsiColorized normalColored() const;
|
util::AnsiColorized normalColored() const;
|
||||||
dev::AnsiColorized frameColored() const;
|
util::AnsiColorized frameColored() const;
|
||||||
dev::AnsiColorized errorColored() const;
|
util::AnsiColorized errorColored() const;
|
||||||
dev::AnsiColorized messageColored() const;
|
util::AnsiColorized messageColored() const;
|
||||||
dev::AnsiColorized secondaryColored() const;
|
util::AnsiColorized secondaryColored() const;
|
||||||
dev::AnsiColorized highlightColored() const;
|
util::AnsiColorized highlightColored() const;
|
||||||
dev::AnsiColorized diagColored() const;
|
util::AnsiColorized diagColored() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_colored;
|
bool m_colored;
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
|
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
|
||||||
@ -82,7 +82,6 @@ void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _fi
|
|||||||
|
|
||||||
namespace TokenTraits
|
namespace TokenTraits
|
||||||
{
|
{
|
||||||
|
|
||||||
char const* toString(Token tok)
|
char const* toString(Token tok)
|
||||||
{
|
{
|
||||||
switch (tok)
|
switch (tok)
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/UndefMacros.h>
|
#include <liblangutil/UndefMacros.h>
|
||||||
|
|
||||||
@ -50,7 +50,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
// TOKEN_LIST takes a list of 3 macros M, all of which satisfy the
|
// TOKEN_LIST takes a list of 3 macros M, all of which satisfy the
|
||||||
|
@ -11,4 +11,4 @@ set(sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(lll ${sources})
|
add_library(lll ${sources})
|
||||||
target_link_libraries(lll PUBLIC evmasm devcore)
|
target_link_libraries(lll PUBLIC evmasm solutil)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <liblll/CompilerState.h>
|
#include <liblll/CompilerState.h>
|
||||||
#include <liblll/Parser.h>
|
#include <liblll/Parser.h>
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libsolutil/CommonIO.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
@ -40,9 +40,10 @@
|
|||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::eth;
|
using namespace solidity::util;
|
||||||
using namespace dev::lll;
|
using namespace solidity::evmasm;
|
||||||
|
using namespace solidity::lll;
|
||||||
|
|
||||||
void CodeFragment::finalise(CompilerState const& _cs)
|
void CodeFragment::finalise(CompilerState const& _cs)
|
||||||
{
|
{
|
||||||
@ -608,7 +609,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
|||||||
int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0;
|
int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0;
|
||||||
|
|
||||||
// The conditions
|
// The conditions
|
||||||
eth::AssemblyItems jumpTags;
|
evmasm::AssemblyItems jumpTags;
|
||||||
for (unsigned i = 0; i < code.size() - 1; i += 2)
|
for (unsigned i = 0; i < code.size() - 1; i += 2)
|
||||||
{
|
{
|
||||||
requireDeposit(i, 1);
|
requireDeposit(i, 1);
|
||||||
@ -675,7 +676,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
|||||||
requireMaxSize(3);
|
requireMaxSize(3);
|
||||||
requireDeposit(1, 1);
|
requireDeposit(1, 1);
|
||||||
|
|
||||||
auto subPush = m_asm.appendSubroutine(make_shared<eth::Assembly>(code[0].assembly(ns)));
|
auto subPush = m_asm.appendSubroutine(make_shared<evmasm::Assembly>(code[0].assembly(ns)));
|
||||||
m_asm.append(Instruction::DUP1);
|
m_asm.append(Instruction::DUP1);
|
||||||
if (code.size() == 3)
|
if (code.size() == 3)
|
||||||
{
|
{
|
||||||
|
@ -24,14 +24,12 @@
|
|||||||
#include <liblll/Exceptions.h>
|
#include <liblll/Exceptions.h>
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
#include <libevmasm/Assembly.h>
|
#include <libevmasm/Assembly.h>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
|
|
||||||
namespace boost { namespace spirit { class utree; } }
|
namespace boost { namespace spirit { class utree; } }
|
||||||
namespace sp = boost::spirit;
|
namespace sp = boost::spirit;
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::lll
|
||||||
{
|
|
||||||
namespace lll
|
|
||||||
{
|
{
|
||||||
|
|
||||||
struct CompilerState;
|
struct CompilerState;
|
||||||
@ -47,7 +45,7 @@ public:
|
|||||||
static CodeFragment compile(std::string _src, CompilerState& _s, ReadCallback const& _readFile);
|
static CodeFragment compile(std::string _src, CompilerState& _s, ReadCallback const& _readFile);
|
||||||
|
|
||||||
/// Consolidates data and compiles code.
|
/// Consolidates data and compiles code.
|
||||||
eth::Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; }
|
evmasm::Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void finalise(CompilerState const& _cs);
|
void finalise(CompilerState const& _cs);
|
||||||
@ -55,17 +53,16 @@ private:
|
|||||||
template <class T> static void error() { BOOST_THROW_EXCEPTION(T() ); }
|
template <class T> static void error() { BOOST_THROW_EXCEPTION(T() ); }
|
||||||
template <class T> static void error(std::string const& reason) {
|
template <class T> static void error(std::string const& reason) {
|
||||||
auto err = T();
|
auto err = T();
|
||||||
err << errinfo_comment(reason);
|
err << util::errinfo_comment(reason);
|
||||||
BOOST_THROW_EXCEPTION(err);
|
BOOST_THROW_EXCEPTION(err);
|
||||||
}
|
}
|
||||||
void constructOperation(sp::utree const& _t, CompilerState& _s);
|
void constructOperation(sp::utree const& _t, CompilerState& _s);
|
||||||
|
|
||||||
bool m_finalised = false;
|
bool m_finalised = false;
|
||||||
eth::Assembly m_asm;
|
evmasm::Assembly m_asm;
|
||||||
ReadCallback m_readFile;
|
ReadCallback m_readFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
static CodeFragment const NullCodeFragment;
|
static CodeFragment const NullCodeFragment;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -25,10 +25,11 @@
|
|||||||
#include <liblll/CodeFragment.h>
|
#include <liblll/CodeFragment.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::lll;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::lll;
|
||||||
|
|
||||||
bytes dev::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
bytes solidity::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -66,7 +67,7 @@ bytes dev::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _
|
|||||||
return bytes();
|
return bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dev::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
std::string solidity::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -104,7 +105,7 @@ std::string dev::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _ev
|
|||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
string dev::lll::parseLLL(string _src)
|
string solidity::lll::parseLLL(string _src)
|
||||||
{
|
{
|
||||||
sp::utree o;
|
sp::utree o;
|
||||||
|
|
||||||
|
@ -21,16 +21,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
|
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::lll
|
||||||
{
|
|
||||||
namespace lll
|
|
||||||
{
|
{
|
||||||
|
|
||||||
using ReadCallback = std::function<std::string(std::string const&)>;
|
using ReadCallback = std::function<std::string(std::string const&)>;
|
||||||
@ -40,4 +38,3 @@ std::string compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion,
|
|||||||
bytes compileLLL(std::string _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector<std::string>* _errors = nullptr, ReadCallback const& _readFile = ReadCallback());
|
bytes compileLLL(std::string _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector<std::string>* _errors = nullptr, ReadCallback const& _readFile = ReadCallback());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include <liblll/CodeFragment.h>
|
#include <liblll/CodeFragment.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::lll;
|
using namespace solidity::lll;
|
||||||
|
|
||||||
CompilerState::CompilerState()
|
CompilerState::CompilerState()
|
||||||
{
|
{
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include <liblll/CodeFragment.h>
|
#include <liblll/CodeFragment.h>
|
||||||
#include <boost/spirit/include/support_utree.hpp>
|
#include <boost/spirit/include/support_utree.hpp>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::lll
|
||||||
{
|
|
||||||
namespace lll
|
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Macro
|
struct Macro
|
||||||
@ -54,4 +52,3 @@ struct CompilerState
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -21,15 +21,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::lll
|
||||||
{
|
|
||||||
namespace lll
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/// Compile a Low-level Lisp-like Language program into EVM-code.
|
/// Compile a Low-level Lisp-like Language program into EVM-code.
|
||||||
class CompilerException: public dev::Exception {};
|
class CompilerException: public util::Exception {};
|
||||||
class InvalidOperation: public CompilerException {};
|
class InvalidOperation: public CompilerException {};
|
||||||
class IntegerOutOfRange: public CompilerException {};
|
class IntegerOutOfRange: public CompilerException {};
|
||||||
class EmptyList: public CompilerException {};
|
class EmptyList: public CompilerException {};
|
||||||
@ -42,4 +40,3 @@ class BareSymbol: public CompilerException {};
|
|||||||
class ParserException: public CompilerException {};
|
class ParserException: public CompilerException {};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -32,13 +32,14 @@
|
|||||||
#include <boost/spirit/include/support_utree.hpp>
|
#include <boost/spirit/include/support_utree.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::lll;
|
using namespace solidity::util;
|
||||||
|
using namespace solidity::lll;
|
||||||
namespace qi = boost::spirit::qi;
|
namespace qi = boost::spirit::qi;
|
||||||
namespace px = boost::phoenix;
|
namespace px = boost::phoenix;
|
||||||
namespace sp = boost::spirit;
|
namespace sp = boost::spirit;
|
||||||
|
|
||||||
void dev::lll::killBigints(sp::utree const& _this)
|
void solidity::lll::killBigints(sp::utree const& _this)
|
||||||
{
|
{
|
||||||
switch (_this.which())
|
switch (_this.which())
|
||||||
{
|
{
|
||||||
@ -48,7 +49,7 @@ void dev::lll::killBigints(sp::utree const& _this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dev::lll::debugOutAST(ostream& _out, sp::utree const& _this)
|
void solidity::lll::debugOutAST(ostream& _out, sp::utree const& _this)
|
||||||
{
|
{
|
||||||
switch (_this.which())
|
switch (_this.which())
|
||||||
{
|
{
|
||||||
@ -74,7 +75,7 @@ void dev::lll::debugOutAST(ostream& _out, sp::utree const& _this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev {
|
namespace solidity {
|
||||||
namespace lll {
|
namespace lll {
|
||||||
namespace parseTreeLLL_ {
|
namespace parseTreeLLL_ {
|
||||||
|
|
||||||
@ -89,11 +90,11 @@ struct tagNode
|
|||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
void dev::lll::parseTreeLLL(string const& _s, sp::utree& o_out)
|
void solidity::lll::parseTreeLLL(string const& _s, sp::utree& o_out)
|
||||||
{
|
{
|
||||||
using qi::standard::space;
|
using qi::standard::space;
|
||||||
using qi::standard::space_type;
|
using qi::standard::space_type;
|
||||||
using dev::lll::parseTreeLLL_::tagNode;
|
using solidity::lll::parseTreeLLL_::tagNode;
|
||||||
using symbol_type = sp::basic_string<std::string, sp::utree_type::symbol_type>;
|
using symbol_type = sp::basic_string<std::string, sp::utree_type::symbol_type>;
|
||||||
using it = string::const_iterator;
|
using it = string::const_iterator;
|
||||||
|
|
||||||
|
@ -22,16 +22,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <liblll/Exceptions.h>
|
#include <liblll/Exceptions.h>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace boost { namespace spirit { class utree; } }
|
namespace boost { namespace spirit { class utree; } }
|
||||||
namespace sp = boost::spirit;
|
namespace sp = boost::spirit;
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::lll
|
||||||
{
|
|
||||||
namespace lll
|
|
||||||
{
|
{
|
||||||
|
|
||||||
void killBigints(sp::utree const& _this);
|
void killBigints(sp::utree const& _this);
|
||||||
@ -39,4 +37,3 @@ void parseTreeLLL(std::string const& _s, sp::utree& o_out);
|
|||||||
void debugOutAST(std::ostream& _out, sp::utree const& _this);
|
void debugOutAST(std::ostream& _out, sp::utree const& _this);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#include <libsolidity/interface/StandardCompiler.h>
|
#include <libsolidity/interface/StandardCompiler.h>
|
||||||
#include <libsolidity/interface/Version.h>
|
#include <libsolidity/interface/Version.h>
|
||||||
#include <libyul/YulString.h>
|
#include <libyul/YulString.h>
|
||||||
#include <libdevcore/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libdevcore/JSON.h>
|
#include <libsolutil/JSON.h>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -34,8 +34,11 @@
|
|||||||
#include "license.h"
|
#include "license.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
|
using namespace solidity::util;
|
||||||
|
|
||||||
|
using solidity::frontend::ReadCallback;
|
||||||
|
using solidity::frontend::StandardCompiler;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -122,7 +125,7 @@ extern char const* solidity_license() noexcept
|
|||||||
|
|
||||||
extern char const* solidity_version() noexcept
|
extern char const* solidity_version() noexcept
|
||||||
{
|
{
|
||||||
return VersionString.c_str();
|
return frontend::VersionString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback, void* _readContext) noexcept
|
extern char* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback, void* _readContext) noexcept
|
||||||
|
@ -151,7 +151,7 @@ if (NOT (${Z3_FOUND} OR ${CVC4_FOUND}))
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(solidity ${sources} ${z3_SRCS} ${cvc4_SRCS})
|
add_library(solidity ${sources} ${z3_SRCS} ${cvc4_SRCS})
|
||||||
target_link_libraries(solidity PUBLIC yul evmasm langutil devcore Boost::boost Boost::filesystem Boost::system)
|
target_link_libraries(solidity PUBLIC yul evmasm langutil solutil Boost::boost Boost::filesystem Boost::system)
|
||||||
|
|
||||||
if (${Z3_FOUND})
|
if (${Z3_FOUND})
|
||||||
target_link_libraries(solidity PUBLIC z3::libz3)
|
target_link_libraries(solidity PUBLIC z3::libz3)
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::solidity;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
void ConstantEvaluator::endVisit(UnaryOperation const& _operation)
|
void ConstantEvaluator::endVisit(UnaryOperation const& _operation)
|
||||||
{
|
{
|
||||||
|
@ -24,14 +24,12 @@
|
|||||||
|
|
||||||
#include <libsolidity/ast/ASTVisitor.h>
|
#include <libsolidity/ast/ASTVisitor.h>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
class ErrorReporter;
|
class ErrorReporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::frontend
|
||||||
{
|
|
||||||
namespace solidity
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class TypeChecker;
|
class TypeChecker;
|
||||||
@ -72,4 +70,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
using namespace dev::solidity;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -208,18 +208,18 @@ void ContractLevelChecker::checkAbstractFunctions(ContractDefinition const& _con
|
|||||||
|
|
||||||
if (_contract.abstract())
|
if (_contract.abstract())
|
||||||
{
|
{
|
||||||
if (_contract.contractKind() == ContractDefinition::ContractKind::Interface)
|
if (_contract.contractKind() == ContractKind::Interface)
|
||||||
m_errorReporter.typeError(_contract.location(), "Interfaces do not need the \"abstract\" keyword, they are abstract implicitly.");
|
m_errorReporter.typeError(_contract.location(), "Interfaces do not need the \"abstract\" keyword, they are abstract implicitly.");
|
||||||
else if (_contract.contractKind() == ContractDefinition::ContractKind::Library)
|
else if (_contract.contractKind() == ContractKind::Library)
|
||||||
m_errorReporter.typeError(_contract.location(), "Libraries cannot be abstract.");
|
m_errorReporter.typeError(_contract.location(), "Libraries cannot be abstract.");
|
||||||
else
|
else
|
||||||
solAssert(_contract.contractKind() == ContractDefinition::ContractKind::Contract, "");
|
solAssert(_contract.contractKind() == ContractKind::Contract, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// For libraries, we emit errors on function-level, so this is fine as long as we do
|
// For libraries, we emit errors on function-level, so this is fine as long as we do
|
||||||
// not have inheritance for libraries.
|
// not have inheritance for libraries.
|
||||||
if (
|
if (
|
||||||
_contract.contractKind() == ContractDefinition::ContractKind::Contract &&
|
_contract.contractKind() == ContractKind::Contract &&
|
||||||
!_contract.abstract() &&
|
!_contract.abstract() &&
|
||||||
!_contract.annotation().unimplementedFunctions.empty()
|
!_contract.annotation().unimplementedFunctions.empty()
|
||||||
)
|
)
|
||||||
@ -361,10 +361,10 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c
|
|||||||
|
|
||||||
void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract)
|
void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract)
|
||||||
{
|
{
|
||||||
set<FixedHash<4>> hashes;
|
set<util::FixedHash<4>> hashes;
|
||||||
for (auto const& it: _contract.interfaceFunctionList())
|
for (auto const& it: _contract.interfaceFunctionList())
|
||||||
{
|
{
|
||||||
FixedHash<4> const& hash = it.first;
|
util::FixedHash<4> const& hash = it.first;
|
||||||
if (hashes.count(hash))
|
if (hashes.count(hash))
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
_contract.location(),
|
_contract.location(),
|
||||||
|
@ -28,14 +28,12 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
class ErrorReporter;
|
class ErrorReporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::frontend
|
||||||
{
|
|
||||||
namespace solidity
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,4 +88,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
#include <libsolidity/analysis/ControlFlowAnalyzer.h>
|
#include <libsolidity/analysis/ControlFlowAnalyzer.h>
|
||||||
|
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
#include <libdevcore/Algorithms.h>
|
#include <libsolutil/Algorithms.h>
|
||||||
#include <boost/range/algorithm/sort.hpp>
|
#include <boost/range/algorithm/sort.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
using namespace dev::solidity;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
bool ControlFlowAnalyzer::analyze(ASTNode const& _astRoot)
|
bool ControlFlowAnalyzer::analyze(ASTNode const& _astRoot)
|
||||||
{
|
{
|
||||||
@ -151,7 +151,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod
|
|||||||
void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const* _exit, CFGNode const* _revert) const
|
void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const* _exit, CFGNode const* _revert) const
|
||||||
{
|
{
|
||||||
// collect all nodes reachable from the entry point
|
// collect all nodes reachable from the entry point
|
||||||
std::set<CFGNode const*> reachable = BreadthFirstSearch<CFGNode const*>{{_entry}}.run(
|
std::set<CFGNode const*> reachable = util::BreadthFirstSearch<CFGNode const*>{{_entry}}.run(
|
||||||
[](CFGNode const* _node, auto&& _addChild) {
|
[](CFGNode const* _node, auto&& _addChild) {
|
||||||
for (CFGNode const* exit: _node->exits)
|
for (CFGNode const* exit: _node->exits)
|
||||||
_addChild(exit);
|
_addChild(exit);
|
||||||
@ -161,7 +161,7 @@ void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const*
|
|||||||
// traverse all paths backwards from exit and revert
|
// traverse all paths backwards from exit and revert
|
||||||
// and extract (valid) source locations of unreachable nodes into sorted set
|
// and extract (valid) source locations of unreachable nodes into sorted set
|
||||||
std::set<SourceLocation> unreachable;
|
std::set<SourceLocation> unreachable;
|
||||||
BreadthFirstSearch<CFGNode const*>{{_exit, _revert}}.run(
|
util::BreadthFirstSearch<CFGNode const*>{{_exit, _revert}}.run(
|
||||||
[&](CFGNode const* _node, auto&& _addChild) {
|
[&](CFGNode const* _node, auto&& _addChild) {
|
||||||
if (!reachable.count(_node) && !_node->location.isEmpty())
|
if (!reachable.count(_node) && !_node->location.isEmpty())
|
||||||
unreachable.insert(_node->location);
|
unreachable.insert(_node->location);
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
#include <libsolidity/analysis/ControlFlowGraph.h>
|
#include <libsolidity/analysis/ControlFlowGraph.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::frontend
|
||||||
{
|
|
||||||
namespace solidity
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class ControlFlowAnalyzer: private ASTConstVisitor
|
class ControlFlowAnalyzer: private ASTConstVisitor
|
||||||
@ -47,4 +45,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
||||||
|
|
||||||
using namespace dev;
|
|
||||||
using namespace langutil;
|
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
|
using namespace solidity::langutil;
|
||||||
|
using namespace solidity::frontend;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ControlFlowBuilder::ControlFlowBuilder(CFG::NodeContainer& _nodeContainer, FunctionFlow const& _functionFlow):
|
ControlFlowBuilder::ControlFlowBuilder(CFG::NodeContainer& _nodeContainer, FunctionFlow const& _functionFlow):
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace dev {
|
namespace solidity::frontend {
|
||||||
namespace solidity {
|
|
||||||
|
|
||||||
/** Helper class that builds the control flow of a function or modifier.
|
/** Helper class that builds the control flow of a function or modifier.
|
||||||
* Modifiers are not yet applied to the functions. This is done in a second
|
* Modifiers are not yet applied to the functions. This is done in a second
|
||||||
@ -161,4 +160,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
using namespace dev::solidity;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
bool CFG::constructFlow(ASTNode const& _astRoot)
|
bool CFG::constructFlow(ASTNode const& _astRoot)
|
||||||
{
|
{
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::frontend
|
||||||
{
|
|
||||||
namespace solidity
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,4 +152,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
|
|
||||||
#include <libsolidity/ast/AST.h>
|
#include <libsolidity/ast/AST.h>
|
||||||
#include <libsolidity/ast/Types.h>
|
#include <libsolidity/ast/Types.h>
|
||||||
#include <libdevcore/StringUtils.h>
|
#include <libsolutil/StringUtils.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace dev::solidity;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
Declaration const* DeclarationContainer::conflictingDeclaration(
|
Declaration const* DeclarationContainer::conflictingDeclaration(
|
||||||
Declaration const& _declaration,
|
Declaration const& _declaration,
|
||||||
@ -118,7 +118,7 @@ bool DeclarationContainer::registerDeclaration(
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
vector<Declaration const*>& decls = _invisible ? m_invisibleDeclarations[*_name] : m_declarations[*_name];
|
vector<Declaration const*>& decls = _invisible ? m_invisibleDeclarations[*_name] : m_declarations[*_name];
|
||||||
if (!contains(decls, &_declaration))
|
if (!util::contains(decls, &_declaration))
|
||||||
decls.push_back(&_declaration);
|
decls.push_back(&_declaration);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -148,13 +148,13 @@ vector<ASTString> DeclarationContainer::similarNames(ASTString const& _name) con
|
|||||||
for (auto const& declaration: m_declarations)
|
for (auto const& declaration: m_declarations)
|
||||||
{
|
{
|
||||||
string const& declarationName = declaration.first;
|
string const& declarationName = declaration.first;
|
||||||
if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
||||||
similar.push_back(declarationName);
|
similar.push_back(declarationName);
|
||||||
}
|
}
|
||||||
for (auto const& declaration: m_invisibleDeclarations)
|
for (auto const& declaration: m_invisibleDeclarations)
|
||||||
{
|
{
|
||||||
string const& declarationName = declaration.first;
|
string const& declarationName = declaration.first;
|
||||||
if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
||||||
similar.push_back(declarationName);
|
similar.push_back(declarationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace dev
|
namespace solidity::frontend
|
||||||
{
|
|
||||||
namespace solidity
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,4 +74,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace solidity;
|
||||||
using namespace langutil;
|
using namespace solidity::langutil;
|
||||||
using namespace dev::solidity;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)
|
bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user