mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9467 from ethereum/develop
Merge develop into release for 0.6.12
This commit is contained in:
commit
27d51765c0
@ -7,18 +7,21 @@
|
||||
# - ems: Emscripten
|
||||
version: 2.1
|
||||
parameters:
|
||||
ubuntu-1804-docker-image-rev:
|
||||
ubuntu-1804-docker-image:
|
||||
type: string
|
||||
default: "4"
|
||||
ubuntu-2004-docker-image-rev:
|
||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:4484ac3da8fdc337cc77a7a7be1af71cd0f28f9c890d934f1d6ae7532beb66b1"
|
||||
ubuntu-2004-docker-image:
|
||||
type: string
|
||||
default: "2"
|
||||
ubuntu-2004-clang-docker-image-rev:
|
||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:48b5bb6b91ac7dddfe9345c88876ebed126c652258800f114caed69db73b29bf"
|
||||
ubuntu-2004-clang-docker-image:
|
||||
type: string
|
||||
default: "2"
|
||||
ubuntu-1604-clang-ossfuzz-docker-image-rev:
|
||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d8775de58167db5a11690fdb6ef639317fe1e579ec5d46e9732d2d903b55d135"
|
||||
ubuntu-1604-clang-ossfuzz-docker-image:
|
||||
type: string
|
||||
default: "2"
|
||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:db52f3257396814215744a19904e42c07e040ab36b68be72a27ba71ad2f1083c"
|
||||
emscripten-docker-image:
|
||||
type: string
|
||||
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc"
|
||||
|
||||
defaults:
|
||||
|
||||
@ -33,26 +36,11 @@ defaults:
|
||||
|
||||
- run_build: &run_build
|
||||
name: Build
|
||||
command: |
|
||||
set -ex
|
||||
if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n > prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; fi
|
||||
echo -n "$CIRCLE_SHA1" > commit_hash.txt
|
||||
mkdir -p build
|
||||
cd build
|
||||
[ -n "$COVERAGE" -a "$CIRCLE_BRANCH" != release -a -z "$CIRCLE_TAG" ] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} $CMAKE_OPTIONS -G "Unix Makefiles"
|
||||
make -j4
|
||||
command: scripts/ci/build.sh
|
||||
|
||||
- run_build_ossfuzz: &run_build_ossfuzz
|
||||
name: Build_ossfuzz
|
||||
command: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
protoc --proto_path=../test/tools/ossfuzz yulProto.proto --cpp_out=../test/tools/ossfuzz
|
||||
protoc --proto_path=../test/tools/ossfuzz abiV2Proto.proto --cpp_out=../test/tools/ossfuzz
|
||||
protoc --proto_path=../test/tools/ossfuzz solProto.proto --cpp_out=../test/tools/ossfuzz
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} $CMAKE_OPTIONS
|
||||
make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j4
|
||||
command: scripts/ci/build_ossfuzz.sh
|
||||
|
||||
- run_proofs: &run_proofs
|
||||
name: Correctness proofs for optimization rules
|
||||
@ -97,6 +85,7 @@ defaults:
|
||||
- test/tools/ossfuzz/strictasm_diff_ossfuzz
|
||||
- test/tools/ossfuzz/strictasm_opt_ossfuzz
|
||||
- test/tools/ossfuzz/yul_proto_diff_ossfuzz
|
||||
- test/tools/ossfuzz/yul_proto_diff_custom_mutate_ossfuzz
|
||||
- test/tools/ossfuzz/yul_proto_ossfuzz
|
||||
- test/tools/ossfuzz/sol_proto_ossfuzz
|
||||
|
||||
@ -130,7 +119,7 @@ defaults:
|
||||
|
||||
- test_ubuntu1604_clang: &test_ubuntu1604_clang
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu1604-clang-ossfuzz-<< pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >>
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
@ -141,7 +130,7 @@ defaults:
|
||||
|
||||
- test_ubuntu2004_clang: &test_ubuntu2004_clang
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-clang-<< pipeline.parameters.ubuntu-2004-clang-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
@ -152,7 +141,8 @@ defaults:
|
||||
|
||||
- test_ubuntu2004: &test_ubuntu2004
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
|
||||
parallelism: 6
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
@ -387,7 +377,7 @@ jobs:
|
||||
|
||||
chk_docs_pragma_min_version:
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
|
||||
environment:
|
||||
TERM: xterm
|
||||
steps:
|
||||
@ -396,7 +386,7 @@ jobs:
|
||||
|
||||
b_ubu_clang: &build_ubuntu2004_clang
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-clang-<< pipeline.parameters.ubuntu-2004-clang-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
|
||||
environment:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
@ -409,7 +399,7 @@ jobs:
|
||||
|
||||
b_ubu_asan_clang: &build_ubuntu2004_clang
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-clang-<< pipeline.parameters.ubuntu-2004-clang-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
|
||||
environment:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
@ -421,8 +411,11 @@ jobs:
|
||||
- persist_to_workspace: *artifacts_executables
|
||||
|
||||
b_ubu: &build_ubuntu2004
|
||||
resource_class: xlarge
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
|
||||
environment:
|
||||
MAKEFLAGS: -j 10
|
||||
steps:
|
||||
- checkout
|
||||
- run: *run_build
|
||||
@ -437,7 +430,7 @@ jobs:
|
||||
|
||||
b_ubu18: &build_ubuntu1804
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu1804-<< pipeline.parameters.ubuntu-1804-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-1804-docker-image >>
|
||||
environment:
|
||||
CMAKE_OPTIONS: -DCMAKE_CXX_FLAGS=-O2
|
||||
CMAKE_BUILD_TYPE: RelWithDebugInfo
|
||||
@ -491,7 +484,7 @@ jobs:
|
||||
|
||||
b_ubu_ossfuzz: &build_ubuntu1604_clang
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu1604-clang-ossfuzz-<< pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >>
|
||||
environment:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
@ -597,9 +590,11 @@ jobs:
|
||||
- store_artifacts: *artifacts_test_results
|
||||
|
||||
b_ems:
|
||||
resource_class: xlarge
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:emsdk-1.39.15-2
|
||||
- image: << pipeline.parameters.emscripten-docker-image >>
|
||||
environment:
|
||||
MAKEFLAGS: -j 10
|
||||
TERM: xterm
|
||||
steps:
|
||||
- checkout
|
||||
@ -633,7 +628,7 @@ jobs:
|
||||
|
||||
b_docs:
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
|
||||
steps:
|
||||
- checkout
|
||||
- run: *setup_prerelease_commit_hash
|
||||
@ -649,7 +644,7 @@ jobs:
|
||||
|
||||
t_ubu_soltest_enforce_yul: &t_ubu_soltest_enforce_yul
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
|
||||
environment:
|
||||
EVM: constantinople
|
||||
SOLTEST_FLAGS: --enforce-via-yul
|
||||
@ -675,7 +670,7 @@ jobs:
|
||||
|
||||
t_ubu_cli: &t_ubu_cli
|
||||
docker:
|
||||
- image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >>
|
||||
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
|
||||
environment:
|
||||
TERM: xterm
|
||||
steps:
|
||||
|
@ -54,7 +54,7 @@ get_logfile_basename() {
|
||||
echo -ne "${filename}"
|
||||
}
|
||||
|
||||
BOOST_TEST_ARGS="--color_output=no --show_progress=yes --logger=JUNIT,error,test_results/`get_logfile_basename`.xml"
|
||||
BOOST_TEST_ARGS="--color_output=no --show_progress=yes --logger=JUNIT,error,test_results/`get_logfile_basename`.xml ${BOOST_TEST_ARGS}"
|
||||
SOLTEST_ARGS="--evm-version=$EVM $SOLTEST_FLAGS"
|
||||
test "${OPTIMIZE}" = "1" && SOLTEST_ARGS="${SOLTEST_ARGS} --optimize"
|
||||
test "${ABI_ENCODER_V2}" = "1" && SOLTEST_ARGS="${SOLTEST_ARGS} --abiencoderv2"
|
||||
|
@ -28,10 +28,49 @@ set -e
|
||||
|
||||
REPODIR="$(realpath $(dirname $0)/..)"
|
||||
|
||||
for OPTIMIZE in 0 1; do
|
||||
for EVM in homestead byzantium constantinople petersburg istanbul; do
|
||||
EVM=$EVM OPTIMIZE=$OPTIMIZE ${REPODIR}/.circleci/soltest.sh
|
||||
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul)
|
||||
OPTIMIZE_VALUES=(0 1)
|
||||
STEPS=$(( 1 + ${#EVM_VALUES[@]} * ${#OPTIMIZE_VALUES[@]} ))
|
||||
|
||||
if (( $CIRCLE_NODE_TOTAL )) && (( $CIRCLE_NODE_TOTAL > 1 ))
|
||||
then
|
||||
# Run step 1 as the only step on the first executor
|
||||
# and evenly distribute the other steps among
|
||||
# the other executors.
|
||||
# The first step takes much longer than the other steps.
|
||||
if (( $CIRCLE_NODE_INDEX == 0 ))
|
||||
then
|
||||
RUN_STEPS="1"
|
||||
else
|
||||
export CIRCLE_NODE_INDEX=$(($CIRCLE_NODE_INDEX - 1))
|
||||
export CIRCLE_NODE_TOTAL=$(($CIRCLE_NODE_TOTAL - 1))
|
||||
RUN_STEPS=$(seq 2 "$STEPS" | circleci tests split)
|
||||
fi
|
||||
else
|
||||
RUN_STEPS=$(seq "$STEPS")
|
||||
fi
|
||||
|
||||
# turn newlines into spaces
|
||||
RUN_STEPS=$(echo $RUN_STEPS)
|
||||
|
||||
echo "Running steps $RUN_STEPS..."
|
||||
|
||||
STEP=1
|
||||
|
||||
[[ " $RUN_STEPS " =~ " $STEP " ]] && EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 "${REPODIR}/.circleci/soltest.sh"
|
||||
STEP=$(($STEP + 1))
|
||||
|
||||
for OPTIMIZE in ${OPTIMIZE_VALUES[@]}
|
||||
do
|
||||
for EVM in ${EVM_VALUES[@]}
|
||||
do
|
||||
[[ " $RUN_STEPS " =~ " $STEP " ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh"
|
||||
STEP=$(($STEP + 1))
|
||||
done
|
||||
done
|
||||
|
||||
EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh
|
||||
if (($STEP != $STEPS + 1))
|
||||
then
|
||||
echo "Step counter not properly adjusted!" >2
|
||||
exit 1
|
||||
fi
|
||||
|
43
.github/workflows/buildpack-deps.yml
vendored
Normal file
43
.github/workflows/buildpack-deps.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: buildpack-deps
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
paths:
|
||||
- 'scripts/docker/buildpack-deps/Dockerfile.emscripten'
|
||||
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz'
|
||||
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu1804'
|
||||
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang'
|
||||
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004'
|
||||
|
||||
jobs:
|
||||
buildpack-deps:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
DOCKER_REPOSITORY: solbuildpackpusher/solidity-buildpack-deps
|
||||
IMAGE_NAME: buildpack-deps
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image_variant: [emscripten, ubuntu1604.clang.ossfuzz, ubuntu1804, ubuntu2004.clang, ubuntu2004]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Upgrade ${{ env.IMAGE_NAME }}-${{ matrix.image_variant }}
|
||||
run: |
|
||||
echo ${DOCKERHUB_TOKEN} | docker login -u solbuildpackpusher --password-stdin
|
||||
scripts/ci/docker_upgrade.sh ${{ env.IMAGE_NAME }} ${{ matrix.image_variant }} ${{ env.DOCKER_REPOSITORY }}
|
||||
docker logout
|
||||
|
||||
- name: comment PR
|
||||
if: "env.DOCKER_IMAGE"
|
||||
uses: aarlt/comment-on-pr@v1.2.0
|
||||
with:
|
||||
msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`."
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -32,10 +32,10 @@ prerelease.txt
|
||||
|
||||
# Build directory
|
||||
build/
|
||||
build*/
|
||||
/build*/
|
||||
emscripten_build/
|
||||
docs/_build
|
||||
docs/utils/__pycache__
|
||||
__pycache__
|
||||
docs/utils/*.pyc
|
||||
/deps/downloads/
|
||||
deps/install
|
||||
|
@ -47,6 +47,7 @@ env:
|
||||
- SOLC_TESTS=On
|
||||
- SOLC_STOREBYTECODE=Off
|
||||
- SOLC_DOCKER=Off
|
||||
- MAKEFLAGS="-j 4"
|
||||
|
||||
matrix:
|
||||
include:
|
||||
@ -112,7 +113,7 @@ matrix:
|
||||
before_install:
|
||||
- nvm install 10
|
||||
- nvm use 10
|
||||
- docker pull ethereum/solidity-buildpack-deps:emsdk-1.39.15-2
|
||||
- docker pull solbuildpackpusher/solidity-buildpack-deps@sha256:d557d015918c3cf68b0d22839bab41013f0757b651a7fef21595f89721dbebcc
|
||||
env:
|
||||
- SOLC_EMSCRIPTEN=On
|
||||
- SOLC_INSTALL_DEPS_TRAVIS=Off
|
||||
|
@ -10,7 +10,7 @@ include(EthPolicy)
|
||||
eth_policy()
|
||||
|
||||
# project name and version should be set after cmake_policy CMP0048
|
||||
set(PROJECT_VERSION "0.6.11")
|
||||
set(PROJECT_VERSION "0.6.12")
|
||||
# OSX target needed in order to support std::visit
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
|
||||
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
|
||||
|
29
Changelog.md
29
Changelog.md
@ -1,3 +1,32 @@
|
||||
### 0.6.12 (2020-07-22)
|
||||
|
||||
Language Features:
|
||||
* NatSpec: Implement tag ``@inheritdoc`` to copy documentation from a specific base contract.
|
||||
* Wasm backend: Add ``i32.ctz``, ``i64.ctz``, ``i32.popcnt``, and ``i64.popcnt``.
|
||||
|
||||
|
||||
Compiler Features:
|
||||
* Code Generator: Avoid double cleanup when copying to memory.
|
||||
* Code Generator: Evaluate ``keccak256`` of string literals at compile-time.
|
||||
* Optimizer: Add rule to remove shifts inside the byte opcode.
|
||||
* Peephole Optimizer: Add rule to remove swap after dup.
|
||||
* Peephole Optimizer: Remove unnecessary masking of tags.
|
||||
* Yul EVM Code Transform: Free stack slots directly after visiting the right-hand-side of variable declarations instead of at the end of the statement only.
|
||||
|
||||
|
||||
Bugfixes:
|
||||
* SMTChecker: Fix error in events with indices of type static array.
|
||||
* SMTChecker: Fix internal error in sequential storage array pushes (``push().push()``).
|
||||
* SMTChecker: Fix internal error when using bitwise operators on fixed bytes type.
|
||||
* SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches.
|
||||
* Type Checker: Fix internal compiler error related to oversized types.
|
||||
* Type Checker: Fix overload resolution in combination with ``{value: ...}``.
|
||||
|
||||
|
||||
Build System:
|
||||
* Update internal dependency of jsoncpp to 1.9.3.
|
||||
|
||||
|
||||
### 0.6.11 (2020-07-07)
|
||||
|
||||
Language Features:
|
||||
|
@ -50,6 +50,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
||||
add_compile_options(-pedantic)
|
||||
add_compile_options(-Wno-unknown-pragmas)
|
||||
add_compile_options(-Wimplicit-fallthrough)
|
||||
add_compile_options(-Wsign-conversion)
|
||||
|
||||
# Configuration-specific compiler settings.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
|
||||
|
@ -37,15 +37,16 @@ endif()
|
||||
ExternalProject_Add(jsoncpp-project
|
||||
PREFIX "${prefix}"
|
||||
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
|
||||
DOWNLOAD_NAME jsoncpp-1.9.2.tar.gz
|
||||
URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.2.tar.gz
|
||||
URL_HASH SHA256=77a402fb577b2e0e5d0bdc1cf9c65278915cdb25171e3452c68b6da8a561f8f0
|
||||
DOWNLOAD_NAME jsoncpp-1.9.3.tar.gz
|
||||
URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz
|
||||
URL_HASH SHA256=8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d
|
||||
CMAKE_COMMAND ${JSONCPP_CMAKE_COMMAND}
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
# Build static lib but suitable to be included in a shared lib.
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
|
||||
-DJSONCPP_WITH_EXAMPLE=OFF
|
||||
-DJSONCPP_WITH_TESTS=OFF
|
||||
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
|
||||
-DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS}
|
||||
|
@ -1113,6 +1113,10 @@
|
||||
"bugs": [],
|
||||
"released": "2020-07-07"
|
||||
},
|
||||
"0.6.12": {
|
||||
"bugs": [],
|
||||
"released": "2020-07-22"
|
||||
},
|
||||
"0.6.2": {
|
||||
"bugs": [
|
||||
"MissingEscapingInFormatting",
|
||||
|
@ -77,7 +77,7 @@ version stands as a reference.
|
||||
* `Japanese <https://solidity-jp.readthedocs.io>`_
|
||||
* `Korean <http://solidity-kr.readthedocs.io>`_ (in progress)
|
||||
* `Russian <https://github.com/ethereum/wiki/wiki/%5BRussian%5D-%D0%A0%D1%83%D0%BA%D0%BE%D0%B2%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D0%BE-%D0%BF%D0%BE-Solidity>`_ (rather outdated)
|
||||
* `Simplified Chinese <http://solidity-cn.readthedocs.io>`_ (in progress)
|
||||
* `Simplified Chinese <https://learnblockchain.cn/docs/solidity/>`_ (in progress)
|
||||
* `Spanish <https://solidity-es.readthedocs.io>`_
|
||||
* `Turkish <https://github.com/denizozzgur/Solidity_TR/blob/master/README.md>`_ (partial)
|
||||
|
||||
|
@ -49,7 +49,7 @@ The following example shows a contract and a function using all available tags.
|
||||
.. code:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
pragma solidity >0.6.10 <0.7.0;
|
||||
|
||||
/// @title A simulator for trees
|
||||
/// @author Larry A. Gardner
|
||||
@ -60,9 +60,33 @@ The following example shows a contract and a function using all available tags.
|
||||
/// @dev The Alexandr N. Tetearing algorithm could increase precision
|
||||
/// @param rings The number of rings from dendrochronological sample
|
||||
/// @return age in years, rounded up for partial years
|
||||
function age(uint256 rings) external pure returns (uint256) {
|
||||
function age(uint256 rings) external virtual pure returns (uint256) {
|
||||
return rings + 1;
|
||||
}
|
||||
|
||||
/// @notice Returns the amount of leaves the tree has.
|
||||
/// @dev Returns only a fixed number.
|
||||
function leaves() external virtual pure returns(uint256) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
contract Plant {
|
||||
function leaves() external virtual pure returns(uint256) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
contract KumquatTree is Tree, Plant {
|
||||
function age(uint256 rings) external override pure returns (uint256) {
|
||||
return rings + 2;
|
||||
}
|
||||
|
||||
/// Return the amount of leaves that this specific kind of tree has
|
||||
/// @inheritdoc Tree
|
||||
function leaves() external override(Tree, Plant) pure returns(uint256) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
.. _header-tags:
|
||||
@ -75,16 +99,17 @@ NatSpec tag and where it may be used. As a special case, if no tags are
|
||||
used then the Solidity compiler will interpret a ``///`` or ``/**`` comment
|
||||
in the same way as if it were tagged with ``@notice``.
|
||||
|
||||
=========== =============================================================================== =============================
|
||||
=============== ====================================================================================== =============================
|
||||
Tag Context
|
||||
=========== =============================================================================== =============================
|
||||
=============== ====================================================================================== =============================
|
||||
``@title`` A title that should describe the contract/interface contract, interface
|
||||
``@author`` The name of the author contract, interface
|
||||
``@notice`` Explain to an end user what this does contract, interface, function, public state variable, event
|
||||
``@dev`` Explain to a developer any extra details contract, interface, function, state variable, event
|
||||
``@param`` Documents a parameter just like in doxygen (must be followed by parameter name) function, event
|
||||
``@return`` Documents the return variables of a contract's function function, public state variable
|
||||
=========== =============================================================================== =============================
|
||||
``@inheritdoc`` Copies all missing tags from the base function (must be followed by the contract name) function, public state variable
|
||||
=============== ====================================================================================== =============================
|
||||
|
||||
If your function returns multiple values, like ``(int quotient, int remainder)``
|
||||
then use multiple ``@return`` statements in the same format as the
|
||||
@ -127,6 +152,7 @@ base function. Exceptions to this are:
|
||||
|
||||
* When the parameter names are different.
|
||||
* When there is more than one base function.
|
||||
* When there is an explicit ``@inheritdoc`` tag which specifies which contract should be used to inherit.
|
||||
|
||||
.. _header-output:
|
||||
|
||||
|
@ -237,6 +237,23 @@ memory arrays, i.e. the following is not possible:
|
||||
It is planned to remove this restriction in the future, but it creates some
|
||||
complications because of how arrays are passed in the ABI.
|
||||
|
||||
If you want to initialize dynamically-sized arrays, you have to assign the
|
||||
individual elements:
|
||||
|
||||
::
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f() public pure {
|
||||
uint[] memory x = new uint[](3);
|
||||
x[0] = 1;
|
||||
x[1] = 3;
|
||||
x[2] = 4;
|
||||
}
|
||||
}
|
||||
|
||||
.. index:: ! array;length, length, push, pop, !array;push, !array;pop
|
||||
|
||||
.. _array-members:
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file Assembly.cpp
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
@ -91,8 +92,8 @@ string locationFromSources(StringMap const& _sourceCodes, SourceLocation const&
|
||||
class Functionalizer
|
||||
{
|
||||
public:
|
||||
Functionalizer (ostream& _out, string const& _prefix, StringMap const& _sourceCodes):
|
||||
m_out(_out), m_prefix(_prefix), m_sourceCodes(_sourceCodes)
|
||||
Functionalizer (ostream& _out, string const& _prefix, StringMap const& _sourceCodes, Assembly const& _assembly):
|
||||
m_out(_out), m_prefix(_prefix), m_sourceCodes(_sourceCodes), m_assembly(_assembly)
|
||||
{}
|
||||
|
||||
void feed(AssemblyItem const& _item)
|
||||
@ -103,6 +104,9 @@ public:
|
||||
m_location = _item.location();
|
||||
printLocation();
|
||||
}
|
||||
|
||||
string expression = _item.toAssemblyText(m_assembly);
|
||||
|
||||
if (!(
|
||||
_item.canBeFunctional() &&
|
||||
_item.returnValues() <= 1 &&
|
||||
@ -110,10 +114,9 @@ public:
|
||||
))
|
||||
{
|
||||
flush();
|
||||
m_out << m_prefix << (_item.type() == Tag ? "" : " ") << _item.toAssemblyText() << endl;
|
||||
m_out << m_prefix << (_item.type() == Tag ? "" : " ") << expression << endl;
|
||||
return;
|
||||
}
|
||||
string expression = _item.toAssemblyText();
|
||||
if (_item.arguments() > 0)
|
||||
{
|
||||
expression += "(";
|
||||
@ -159,13 +162,14 @@ private:
|
||||
ostream& m_out;
|
||||
string const& m_prefix;
|
||||
StringMap const& m_sourceCodes;
|
||||
Assembly const& m_assembly;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void Assembly::assemblyStream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const
|
||||
{
|
||||
Functionalizer f(_out, _prefix, _sourceCodes);
|
||||
Functionalizer f(_out, _prefix, _sourceCodes, *this);
|
||||
|
||||
for (auto const& i: m_items)
|
||||
f.feed(i);
|
||||
@ -521,6 +525,7 @@ map<u256, u256> Assembly::optimiseInternal(
|
||||
|
||||
LinkerObject const& Assembly::assemble() const
|
||||
{
|
||||
assertThrow(!m_invalid, AssemblyException, "Attempted to assemble invalid Assembly object.");
|
||||
// Return the already assembled object, if present.
|
||||
if (!m_assembledObject.bytecode.empty())
|
||||
return m_assembledObject;
|
||||
@ -637,7 +642,7 @@ LinkerObject const& Assembly::assemble() const
|
||||
case PushSubSize:
|
||||
{
|
||||
assertThrow(i.data() <= numeric_limits<size_t>::max(), AssemblyException, "");
|
||||
auto s = m_subs.at(static_cast<size_t>(i.data()))->assemble().bytecode.size();
|
||||
auto s = subAssemblyById(static_cast<size_t>(i.data()))->assemble().bytecode.size();
|
||||
i.setPushedValue(u256(s));
|
||||
uint8_t b = max<unsigned>(1, util::bytesRequired(s));
|
||||
ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b);
|
||||
@ -705,25 +710,20 @@ LinkerObject const& Assembly::assemble() const
|
||||
// Append an INVALID here to help tests find miscompilation.
|
||||
ret.bytecode.push_back(uint8_t(Instruction::INVALID));
|
||||
|
||||
for (size_t i = 0; i < m_subs.size(); ++i)
|
||||
for (auto const& [subIdPath, bytecodeOffset]: subRef)
|
||||
{
|
||||
auto references = subRef.equal_range(i);
|
||||
if (references.first == references.second)
|
||||
continue;
|
||||
for (auto ref = references.first; ref != references.second; ++ref)
|
||||
{
|
||||
bytesRef r(ret.bytecode.data() + ref->second, bytesPerDataRef);
|
||||
bytesRef r(ret.bytecode.data() + bytecodeOffset, bytesPerDataRef);
|
||||
toBigEndian(ret.bytecode.size(), r);
|
||||
ret.append(subAssemblyById(subIdPath)->assemble());
|
||||
}
|
||||
ret.append(m_subs[i]->assemble());
|
||||
}
|
||||
|
||||
for (auto const& i: tagRef)
|
||||
{
|
||||
size_t subId;
|
||||
size_t tagId;
|
||||
tie(subId, tagId) = i.second;
|
||||
assertThrow(subId == numeric_limits<size_t>::max() || subId < m_subs.size(), AssemblyException, "Invalid sub id");
|
||||
std::vector<size_t> const& tagPositions =
|
||||
vector<size_t> const& tagPositions =
|
||||
subId == numeric_limits<size_t>::max() ?
|
||||
m_tagPositionsInBytecode :
|
||||
m_subs[subId]->m_tagPositionsInBytecode;
|
||||
@ -756,3 +756,51 @@ LinkerObject const& Assembly::assemble() const
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
vector<size_t> Assembly::decodeSubPath(size_t _subObjectId) const
|
||||
{
|
||||
if (_subObjectId < m_subs.size())
|
||||
return {_subObjectId};
|
||||
|
||||
auto subIdPathIt = find_if(
|
||||
m_subPaths.begin(),
|
||||
m_subPaths.end(),
|
||||
[_subObjectId](auto const& subId) { return subId.second == _subObjectId; }
|
||||
);
|
||||
|
||||
assertThrow(subIdPathIt != m_subPaths.end(), AssemblyException, "");
|
||||
return subIdPathIt->first;
|
||||
}
|
||||
|
||||
size_t Assembly::encodeSubPath(vector<size_t> const& _subPath)
|
||||
{
|
||||
assertThrow(!_subPath.empty(), AssemblyException, "");
|
||||
if (_subPath.size() == 1)
|
||||
{
|
||||
assertThrow(_subPath[0] < m_subs.size(), AssemblyException, "");
|
||||
return _subPath[0];
|
||||
}
|
||||
|
||||
if (m_subPaths.find(_subPath) == m_subPaths.end())
|
||||
{
|
||||
size_t objectId = numeric_limits<size_t>::max() - m_subPaths.size();
|
||||
assertThrow(objectId >= m_subs.size(), AssemblyException, "");
|
||||
m_subPaths[_subPath] = objectId;
|
||||
}
|
||||
|
||||
return m_subPaths[_subPath];
|
||||
}
|
||||
|
||||
Assembly const* Assembly::subAssemblyById(size_t _subId) const
|
||||
{
|
||||
vector<size_t> subIds = decodeSubPath(_subId);
|
||||
Assembly const* currentAssembly = this;
|
||||
for (size_t currentSubId: subIds)
|
||||
{
|
||||
currentAssembly = currentAssembly->m_subs.at(currentSubId).get();
|
||||
assertThrow(currentAssembly, AssemblyException, "");
|
||||
}
|
||||
|
||||
assertThrow(currentAssembly != this, AssemblyException, "");
|
||||
return currentAssembly;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -142,6 +143,12 @@ public:
|
||||
std::map<std::string, unsigned> const& _sourceIndices = std::map<std::string, unsigned>()
|
||||
) const;
|
||||
|
||||
/// Mark this assembly as invalid. Calling ``assemble`` on it will throw.
|
||||
void markAsInvalid() { m_invalid = true; }
|
||||
|
||||
std::vector<size_t> decodeSubPath(size_t _subObjectId) const;
|
||||
size_t encodeSubPath(std::vector<size_t> const& _subPath);
|
||||
|
||||
protected:
|
||||
/// Does the same operations as @a optimise, but should only be applied to a sub and
|
||||
/// returns the replaced tags. Also takes an argument containing the tags of this assembly
|
||||
@ -161,6 +168,10 @@ private:
|
||||
);
|
||||
static std::string toStringInHex(u256 _value);
|
||||
|
||||
bool m_invalid = false;
|
||||
|
||||
Assembly const* subAssemblyById(size_t _subId) const;
|
||||
|
||||
protected:
|
||||
/// 0 is reserved for exception
|
||||
unsigned m_usedTags = 1;
|
||||
@ -174,6 +185,10 @@ protected:
|
||||
std::map<util::h256, std::string> m_libraries; ///< Identifiers of libraries to be linked.
|
||||
std::map<util::h256, std::string> m_immutables; ///< Identifiers of immutables.
|
||||
|
||||
/// Map from a vector representing a path to a particular sub assembly to sub assembly id.
|
||||
/// This map is used only for sub-assemblies which are not direct sub-assemblies (where path is having more than one value).
|
||||
std::map<std::vector<size_t>, size_t> m_subPaths;
|
||||
|
||||
mutable LinkerObject m_assembledObject;
|
||||
mutable std::vector<size_t> m_tagPositionsInBytecode;
|
||||
|
||||
|
@ -14,10 +14,14 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libevmasm/AssemblyItem.h>
|
||||
|
||||
#include <libevmasm/Assembly.h>
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
#include <libsolutil/FixedHash.h>
|
||||
#include <liblangutil/SourceLocation.h>
|
||||
|
||||
@ -169,7 +173,7 @@ string AssemblyItem::getJumpTypeAsString() const
|
||||
}
|
||||
}
|
||||
|
||||
string AssemblyItem::toAssemblyText() const
|
||||
string AssemblyItem::toAssemblyText(Assembly const& _assembly) const
|
||||
{
|
||||
string text;
|
||||
switch (type())
|
||||
@ -207,11 +211,18 @@ string AssemblyItem::toAssemblyText() const
|
||||
text = string("data_") + util::toHex(data());
|
||||
break;
|
||||
case PushSub:
|
||||
text = string("dataOffset(sub_") + to_string(static_cast<size_t>(data())) + ")";
|
||||
break;
|
||||
case PushSubSize:
|
||||
text = string("dataSize(sub_") + to_string(static_cast<size_t>(data())) + ")";
|
||||
{
|
||||
vector<string> subPathComponents;
|
||||
for (size_t subPathComponentId: _assembly.decodeSubPath(static_cast<size_t>(data())))
|
||||
subPathComponents.emplace_back("sub_" + to_string(subPathComponentId));
|
||||
text =
|
||||
(type() == PushSub ? "dataOffset"s : "dataSize"s) +
|
||||
"(" +
|
||||
solidity::util::joinHumanReadable(subPathComponents, ".") +
|
||||
")";
|
||||
break;
|
||||
}
|
||||
case PushProgramSize:
|
||||
text = string("bytecodeSize");
|
||||
break;
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file AssemblyItem.h
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
@ -151,7 +152,7 @@ public:
|
||||
void setPushedValue(u256 const& _value) const { m_pushedValue = std::make_shared<u256>(_value); }
|
||||
u256 const* pushedValue() const { return m_pushedValue.get(); }
|
||||
|
||||
std::string toAssemblyText() const;
|
||||
std::string toAssemblyText(Assembly const& _assembly) const;
|
||||
|
||||
size_t m_modifierDepth = 0;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file BlockDeduplicator.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file BlockDeduplicator.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file CommonSubexpressionEliminator.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file CommonSubexpressionEliminator.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file ConstantOptimiser.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file ConstantOptimiser.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file ControlFlowGraph.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file ControlFlowGraph.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file Exceptions.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file ExpressionClasses.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file ExpressionClasses.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libevmasm/GasMeter.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file GasMeter.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file Instruction.cpp
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file Instruction.h
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
@ -174,16 +175,16 @@ enum class Instruction: uint8_t
|
||||
LOG3, ///< Makes a log entry; 3 topics.
|
||||
LOG4, ///< Makes a log entry; 4 topics.
|
||||
|
||||
JUMPTO = 0xb0, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
|
||||
JUMPIF, ///< conditionally alter the program counter -- not part of Instructions.cpp
|
||||
JUMPV, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
|
||||
JUMPSUB, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
|
||||
JUMPSUBV, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
|
||||
BEGINSUB, ///< set a potential jumpsub destination -- not part of Instructions.cpp
|
||||
BEGINDATA, ///< begin the data section -- not part of Instructions.cpp
|
||||
RETURNSUB, ///< return to subroutine jumped from -- not part of Instructions.cpp
|
||||
PUTLOCAL, ///< pop top of stack to local variable -- not part of Instructions.cpp
|
||||
GETLOCAL, ///< push local variable to top of stack -- not part of Instructions.cpp
|
||||
EIP615_JUMPTO = 0xb0, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
|
||||
EIP615_JUMPIF, ///< conditionally alter the program counter -- not part of Instructions.cpp
|
||||
EIP615_JUMPV, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
|
||||
EIP615_JUMPSUB, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
|
||||
EIP615_JUMPSUBV, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
|
||||
EIP615_BEGINSUB, ///< set a potential jumpsub destination -- not part of Instructions.cpp
|
||||
EIP615_BEGINDATA, ///< begin the data section -- not part of Instructions.cpp
|
||||
EIP615_RETURNSUB, ///< return to subroutine jumped from -- not part of Instructions.cpp
|
||||
EIP615_PUTLOCAL, ///< pop top of stack to local variable -- not part of Instructions.cpp
|
||||
EIP615_GETLOCAL, ///< push local variable to top of stack -- not part of Instructions.cpp
|
||||
|
||||
CREATE = 0xf0, ///< create a new account with associated code
|
||||
CALL, ///< message-call into an account
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Alex Beregszaszi
|
||||
* Removes unused JUMPDESTs.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Alex Beregszaszi
|
||||
* Removes unused JUMPDESTs.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file KnownState.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file KnownState.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file LinkerObject.cpp
|
||||
* @author Christian R <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file Assembly.h
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file PathGasMeter.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file PathGasMeter.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file PeepholeOptimiser.cpp
|
||||
* Performs local optimising code changes to assembly.
|
||||
@ -205,6 +206,30 @@ struct SwapComparison: SimplePeepholeOptimizerMethod<SwapComparison, 2>
|
||||
}
|
||||
};
|
||||
|
||||
/// Remove swapN after dupN
|
||||
struct DupSwap: SimplePeepholeOptimizerMethod<DupSwap, 2>
|
||||
{
|
||||
static size_t applySimple(
|
||||
AssemblyItem const& _dupN,
|
||||
AssemblyItem const& _swapN,
|
||||
std::back_insert_iterator<AssemblyItems> _out
|
||||
)
|
||||
{
|
||||
if (
|
||||
SemanticInformation::isDupInstruction(_dupN) &&
|
||||
SemanticInformation::isSwapInstruction(_swapN) &&
|
||||
getDupNumber(_dupN.instruction()) == getSwapNumber(_swapN.instruction())
|
||||
)
|
||||
{
|
||||
*_out = _dupN;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct IsZeroIsZeroJumpI: SimplePeepholeOptimizerMethod<IsZeroIsZeroJumpI, 4>
|
||||
{
|
||||
static size_t applySimple(
|
||||
@ -266,9 +291,10 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod<TagConjunctions, 3>
|
||||
std::back_insert_iterator<AssemblyItems> _out
|
||||
)
|
||||
{
|
||||
if (_and != Instruction::AND)
|
||||
return false;
|
||||
if (
|
||||
_pushTag.type() == PushTag &&
|
||||
_and == Instruction::AND &&
|
||||
_pushConstant.type() == Push &&
|
||||
(_pushConstant.data() & u256(0xFFFFFFFF)) == u256(0xFFFFFFFF)
|
||||
)
|
||||
@ -276,6 +302,16 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod<TagConjunctions, 3>
|
||||
*_out = _pushTag;
|
||||
return true;
|
||||
}
|
||||
else if (
|
||||
// tag and constant are swapped
|
||||
_pushConstant.type() == PushTag &&
|
||||
_pushTag.type() == Push &&
|
||||
(_pushTag.data() & u256(0xFFFFFFFF)) == u256(0xFFFFFFFF)
|
||||
)
|
||||
{
|
||||
*_out = _pushConstant;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -357,7 +393,7 @@ bool PeepholeOptimiser::optimise()
|
||||
applyMethods(
|
||||
state,
|
||||
PushPop(), OpPop(), DoublePush(), DoubleSwap(), CommutativeSwap(), SwapComparison(),
|
||||
IsZeroIsZeroJumpI(), JumpToNext(), UnreachableCode(),
|
||||
DupSwap(), IsZeroIsZeroJumpI(), JumpToNext(), UnreachableCode(),
|
||||
TagConjunctions(), TruthyAnd(), Identity()
|
||||
);
|
||||
if (m_optimisedItems.size() < m_items.size() || (
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file PeepholeOptimiser.h
|
||||
* Performs local optimising code changes to assembly.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @date 2018
|
||||
* Templatized list of simplification rules.
|
||||
@ -571,6 +572,20 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart7(
|
||||
feasibilityFunction
|
||||
});
|
||||
|
||||
rules.push_back({
|
||||
Builtins::BYTE(A, Builtins::SHL(B, X)),
|
||||
[=]() -> Pattern { return Builtins::BYTE(A.d() + B.d() / 8, X); },
|
||||
false,
|
||||
[=] { return B.d() % 8 == 0 && A.d() <= 32 && B.d() <= 256; }
|
||||
});
|
||||
|
||||
rules.push_back({
|
||||
Builtins::BYTE(A, Builtins::SHR(B, X)),
|
||||
[=]() -> Pattern { return A.d() < B.d() / 8 ? Word(0) : Builtins::BYTE(A.d() - B.d() / 8, X); },
|
||||
false,
|
||||
[=] { return B.d() % 8 == 0 && A.d() < Pattern::WordSize / 8 && B.d() <= Pattern::WordSize; }
|
||||
});
|
||||
|
||||
return rules;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file SemanticInformation.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file SemanticInformation.h
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Expression simplification pattern.
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file ExpressionClasses.cpp
|
||||
* @author Christian <c@ethdev.com>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @file SimplificationRules
|
||||
* @author Christian <chris@ethereum.org>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* EVM versioning.
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* EVM versioning.
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Rhett <roadriverrail@gmail.com>
|
||||
* @date 2017
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Rhett <roadriverrail@gmail.com>
|
||||
* @date 2017
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Liana <liana@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <chris@ethereum.org>
|
||||
* @date 2016
|
||||
@ -245,14 +246,14 @@ unsigned SemVerMatchExpressionParser::parseVersionPart()
|
||||
return 0;
|
||||
else if ('1' <= c && c <= '9')
|
||||
{
|
||||
unsigned v(c - '0');
|
||||
auto v = static_cast<unsigned>(c - '0');
|
||||
// If we skip to the next token, the current number is terminated.
|
||||
while (m_pos == startPos && '0' <= currentChar() && currentChar() <= '9')
|
||||
{
|
||||
c = currentChar();
|
||||
if (v * 10 < v || v * 10 + unsigned(c - '0') < v * 10)
|
||||
if (v * 10 < v || v * 10 + static_cast<unsigned>(c - '0') < v * 10)
|
||||
throw SemVerError();
|
||||
v = v * 10 + unsigned(c - '0');
|
||||
v = v * 10 + static_cast<unsigned>(c - '0');
|
||||
nextChar();
|
||||
}
|
||||
return v;
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <chris@ethereum.org>
|
||||
* @date 2016
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Lefteris Karapetsas <lefteris@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#include <liblangutil/SourceReferenceExtractor.h>
|
||||
#include <liblangutil/CharStream.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#pragma once
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Formatting functions for errors referencing positions and locations in the source.
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Formatting functions for errors referencing positions and locations in the source.
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/** @file UndefMacros.h
|
||||
* @author Lefteris <lefteris@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsmtutil/CHCSmtLib2Interface.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
/**
|
||||
* Interface for solving Horn systems via smtlib2.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
/**
|
||||
* Interface for constrained Horn solvers.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsmtutil/CVC4Interface.h>
|
||||
|
||||
@ -191,7 +192,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
|
||||
return m_context.mkExpr(CVC4::kind::BITVECTOR_AND, arguments[0], arguments[1]);
|
||||
else if (n == "int2bv")
|
||||
{
|
||||
size_t size = std::stoi(_expr.arguments[1].name);
|
||||
size_t size = std::stoul(_expr.arguments[1].name);
|
||||
auto i2bvOp = m_context.mkConst(CVC4::IntToBitVector(size));
|
||||
// CVC4 treats all BVs as unsigned, so we need to manually apply 2's complement if needed.
|
||||
return m_context.mkExpr(
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsmtutil/SMTLib2Interface.h>
|
||||
|
||||
@ -139,7 +140,7 @@ string SMTLib2Interface::toSExpr(Expression const& _expr)
|
||||
std::string sexpr = "(";
|
||||
if (_expr.name == "int2bv")
|
||||
{
|
||||
size_t size = std::stoi(_expr.arguments[1].name);
|
||||
size_t size = std::stoul(_expr.arguments[1].name);
|
||||
auto arg = toSExpr(_expr.arguments.front());
|
||||
auto int2bv = "(_ int2bv " + to_string(size) + ")";
|
||||
// Some solvers treat all BVs as unsigned, so we need to manually apply 2's complement if needed.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsmtutil/SMTPortfolio.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -59,10 +60,10 @@ class Expression
|
||||
public:
|
||||
explicit Expression(bool _v): Expression(_v ? "true" : "false", Kind::Bool) {}
|
||||
explicit Expression(std::shared_ptr<SortSort> _sort, std::string _name = ""): Expression(std::move(_name), {}, _sort) {}
|
||||
Expression(size_t _number): Expression(std::to_string(_number), Kind::Int) {}
|
||||
Expression(u256 const& _number): Expression(_number.str(), Kind::Int) {}
|
||||
Expression(s256 const& _number): Expression(_number.str(), Kind::Int) {}
|
||||
Expression(bigint const& _number): Expression(_number.str(), Kind::Int) {}
|
||||
Expression(size_t _number): Expression(std::to_string(_number), {}, SortProvider::sintSort) {}
|
||||
Expression(u256 const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {}
|
||||
Expression(s256 const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {}
|
||||
Expression(bigint const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {}
|
||||
|
||||
Expression(Expression const&) = default;
|
||||
Expression(Expression&&) = default;
|
||||
@ -262,23 +263,28 @@ public:
|
||||
}
|
||||
friend Expression operator+(Expression _a, Expression _b)
|
||||
{
|
||||
return Expression("+", std::move(_a), std::move(_b), Kind::Int);
|
||||
auto intSort = _a.sort;
|
||||
return Expression("+", {std::move(_a), std::move(_b)}, intSort);
|
||||
}
|
||||
friend Expression operator-(Expression _a, Expression _b)
|
||||
{
|
||||
return Expression("-", std::move(_a), std::move(_b), Kind::Int);
|
||||
auto intSort = _a.sort;
|
||||
return Expression("-", {std::move(_a), std::move(_b)}, intSort);
|
||||
}
|
||||
friend Expression operator*(Expression _a, Expression _b)
|
||||
{
|
||||
return Expression("*", std::move(_a), std::move(_b), Kind::Int);
|
||||
auto intSort = _a.sort;
|
||||
return Expression("*", {std::move(_a), std::move(_b)}, intSort);
|
||||
}
|
||||
friend Expression operator/(Expression _a, Expression _b)
|
||||
{
|
||||
return Expression("/", std::move(_a), std::move(_b), Kind::Int);
|
||||
auto intSort = _a.sort;
|
||||
return Expression("/", {std::move(_a), std::move(_b)}, intSort);
|
||||
}
|
||||
friend Expression operator%(Expression _a, Expression _b)
|
||||
{
|
||||
return Expression("mod", std::move(_a), std::move(_b), Kind::Int);
|
||||
auto intSort = _a.sort;
|
||||
return Expression("mod", {std::move(_a), std::move(_b)}, intSort);
|
||||
}
|
||||
friend Expression operator&(Expression _a, Expression _b)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
|
||||
#include <libsmtutil/Sorts.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsmtutil/Z3CHCInterface.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
/**
|
||||
* Z3 specific Horn solver interface.
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsmtutil/Z3Interface.h>
|
||||
|
||||
@ -184,7 +185,7 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
|
||||
return arguments[0] & arguments[1];
|
||||
else if (n == "int2bv")
|
||||
{
|
||||
size_t size = std::stoi(_expr.arguments[1].name);
|
||||
size_t size = std::stoul(_expr.arguments[1].name);
|
||||
return z3::int2bv(size, arguments[0]);
|
||||
}
|
||||
else if (n == "bv2int")
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -16,6 +16,8 @@ set(sources
|
||||
analysis/DeclarationTypeChecker.h
|
||||
analysis/DocStringAnalyser.cpp
|
||||
analysis/DocStringAnalyser.h
|
||||
analysis/DocStringTagParser.cpp
|
||||
analysis/DocStringTagParser.h
|
||||
analysis/ImmutableValidator.cpp
|
||||
analysis/ImmutableValidator.h
|
||||
analysis/GlobalContext.cpp
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2015
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that verifies overloads, abstract contracts, function clashes and others
|
||||
* checks at contract or function level.
|
||||
@ -60,6 +61,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract)
|
||||
checkLibraryRequirements(_contract);
|
||||
checkBaseABICompatibility(_contract);
|
||||
checkPayableFallbackWithoutReceive(_contract);
|
||||
checkStorageSize(_contract);
|
||||
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
}
|
||||
@ -458,3 +460,20 @@ void ContractLevelChecker::checkPayableFallbackWithoutReceive(ContractDefinition
|
||||
SecondarySourceLocation{}.append("The payable fallback function is defined here.", fallback->location())
|
||||
);
|
||||
}
|
||||
|
||||
void ContractLevelChecker::checkStorageSize(ContractDefinition const& _contract)
|
||||
{
|
||||
bigint size = 0;
|
||||
vector<VariableDeclaration const*> variables;
|
||||
for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts))
|
||||
for (VariableDeclaration const* variable: contract->stateVariables())
|
||||
if (!(variable->isConstant() || variable->immutable()))
|
||||
{
|
||||
size += variable->annotation().type->storageSizeUpperBound();
|
||||
if (size >= bigint(1) << 256)
|
||||
{
|
||||
m_errorReporter.typeError(7676_error, _contract.location(), "Contract too large for storage.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that verifies overloads, abstract contracts, function clashes and others
|
||||
* checks at contract or function level.
|
||||
@ -83,6 +84,8 @@ private:
|
||||
|
||||
/// Warns if the contract has a payable fallback, but no receive ether function.
|
||||
void checkPayableFallbackWithoutReceive(ContractDefinition const& _contract);
|
||||
/// Error if the contract requires too much storage
|
||||
void checkStorageSize(ContractDefinition const& _contract);
|
||||
|
||||
OverrideChecker m_overrideChecker;
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsolidity/analysis/ControlFlowAnalyzer.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
||||
#include <libyul/AsmData.h>
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libsolidity/analysis/ControlFlowGraph.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2014
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user