diff --git a/.circleci/config.yml b/.circleci/config.yml index 77d68d8697ab..6c7a6b6bd54a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,25 +9,25 @@ version: 2.1 parameters: ubuntu-2004-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-21 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:6f64c7b35aabddb416d28f621a3c4bbae768c257d6866f6a7f05f8225acc94f0" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-23 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:84a1fb8771236e8d9aa5c615a425b8929e56a6e4f150a60078c8d74a1ceaa6c2" ubuntu-2204-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2204-6 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:6eee10420382588b274374c6a18cb2e5d4f8a9fef5cf440b3a1acfc32bf52837" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2204-8 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:1c3a4118218640b2bf632242979a63d48f3d9c70d48be9574332f2dbbd04b192" ubuntu-2204-clang-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2204.clang-5 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:e991421ce9f44d6476b29588fc355da1c3b3fedcc424fd12d844bbe310ad7851" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2204.clang-7 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:0f47e733e100080c4174381c262cfcf974bc8e7c3c41b8dff611b9641c82f714" ubuntu-clang-ossfuzz-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu.clang.ossfuzz-4 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:b122ef9dca71a8f90b74f3ba13cda4453681506e4a4ff047e7bc2130c76b0d1e" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu.clang.ossfuzz-6 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:8883fa2845bbc1e0922af60439313666e4ba325f67a117e17d78cca3ea6589b3" emscripten-docker-image: type: string - # NOTE: Please remember to update the `build_emscripten.sh` whenever the hash of this image changes. - # solbuildpackpusher/solidity-buildpack-deps:emscripten-16 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:19fcb5ac029bbc27ec36e10f7d14ea224d8010145f9690562ef084fd16146b0c" + # NOTE: Please remember to update the `scripts/build_emscripten.sh` whenever the hash of this image changes. + # solbuildpackpusher/solidity-buildpack-deps:emscripten-17 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:c57f2bfb8c15d70fe290629358dd1c73dc126e3760f443b54764797556b887d4" evm-version: type: string default: london @@ -331,9 +331,6 @@ commands: - checkout - attach_workspace: at: build - - run: - name: Install dependencies - command: pip install --user deepdiff colorama - run: name: Executing solc LSP test suite command: test/lsp.py build/solc/solc --non-interactive @@ -801,13 +798,6 @@ defaults: compile_only: 1 image: cimg/node:18.16 - - job_native_test_ext_perpetual_pools: &job_native_test_ext_perpetual_pools - <<: *requires_b_ubu_static - name: t_native_test_ext_perpetual_pools - project: perpetual-pools - binary_type: native - image: cimg/node:18.16 - - job_native_test_ext_uniswap: &job_native_test_ext_uniswap <<: *requires_b_ubu_static name: t_native_test_ext_uniswap @@ -934,19 +924,9 @@ jobs: - matrix_notify_failure_unless_pr chk_pylint: - <<: *base_cimg_small + <<: *base_ubuntu2204_small steps: - checkout - - install_python3: - packages: > - pylint - z3-solver - pygments-lexer-solidity - parsec - tabulate - deepdiff - colorama - requests - run: pylint --version - run: name: Linting Python Scripts @@ -983,11 +963,9 @@ jobs: - matrix_notify_failure_unless_pr chk_proofs: - <<: *base_cimg_small + <<: *base_ubuntu2204_small steps: - checkout - - install_python3: - packages: z3-solver - run_proofs - matrix_notify_failure_unless_pr @@ -1002,10 +980,6 @@ jobs: <<: *base_ubuntu2204_small steps: - checkout - - run: - # TODO: Add these to the base image - name: Install gas_diff_stats.py dependencies - command: python3 -m pip install --user parsec tabulate - run: name: Python unit tests command: python3 test/pyscriptTests.py @@ -1181,7 +1155,7 @@ jobs: - run: name: Install build dependencies command: | - pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake cvc4 git openssh tar + pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake git openssh tar - checkout - run_build - store_artifacts_solc @@ -1308,7 +1282,7 @@ jobs: - run: name: Install runtime dependencies command: | - pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake z3 cvc4 git openssh tar + pacman --noconfirm -Syu --noprogressbar --needed z3 - soltest t_ubu_clang_soltest: &t_ubu_clang_soltest @@ -1461,7 +1435,7 @@ jobs: name: Install dependencies command: | cd hardhat - pnpm install + pnpm install --no-frozen-lockfile - run: name: Run hardhat-core test suite command: | @@ -1517,14 +1491,6 @@ jobs: if command -v npm &> /dev/null; then sudo npm install -g pnpm fi - - install_python3: - packages: requests - - run: - name: Install lsof - command: | - # lsof is used by Colony in its stop-blockchain-client.sh script - sudo apt update - sudo apt-get --quiet --assume-yes --no-install-recommends install lsof - when: condition: << parameters.python2 >> steps: @@ -1771,8 +1737,8 @@ jobs: - run: git config --global core.autocrlf false - checkout - run: - name: Force install python3.12.2 - command: choco install python3 --pre --force --version=3.12.2 + name: Force install python3.12 + command: choco install python312 --pre --force - run: name: Create a symlink for python3 command: ln -s /c/ProgramData/chocolatey/bin/python3.12 /c/ProgramData/chocolatey/bin/python3 @@ -1917,7 +1883,6 @@ workflows: - t_ext: *job_native_test_ext_zeppelin - t_ext: *job_native_test_ext_ens - t_ext: *job_native_test_ext_yield_liquidator - - t_ext: *job_native_test_ext_perpetual_pools - t_ext: *job_native_test_ext_uniswap - t_ext: *job_native_test_ext_prb_math - t_ext: *job_native_test_ext_elementfi @@ -1939,7 +1904,6 @@ workflows: - t_native_test_ext_zeppelin - t_native_test_ext_ens - t_native_test_ext_yield_liquidator - - t_native_test_ext_perpetual_pools - t_native_test_ext_uniswap - t_native_test_ext_elementfi - t_native_test_ext_brink diff --git a/.circleci/osx_install_dependencies.sh b/.circleci/osx_install_dependencies.sh index adfb21915488..d868cef1ea3b 100755 --- a/.circleci/osx_install_dependencies.sh +++ b/.circleci/osx_install_dependencies.sh @@ -57,6 +57,9 @@ then brew install coreutils brew install diffutils brew install grep + # JRE is required to run eldarica solver + brew install openjdk@11 + brew install unzip # install historical cmake chmod +x .circleci/install_cmake.sh @@ -76,6 +79,14 @@ then cd .. sudo rm -rf "$boost_dir" + # eldarica + eldarica_version="2.1" + wget "https://github.com/uuverifiers/eldarica/releases/download/v${eldarica_version}/eldarica-bin-${eldarica_version}.zip" -O /tmp/eld_binaries.zip + validate_checksum /tmp/eld_binaries.zip 0ac43f45c0925383c9d2077f62bbb515fd792375f3b2b101b30c9e81dcd7785c + unzip /tmp/eld_binaries.zip -d /tmp + sudo mv /tmp/eldarica/{eld,eld-client,target,eldEnv} /usr/local/bin + rm -rf /tmp/{eldarica,eld_binaries.zip} + # z3 z3_version="4.12.1" z3_dir="z3-z3-$z3_version" diff --git a/.github/workflows/buildpack-deps.yml b/.github/workflows/buildpack-deps.yml deleted file mode 100644 index 6a261bd2eb9c..000000000000 --- a/.github/workflows/buildpack-deps.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: buildpack-deps - -on: - pull_request: - branches: [ develop ] - paths: - - 'scripts/docker/buildpack-deps/Dockerfile.emscripten' - - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu.clang.ossfuzz' - - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004' - - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang' - - 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2204' - -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, ubuntu.clang.ossfuzz, ubuntu2004, ubuntu2204.clang, ubuntu2204] - - 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" - # NOTE: Can't update to v1.3.1 due to an error: `/entrypoint.sh:5:in 'require_relative': cannot load such file -- /lib/github (LoadError)` - uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b #v1.3.0 - with: - msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." - check_for_duplicate_msg: false - diff --git a/CMakeLists.txt b/CMakeLists.txt index 18af34d26bf0..91c1056ec3a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.8.25") +set(PROJECT_VERSION "0.8.26") # OSX target needed in order to support std::visit set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) @@ -37,16 +37,23 @@ option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libs option(STRICT_Z3_VERSION "Use the latest version of Z3" ON) option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON) option(PROFILE_OPTIMIZER_STEPS "Output performance metrics for the optimiser steps." OFF) +option(USE_SYSTEM_LIBRARIES "Use system libraries" OFF) +option(ONLY_BUILD_SOLIDITY_LIBRARIES "Only build solidity libraries" OFF) +option(STRICT_NLOHMANN_JSON_VERSION "Strictly check installed nlohmann json version" ON) +mark_as_advanced(USE_SYSTEM_LIBRARIES) +mark_as_advanced(ONLY_BUILD_SOLIDITY_LIBRARIES) +mark_as_advanced(STRICT_NLOHMANN_JSON_VERSION) # Setup cccache. include(EthCcache) # Let's find our dependencies include(EthDependencies) -include(fmtlib) -include(jsoncpp) -include(range-v3) -include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) +if (NOT USE_SYSTEM_LIBRARIES) + include(fmtlib) + include(nlohmann-json) + include(range-v3) +endif() find_package(Threads) @@ -58,6 +65,10 @@ if (PROFILE_OPTIMIZER_STEPS) add_definitions(-DPROFILE_OPTIMIZER_STEPS) endif() +if (STRICT_NLOHMANN_JSON_VERSION) + add_definitions(-DSTRICT_NLOHMANN_JSON_VERSION_CHECK) +endif() + # Figure out what compiler and system are we using include(EthCompilerSettings) @@ -141,12 +152,15 @@ add_subdirectory(libyul) add_subdirectory(libsolidity) add_subdirectory(libsolc) add_subdirectory(libstdlib) -add_subdirectory(tools) -if (NOT EMSCRIPTEN) - add_subdirectory(solc) -endif() +if (NOT ONLY_BUILD_SOLIDITY_LIBRARIES) + add_subdirectory(tools) -if (TESTS AND NOT EMSCRIPTEN) - add_subdirectory(test) + if (NOT EMSCRIPTEN) + add_subdirectory(solc) + endif() + + if (TESTS AND NOT EMSCRIPTEN) + add_subdirectory(test) + endif() endif() diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 5b9129fbd07b..2305ae1ec752 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -20,7 +20,7 @@ Yes: ```cpp if (a == b[i]) - printf("Hello\n"); // NOTE spaces used instead of tab here for clarity - first byte should be '\t'. + printf("Hello\n"); // NOTE spaces used instead of tab here for clarity - first byte should be '\t'. foo->bar( someLongVariableName, anotherLongVariableName, diff --git a/Changelog.md b/Changelog.md index f72a654a530a..581961fa00c0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,33 @@ -### 0.8.25 (2023-03-14) +### 0.8.26 (2024-05-21) + +Language Features: + * Introduce a new overload ``require(bool, Error)`` that allows usage of ``require`` functions with custom errors. This feature is available in the ``via-ir`` pipeline only. + + +Compiler Features: + * SMTChecker: Create balance check verification target for CHC engine. + * Yul IR Code Generation: Cheaper code for reverting with errors of a small static encoding size. + * Yul Optimizer: New, faster default optimizer step sequence. + + +Bugfixes: + * Commandline Interface: Fix ICE when the optimizer is disabled and an empty/blank string is used for ``--yul-optimizations`` sequence. + * SMTChecker: Fix false positive when comparing hashes of same array or string literals. + * SMTChecker: Fix internal error on mapping access caused by too strong requirements on sort compatibility of the index and mapping domain. + * SMTChecker: Fix internal error when using an empty tuple in a conditional operator. + * SMTChecker: Fix internal error when using bitwise operators with an array element as argument. + * Standard JSON Interface: Fix ICE when the optimizer is disabled and an empty/blank string is used for ``optimizerSteps`` sequence. + * StaticAnalyzer: Only raise a compile time error for division and modulo by zero when it's between literals. + * TypeChecker: Fix compiler crash when the left-hand side of an assignment was a parenthesized non-tuple expression of a tuple type. + * Yul Optimizer: Fix optimizer executing each repeating part of the step sequence at least twice, even if the code size already became stable after the first iteration. + * Yul Optimizer: Fix the order of assignments generated by ``SSATransform`` being dependent on AST IDs, sometimes resulting in different (but equivalent) bytecode when unrelated files were added to the compilation pipeline. + + +Build System: +* Replace internal JSON library jsoncpp with nlohmann::json. + + +### 0.8.25 (2024-03-14) Compiler Features: * Code Generator: Use ``MCOPY`` instead of ``MLOAD``/``MSTORE`` loop when copying byte arrays. @@ -14,7 +43,6 @@ Bugfixes: * SMTChecker: Fix internal error caused by not respecting the sign of an integer type when constructing zero-value SMT expressions. * SMTChecker: Run Eldarica only when explicitly requested with `--model-checker-solvers eld`, even when it is present on the system. - ### 0.8.24 (2024-01-25) Language Features: diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 6cfa864c1d1a..5c2802d1fe20 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -171,25 +171,25 @@ elseif (DEFINED MSVC) # CMAKE_CXX_FLAGS_RELWITHDEBINFO for GCC/Clang does not include NDEBUG string(REPLACE "/DNDEBUG" " " CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - add_compile_options(/MP) # enable parallel compilation - add_compile_options(/EHsc) # specify Exception Handling Model in msvc + add_compile_options(/MP) # enable parallel compilation + add_compile_options(/EHsc) # specify Exception Handling Model in msvc if(PEDANTIC) - add_compile_options(/WX) # enable warnings-as-errors + add_compile_options(/WX) # enable warnings-as-errors endif() - add_compile_options(/wd4068) # disable unknown pragma warning (4068) - add_compile_options(/wd4996) # disable unsafe function warning (4996) - add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503) - add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267) - add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180) - add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290) - add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244) - add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800) - add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement - add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions - add_compile_options(/utf-8) # enable utf-8 encoding (solves warning 4819) - add_compile_options(-DBOOST_REGEX_NO_LIB) # disable automatic boost::regex library selection - add_compile_options(-D_REGEX_MAX_STACK_COUNT=200000L) # increase std::regex recursion depth limit - add_compile_options(/permissive-) # specify standards conformance mode to the compiler + add_compile_options(/wd4068) # disable unknown pragma warning (4068) + add_compile_options(/wd4996) # disable unsafe function warning (4996) + add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503) + add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267) + add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180) + add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290) + add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244) + add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800) + add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement + add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions + add_compile_options(/utf-8) # enable utf-8 encoding (solves warning 4819) + add_compile_options(-DBOOST_REGEX_NO_LIB) # disable automatic boost::regex library selection + add_compile_options(-D_REGEX_MAX_STACK_COUNT=200000L) # increase std::regex recursion depth limit + add_compile_options(/permissive-) # specify standards conformance mode to the compiler # disable empty object file warning set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index 7a84a01d9868..16f30a640d27 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -10,9 +10,9 @@ if (DEFINED MSVC) else() get_filename_component(DEPS_DIR "${CMAKE_CURRENT_LIST_DIR}/../deps/install" ABSOLUTE) set(ETH_DEPENDENCY_INSTALL_DIR - "${DEPS_DIR}/x64" # Old location for deps. - "${DEPS_DIR}/win64" # New location for deps. - "${DEPS_DIR}/win64/Release/share" # LLVM shared cmake files. + "${DEPS_DIR}/x64" # Old location for deps. + "${DEPS_DIR}/win64" # New location for deps. + "${DEPS_DIR}/win64/Release/share" # LLVM shared cmake files. ) endif() set (CMAKE_PREFIX_PATH ${ETH_DEPENDENCY_INSTALL_DIR} ${CMAKE_PREFIX_PATH}) diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake deleted file mode 100644 index c47c2697a3dc..000000000000 --- a/cmake/jsoncpp.cmake +++ /dev/null @@ -1,72 +0,0 @@ -include(ExternalProject) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") - set(JSONCPP_CMAKE_COMMAND emcmake cmake) -else() - set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND}) -endif() - -set(prefix "${PROJECT_BINARY_DIR}/deps") -set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") -set(JSONCPP_INCLUDE_DIR "${prefix}/include") - -# TODO: Investigate why this breaks some emscripten builds and -# check whether this can be removed after updating the emscripten -# versions used in the CI runs. -if(EMSCRIPTEN) - # Do not include all flags in CMAKE_CXX_FLAGS for emscripten, - # but only use -std=c++17. Using all flags causes build failures - # at the moment. - set(JSONCPP_CXX_FLAGS -std=c++17) -else() - # jsoncpp uses implicit casts for comparing integer and - # floating point numbers. This causes clang-10 (used by ossfuzz builder) - # to error on the implicit conversions. Here, we request jsoncpp - # to unconditionally use static casts for these conversions by defining the - # JSON_USE_INT64_DOUBLE_CONVERSION preprocessor macro. Doing so, - # not only gets rid of the implicit conversion error that clang-10 produces - # but also forces safer behavior in general. - set(JSONCPP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_USE_INT64_DOUBLE_CONVERSION") -endif() - -set(byproducts "") -if(CMAKE_VERSION VERSION_GREATER 3.1) - set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}") -endif() - -# Propagate CMAKE_MSVC_RUNTIME_LIBRARY on Windows builds, if set. -if (WIN32 AND POLICY CMP0091 AND CMAKE_MSVC_RUNTIME_LIBRARY) - list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW") - list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}") -endif() - -string(REPLACE ";" "$" CMAKE_OSX_ARCHITECTURES_ "${CMAKE_OSX_ARCHITECTURES}") -ExternalProject_Add(jsoncpp-project - PREFIX "${prefix}" - DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/deps/downloads" - 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= - -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} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} - ${JSONCPP_CMAKE_ARGS} - ${byproducts} -) - -# Create jsoncpp imported library -add_library(jsoncpp STATIC IMPORTED) -file(MAKE_DIRECTORY ${JSONCPP_INCLUDE_DIR}) # Must exist. -set_property(TARGET jsoncpp PROPERTY IMPORTED_LOCATION ${JSONCPP_LIBRARY}) -set_property(TARGET jsoncpp PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR}) -set_property(TARGET jsoncpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR}) -add_dependencies(jsoncpp jsoncpp-project) diff --git a/cmake/nlohmann-json.cmake b/cmake/nlohmann-json.cmake new file mode 100644 index 000000000000..02891e6a7ba6 --- /dev/null +++ b/cmake/nlohmann-json.cmake @@ -0,0 +1,21 @@ +include(ExternalProject) + +ExternalProject_Add(nlohmann-json-project + DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/nlohmann/nlohmann" + DOWNLOAD_NAME json.hpp + DOWNLOAD_NO_EXTRACT 1 + URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.hpp + URL_HASH SHA256=9bea4c8066ef4a1c206b2be5a36302f8926f7fdc6087af5d20b417d0cf103ea6 + CMAKE_COMMAND true + BUILD_COMMAND true + INSTALL_COMMAND true +) + +# Create nlohmann-json imported library +add_library(nlohmann-json INTERFACE IMPORTED) +file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/deps/nlohmann) # Must exist. +set_target_properties(nlohmann-json PROPERTIES + INTERFACE_COMPILE_OPTIONS "\$<\$:/permissive->" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/deps/nlohmann + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/deps/nlohmann) +add_dependencies(nlohmann-json nlohmann-json-project) \ No newline at end of file diff --git a/cmake/templates/license.h.in b/cmake/templates/license.h.in index 2d7f2691a81c..7ade6be05929 100644 --- a/cmake/templates/license.h.in +++ b/cmake/templates/license.h.in @@ -3,7 +3,7 @@ #include static std::string const otherLicenses{R"(Most of the code is licensed under GPLv3 (see below), the license for individual -parts are as follows: +parts and dependencies are as follows: libkeccak-tiny: The file libsolutil/Keccak256.cpp incorporates libkeccak-tiny. @@ -11,6 +11,26 @@ libkeccak-tiny: A single-file implementation of SHA-3 and SHAKE implemented by David Leon Gil License: CC0, attribution kindly requested. Blame taken too, but not liability. +nlohmann-json: + The source code of nlohmann-json is licensed under the following + conditions: + + The class is licensed under the MIT License: + + Copyright © 2013-2022 Niels Lohmann + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the MIT License (see above). Copyright © 2008-2009 Björn Hoehrmann bjoern@hoehrmann.de + + The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the MIT License (see above). Copyright © 2009 Florian Loitsch + + The class contains a copy of Hedley from Evan Nemerson which is licensed as CC0-1.0. + picosha2: The file libsolutil/picosha2.h is imported. @@ -34,62 +54,160 @@ picosha2: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -jsoncpp: - The JsonCpp library's source code, including accompanying documentation, - tests and demonstration applications, are licensed under the following - conditions... +range-v3: + The range-v3 library is licensed under the following conditions: + + ======================================================== + Boost Software License - Version 1.0 - August 17th, 2003 + ======================================================== - The JsonCpp Authors explicitly disclaim copyright in all - jurisdictions which recognize such a disclaimer. In such jurisdictions, - this software is released into the Public Domain. + Permission is hereby granted, free of charge, to any person or organization + obtaining a copy of the software and accompanying documentation covered by + this license (the "Software") to use, reproduce, display, distribute, + execute, and transmit the Software, and to prepare derivative works of the + Software, and to permit third-parties to whom the Software is furnished to + do so, all subject to the following: - In jurisdictions which do not recognize Public Domain property (e.g. Germany as of - 2010), this software is Copyright (c) 2007-2010 by The JsonCpp Authors, and is - released under the terms of the MIT License (see below). + The copyright notices in the Software and this entire statement, including + the above license grant, this restriction and the following disclaimer, + must be included in all copies of the Software, in whole or in part, and + all derivative works of the Software, unless such copies or derivative + works are solely in the form of machine-executable object code generated by + a source language processor. - In jurisdictions which recognize Public Domain property, the user of this - software may choose to accept it either as 1) Public Domain, 2) under the - conditions of the MIT License (see below), or 3) under the terms of dual - Public Domain/MIT License conditions described here, as they choose. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. - The MIT License is about as close to Public Domain as a license can get, and is - described in clear, concise terms at: + ============================================================================== + libc++ License + ============================================================================== - http://en.wikipedia.org/wiki/MIT_License + The libc++ library is dual licensed under both the University of Illinois + "BSD-Like" license and the MIT license. As a user of this code you may choose + to use it under either license. As a contributor, you agree to allow your code + to be used under both. - The full text of the MIT License follows: + Full text of the relevant licenses is included below. - ======================================================================== - Copyright (c) 2007-2010 The JsonCpp Authors + ============================================================================== - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, copy, - modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: + University of Illinois/NCSA + Open Source License - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. + Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + http://llvm.org/svn/llvm-project/libcxx/trunk/CREDITS.TXT - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + All rights reserved. + + Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal with + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. - ======================================================================== - (END LICENSE TEXT) - The MIT license is compatible with both the GPL and commercial - software, affording one all of the rights of Public Domain with the - minor nuisance of being required to keep the above copyright notice - and license text in the source code. Note also that by accepting the - Public Domain "license" you can re-license your copy using whatever - license you like. + ============================================================================== + + Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + http://llvm.org/svn/llvm-project/libcxx/trunk/CREDITS.TXT + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + ============================================================================== + Stepanov and McJones, "Elements of Programming" license + ============================================================================== + + // Copyright (c) 2009 Alexander Stepanov and Paul McJones + // + // Permission to use, copy, modify, distribute and sell this software + // and its documentation for any purpose is hereby granted without + // fee, provided that the above copyright notice appear in all copies + // and that both that copyright notice and this permission notice + // appear in supporting documentation. The authors make no + // representations about the suitability of this software for any + // purpose. It is provided "as is" without express or implied + // warranty. + // + // Algorithms from + // Elements of Programming + // by Alexander Stepanov and Paul McJones + // Addison-Wesley Professional, 2009 + + ============================================================================== + SGI C++ Standard Template Library license + ============================================================================== + + // Copyright (c) 1994 + // Hewlett-Packard Company + // + // Permission to use, copy, modify, distribute and sell this software + // and its documentation for any purpose is hereby granted without fee, + // provided that the above copyright notice appear in all copies and + // that both that copyright notice and this permission notice appear + // in supporting documentation. Hewlett-Packard Company makes no + // representations about the suitability of this software for any + // purpose. It is provided "as is" without express or implied warranty. + // + // Copyright (c) 1996 + // Silicon Graphics Computer Systems, Inc. + // + // Permission to use, copy, modify, distribute and sell this software + // and its documentation for any purpose is hereby granted without fee, + // provided that the above copyright notice appear in all copies and + // that both that copyright notice and this permission notice appear + // in supporting documentation. Silicon Graphics makes no + // representations about the suitability of this software for any + // purpose. It is provided "as is" without express or implied warranty. + // scanner/token: The liblangutil/{CharStream,Scanner,Token}.{h,cpp} files are derived from @@ -167,6 +285,19 @@ base64: Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ +Z3: + The Z3 library is licensed under the following terms: + + Copyright (c) Microsoft Corporation + All rights reserved. + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + All other code is licensed under GPL version 3: diff --git a/docs/_static/css/toggle.css b/docs/_static/css/toggle.css index 6f03e6fb6aba..d525ab62a78f 100644 --- a/docs/_static/css/toggle.css +++ b/docs/_static/css/toggle.css @@ -85,4 +85,9 @@ html.transition *:after { .wy-menu-vertical a:hover { background-color: #0002; +} + +body { + font-weight: 300; + letter-spacing: 0.5px; } \ No newline at end of file diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 7022635fde1a..037a36341c16 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1892,7 +1892,11 @@ }, "0.8.25": { "bugs": [], - "released": "2023-03-14" + "released": "2024-03-14" + }, + "0.8.26": { + "bugs": [], + "released": "2024-05-21" }, "0.8.3": { "bugs": [ diff --git a/docs/cheatsheet.rst b/docs/cheatsheet.rst index bc678c647d54..6b69b81be34a 100644 --- a/docs/cheatsheet.rst +++ b/docs/cheatsheet.rst @@ -23,7 +23,7 @@ ABI Encoding and Decoding Functions - ``abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory)``: :ref:`ABI `-encodes the given arguments starting from the second and prepends the given four-byte selector - ``abi.encodeCall(function functionPointer, (...)) returns (bytes memory)``: ABI-encodes a call to ``functionPointer`` with the arguments found in the - tuple. Performs a full type-check, ensuring the types match the function signature. Result equals ``abi.encodeWithSelector(functionPointer.selector, (...))`` + tuple. Performs a full type-check, ensuring the types match the function signature. Result equals ``abi.encodeWithSelector(functionPointer.selector, ...)`` - ``abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)``: Equivalent to ``abi.encodeWithSelector(bytes4(keccak256(bytes(signature))), ...)`` diff --git a/docs/contracts/errors.rst b/docs/contracts/errors.rst index 19577a3872ba..8c57586e96f8 100644 --- a/docs/contracts/errors.rst +++ b/docs/contracts/errors.rst @@ -1,22 +1,25 @@ -.. index:: ! error, revert, ! selector; of an error +.. index:: ! error, revert, require, ! selector; of an error .. _errors: -******************************* -Errors and the Revert Statement -******************************* +************* +Custom Errors +************* Errors in Solidity provide a convenient and gas-efficient way to explain to the user why an operation failed. They can be defined inside and outside of contracts (including interfaces and libraries). They have to be used together with the :ref:`revert statement ` -which causes -all changes in the current call to be reverted and passes the error data back to the -caller. +or the :ref:`require function `. +In the case of ``revert`` statements, or ``require`` calls where the condition is evaluated to be false, +all changes in the current call are reverted, and the error data passed back to the caller. + +The example below shows custom error usage with the ``revert`` statement in function ``transferWithRevertError``, +as well as the newer approach with ``require`` in function ``transferWithRequireError``. .. code-block:: solidity // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.8.4; + pragma solidity ^0.8.26; /// Insufficient balance for transfer. Needed `required` but only /// `available` available. @@ -24,9 +27,10 @@ caller. /// @param required requested amount to transfer. error InsufficientBalance(uint256 available, uint256 required); + // This will only compile via IR contract TestToken { mapping(address => uint) balance; - function transfer(address to, uint256 amount) public { + function transferWithRevertError(address to, uint256 amount) public { if (amount > balance[msg.sender]) revert InsufficientBalance({ available: balance[msg.sender], @@ -35,12 +39,22 @@ caller. balance[msg.sender] -= amount; balance[to] += amount; } + function transferWithRequireError(address to, uint256 amount) public { + require(amount <= balance[msg.sender], InsufficientBalance(balance[msg.sender], amount)); + balance[msg.sender] -= amount; + balance[to] += amount; + } // ... } +Another important detail to mention when it comes to using ``require`` with custom errors, is that memory +allocation for the error-based revert reason will only happen in the reverting case, which, along with +optimization of constants and string literals makes this about as gas-efficient as the +``if (!condition) revert CustomError(args)`` pattern. + Errors cannot be overloaded or overridden but are inherited. The same error can be defined in multiple places as long as the scopes are distinct. -Instances of errors can only be created using ``revert`` statements. +Instances of errors can only be created using ``revert`` statements, or as the second argument to ``require`` functions. The error creates data that is then passed to the caller with the revert operation to either return to the off-chain component or catch it in a :ref:`try/catch statement `. @@ -65,8 +79,7 @@ The selector consists of the first four bytes of the keccak256-hash of the signa only the name of the error is relevant, not the contract or file where it is defined. The statement ``require(condition, "description");`` would be equivalent to -``if (!condition) revert Error("description")`` if you could define -``error Error(string)``. +``if (!condition) revert Error("description")`` if you could define ``error Error(string)``. Note, however, that ``Error`` is a built-in type and cannot be defined in user-supplied code. Similarly, a failing ``assert`` or similar conditions will revert with an error diff --git a/docs/control-structures.rst b/docs/control-structures.rst index a006d71d1536..f2cdde453fbc 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -594,6 +594,8 @@ The built-in errors ``Error(string)`` and ``Panic(uint256)`` are used by special functions, as explained below. ``Error`` is used for "regular" error conditions while ``Panic`` is used for errors that should not be present in bug-free code. +.. _assert-and-require-statements: + Panic via ``assert`` and Error via ``require`` ---------------------------------------------- @@ -625,21 +627,24 @@ The error code supplied with the error data indicates the kind of panic. #. 0x41: If you allocate too much memory or create an array that is too large. #. 0x51: If you call a zero-initialized variable of internal function type. -The ``require`` function either creates an error without any data or -an error of type ``Error(string)``. It -should be used to ensure valid conditions -that cannot be detected until execution time. -This includes conditions on inputs -or return values from calls to external contracts. +The ``require`` function provides three overloads: + +1. ``require(bool)`` which will revert without any data (not even an error selector). +2. ``require(bool, string)`` which will revert with an ``Error(string)``. +3. ``require(bool, error)`` which will revert with the custom, user supplied error provided as the second argument. .. note:: + ``require`` arguments are evaluated unconditionally, so take special care to make sure that + they are not expressions with unexpected side-effects. + For example, in ``require(condition, CustomError(f()));`` and ``require(condition, f());``, + function ``f()`` will be called regardless of whether the supplied condition is ``true`` or ``false``. - It is currently not possible to use custom errors in combination - with ``require``. Please use ``if (!condition) revert CustomError();`` instead. +.. note:: + Using custom errors with ``require`` is only supported by the via IR pipeline, i.e. compilation via Yul. + For the legacy pipeline, please use ``if (!condition) revert CustomError();`` instead. An ``Error(string)`` exception (or an exception without data) is generated -by the compiler -in the following situations: +by the compiler in the following situations: #. Calling ``require(x)`` where ``x`` evaluates to ``false``. #. If you use ``revert()`` or ``revert("description")``. @@ -662,10 +667,10 @@ an ``Error`` or a ``Panic`` (or whatever else was given): #. If you create a contract using the ``new`` keyword but the contract creation :ref:`does not finish properly`. -You can optionally provide a message string for ``require``, but not for ``assert``. +You can optionally provide a message string or a custom error to ``require``, but not to ``assert``. .. note:: - If you do not provide a string argument to ``require``, it will revert + If you do not provide a string or custom error argument to ``require``, it will revert with empty error data, not even including the error selector. diff --git a/docs/grammar/SolidityParser.g4 b/docs/grammar/SolidityParser.g4 index c46cefd2fa34..e6d3ed7ccaea 100644 --- a/docs/grammar/SolidityParser.g4 +++ b/docs/grammar/SolidityParser.g4 @@ -251,7 +251,7 @@ structMember: type=typeName name=identifier Semicolon; /** * Definition of an enum. Can occur at top-level within a source unit or within a contract, library or interface. */ -enumDefinition: Enum name=identifier LBrace enumValues+=identifier (Comma enumValues+=identifier)* RBrace; +enumDefinition: Enum name=identifier LBrace enumValues+=identifier (Comma enumValues+=identifier)* RBrace; /** * Definition of a user defined value type. Can occur at top-level within a source unit or within a contract, library or interface. */ @@ -400,7 +400,7 @@ expression: | New typeName # NewExpr | tupleExpression # Tuple | inlineArrayExpression # InlineArray - | ( + | ( identifier | literal | literalWithSubDenomination diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst index 8d5b421d3a19..f079fb0245a8 100644 --- a/docs/installing-solidity.rst +++ b/docs/installing-solidity.rst @@ -249,7 +249,6 @@ Each one includes a ``list.json`` file listing the available binaries. For examp "keccak256": "0x300330ecd127756b824aa13e843cb1f43c473cb22eaf3750d5fb9c99279af8c3", "sha256": "0x2b55ed5fec4d9625b6c7b3ab1abd2b7fb7dd2a9c68543bf0323db2c7e2d55af2", "urls": [ - "bzzr://16c5f09109c793db99fe35f037c6092b061bd39260ee7a677c8a97f18c955ab1", "dweb:/ipfs/QmTLs5MuLEWXQkths41HiACoXDiH8zxyqBHGFDRSzVE5CS" ] } @@ -264,7 +263,7 @@ This means that: In this case git is not necessary and symlinks are resolved transparently, either by serving a copy of the file or returning a HTTP redirect. - The file is also available on IPFS at `QmTLs5MuLEWXQkths41HiACoXDiH8zxyqBHGFDRSzVE5CS`_. -- The file might in future be available on Swarm at `16c5f09109c793db99fe35f037c6092b061bd39260ee7a677c8a97f18c955ab1`_. + Please, be aware that the order of items in the ``urls`` array is not predetermined or guaranteed and users should not rely on it. - You can verify the integrity of the binary by comparing its keccak256 hash to ``0x300330ecd127756b824aa13e843cb1f43c473cb22eaf3750d5fb9c99279af8c3``. The hash can be computed on the command-line using ``keccak256sum`` utility provided by `sha3sum`_ or `keccak256() function @@ -305,14 +304,12 @@ This means that: in the long-term. .. _IPFS: https://ipfs.io -.. _Swarm: https://swarm-gateways.net/bzz:/swarm.eth .. _solc-bin: https://github.com/ethereum/solc-bin/ .. _Solidity release page on GitHub: https://github.com/ethereum/solidity/releases .. _sha3sum: https://github.com/maandree/sha3sum .. _keccak256() function from ethereumjs-util: https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_hash_.md#const-keccak256 .. _WebAssembly builds: https://emscripten.org/docs/compiling/WebAssembly.html .. _QmTLs5MuLEWXQkths41HiACoXDiH8zxyqBHGFDRSzVE5CS: https://gateway.ipfs.io/ipfs/QmTLs5MuLEWXQkths41HiACoXDiH8zxyqBHGFDRSzVE5CS -.. _16c5f09109c793db99fe35f037c6092b061bd39260ee7a677c8a97f18c955ab1: https://swarm-gateways.net/bzz:/16c5f09109c793db99fe35f037c6092b061bd39260ee7a677c8a97f18c955ab1/ .. _building-from-source: diff --git a/docs/internals/optimizer.rst b/docs/internals/optimizer.rst index e79f716dd7cd..847e30cb6738 100644 --- a/docs/internals/optimizer.rst +++ b/docs/internals/optimizer.rst @@ -46,7 +46,7 @@ for a stand-alone Yul mode. enabled by default and can only be turned off via the :ref:`Standard JSON `. .. note:: - An empty optimizer sequence is accepted even without ``--optimize`` in order to fully disable + An empty optimizer sequence, i.e ``:``, is accepted even without ``--optimize`` in order to fully disable the user-supplied portion of the Yul :ref:`optimizer sequence `, as by default, even when the optimizer is not turned on, the :ref:`unused pruner ` step will be run. @@ -295,11 +295,11 @@ backtracking. All components of the Yul-based optimizer module are explained below. The following transformation steps are the main components: -- SSA Transform -- Common Subexpression Eliminator -- Expression Simplifier -- Unused Assign Eliminator -- Full Inliner +- SSATransform +- CommonSubexpressionEliminator +- ExpressionSimplifier +- UnusedAssignEliminator +- FullInliner .. _optimizer-steps: @@ -313,7 +313,7 @@ on the individual steps and their sequence below. Abbreviation Full name ============ =============================== ``f`` :ref:`block-flattener` -``l`` :ref:`circular-reference-pruner` +``l`` :ref:`circular-references-pruner` ``c`` :ref:`common-subexpression-eliminator` ``C`` :ref:`conditional-simplifier` ``U`` :ref:`conditional-unsimplifier` @@ -336,8 +336,8 @@ Abbreviation Full name ``L`` :ref:`load-resolver` ``M`` :ref:`loop-invariant-code-motion` ``m`` :ref:`rematerialiser` -``V`` :ref:`SSA-reverser` -``a`` :ref:`SSA-transform` +``V`` :ref:`ssa-reverser` +``a`` :ref:`ssa-transform` ``t`` :ref:`structural-simplifier` ``r`` :ref:`unused-assign-eliminator` ``p`` :ref:`unused-function-parameter-pruner` @@ -416,7 +416,7 @@ and functions can be optimized in isolation without having to traverse the AST c FunctionGrouper ^^^^^^^^^^^^^^^ -The function grouper has to be applied after the disambiguator and the function hoister. +The function grouper has to be applied after the Disambiguator and the FunctionHoister. Its effect is that all topmost elements that are not function definitions are moved into a single block which is the first statement of the root block. @@ -429,14 +429,14 @@ After this step, a program has the following normal form: Where ``I`` is a (potentially empty) block that does not contain any function definitions (not even recursively) and ``F`` is a list of function definitions such that no function contains a function definition. -The benefit of this stage is that we always know where the list of function begins. +The benefit of this stage is that we always know where the list of functions begins. .. _for-loop-condition-into-body: ForLoopConditionIntoBody ^^^^^^^^^^^^^^^^^^^^^^^^ -This transformation moves the loop-iteration condition of a for-loop into loop body. +This transformation moves the loop-iteration condition of a ``for`` loop into loop body. We need this transformation because :ref:`expression-splitter` will not apply to iteration condition expressions (the ``C`` in the following example). @@ -455,7 +455,7 @@ is transformed to Body... } -This transformation can also be useful when paired with ``LoopInvariantCodeMotion``, since +This transformation can also be useful when paired with LoopInvariantCodeMotion, since invariants in the loop-invariant conditions can then be taken outside the loop. .. _for-loop-init-rewriter: @@ -463,7 +463,7 @@ invariants in the loop-invariant conditions can then be taken outside the loop. ForLoopInitRewriter ^^^^^^^^^^^^^^^^^^^ -This transformation moves the initialization part of a for-loop to before +This transformation moves the initialization part of a ``for`` loop to before the loop: .. code-block:: text @@ -482,7 +482,7 @@ is transformed to } This eases the rest of the optimization process because we can ignore -the complicated scoping rules of the for loop initialization block. +the complicated scoping rules of the ``for`` loop initialization block. .. _var-decl-initializer: @@ -600,7 +600,7 @@ and it is also easier to perform function call inlining. Furthermore, it is simp to replace individual parts of expressions or re-organize the "expression tree". The drawback is that such code is much harder to read for humans. -.. _SSA-transform: +.. _ssa-transform: SSATransform ^^^^^^^^^^^^ @@ -645,19 +645,19 @@ are not modified) perform the following transforms: Furthermore, always record the current value of ``i`` used for ``a`` and replace each reference to ``a`` by ``a_i``. The current value mapping is cleared for a variable ``a`` at the end of each block -in which it was assigned to and at the end of the for loop init block if it is assigned -inside the for loop body or post block. +in which it was assigned to and at the end of the ``for`` loop init block if it is assigned +inside the ``for`` loop body or post block. If a variable's value is cleared according to the rule above and the variable is declared outside the block, a new SSA variable will be created at the location where control flow joins, this includes the beginning of loop post/body block and the location right after -If/Switch/ForLoop/Block statement. +``if``/``switch``/``for``/block statement. -After this stage, the Unused Assign Eliminator is recommended to remove the unnecessary +After this stage, the UnusedAssignEliminator is recommended to remove the unnecessary intermediate assignments. -This stage provides best results if the Expression Splitter and the Common Subexpression Eliminator +This stage provides best results if the ExpressionSplitter and the CommonSubexpressionEliminator are run right before it, because then it does not generate excessive amounts of variables. -On the other hand, the Common Subexpression Eliminator could be more efficient if run after the +On the other hand, the CommonSubexpressionEliminator could be more efficient if run after the SSA transform. .. _unused-assign-eliminator: @@ -691,7 +691,7 @@ The SSA transform converts this snippet to the following: sstore(a_3, 1) } -The Unused Assign Eliminator removes all the three assignments to ``a``, because +The UnusedAssignEliminator removes all the three assignments to ``a``, because the value of ``a`` is not used and thus turn this snippet into strict SSA form: @@ -716,7 +716,7 @@ mapping from assignment statements to the three states value will be used later by a reference to the variable. When an assignment is visited, it is added to the mapping in the "undecided" state -(see remark about for loops below) and every other assignment to the same variable +(see remark about ``for`` loops below) and every other assignment to the same variable that is still in the "undecided" state is changed to "unused". When a variable is referenced, the state of any assignment to that variable still in the "undecided" state is changed to "used". @@ -731,7 +731,7 @@ Conflicting values are resolved in the following way: - "unused", "used" -> "used" - "undecided", "used" -> "used" -For for-loops, the condition, body and post-part are visited twice, taking +For ``for`` loops, the condition, body and post-part are visited twice, taking the joining control-flow at the condition into account. In other words, we create three control flow paths: Zero runs of the loop, one run and two runs and then combine them at the end. @@ -757,13 +757,13 @@ and thus .. code-block:: none - max(s, f(s), f(f(s))) = max(s, f(s), f(f(s)), f(f(f(s))), ...). + max(s, f(s), f(f(s))) = max(s, f(s), f(f(s)), f(f(f(s))), ...) In summary, running the loop at most twice is enough because there are only three different states. -For switch statements that have a "default"-case, there is no control-flow -part that skips the switch. +For ``switch`` statements that have a default case, there is no control-flow +part that skips the ``switch``. When a variable goes out of scope, all statements still in the "undecided" state are changed to "unused", unless the variable is the return @@ -793,7 +793,7 @@ The following parts make an expression non-movable: DataflowAnalyzer ^^^^^^^^^^^^^^^^ -The Dataflow Analyzer is not an optimizer step itself but is used as a tool +The DataflowAnalyzer is not an optimizer step itself but is used as a tool by other components. While traversing the AST, it tracks the current value of each variable, as long as that value is a movable expression. It records the variables that are part of the expression @@ -804,7 +804,7 @@ of the currently stored expression for ``b``. At control-flow joins, knowledge about variables is cleared if they have or would be assigned in any of the control-flow paths. For instance, upon entering a -for loop, all variables are cleared that will be assigned during the +``for`` loop, all variables are cleared that will be assigned during the body or the post block. Expression-Scale Simplifications @@ -818,7 +818,7 @@ and hopefully simpler expressions. CommonSubexpressionEliminator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -This step uses the Dataflow Analyzer and replaces subexpressions that +This step uses the DataflowAnalyzer and replaces subexpressions that syntactically match the current value of a variable by a reference to that variable. This is an equivalence transform because such subexpressions have to be movable. @@ -828,24 +828,24 @@ current value if the value is an identifier. The combination of the two rules above allow to compute a local value numbering, which means that if two variables have the same -value, one of them will always be unused. The Unused Pruner or the -Unused Assign Eliminator will then be able to fully eliminate such +value, one of them will always be unused. The UnusedPruner or the +UnusedAssignEliminator will then be able to fully eliminate such variables. -This step is especially efficient if the expression splitter is run +This step is especially efficient if the ExpressionSplitter is run before. If the code is in pseudo-SSA form, the values of variables are available for a longer time and thus we have a higher chance of expressions to be replaceable. -The expression simplifier will be able to perform better replacements -if the common subexpression eliminator was run right before it. +The ExpressionSimplifier will be able to perform better replacements +if the CommonSubexpressionEliminator was run right before it. .. _expression-simplifier: ExpressionSimplifier ^^^^^^^^^^^^^^^^^^^^ -The ExpressionSimplifier uses the Dataflow Analyzer and makes use +The ExpressionSimplifier uses the DataflowAnalyzer and makes use of a list of equivalence transforms on expressions like ``X + 0 -> X`` to simplify the code. @@ -857,7 +857,7 @@ even when the code is in pseudo-SSA form. Some of the patterns like ``X - X -> 0`` can only be applied as long as the expression ``X`` is movable, because otherwise it would remove its potential side-effects. Since variable references are always movable, even if their current -value might not be, the Expression Simplifier is again more powerful +value might not be, the ExpressionSimplifier is again more powerful in split or pseudo-SSA form. .. _literal-rematerialiser: @@ -877,12 +877,12 @@ currently stored in storage resp. memory, if known. Works best if the code is in SSA form. -Prerequisite: Disambiguator, ForLoopInitRewriter. +Prerequisites: Disambiguator, ForLoopInitRewriter. Statement-Scale Simplifications ------------------------------- -.. _circular-reference-pruner: +.. _circular-references-pruner: CircularReferencesPruner ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -895,7 +895,7 @@ neither externally referenced nor referenced from the outermost context. ConditionalSimplifier ^^^^^^^^^^^^^^^^^^^^^ -The Conditional Simplifier inserts assignments to condition variables if the value can be determined +The ConditionalSimplifier inserts assignments to condition variables if the value can be determined from the control-flow. Destroys SSA form. @@ -906,12 +906,12 @@ we cannot assign a specific value. Current features: -- switch cases: insert " := " -- after if statement with terminating control-flow, insert " := 0" +- ``switch`` cases: insert `` := `` +- after ``if`` statement with terminating control-flow, insert `` := 0`` Future features: -- allow replacements by "1" +- allow replacements by ``1`` - take termination of user-defined functions into account Works best with SSA form and if dead code removal has run before. @@ -923,7 +923,7 @@ Prerequisite: Disambiguator. ConditionalUnsimplifier ^^^^^^^^^^^^^^^^^^^^^^^ -Reverse of Conditional Simplifier. +Reverse of ConditionalSimplifier. .. _control-flow-simplifier: @@ -932,14 +932,14 @@ ControlFlowSimplifier Simplifies several control-flow structures: -- replace if with empty body with pop(condition) -- remove empty default switch case -- remove empty switch case if no default case exists -- replace switch with no cases with pop(expression) -- turn switch with single case into if -- replace switch with only default case with pop(expression) and body -- replace switch with const expr with matching case body -- replace ``for`` with terminating control flow and without other break/continue by ``if`` +- replace ``if`` with empty body with ``pop(condition)`` +- remove empty default ``switch`` case +- remove empty ``switch`` case if no default case exists +- replace ``switch`` with no cases with ``pop(expression)`` +- turn ``switch`` with single case into ``if`` +- replace ``switch`` with only default case with ``pop(expression)`` and body +- replace ``switch`` with const expr with matching case body +- replace ``for`` with terminating control flow and without other ``break``/``continue`` by ``if`` - remove ``leave`` at the end of a function. None of these operations depend on the data flow. The StructuralSimplifier @@ -949,6 +949,7 @@ The ControlFlowSimplifier does record the presence or absence of ``break`` and ``continue`` statements during its traversal. Prerequisite: Disambiguator, FunctionHoister, ForLoopInitRewriter. + Important: Introduces EVM opcodes and thus can only be used on EVM code for now. .. _dead-code-eliminator: @@ -959,15 +960,16 @@ DeadCodeEliminator This optimization stage removes unreachable code. Unreachable code is any code within a block which is preceded by a -leave, return, invalid, break, continue, selfdestruct, revert or by a call to a user-defined function that recurses infinitely. +``leave``, ``return``, ``invalid``, ``break``, ``continue``, ``selfdestruct``, ``revert`` or by +a call to a user-defined function that recurses infinitely. Function definitions are retained as they might be called by earlier code and thus are considered reachable. -Because variables declared in a for loop's init block have their scope extended to the loop body, +Because variables declared in a ``for`` loop's init block have their scope extended to the loop body, we require ForLoopInitRewriter to run before this step. -Prerequisite: ForLoopInitRewriter, Function Hoister, Function Grouper +Prerequisites: ForLoopInitRewriter, FunctionHoister, FunctionGrouper. .. _equal-store-eliminator: @@ -978,12 +980,12 @@ This steps removes ``mstore(k, v)`` and ``sstore(k, v)`` calls if there was a previous call to ``mstore(k, v)`` / ``sstore(k, v)``, no other store in between and the values of ``k`` and ``v`` did not change. -This simple step is effective if run after the SSA transform and the -Common Subexpression Eliminator, because SSA will make sure that the variables -will not change and the Common Subexpression Eliminator re-uses exactly the same +This simple step is effective if run after the SSATransform and the +CommonSubexpressionEliminator, because SSA will make sure that the variables +will not change and the CommonSubexpressionEliminator re-uses exactly the same variable if the value is known to be the same. -Prerequisites: Disambiguator, ForLoopInitRewriter +Prerequisites: Disambiguator, ForLoopInitRewriter. .. _unused-pruner: @@ -992,8 +994,8 @@ UnusedPruner This step removes the definitions of all functions that are never referenced. -It also removes the declaration of variables that are never referenced. -If the declaration assigns a value that is not movable, the expression is retained, +It also removes declarations of variables that are never referenced. +If a declaration assigns a value that is not movable, the expression is retained, but its value is discarded. All movable expression statements (expressions that are not assigned) are removed. @@ -1006,22 +1008,22 @@ StructuralSimplifier This is a general step that performs various kinds of simplifications on a structural level: -- replace if statement with empty body by ``pop(condition)`` -- replace if statement with true condition by its body -- remove if statement with false condition -- turn switch with single case into if -- replace switch with only default case by ``pop(expression)`` and body -- replace switch with literal expression by matching case body -- replace for loop with false condition by its initialization part +- replace ``if`` statement with empty body by ``pop(condition)`` +- replace ``if`` statement with true condition by its body +- remove ``if`` statement with false condition +- turn ``switch`` with single case into ``if`` +- replace ``switch`` with only default case by ``pop(expression)`` and body +- replace ``switch`` with literal expression by matching case body +- replace ``for`` loop with false condition by its initialization part -This component uses the Dataflow Analyzer. +This component uses the DataflowAnalyzer. .. _block-flattener: BlockFlattener ^^^^^^^^^^^^^^ -This stage eliminates nested blocks by inserting the statement in the +This stage eliminates nested blocks by inserting the statements in the inner block at the appropriate place in the outer block. It depends on the FunctionGrouper and does not flatten the outermost block to keep the form produced by the FunctionGrouper. @@ -1062,10 +1064,9 @@ This optimization moves movable SSA variable declarations outside the loop. Only statements at the top level in a loop's body or post block are considered, i.e variable declarations inside conditional branches will not be moved out of the loop. -Requirements: +ExpressionSplitter and SSATransform should be run upfront to obtain better results. -- The Disambiguator, ForLoopInitRewriter and FunctionHoister must be run upfront. -- Expression splitter and SSA transform should be run upfront to obtain better result. +Prerequisites: Disambiguator, ForLoopInitRewriter, FunctionHoister. Function-Level Optimizations @@ -1092,7 +1093,7 @@ function ``f_1`` that takes only one argument, i.e., Other optimization steps will be able to make more simplifications to the function. The optimization step is mainly useful for functions that would not be inlined. -Prerequisites: Disambiguator, FunctionHoister +Prerequisites: Disambiguator, FunctionHoister. LiteralRematerialiser is recommended as a prerequisite, even though it's not required for correctness. @@ -1122,7 +1123,7 @@ The step LiteralRematerialiser is not required for correctness. It helps deal wi ``function f(x) -> y { revert(y, y} }`` where the literal ``y`` will be replaced by its value ``0``, allowing us to rewrite the function. -.. index:: ! unused store eliminator +.. index:: ! UnusedStoreEliminator .. _unused-store-eliminator: UnusedStoreEliminator @@ -1149,7 +1150,7 @@ For example, the following code sstore(c, 3) } -will be transformed into the code below after the Unused Store Eliminator step is run +will be transformed into the code below after the UnusedStoreEliminator step is run .. code-block:: yul @@ -1159,7 +1160,7 @@ will be transformed into the code below after the Unused Store Eliminator step i sstore(c, 3) } -For memory store operations, things are generally simpler, at least in the outermost yul block as all such +For memory store operations, things are generally simpler, at least in the outermost Yul block as all such statements will be removed if they are never read from in any code path. At function analysis level, however, the approach is similar to ``sstore``, as we do not know whether the memory location will be read once we leave the function's scope, so the statement will be removed only if all code paths lead to a memory overwrite. @@ -1177,8 +1178,8 @@ If two functions are syntactically equivalent, while allowing variable renaming but not any re-ordering, then any reference to one of the functions is replaced by the other. -The actual removal of the function is performed by the Unused Pruner. +The actual removal of the function is performed by the UnusedPruner. Function Inlining ----------------- @@ -1199,7 +1200,7 @@ Furthermore, for all parameters, all of the following need to be true: - The argument is movable. - The parameter is either referenced less than twice in the function body, or the argument is rather cheap - ("cost" of at most 1, like a constant up to 0xff). + ("cost" of at most 1, like a constant up to ``0xff``). Example: The function to be inlined has the form of ``function f(...) -> r { r := E }`` where ``E`` is an expression that does not reference ``r`` and all arguments in the function call are movable expressions. @@ -1255,7 +1256,7 @@ variables as much as possible. ExpressionJoiner ^^^^^^^^^^^^^^^^ -This is the opposite operation of the expression splitter. It turns a sequence of +This is the opposite operation of the ExpressionSplitter. It turns a sequence of variable declarations that have exactly one reference into a complex expression. This stage fully preserves the order of function calls and opcode executions. It does not make use of any information concerning the commutativity of the opcodes; @@ -1275,21 +1276,21 @@ Because of that, the snippet ``let x := add(0, 2) let y := mul(x, 3)`` is transformed to ``let y := mul(add(0, 2), 3)``, even though the ``add`` opcode would be executed after the evaluation of the literal ``3``. -.. _SSA-reverser: +.. _ssa-reverser: SSAReverser ^^^^^^^^^^^ -This is a tiny step that helps in reversing the effects of the SSA transform -if it is combined with the Common Subexpression Eliminator and the -Unused Pruner. +This is a tiny step that helps in reversing the effects of the SSATransform +if it is combined with the CommonSubexpressionEliminator and the +UnusedPruner. The SSA form we generate is detrimental to code generation because it produces many local variables. It would be better to just re-use existing variables with assignments instead of fresh variable declarations. -The SSA transform rewrites +The SSATransform rewrites .. code-block:: yul @@ -1307,7 +1308,7 @@ to a := a_2 The problem is that instead of ``a``, the variable ``a_1`` is used -whenever ``a`` was referenced. The SSA transform changes statements +whenever ``a`` was referenced. The SSATransform changes statements of this form by just swapping out the declaration and the assignment. The above snippet is turned into @@ -1320,10 +1321,10 @@ snippet is turned into let a_2 := a This is a very simple equivalence transform, but when we now run the -Common Subexpression Eliminator, it will replace all occurrences of ``a_1`` -by ``a`` (until ``a`` is re-assigned). The Unused Pruner will then +CommonSubexpressionEliminator, it will replace all occurrences of ``a_1`` +by ``a`` (until ``a`` is re-assigned). The UnusedPruner will then eliminate the variable ``a_1`` altogether and thus fully reverse the -SSA transform. +SSATransform. .. _stack-compressor: @@ -1354,9 +1355,9 @@ is comparatively cheap to evaluate. Furthermore, it is only semantically equival the value of the expression did not change between the point of assignment and the point of use. The main benefit of this stage is that it can save stack slots if it leads to a variable being eliminated completely (see below), but it can also -save a DUP opcode on the EVM if the expression is very cheap. +save a ``DUP`` opcode on the EVM if the expression is very cheap. -The Rematerialiser uses the Dataflow Analyzer to track the current values of variables, +The Rematerialiser uses the DataflowAnalyzer to track the current values of variables, which are always movable. If the value is very cheap or the variable was explicitly requested to be eliminated, the variable reference is replaced by its current value. diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index ded46814dc21..6bbd54f70b7b 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -85,8 +85,9 @@ registering with a username and password, all you need is an Ethereum keypair. .. code-block:: solidity // SPDX-License-Identifier: GPL-3.0 - pragma solidity ^0.8.4; + pragma solidity ^0.8.26; + // This will only compile via IR contract Coin { // The keyword "public" makes variables // accessible from other contracts @@ -118,12 +119,7 @@ registering with a username and password, all you need is an Ethereum keypair. // Sends an amount of existing coins // from any caller to an address function send(address receiver, uint amount) public { - if (amount > balances[msg.sender]) - revert InsufficientBalance({ - requested: amount, - available: balances[msg.sender] - }); - + require(amount <= balances[msg.sender], InsufficientBalance(amount, balances[msg.sender])); balances[msg.sender] -= amount; balances[receiver] += amount; emit Sent(msg.sender, receiver, amount); @@ -225,8 +221,8 @@ than the maximum value of ``uint`` (``2**256 - 1``). This is also true for the s :ref:`Errors ` allow you to provide more information to the caller about why a condition or operation failed. Errors are used together with the :ref:`revert statement `. The ``revert`` statement unconditionally -aborts and reverts all changes similar to the ``require`` function, but it also -allows you to provide the name of an error and additional data which will be supplied to the caller +aborts and reverts all changes, much like the :ref:`require function `. +Both approaches allow you to provide the name of an error and additional data which will be supplied to the caller (and eventually to the front-end application or block explorer) so that a failure can more easily be debugged or reacted upon. @@ -603,7 +599,7 @@ Precompiled Contracts ===================== There is a small set of contract addresses that are special: -The address range between ``1`` and (including) ``8`` contains +The address range between ``1`` and (including) ``0x0a`` contains "precompiled contracts" that can be called as any other contract but their behavior (and their gas consumption) is not defined by EVM code stored at that address (they do not contain code) diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index f92958b90c02..b187ea84c74f 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -117,9 +117,9 @@ Tag =============== ====================================================================================== ============================= ``@title`` A title that should describe the contract/interface contract, library, interface, struct, enum ``@author`` The name of the author contract, library, interface, struct, enum -``@notice`` Explain to an end user what this does contract, library, interface, function, public state variable, event, struct, enum -``@dev`` Explain to a developer any extra details contract, library, interface, function, state variable, event, struct, enum -``@param`` Documents a parameter just like in Doxygen (must be followed by parameter name) function, event +``@notice`` Explain to an end user what this does contract, library, interface, function, public state variable, event, struct, enum, error +``@dev`` Explain to a developer any extra details contract, library, interface, function, state variable, event, struct, enum, error +``@param`` Documents a parameter just like in Doxygen (must be followed by parameter name) function, event, error ``@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 ``@custom:...`` Custom tag, semantics is application-defined everywhere diff --git a/docs/resources.rst b/docs/resources.rst index 85b3cf9a3912..1773859d4eaf 100644 --- a/docs/resources.rst +++ b/docs/resources.rst @@ -110,7 +110,7 @@ Solidity Tools * `leafleth `_ A documentation generator for Solidity smart-contracts. -* `Scaffold-ETH `_ +* `Scaffold-ETH 2 `_ Forkable Ethereum development stack focused on fast product iterations. * `sol2uml `_ diff --git a/docs/types/conversion.rst b/docs/types/conversion.rst index dafb336bd01e..92f0e19dc359 100644 --- a/docs/types/conversion.rst +++ b/docs/types/conversion.rst @@ -174,15 +174,14 @@ converted to any fixed-size bytes type: bytes4 g = 0x0; // fine String literals and hex string literals can be implicitly converted to fixed-size byte arrays, -if their number of characters matches the size of the bytes type: +if their number of characters is less than or equal to the size of the bytes type: .. code-block:: solidity bytes2 a = hex"1234"; // fine bytes2 b = "xy"; // fine - bytes2 c = hex"12"; // not allowed - bytes2 d = hex"123"; // not allowed - bytes2 e = "x"; // not allowed + bytes2 c = hex"12"; // fine + bytes2 e = "x"; // fine bytes2 f = "xyz"; // not allowed .. index:: literal;address @@ -199,4 +198,4 @@ An ``address a`` can be converted explicitly to ``address payable`` via ``payabl .. note:: Prior to version 0.8.0, it was possible to explicitly convert from any integer type (of any size, signed or unsigned) to ``address`` or ``address payable``. - Starting with in 0.8.0 only conversion from ``uint160`` is allowed. \ No newline at end of file + Starting with 0.8.0 only conversion from ``uint160`` is allowed. diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index d2e9300e64a4..a6c48d2416d9 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -392,8 +392,7 @@ Array Members // Data location for all state variables is storage. bool[2][] pairsOfFlags; - // newPairs is stored in memory - the only possibility - // for public contract function arguments + // newPairs is stored in memory function setAllFlagPairs(bool[2][] memory newPairs) public { // assignment to a storage array performs a copy of ``newPairs`` and // replaces the complete array ``pairsOfFlags``. diff --git a/libevmasm/AbstractAssemblyStack.h b/libevmasm/AbstractAssemblyStack.h index 6be78cbc7cac..278edf5c273b 100644 --- a/libevmasm/AbstractAssemblyStack.h +++ b/libevmasm/AbstractAssemblyStack.h @@ -40,7 +40,7 @@ class AbstractAssemblyStack virtual std::string const* sourceMapping(std::string const& _contractName) const = 0; virtual std::string const* runtimeSourceMapping(std::string const& _contractName) const = 0; - virtual Json::Value assemblyJSON(std::string const& _contractName) const = 0; + virtual Json assemblyJSON(std::string const& _contractName) const = 0; virtual std::string assemblyString(std::string const& _contractName, StringMap const& _sourceCodes) const = 0; virtual std::string const filesystemFriendlyName(std::string const& _contractName) const = 0; diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 067e230343d0..356a2818a4cd 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -80,10 +80,10 @@ unsigned Assembly::codeSize(unsigned subTagSize) const } } -void Assembly::importAssemblyItemsFromJSON(Json::Value const& _code, std::vector const& _sourceList) +void Assembly::importAssemblyItemsFromJSON(Json const& _code, std::vector const& _sourceList) { solAssert(m_items.empty()); - solRequire(_code.isArray(), AssemblyImportException, "Supplied JSON is not an array."); + solRequire(_code.is_array(), AssemblyImportException, "Supplied JSON is not an array."); for (auto jsonItemIter = std::begin(_code); jsonItemIter != std::end(_code); ++jsonItemIter) { AssemblyItem const& newItem = m_items.emplace_back(createAssemblyItemFromJSON(*jsonItemIter, _sourceList)); @@ -98,11 +98,11 @@ void Assembly::importAssemblyItemsFromJSON(Json::Value const& _code, std::vector } } -AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std::vector const& _sourceList) +AssemblyItem Assembly::createAssemblyItemFromJSON(Json const& _json, std::vector const& _sourceList) { - solRequire(_json.isObject(), AssemblyImportException, "Supplied JSON is not an object."); + solRequire(_json.is_object(), AssemblyImportException, "Supplied JSON is not an object."); static std::set const validMembers{"name", "begin", "end", "source", "value", "modifierDepth", "jumpType"}; - for (std::string const& member: _json.getMemberNames()) + for (auto const& [member, _]: _json.items()) solRequire( validMembers.count(member), AssemblyImportException, @@ -124,14 +124,14 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: solRequire(!name.empty(), AssemblyImportException, "Member 'name' is empty."); SourceLocation location; - if (_json.isMember("begin")) + if (_json.contains("begin")) location.start = get(_json["begin"]); - if (_json.isMember("end")) + if (_json.contains("end")) location.end = get(_json["end"]); - int srcIndex = getOrDefault(_json["source"], -1); - size_t modifierDepth = static_cast(getOrDefault(_json["modifierDepth"], 0)); - std::string value = getOrDefault(_json["value"], ""); - std::string jumpType = getOrDefault(_json["jumpType"], ""); + int srcIndex = getOrDefault(_json, "source", -1); + size_t modifierDepth = static_cast(getOrDefault(_json, "modifierDepth", 0)); + std::string value = getOrDefault(_json, "value", ""); + std::string jumpType = getOrDefault(_json, "jumpType", ""); auto updateUsedTags = [&](u256 const& data) { @@ -429,11 +429,11 @@ std::string Assembly::assemblyString( return tmp.str(); } -Json::Value Assembly::assemblyJSON(std::map const& _sourceIndices, bool _includeSourceList) const +Json Assembly::assemblyJSON(std::map const& _sourceIndices, bool _includeSourceList) const { - Json::Value root; - root[".code"] = Json::arrayValue; - Json::Value& code = root[".code"]; + Json root; + root[".code"] = Json::array(); + Json& code = root[".code"]; for (AssemblyItem const& item: m_items) { int sourceIndex = -1; @@ -445,7 +445,7 @@ Json::Value Assembly::assemblyJSON(std::map const& _sourc } auto [name, data] = item.nameAndData(m_evmVersion); - Json::Value jsonItem; + Json jsonItem; jsonItem["name"] = name; jsonItem["begin"] = item.location().start; jsonItem["end"] = item.location().end; @@ -461,32 +461,32 @@ Json::Value Assembly::assemblyJSON(std::map const& _sourc if (!data.empty()) jsonItem["value"] = data; jsonItem["source"] = sourceIndex; - code.append(std::move(jsonItem)); + code.emplace_back(std::move(jsonItem)); if (item.type() == AssemblyItemType::Tag) { - Json::Value jumpdest; + Json jumpdest; jumpdest["name"] = "JUMPDEST"; jumpdest["begin"] = item.location().start; jumpdest["end"] = item.location().end; jumpdest["source"] = sourceIndex; if (item.m_modifierDepth != 0) jumpdest["modifierDepth"] = static_cast(item.m_modifierDepth); - code.append(std::move(jumpdest)); + code.emplace_back(std::move(jumpdest)); } } if (_includeSourceList) { - root["sourceList"] = Json::arrayValue; - Json::Value& jsonSourceList = root["sourceList"]; + root["sourceList"] = Json::array(); + Json& jsonSourceList = root["sourceList"]; for (auto const& [name, index]: _sourceIndices) jsonSourceList[index] = name; } if (!m_data.empty() || !m_subs.empty()) { - root[".data"] = Json::objectValue; - Json::Value& data = root[".data"]; + root[".data"] = Json::object(); + Json& data = root[".data"]; for (auto const& i: m_data) if (u256(i.first) >= m_subs.size()) data[util::toHex(toBigEndian((u256)i.first), util::HexPrefix::DontAdd, util::HexCase::Upper)] = util::toHex(i.second); @@ -506,110 +506,107 @@ Json::Value Assembly::assemblyJSON(std::map const& _sourc } std::pair, std::vector> Assembly::fromJSON( - Json::Value const& _json, + Json const& _json, std::vector const& _sourceList, size_t _level ) { - solRequire(_json.isObject(), AssemblyImportException, "Supplied JSON is not an object."); + solRequire(_json.is_object(), AssemblyImportException, "Supplied JSON is not an object."); static std::set const validMembers{".code", ".data", ".auxdata", "sourceList"}; - for (std::string const& attribute: _json.getMemberNames()) + for (auto const& [attribute, _]: _json.items()) solRequire(validMembers.count(attribute), AssemblyImportException, "Unknown attribute '" + attribute + "'."); if (_level == 0) { - if (_json.isMember("sourceList")) + if (_json.contains("sourceList")) { - solRequire(_json["sourceList"].isArray(), AssemblyImportException, "Optional member 'sourceList' is not an array."); - for (Json::Value const& sourceName: _json["sourceList"]) - solRequire(sourceName.isString(), AssemblyImportException, "The 'sourceList' array contains an item that is not a string."); + solRequire(_json["sourceList"].is_array(), AssemblyImportException, "Optional member 'sourceList' is not an array."); + for (Json const& sourceName: _json["sourceList"]) + solRequire(sourceName.is_string(), AssemblyImportException, "The 'sourceList' array contains an item that is not a string."); } } else solRequire( - !_json.isMember("sourceList"), + !_json.contains("sourceList"), AssemblyImportException, "Member 'sourceList' may only be present in the root JSON object." ); auto result = std::make_shared(EVMVersion{}, _level == 0 /* _creation */, "" /* _name */); std::vector parsedSourceList; - if (_json.isMember("sourceList")) + if (_json.contains("sourceList")) { solAssert(_level == 0); solAssert(_sourceList.empty()); - for (Json::Value const& sourceName: _json["sourceList"]) + for (Json const& sourceName: _json["sourceList"]) { solRequire( - std::find(parsedSourceList.begin(), parsedSourceList.end(), sourceName.asString()) == parsedSourceList.end(), + std::find(parsedSourceList.begin(), parsedSourceList.end(), sourceName.get()) == parsedSourceList.end(), AssemblyImportException, "Items in 'sourceList' array are not unique." ); - parsedSourceList.emplace_back(sourceName.asString()); + parsedSourceList.emplace_back(sourceName.get()); } } - solRequire(_json.isMember(".code"), AssemblyImportException, "Member '.code' is missing."); - solRequire(_json[".code"].isArray(), AssemblyImportException, "Member '.code' is not an array."); - for (Json::Value const& codeItem: _json[".code"]) - solRequire(codeItem.isObject(), AssemblyImportException, "The '.code' array contains an item that is not an object."); + solRequire(_json.contains(".code"), AssemblyImportException, "Member '.code' is missing."); + solRequire(_json[".code"].is_array(), AssemblyImportException, "Member '.code' is not an array."); + for (Json const& codeItem: _json[".code"]) + solRequire(codeItem.is_object(), AssemblyImportException, "The '.code' array contains an item that is not an object."); result->importAssemblyItemsFromJSON(_json[".code"], _level == 0 ? parsedSourceList : _sourceList); - if (_json.isMember(".auxdata")) + if (_json.contains(".auxdata")) { - solRequire(_json[".auxdata"].isString(), AssemblyImportException, "Optional member '.auxdata' is not a string."); - result->m_auxiliaryData = fromHex(_json[".auxdata"].asString()); + solRequire(_json[".auxdata"].is_string(), AssemblyImportException, "Optional member '.auxdata' is not a string."); + result->m_auxiliaryData = fromHex(_json[".auxdata"].get()); solRequire(!result->m_auxiliaryData.empty(), AssemblyImportException, "Optional member '.auxdata' is not a valid hexadecimal string."); } - if (_json.isMember(".data")) + if (_json.contains(".data")) { - solRequire(_json[".data"].isObject(), AssemblyImportException, "Optional member '.data' is not an object."); - Json::Value const& data = _json[".data"]; + solRequire(_json[".data"].is_object(), AssemblyImportException, "Optional member '.data' is not an object."); + Json const& data = _json[".data"]; std::map> subAssemblies; - for (Json::ValueConstIterator dataIter = data.begin(); dataIter != data.end(); dataIter++) + for (auto const& [key, value] : data.items()) { - solAssert(dataIter.key().isString()); - std::string dataItemID = dataIter.key().asString(); - Json::Value const& dataItem = data[dataItemID]; - if (dataItem.isString()) + if (value.is_string()) { solRequire( - dataItem.asString().empty() || !fromHex(dataItem.asString()).empty(), + value.get().empty() || !fromHex(value.get()).empty(), AssemblyImportException, - "The value for key '" + dataItemID + "' inside '.data' is not a valid hexadecimal string." + "The value for key '" + key + "' inside '.data' is not a valid hexadecimal string." ); - result->m_data[h256(fromHex(dataItemID))] = fromHex(dataItem.asString()); + result->m_data[h256(fromHex(key))] = fromHex(value.get()); } - else if (dataItem.isObject()) + else if (value.is_object()) { size_t index{}; try { // Using signed variant because stoul() still accepts negative numbers and // just lets them wrap around. - int parsedDataItemID = std::stoi(dataItemID, nullptr, 16); - solRequire(parsedDataItemID >= 0, AssemblyImportException, "The key '" + dataItemID + "' inside '.data' is out of the supported integer range."); + int parsedDataItemID = std::stoi(key, nullptr, 16); + solRequire(parsedDataItemID >= 0, AssemblyImportException, "The key '" + key + "' inside '.data' is out of the supported integer range."); index = static_cast(parsedDataItemID); } catch (std::invalid_argument const&) { - solThrow(AssemblyImportException, "The key '" + dataItemID + "' inside '.data' is not an integer."); + solThrow(AssemblyImportException, "The key '" + key + "' inside '.data' is not an integer."); } catch (std::out_of_range const&) { - solThrow(AssemblyImportException, "The key '" + dataItemID + "' inside '.data' is out of the supported integer range."); + solThrow(AssemblyImportException, "The key '" + key + "' inside '.data' is out of the supported integer range."); } - auto [subAssembly, emptySourceList] = Assembly::fromJSON(dataItem, _level == 0 ? parsedSourceList : _sourceList, _level + 1); + auto [subAssembly, emptySourceList] = Assembly::fromJSON(value, _level == 0 ? parsedSourceList : _sourceList, _level + 1); solAssert(subAssembly); solAssert(emptySourceList.empty()); solAssert(subAssemblies.count(index) == 0); subAssemblies[index] = subAssembly; } else - solThrow(AssemblyImportException, "The value of key '" + dataItemID + "' inside '.data' is neither a hex string nor an object."); + solThrow(AssemblyImportException, "The value of key '" + key + "' inside '.data' is neither a hex string nor an object."); } if (!subAssemblies.empty()) diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index 6e900282569b..123d7f3ddd8c 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -30,11 +30,10 @@ #include #include #include +#include #include -#include - #include #include #include @@ -150,7 +149,7 @@ class Assembly ) const; /// Create a JSON representation of the assembly. - Json::Value assemblyJSON(std::map const& _sourceIndices, bool _includeSourceList = true) const; + Json assemblyJSON(std::map const& _sourceIndices, bool _includeSourceList = true) const; /// Constructs an @a Assembly from the serialized JSON representation. /// @param _json JSON object containing assembly in the format produced by assemblyJSON(). @@ -163,7 +162,7 @@ class Assembly /// @returns Created @a Assembly and the source list read from the 'sourceList' field of the root /// assembly or an empty list (in recursive calls). static std::pair, std::vector> fromJSON( - Json::Value const& _json, + Json const& _json, std::vector const& _sourceList = {}, size_t _level = 0 ); @@ -188,13 +187,13 @@ class Assembly /// the code array. This method only works on clean Assembly objects that don't have any items defined yet. /// @param _json JSON array that contains assembly items (e.g. json['.code']) /// @param _sourceList List of source names. - void importAssemblyItemsFromJSON(Json::Value const& _code, std::vector const& _sourceList); + void importAssemblyItemsFromJSON(Json const& _code, std::vector const& _sourceList); /// Creates an AssemblyItem from a given JSON representation. /// @param _json JSON object that consists a single assembly item /// @param _sourceList List of source names. /// @returns AssemblyItem of _json argument. - AssemblyItem createAssemblyItemFromJSON(Json::Value const& _json, std::vector const& _sourceList); + AssemblyItem createAssemblyItemFromJSON(Json const& _json, std::vector const& _sourceList); private: bool m_invalid = false; diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 2adaa023a13e..c88a9663f3b7 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -127,7 +127,7 @@ size_t AssemblyItem::bytesRequired(size_t _addressLength, Precision _precision) return 1 + std::max(1, numberEncodingSize(data())); case PushSubSize: case PushProgramSize: - return 1 + 4; // worst case: a 16MB program + return 1 + 4; // worst case: a 16MB program case PushTag: case PushData: case PushSub: diff --git a/libevmasm/EVMAssemblyStack.cpp b/libevmasm/EVMAssemblyStack.cpp index a06044256faf..20605ee354a0 100644 --- a/libevmasm/EVMAssemblyStack.cpp +++ b/libevmasm/EVMAssemblyStack.cpp @@ -36,12 +36,12 @@ namespace solidity::evmasm void EVMAssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source) { - Json::Value assemblyJson; + Json assemblyJson; solRequire(jsonParseStrict(_source, assemblyJson), AssemblyImportException, "Could not parse JSON file."); analyze(_sourceName, assemblyJson); } -void EVMAssemblyStack::analyze(std::string const& _sourceName, Json::Value const& _assemblyJson) +void EVMAssemblyStack::analyze(std::string const& _sourceName, Json const& _assemblyJson) { solAssert(!m_evmAssembly); m_name = _sourceName; @@ -99,7 +99,7 @@ std::string const* EVMAssemblyStack::runtimeSourceMapping(std::string const& _co return &m_runtimeSourceMapping; } -Json::Value EVMAssemblyStack::assemblyJSON(std::string const& _contractName) const +Json EVMAssemblyStack::assemblyJSON(std::string const& _contractName) const { solAssert(_contractName == m_name); solAssert(m_evmAssembly); diff --git a/libevmasm/EVMAssemblyStack.h b/libevmasm/EVMAssemblyStack.h index 7fe77e7d208b..f2516c0b8a0a 100644 --- a/libevmasm/EVMAssemblyStack.h +++ b/libevmasm/EVMAssemblyStack.h @@ -43,7 +43,7 @@ class EVMAssemblyStack: public AbstractAssemblyStack /// Runs analysis steps. /// Multiple calls overwrite the previous state. /// @throws AssemblyImportException, if JSON could not be validated. - void analyze(std::string const& _sourceName, Json::Value const& _assemblyJson); + void analyze(std::string const& _sourceName, Json const& _assemblyJson); void assemble(); @@ -58,7 +58,7 @@ class EVMAssemblyStack: public AbstractAssemblyStack virtual std::string const* sourceMapping(std::string const& _contractName) const override; virtual std::string const* runtimeSourceMapping(std::string const& _contractName) const override; - virtual Json::Value assemblyJSON(std::string const& _contractName) const override; + virtual Json assemblyJSON(std::string const& _contractName) const override; virtual std::string assemblyString(std::string const& _contractName, StringMap const& _sourceCodes) const override; virtual std::string const filesystemFriendlyName(std::string const& _contractName) const override; diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index d0750513a39c..68de80037023 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -198,172 +198,172 @@ std::map const solidity::evmasm::c_instructions = /// @note InstructionInfo is assumed to be the same across all EVM versions except for the instruction name. static std::map const c_instructionInfo = -{ // Add, Args, Ret, SideEffects, GasPriceTier - { Instruction::STOP, { "STOP", 0, 0, 0, true, Tier::Zero } }, - { Instruction::ADD, { "ADD", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::SUB, { "SUB", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::MUL, { "MUL", 0, 2, 1, false, Tier::Low } }, - { Instruction::DIV, { "DIV", 0, 2, 1, false, Tier::Low } }, - { Instruction::SDIV, { "SDIV", 0, 2, 1, false, Tier::Low } }, - { Instruction::MOD, { "MOD", 0, 2, 1, false, Tier::Low } }, - { Instruction::SMOD, { "SMOD", 0, 2, 1, false, Tier::Low } }, - { Instruction::EXP, { "EXP", 0, 2, 1, false, Tier::Special } }, - { Instruction::NOT, { "NOT", 0, 1, 1, false, Tier::VeryLow } }, - { Instruction::LT, { "LT", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::GT, { "GT", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::SLT, { "SLT", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::SGT, { "SGT", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::EQ, { "EQ", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false, Tier::VeryLow } }, - { Instruction::AND, { "AND", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::OR, { "OR", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::XOR, { "XOR", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::BYTE, { "BYTE", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::SHL, { "SHL", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::SHR, { "SHR", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::SAR, { "SAR", 0, 2, 1, false, Tier::VeryLow } }, - { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, Tier::Mid } }, - { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, Tier::Mid } }, - { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, Tier::Low } }, - { Instruction::KECCAK256, { "KECCAK256", 0, 2, 1, true, Tier::Special } }, - { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, Tier::Base } }, - { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, Tier::Special } }, - { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, Tier::Base } }, - { Instruction::CALLER, { "CALLER", 0, 0, 1, false, Tier::Base } }, - { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, Tier::Base } }, - { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, Tier::VeryLow } }, - { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, Tier::Base } }, - { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true, Tier::VeryLow } }, - { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false, Tier::Base } }, - { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true, Tier::VeryLow } }, - { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false, Tier::Base } }, - { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false, Tier::Special } }, - { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, Tier::Special } }, - { Instruction::RETURNDATASIZE, {"RETURNDATASIZE", 0, 0, 1, false, Tier::Base } }, - { Instruction::RETURNDATACOPY, {"RETURNDATACOPY", 0, 3, 0, true, Tier::VeryLow } }, - { Instruction::MCOPY, { "MCOPY", 0, 3, 0, true, Tier::VeryLow } }, - { Instruction::EXTCODEHASH, { "EXTCODEHASH", 0, 1, 1, false, Tier::Special } }, - { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, Tier::BlockHash } }, - { Instruction::BLOBHASH, { "BLOBHASH", 0, 1, 1, false, Tier::VeryLow } }, - { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, Tier::Base } }, - { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, Tier::Base } }, - { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false, Tier::Base } }, - { Instruction::PREVRANDAO, { "PREVRANDAO", 0, 0, 1, false, Tier::Base } }, - { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false, Tier::Base } }, - { Instruction::CHAINID, { "CHAINID", 0, 0, 1, false, Tier::Base } }, - { Instruction::SELFBALANCE, { "SELFBALANCE", 0, 0, 1, false, Tier::Low } }, - { Instruction::BASEFEE, { "BASEFEE", 0, 0, 1, false, Tier::Base } }, - { Instruction::BLOBBASEFEE, { "BLOBBASEFEE", 0, 0, 1, false, Tier::Base } }, - { Instruction::POP, { "POP", 0, 1, 0, false, Tier::Base } }, - { Instruction::MLOAD, { "MLOAD", 0, 1, 1, true, Tier::VeryLow } }, - { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true, Tier::VeryLow } }, - { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true, Tier::VeryLow } }, - { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false, Tier::Special } }, - { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true, Tier::Special } }, - { Instruction::TLOAD, { "TLOAD", 0, 1, 1, false, Tier::WarmAccess} }, - { Instruction::TSTORE, { "TSTORE", 0, 2, 0, true, Tier::WarmAccess} }, - { Instruction::JUMP, { "JUMP", 0, 1, 0, true, Tier::Mid } }, - { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, Tier::High } }, - { Instruction::PC, { "PC", 0, 0, 1, false, Tier::Base } }, - { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, Tier::Base } }, - { Instruction::GAS, { "GAS", 0, 0, 1, false, Tier::Base } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, Tier::Special } }, - { Instruction::PUSH0, { "PUSH0", 0, 0, 1, false, Tier::Base } }, - { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false, Tier::VeryLow } }, - { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false, Tier::VeryLow } }, - { Instruction::DUP1, { "DUP1", 0, 1, 2, false, Tier::VeryLow } }, - { Instruction::DUP2, { "DUP2", 0, 2, 3, false, Tier::VeryLow } }, - { Instruction::DUP3, { "DUP3", 0, 3, 4, false, Tier::VeryLow } }, - { Instruction::DUP4, { "DUP4", 0, 4, 5, false, Tier::VeryLow } }, - { Instruction::DUP5, { "DUP5", 0, 5, 6, false, Tier::VeryLow } }, - { Instruction::DUP6, { "DUP6", 0, 6, 7, false, Tier::VeryLow } }, - { Instruction::DUP7, { "DUP7", 0, 7, 8, false, Tier::VeryLow } }, - { Instruction::DUP8, { "DUP8", 0, 8, 9, false, Tier::VeryLow } }, - { Instruction::DUP9, { "DUP9", 0, 9, 10, false, Tier::VeryLow } }, - { Instruction::DUP10, { "DUP10", 0, 10, 11, false, Tier::VeryLow } }, - { Instruction::DUP11, { "DUP11", 0, 11, 12, false, Tier::VeryLow } }, - { Instruction::DUP12, { "DUP12", 0, 12, 13, false, Tier::VeryLow } }, - { Instruction::DUP13, { "DUP13", 0, 13, 14, false, Tier::VeryLow } }, - { Instruction::DUP14, { "DUP14", 0, 14, 15, false, Tier::VeryLow } }, - { Instruction::DUP15, { "DUP15", 0, 15, 16, false, Tier::VeryLow } }, - { Instruction::DUP16, { "DUP16", 0, 16, 17, false, Tier::VeryLow } }, - { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false, Tier::VeryLow } }, - { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false, Tier::VeryLow } }, - { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false, Tier::VeryLow } }, - { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false, Tier::VeryLow } }, - { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false, Tier::VeryLow } }, - { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false, Tier::VeryLow } }, - { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false, Tier::VeryLow } }, - { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false, Tier::VeryLow } }, - { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false, Tier::VeryLow } }, - { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false, Tier::VeryLow } }, - { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false, Tier::VeryLow } }, - { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false, Tier::VeryLow } }, - { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false, Tier::VeryLow } }, - { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false, Tier::VeryLow } }, - { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false, Tier::VeryLow } }, - { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false, Tier::VeryLow } }, - { Instruction::LOG0, { "LOG0", 0, 2, 0, true, Tier::Special } }, - { Instruction::LOG1, { "LOG1", 0, 3, 0, true, Tier::Special } }, - { Instruction::LOG2, { "LOG2", 0, 4, 0, true, Tier::Special } }, - { Instruction::LOG3, { "LOG3", 0, 5, 0, true, Tier::Special } }, - { Instruction::LOG4, { "LOG4", 0, 6, 0, true, Tier::Special } }, - { Instruction::CALLTOKEN, { "CALLTOKEN", 0, 8, 1, true, Tier::Special } }, - { Instruction::TOKENBALANCE, { "TOKENBALANCE", 0, 2, 1, false, Tier::Special } }, - { Instruction::CALLTOKENVALUE, {"CALLTOKENVALUE", 0, 0, 1, false, Tier::Base } }, - { Instruction::CALLTOKENID, {"CALLTOKENID", 0, 0, 1, false, Tier::Base } }, - { Instruction::ISCONTRACT, {"ISCONTRACT", 0, 1, 1, false, Tier::Special } }, - { Instruction::NATIVEFREEZE, {"NATIVEFREEZE", 0, 3, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEUNFREEZE, {"NATIVEUNFREEZE", 0, 2, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEFREEZEEXPIRETIME, {"NATIVEFREEZEEXPIRETIME", 0, 2, 1, false, Tier::BlockHash } }, - { Instruction::NATIVEVOTE, {"NATIVEVOTE", 0, 4, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEWITHDRAWREWARD, {"NATIVEWITHDRAWREWARD", 0, 0, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEFREEZEBALANCEV2, {"NATIVEFREEZEBALANCEV2", 0, 2, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEUNFREEZEBALANCEV2, {"NATIVEUNFREEZEBALANCEV2", 0, 2, 1, true, Tier::BlockHash } }, - { Instruction::NATIVECANCELALLUNFREEZEV2, {"NATIVECANCELALLUNFREEZEV2", 0, 0, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEWITHDRAWEXPIREUNFREEZE, {"NATIVEWITHDRAWEXPIREUNFREEZE", 0, 0, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEDELEGATERESOURCE, {"NATIVEDELEGATERESOURCE", 0, 3, 1, true, Tier::BlockHash } }, - { Instruction::NATIVEUNDELEGATERESOURCE, {"NATIVEUNDELEGATERESOURCE", 0, 3, 1, true, Tier::BlockHash } }, - { Instruction::CREATE, {"CREATE", 0, 3, 1, true, Tier::Special } }, - { Instruction::CALL, {"CALL", 0, 7, 1, true, Tier::Special } }, - { Instruction::CALLCODE, {"CALLCODE", 0, 7, 1, true, Tier::Special } }, - { Instruction::RETURN, {"RETURN", 0, 2, 0, true, Tier::Zero } }, - { Instruction::DELEGATECALL, {"DELEGATECALL", 0, 6, 1, true, Tier::Special } }, - { Instruction::STATICCALL, {"STATICCALL", 0, 6, 1, true, Tier::Special } }, - { Instruction::CREATE2, {"CREATE2", 0, 4, 1, true, Tier::Special } }, - { Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } }, - { Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } }, - { Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Special } } +{ // Add Args Ret SideEffects GasPriceTier + {Instruction::STOP, {"STOP", 0, 0, 0, true, Tier::Zero}}, + {Instruction::ADD, {"ADD", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::SUB, {"SUB", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::MUL, {"MUL", 0, 2, 1, false, Tier::Low}}, + {Instruction::DIV, {"DIV", 0, 2, 1, false, Tier::Low}}, + {Instruction::SDIV, {"SDIV", 0, 2, 1, false, Tier::Low}}, + {Instruction::MOD, {"MOD", 0, 2, 1, false, Tier::Low}}, + {Instruction::SMOD, {"SMOD", 0, 2, 1, false, Tier::Low}}, + {Instruction::EXP, {"EXP", 0, 2, 1, false, Tier::Special}}, + {Instruction::NOT, {"NOT", 0, 1, 1, false, Tier::VeryLow}}, + {Instruction::LT, {"LT", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::GT, {"GT", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::SLT, {"SLT", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::SGT, {"SGT", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::EQ, {"EQ", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::ISZERO, {"ISZERO", 0, 1, 1, false, Tier::VeryLow}}, + {Instruction::AND, {"AND", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::OR, {"OR", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::XOR, {"XOR", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::BYTE, {"BYTE", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::SHL, {"SHL", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::SHR, {"SHR", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::SAR, {"SAR", 0, 2, 1, false, Tier::VeryLow}}, + {Instruction::ADDMOD, {"ADDMOD", 0, 3, 1, false, Tier::Mid}}, + {Instruction::MULMOD, {"MULMOD", 0, 3, 1, false, Tier::Mid}}, + {Instruction::SIGNEXTEND, {"SIGNEXTEND", 0, 2, 1, false, Tier::Low}}, + {Instruction::KECCAK256, {"KECCAK256", 0, 2, 1, true, Tier::Special}}, + {Instruction::ADDRESS, {"ADDRESS", 0, 0, 1, false, Tier::Base}}, + {Instruction::BALANCE, {"BALANCE", 0, 1, 1, false, Tier::Special}}, + {Instruction::ORIGIN, {"ORIGIN", 0, 0, 1, false, Tier::Base}}, + {Instruction::CALLER, {"CALLER", 0, 0, 1, false, Tier::Base}}, + {Instruction::CALLVALUE, {"CALLVALUE", 0, 0, 1, false, Tier::Base}}, + {Instruction::CALLDATALOAD, {"CALLDATALOAD", 0, 1, 1, false, Tier::VeryLow}}, + {Instruction::CALLDATASIZE, {"CALLDATASIZE", 0, 0, 1, false, Tier::Base}}, + {Instruction::CALLDATACOPY, {"CALLDATACOPY", 0, 3, 0, true, Tier::VeryLow}}, + {Instruction::CODESIZE, {"CODESIZE", 0, 0, 1, false, Tier::Base}}, + {Instruction::CODECOPY, {"CODECOPY", 0, 3, 0, true, Tier::VeryLow}}, + {Instruction::GASPRICE, {"GASPRICE", 0, 0, 1, false, Tier::Base}}, + {Instruction::EXTCODESIZE, {"EXTCODESIZE", 0, 1, 1, false, Tier::Special}}, + {Instruction::EXTCODECOPY, {"EXTCODECOPY", 0, 4, 0, true, Tier::Special}}, + {Instruction::RETURNDATASIZE, {"RETURNDATASIZE", 0, 0, 1, false, Tier::Base}}, + {Instruction::RETURNDATACOPY, {"RETURNDATACOPY", 0, 3, 0, true, Tier::VeryLow}}, + {Instruction::MCOPY, {"MCOPY", 0, 3, 0, true, Tier::VeryLow}}, + {Instruction::EXTCODEHASH, {"EXTCODEHASH", 0, 1, 1, false, Tier::Special}}, + {Instruction::BLOCKHASH, {"BLOCKHASH", 0, 1, 1, false, Tier::BlockHash}}, + {Instruction::BLOBHASH, {"BLOBHASH", 0, 1, 1, false, Tier::VeryLow}}, + {Instruction::COINBASE, {"COINBASE", 0, 0, 1, false, Tier::Base}}, + {Instruction::TIMESTAMP, {"TIMESTAMP", 0, 0, 1, false, Tier::Base}}, + {Instruction::NUMBER, {"NUMBER", 0, 0, 1, false, Tier::Base}}, + {Instruction::PREVRANDAO, {"PREVRANDAO", 0, 0, 1, false, Tier::Base}}, + {Instruction::GASLIMIT, {"GASLIMIT", 0, 0, 1, false, Tier::Base}}, + {Instruction::CHAINID, {"CHAINID", 0, 0, 1, false, Tier::Base}}, + {Instruction::SELFBALANCE, {"SELFBALANCE", 0, 0, 1, false, Tier::Low}}, + {Instruction::BASEFEE, {"BASEFEE", 0, 0, 1, false, Tier::Base}}, + {Instruction::BLOBBASEFEE, {"BLOBBASEFEE", 0, 0, 1, false, Tier::Base}}, + {Instruction::POP, {"POP", 0, 1, 0, false, Tier::Base}}, + {Instruction::MLOAD, {"MLOAD", 0, 1, 1, true, Tier::VeryLow}}, + {Instruction::MSTORE, {"MSTORE", 0, 2, 0, true, Tier::VeryLow}}, + {Instruction::MSTORE8, {"MSTORE8", 0, 2, 0, true, Tier::VeryLow}}, + {Instruction::SLOAD, {"SLOAD", 0, 1, 1, false, Tier::Special}}, + {Instruction::SSTORE, {"SSTORE", 0, 2, 0, true, Tier::Special}}, + {Instruction::TLOAD, {"TLOAD", 0, 1, 1, false, Tier::WarmAccess}}, + {Instruction::TSTORE, {"TSTORE", 0, 2, 0, true, Tier::WarmAccess}}, + {Instruction::JUMP, {"JUMP", 0, 1, 0, true, Tier::Mid}}, + {Instruction::JUMPI, {"JUMPI", 0, 2, 0, true, Tier::High}}, + {Instruction::PC, {"PC", 0, 0, 1, false, Tier::Base}}, + {Instruction::MSIZE, {"MSIZE", 0, 0, 1, false, Tier::Base}}, + {Instruction::GAS, {"GAS", 0, 0, 1, false, Tier::Base}}, + {Instruction::JUMPDEST, {"JUMPDEST", 0, 0, 0, true, Tier::Special}}, + {Instruction::PUSH0, {"PUSH0", 0, 0, 1, false, Tier::Base}}, + {Instruction::PUSH1, {"PUSH1", 1, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH2, {"PUSH2", 2, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH3, {"PUSH3", 3, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH4, {"PUSH4", 4, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH5, {"PUSH5", 5, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH6, {"PUSH6", 6, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH7, {"PUSH7", 7, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH8, {"PUSH8", 8, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH9, {"PUSH9", 9, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH10, {"PUSH10", 10, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH11, {"PUSH11", 11, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH12, {"PUSH12", 12, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH13, {"PUSH13", 13, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH14, {"PUSH14", 14, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH15, {"PUSH15", 15, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH16, {"PUSH16", 16, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH17, {"PUSH17", 17, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH18, {"PUSH18", 18, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH19, {"PUSH19", 19, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH20, {"PUSH20", 20, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH21, {"PUSH21", 21, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH22, {"PUSH22", 22, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH23, {"PUSH23", 23, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH24, {"PUSH24", 24, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH25, {"PUSH25", 25, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH26, {"PUSH26", 26, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH27, {"PUSH27", 27, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH28, {"PUSH28", 28, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH29, {"PUSH29", 29, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH30, {"PUSH30", 30, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH31, {"PUSH31", 31, 0, 1, false, Tier::VeryLow}}, + {Instruction::PUSH32, {"PUSH32", 32, 0, 1, false, Tier::VeryLow}}, + {Instruction::DUP1, {"DUP1", 0, 1, 2, false, Tier::VeryLow}}, + {Instruction::DUP2, {"DUP2", 0, 2, 3, false, Tier::VeryLow}}, + {Instruction::DUP3, {"DUP3", 0, 3, 4, false, Tier::VeryLow}}, + {Instruction::DUP4, {"DUP4", 0, 4, 5, false, Tier::VeryLow}}, + {Instruction::DUP5, {"DUP5", 0, 5, 6, false, Tier::VeryLow}}, + {Instruction::DUP6, {"DUP6", 0, 6, 7, false, Tier::VeryLow}}, + {Instruction::DUP7, {"DUP7", 0, 7, 8, false, Tier::VeryLow}}, + {Instruction::DUP8, {"DUP8", 0, 8, 9, false, Tier::VeryLow}}, + {Instruction::DUP9, {"DUP9", 0, 9, 10, false, Tier::VeryLow}}, + {Instruction::DUP10, {"DUP10", 0, 10, 11, false, Tier::VeryLow}}, + {Instruction::DUP11, {"DUP11", 0, 11, 12, false, Tier::VeryLow}}, + {Instruction::DUP12, {"DUP12", 0, 12, 13, false, Tier::VeryLow}}, + {Instruction::DUP13, {"DUP13", 0, 13, 14, false, Tier::VeryLow}}, + {Instruction::DUP14, {"DUP14", 0, 14, 15, false, Tier::VeryLow}}, + {Instruction::DUP15, {"DUP15", 0, 15, 16, false, Tier::VeryLow}}, + {Instruction::DUP16, {"DUP16", 0, 16, 17, false, Tier::VeryLow}}, + {Instruction::SWAP1, {"SWAP1", 0, 2, 2, false, Tier::VeryLow}}, + {Instruction::SWAP2, {"SWAP2", 0, 3, 3, false, Tier::VeryLow}}, + {Instruction::SWAP3, {"SWAP3", 0, 4, 4, false, Tier::VeryLow}}, + {Instruction::SWAP4, {"SWAP4", 0, 5, 5, false, Tier::VeryLow}}, + {Instruction::SWAP5, {"SWAP5", 0, 6, 6, false, Tier::VeryLow}}, + {Instruction::SWAP6, {"SWAP6", 0, 7, 7, false, Tier::VeryLow}}, + {Instruction::SWAP7, {"SWAP7", 0, 8, 8, false, Tier::VeryLow}}, + {Instruction::SWAP8, {"SWAP8", 0, 9, 9, false, Tier::VeryLow}}, + {Instruction::SWAP9, {"SWAP9", 0, 10, 10, false, Tier::VeryLow}}, + {Instruction::SWAP10, {"SWAP10", 0, 11, 11, false, Tier::VeryLow}}, + {Instruction::SWAP11, {"SWAP11", 0, 12, 12, false, Tier::VeryLow}}, + {Instruction::SWAP12, {"SWAP12", 0, 13, 13, false, Tier::VeryLow}}, + {Instruction::SWAP13, {"SWAP13", 0, 14, 14, false, Tier::VeryLow}}, + {Instruction::SWAP14, {"SWAP14", 0, 15, 15, false, Tier::VeryLow}}, + {Instruction::SWAP15, {"SWAP15", 0, 16, 16, false, Tier::VeryLow}}, + {Instruction::SWAP16, {"SWAP16", 0, 17, 17, false, Tier::VeryLow}}, + {Instruction::LOG0, {"LOG0", 0, 2, 0, true, Tier::Special}}, + {Instruction::LOG1, {"LOG1", 0, 3, 0, true, Tier::Special}}, + {Instruction::LOG2, {"LOG2", 0, 4, 0, true, Tier::Special}}, + {Instruction::LOG3, {"LOG3", 0, 5, 0, true, Tier::Special}}, + {Instruction::LOG4, {"LOG4", 0, 6, 0, true, Tier::Special}}, + {Instruction::CALLTOKEN, {"CALLTOKEN", 0, 8, 1, true, Tier::Special}}, + {Instruction::TOKENBALANCE, {"TOKENBALANCE", 0, 2, 1, false, Tier::Special}}, + {Instruction::CALLTOKENVALUE, {"CALLTOKENVALUE", 0, 0, 1, false, Tier::Base}}, + {Instruction::CALLTOKENID, {"CALLTOKENID", 0, 0, 1, false, Tier::Base}}, + {Instruction::ISCONTRACT, {"ISCONTRACT", 0, 1, 1, false, Tier::Special}}, + {Instruction::NATIVEFREEZE, {"NATIVEFREEZE", 0, 3, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEUNFREEZE, {"NATIVEUNFREEZE", 0, 2, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEFREEZEEXPIRETIME, {"NATIVEFREEZEEXPIRETIME", 0, 2, 1, false, Tier::BlockHash}}, + {Instruction::NATIVEVOTE, {"NATIVEVOTE", 0, 4, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEWITHDRAWREWARD, {"NATIVEWITHDRAWREWARD", 0, 0, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEFREEZEBALANCEV2, {"NATIVEFREEZEBALANCEV2", 0, 2, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEUNFREEZEBALANCEV2, {"NATIVEUNFREEZEBALANCEV2", 0, 2, 1, true, Tier::BlockHash}}, + {Instruction::NATIVECANCELALLUNFREEZEV2, {"NATIVECANCELALLUNFREEZEV2", 0, 0, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEWITHDRAWEXPIREUNFREEZE, {"NATIVEWITHDRAWEXPIREUNFREEZE", 0, 0, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEDELEGATERESOURCE, {"NATIVEDELEGATERESOURCE", 0, 3, 1, true, Tier::BlockHash}}, + {Instruction::NATIVEUNDELEGATERESOURCE, {"NATIVEUNDELEGATERESOURCE", 0, 3, 1, true, Tier::BlockHash}}, + {Instruction::CREATE, {"CREATE", 0, 3, 1, true, Tier::Special}}, + {Instruction::CALL, {"CALL", 0, 7, 1, true, Tier::Special}}, + {Instruction::CALLCODE, {"CALLCODE", 0, 7, 1, true, Tier::Special}}, + {Instruction::RETURN, {"RETURN", 0, 2, 0, true, Tier::Zero}}, + {Instruction::DELEGATECALL, {"DELEGATECALL", 0, 6, 1, true, Tier::Special}}, + {Instruction::STATICCALL, {"STATICCALL", 0, 6, 1, true, Tier::Special}}, + {Instruction::CREATE2, {"CREATE2", 0, 4, 1, true, Tier::Special}}, + {Instruction::REVERT, {"REVERT", 0, 2, 0, true, Tier::Zero}}, + {Instruction::INVALID, {"INVALID", 0, 0, 0, true, Tier::Zero}}, + {Instruction::SELFDESTRUCT, {"SELFDESTRUCT", 0, 1, 0, true, Tier::Special}} }; InstructionInfo solidity::evmasm::instructionInfo(Instruction _inst, langutil::EVMVersion _evmVersion) diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 5dd51f8d46d5..171516e25ac2 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -33,184 +33,183 @@ namespace solidity::evmasm /// Virtual machine bytecode instruction. enum class Instruction: uint8_t { - STOP = 0x00, ///< halts execution - ADD, ///< addition operation - MUL, ///< multiplication operation - SUB, ///< subtraction operation - DIV, ///< integer division operation - SDIV, ///< signed integer division operation - MOD, ///< modulo remainder operation - SMOD, ///< signed modulo remainder operation - ADDMOD, ///< unsigned modular addition - MULMOD, ///< unsigned modular multiplication - EXP, ///< exponential operation - SIGNEXTEND, ///< extend length of signed integer - - LT = 0x10, ///< less-than comparison - GT, ///< greater-than comparison - SLT, ///< signed less-than comparison - SGT, ///< signed greater-than comparison - EQ, ///< equality comparison - ISZERO, ///< simple not operator - AND, ///< bitwise AND operation - OR, ///< bitwise OR operation - XOR, ///< bitwise XOR operation - NOT, ///< bitwise NOT operation - BYTE, ///< retrieve single byte from word - SHL, ///< bitwise SHL operation - SHR, ///< bitwise SHR operation - SAR, ///< bitwise SAR operation - - KECCAK256 = 0x20, ///< compute KECCAK-256 hash - - ADDRESS = 0x30, ///< get address of currently executing account - BALANCE, ///< get balance of the given account - ORIGIN, ///< get execution origination address - CALLER, ///< get caller address - CALLVALUE, ///< get deposited value by the instruction/transaction responsible for this execution - CALLDATALOAD, ///< get input data of current environment - CALLDATASIZE, ///< get size of input data in current environment - CALLDATACOPY, ///< copy input data in current environment to memory - CODESIZE, ///< get size of code running in current environment - CODECOPY, ///< copy code running in current environment to memory - GASPRICE, ///< get price of gas in current environment - EXTCODESIZE, ///< get external code size (from another contract) - EXTCODECOPY, ///< copy external code (from another contract) - RETURNDATASIZE = 0x3d, ///< get size of return data buffer - RETURNDATACOPY = 0x3e, ///< copy return data in current environment to memory - EXTCODEHASH = 0x3f, ///< get external code hash (from another contract) - - BLOCKHASH = 0x40, ///< get hash of most recent complete block - COINBASE, ///< get the block's coinbase address - TIMESTAMP, ///< get the block's timestamp - NUMBER, ///< get the block's number - PREVRANDAO, ///< get randomness provided by the beacon chain - GASLIMIT, ///< get the block's gas limit - CHAINID, ///< get the config's chainid param - SELFBALANCE, ///< get balance of the current account - BASEFEE, ///< get the block's basefee - BLOBHASH = 0x49, ///< get a versioned hash of one of the blobs associated with the transaction - BLOBBASEFEE = 0x4a, ///< get the block's blob basefee - - POP = 0x50, ///< remove item from stack - MLOAD, ///< load word from memory - MSTORE, ///< save word to memory - MSTORE8, ///< save byte to memory - SLOAD, ///< load word from storage - SSTORE, ///< save word to storage - JUMP, ///< alter the program counter - JUMPI, ///< conditionally alter the program counter - PC, ///< get the program counter - MSIZE, ///< get the size of active memory - GAS, ///< get the amount of available gas - JUMPDEST, ///< set a potential jump destination - MCOPY = 0x5e, ///< copy between memory areas - - TLOAD = 0x5c, ///< load word from transient storage - TSTORE = 0x5d, ///< save word to transient storage - - PUSH0 = 0x5f, ///< place the value 0 on stack - PUSH1 = 0x60, ///< place 1 byte item on stack - PUSH2, ///< place 2 byte item on stack - PUSH3, ///< place 3 byte item on stack - PUSH4, ///< place 4 byte item on stack - PUSH5, ///< place 5 byte item on stack - PUSH6, ///< place 6 byte item on stack - PUSH7, ///< place 7 byte item on stack - PUSH8, ///< place 8 byte item on stack - PUSH9, ///< place 9 byte item on stack - PUSH10, ///< place 10 byte item on stack - PUSH11, ///< place 11 byte item on stack - PUSH12, ///< place 12 byte item on stack - PUSH13, ///< place 13 byte item on stack - PUSH14, ///< place 14 byte item on stack - PUSH15, ///< place 15 byte item on stack - PUSH16, ///< place 16 byte item on stack - PUSH17, ///< place 17 byte item on stack - PUSH18, ///< place 18 byte item on stack - PUSH19, ///< place 19 byte item on stack - PUSH20, ///< place 20 byte item on stack - PUSH21, ///< place 21 byte item on stack - PUSH22, ///< place 22 byte item on stack - PUSH23, ///< place 23 byte item on stack - PUSH24, ///< place 24 byte item on stack - PUSH25, ///< place 25 byte item on stack - PUSH26, ///< place 26 byte item on stack - PUSH27, ///< place 27 byte item on stack - PUSH28, ///< place 28 byte item on stack - PUSH29, ///< place 29 byte item on stack - PUSH30, ///< place 30 byte item on stack - PUSH31, ///< place 31 byte item on stack - PUSH32, ///< place 32 byte item on stack - - DUP1 = 0x80, ///< copies the highest item in the stack to the top of the stack - DUP2, ///< copies the second highest item in the stack to the top of the stack - DUP3, ///< copies the third highest item in the stack to the top of the stack - DUP4, ///< copies the 4th highest item in the stack to the top of the stack - DUP5, ///< copies the 5th highest item in the stack to the top of the stack - DUP6, ///< copies the 6th highest item in the stack to the top of the stack - DUP7, ///< copies the 7th highest item in the stack to the top of the stack - DUP8, ///< copies the 8th highest item in the stack to the top of the stack - DUP9, ///< copies the 9th highest item in the stack to the top of the stack - DUP10, ///< copies the 10th highest item in the stack to the top of the stack - DUP11, ///< copies the 11th highest item in the stack to the top of the stack - DUP12, ///< copies the 12th highest item in the stack to the top of the stack - DUP13, ///< copies the 13th highest item in the stack to the top of the stack - DUP14, ///< copies the 14th highest item in the stack to the top of the stack - DUP15, ///< copies the 15th highest item in the stack to the top of the stack - DUP16, ///< copies the 16th highest item in the stack to the top of the stack - - SWAP1 = 0x90, ///< swaps the highest and second highest value on the stack - SWAP2, ///< swaps the highest and third highest value on the stack - SWAP3, ///< swaps the highest and 4th highest value on the stack - SWAP4, ///< swaps the highest and 5th highest value on the stack - SWAP5, ///< swaps the highest and 6th highest value on the stack - SWAP6, ///< swaps the highest and 7th highest value on the stack - SWAP7, ///< swaps the highest and 8th highest value on the stack - SWAP8, ///< swaps the highest and 9th highest value on the stack - SWAP9, ///< swaps the highest and 10th highest value on the stack - SWAP10, ///< swaps the highest and 11th highest value on the stack - SWAP11, ///< swaps the highest and 12th highest value on the stack - SWAP12, ///< swaps the highest and 13th highest value on the stack - SWAP13, ///< swaps the highest and 14th highest value on the stack - SWAP14, ///< swaps the highest and 15th highest value on the stack - SWAP15, ///< swaps the highest and 16th highest value on the stack - SWAP16, ///< swaps the highest and 17th highest value on the stack - - LOG0 = 0xa0, ///< Makes a log entry; no topics. - LOG1, ///< Makes a log entry; 1 topic. - LOG2, ///< Makes a log entry; 2 topics. - LOG3, ///< Makes a log entry; 3 topics. - LOG4, ///< Makes a log entry; 4 topics. - - CALLTOKEN = 0xd0, ///< like CALL but send trc10 (tokenID & tokenValue) instead of trx - TOKENBALANCE, ///< query trc10 token balance of the given tokenID - CALLTOKENVALUE, ///< + STOP = 0x00, ///< halts execution + ADD, ///< addition operation + MUL, ///< multiplication operation + SUB, ///< subtraction operation + DIV, ///< integer division operation + SDIV, ///< signed integer division operation + MOD, ///< modulo remainder operation + SMOD, ///< signed modulo remainder operation + ADDMOD, ///< unsigned modular addition + MULMOD, ///< unsigned modular multiplication + EXP, ///< exponential operation + SIGNEXTEND, ///< extend length of signed integer + + LT = 0x10, ///< less-than comparison + GT, ///< greater-than comparison + SLT, ///< signed less-than comparison + SGT, ///< signed greater-than comparison + EQ, ///< equality comparison + ISZERO, ///< simple not operator + AND, ///< bitwise AND operation + OR, ///< bitwise OR operation + XOR, ///< bitwise XOR operation + NOT, ///< bitwise NOT operation + BYTE, ///< retrieve single byte from word + SHL, ///< bitwise SHL operation + SHR, ///< bitwise SHR operation + SAR, ///< bitwise SAR operation + + KECCAK256 = 0x20, ///< compute KECCAK-256 hash + + ADDRESS = 0x30, ///< get address of currently executing account + BALANCE, ///< get balance of the given account + ORIGIN, ///< get execution origination address + CALLER, ///< get caller address + CALLVALUE, ///< get deposited value by the instruction/transaction responsible for this execution + CALLDATALOAD, ///< get input data of current environment + CALLDATASIZE, ///< get size of input data in current environment + CALLDATACOPY, ///< copy input data in current environment to memory + CODESIZE, ///< get size of code running in current environment + CODECOPY, ///< copy code running in current environment to memory + GASPRICE, ///< get price of gas in current environment + EXTCODESIZE, ///< get external code size (from another contract) + EXTCODECOPY, ///< copy external code (from another contract) + RETURNDATASIZE = 0x3d, ///< get size of return data buffer + RETURNDATACOPY = 0x3e, ///< copy return data in current environment to memory + EXTCODEHASH = 0x3f, ///< get external code hash (from another contract) + + BLOCKHASH = 0x40, ///< get hash of most recent complete block + COINBASE, ///< get the block's coinbase address + TIMESTAMP, ///< get the block's timestamp + NUMBER, ///< get the block's number + PREVRANDAO, ///< get randomness provided by the beacon chain + GASLIMIT, ///< get the block's gas limit + CHAINID, ///< get the config's chainid param + SELFBALANCE, ///< get balance of the current account + BASEFEE, ///< get the block's basefee + BLOBHASH = 0x49, ///< get a versioned hash of one of the blobs associated with the transaction + BLOBBASEFEE = 0x4a, ///< get the block's blob basefee + + POP = 0x50, ///< remove item from stack + MLOAD, ///< load word from memory + MSTORE, ///< save word to memory + MSTORE8, ///< save byte to memory + SLOAD, ///< load word from storage + SSTORE, ///< save word to storage + JUMP, ///< alter the program counter + JUMPI, ///< conditionally alter the program counter + PC, ///< get the program counter + MSIZE, ///< get the size of active memory + GAS, ///< get the amount of available gas + JUMPDEST, ///< set a potential jump destination + TLOAD = 0x5c, ///< load word from transient storage + TSTORE = 0x5d, ///< save word to transient storage + MCOPY = 0x5e, ///< copy between memory areas + + PUSH0 = 0x5f, ///< place the value 0 on stack + PUSH1 = 0x60, ///< place 1 byte item on stack + PUSH2, ///< place 2 byte item on stack + PUSH3, ///< place 3 byte item on stack + PUSH4, ///< place 4 byte item on stack + PUSH5, ///< place 5 byte item on stack + PUSH6, ///< place 6 byte item on stack + PUSH7, ///< place 7 byte item on stack + PUSH8, ///< place 8 byte item on stack + PUSH9, ///< place 9 byte item on stack + PUSH10, ///< place 10 byte item on stack + PUSH11, ///< place 11 byte item on stack + PUSH12, ///< place 12 byte item on stack + PUSH13, ///< place 13 byte item on stack + PUSH14, ///< place 14 byte item on stack + PUSH15, ///< place 15 byte item on stack + PUSH16, ///< place 16 byte item on stack + PUSH17, ///< place 17 byte item on stack + PUSH18, ///< place 18 byte item on stack + PUSH19, ///< place 19 byte item on stack + PUSH20, ///< place 20 byte item on stack + PUSH21, ///< place 21 byte item on stack + PUSH22, ///< place 22 byte item on stack + PUSH23, ///< place 23 byte item on stack + PUSH24, ///< place 24 byte item on stack + PUSH25, ///< place 25 byte item on stack + PUSH26, ///< place 26 byte item on stack + PUSH27, ///< place 27 byte item on stack + PUSH28, ///< place 28 byte item on stack + PUSH29, ///< place 29 byte item on stack + PUSH30, ///< place 30 byte item on stack + PUSH31, ///< place 31 byte item on stack + PUSH32, ///< place 32 byte item on stack + + DUP1 = 0x80, ///< copies the highest item in the stack to the top of the stack + DUP2, ///< copies the second highest item in the stack to the top of the stack + DUP3, ///< copies the third highest item in the stack to the top of the stack + DUP4, ///< copies the 4th highest item in the stack to the top of the stack + DUP5, ///< copies the 5th highest item in the stack to the top of the stack + DUP6, ///< copies the 6th highest item in the stack to the top of the stack + DUP7, ///< copies the 7th highest item in the stack to the top of the stack + DUP8, ///< copies the 8th highest item in the stack to the top of the stack + DUP9, ///< copies the 9th highest item in the stack to the top of the stack + DUP10, ///< copies the 10th highest item in the stack to the top of the stack + DUP11, ///< copies the 11th highest item in the stack to the top of the stack + DUP12, ///< copies the 12th highest item in the stack to the top of the stack + DUP13, ///< copies the 13th highest item in the stack to the top of the stack + DUP14, ///< copies the 14th highest item in the stack to the top of the stack + DUP15, ///< copies the 15th highest item in the stack to the top of the stack + DUP16, ///< copies the 16th highest item in the stack to the top of the stack + + SWAP1 = 0x90, ///< swaps the highest and second highest value on the stack + SWAP2, ///< swaps the highest and third highest value on the stack + SWAP3, ///< swaps the highest and 4th highest value on the stack + SWAP4, ///< swaps the highest and 5th highest value on the stack + SWAP5, ///< swaps the highest and 6th highest value on the stack + SWAP6, ///< swaps the highest and 7th highest value on the stack + SWAP7, ///< swaps the highest and 8th highest value on the stack + SWAP8, ///< swaps the highest and 9th highest value on the stack + SWAP9, ///< swaps the highest and 10th highest value on the stack + SWAP10, ///< swaps the highest and 11th highest value on the stack + SWAP11, ///< swaps the highest and 12th highest value on the stack + SWAP12, ///< swaps the highest and 13th highest value on the stack + SWAP13, ///< swaps the highest and 14th highest value on the stack + SWAP14, ///< swaps the highest and 15th highest value on the stack + SWAP15, ///< swaps the highest and 16th highest value on the stack + SWAP16, ///< swaps the highest and 17th highest value on the stack + + LOG0 = 0xa0, ///< Makes a log entry; no topics. + LOG1, ///< Makes a log entry; 1 topic. + LOG2, ///< Makes a log entry; 2 topics. + LOG3, ///< Makes a log entry; 3 topics. + LOG4, ///< Makes a log entry; 4 topics. + + CALLTOKEN = 0xd0, + TOKENBALANCE, + CALLTOKENVALUE, CALLTOKENID, ISCONTRACT, - NATIVEFREEZE, - NATIVEUNFREEZE, - NATIVEFREEZEEXPIRETIME, + NATIVEFREEZE, + NATIVEUNFREEZE, + NATIVEFREEZEEXPIRETIME, NATIVEVOTE, NATIVEWITHDRAWREWARD, NATIVEFREEZEBALANCEV2, NATIVEUNFREEZEBALANCEV2, - NATIVECANCELALLUNFREEZEV2, + NATIVECANCELALLUNFREEZEV2, NATIVEWITHDRAWEXPIREUNFREEZE, NATIVEDELEGATERESOURCE, NATIVEUNDELEGATERESOURCE, - CREATE = 0xf0, ///< create a new account with associated code - CALL, ///< message-call into an account - CALLCODE, ///< message-call with another account's code only - RETURN, ///< halt execution returning output data - DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender - CREATE2 = 0xf5, ///< create new account with associated code at address `sha3(0xff + sender + salt + init code) % 2**160` - STATICCALL = 0xfa, ///< like CALL but disallow state modifications - - REVERT = 0xfd, ///< halt execution, revert state and return output data - INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero) - SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion + CREATE = 0xf0, ///< create a new account with associated code + CALL, ///< message-call into an account + CALLCODE, ///< message-call with another account's code only + RETURN, ///< halt execution returning output data + DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender + CREATE2 = 0xf5, ///< create new account with associated code at address `sha3(0xff + sender + salt + init code) % 2**160` + STATICCALL = 0xfa, ///< like CALL but disallow state modifications + + REVERT = 0xfd, ///< halt execution, revert state and return output data + INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero) + SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion }; /// @returns true if the instruction is of the CALL opcode family @@ -326,12 +325,12 @@ enum class Tier /// Information structure for a particular instruction. struct InstructionInfo { - std::string name; ///< The name of the instruction. - int additional; ///< Additional items required in memory for this instructions (only for PUSH). - int args; ///< Number of items required on the stack for this instruction (and, for the purposes of ret, the number taken from the stack). - int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed. - bool sideEffects; ///< false if the only effect on the execution environment (apart from gas usage) is a change to a topmost segment of the stack - Tier gasPriceTier; ///< Tier for gas pricing. + std::string name; ///< The name of the instruction. + int additional; ///< Additional items required in memory for this instructions (only for PUSH). + int args; ///< Number of items required on the stack for this instruction (and, for the purposes of ret, the number taken from the stack). + int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed. + bool sideEffects; ///< false if the only effect on the execution environment (apart from gas usage) is a change to a topmost segment of the stack + Tier gasPriceTier; ///< Tier for gas pricing. }; /// Information on all the instructions. diff --git a/liblangutil/DebugInfoSelection.cpp b/liblangutil/DebugInfoSelection.cpp index 88e09cdb7aa0..ad0b615c1c1e 100644 --- a/liblangutil/DebugInfoSelection.cpp +++ b/liblangutil/DebugInfoSelection.cpp @@ -83,7 +83,7 @@ std::optional DebugInfoSelection::fromComponents( return selection; } -bool DebugInfoSelection::enable(std::string _component) +bool DebugInfoSelection::enable(std::string const& _component) { auto memberIt = componentMap().find(boost::trim_copy(_component)); if (memberIt == componentMap().end()) diff --git a/liblangutil/DebugInfoSelection.h b/liblangutil/DebugInfoSelection.h index 40ba3d6b2573..3a9432de6d02 100644 --- a/liblangutil/DebugInfoSelection.h +++ b/liblangutil/DebugInfoSelection.h @@ -49,7 +49,7 @@ struct DebugInfoSelection std::vector const& _componentNames, bool _acceptWildcards = false ); - bool enable(std::string _component); + bool enable(std::string const& _component); bool all() const noexcept; bool any() const noexcept; diff --git a/liblangutil/Token.h b/liblangutil/Token.h index e1c38f0c7332..49d739b5e32b 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -42,6 +42,7 @@ #pragma once +#include #include #include #include @@ -64,11 +65,11 @@ namespace solidity::langutil #define IGNORE_TOKEN(name, string, precedence) -#define TOKEN_LIST(T, K) \ - /* End of source indicator. */ \ - T(EOS, "EOS", 0) \ - \ - /* Punctuators (ECMA-262, section 7.7, page 15). */ \ +#define TOKEN_LIST(T, K) \ + /* End of source indicator. */ \ + T(EOS, "EOS", 0) \ + \ + /* Punctuators (ECMA-262, section 7.7, page 15). */ \ T(LParen, "(", 0) \ T(RParen, ")", 0) \ T(LBrack, "[", 0) \ @@ -82,9 +83,9 @@ namespace solidity::langutil T(DoubleArrow, "=>", 0) \ T(RightArrow, "->", 0) \ \ - /* Assignment operators. */ \ - /* IsAssignmentOp() relies on this block of enum values being */ \ - /* contiguous and sorted in the same order!*/ \ + /* Assignment operators. */ \ + /* IsAssignmentOp() relies on this block of enum values being */ \ + /* contiguous and sorted in the same order!*/ \ T(Assign, "=", 2) \ /* The following have to be in exactly the same order as the simple binary operators*/ \ T(AssignBitOr, "|=", 2) \ diff --git a/libsmtutil/CHCSmtLib2Interface.cpp b/libsmtutil/CHCSmtLib2Interface.cpp index ef7c56ac0c06..671ec9b51d6c 100644 --- a/libsmtutil/CHCSmtLib2Interface.cpp +++ b/libsmtutil/CHCSmtLib2Interface.cpp @@ -18,11 +18,17 @@ #include +#include + #include +#include +#include #include #include +#include +#include #include #include @@ -56,7 +62,7 @@ void CHCSmtLib2Interface::reset() m_accumulatedOutput.clear(); m_variables.clear(); m_unhandledQueries.clear(); - m_sortNames.clear(); + m_smtlib2->reset(); } void CHCSmtLib2Interface::registerRelation(Expression const& _expr) @@ -96,7 +102,10 @@ std::tuple CHCSmtLib2Inte CheckResult result; // TODO proper parsing if (boost::starts_with(response, "sat")) - result = CheckResult::UNSATISFIABLE; + { + auto maybeInvariants = invariantsFromSolverResponse(response); + return {CheckResult::UNSATISFIABLE, maybeInvariants.value_or(Expression(true)), {}}; + } else if (boost::starts_with(response, "unsat")) result = CheckResult::SATISFIABLE; else if (boost::starts_with(response, "unknown")) @@ -115,24 +124,18 @@ void CHCSmtLib2Interface::declareVariable(std::string const& _name, SortPointer else if (!m_variables.count(_name)) { m_variables.insert(_name); - write("(declare-var |" + _name + "| " + toSmtLibSort(*_sort) + ')'); + write("(declare-var |" + _name + "| " + toSmtLibSort(_sort) + ')'); } } -std::string CHCSmtLib2Interface::toSmtLibSort(Sort const& _sort) +std::string CHCSmtLib2Interface::toSmtLibSort(SortPointer _sort) { - if (!m_sortNames.count(&_sort)) - m_sortNames[&_sort] = m_smtlib2->toSmtLibSort(_sort); - return m_sortNames.at(&_sort); + return m_smtlib2->toSmtLibSort(_sort); } std::string CHCSmtLib2Interface::toSmtLibSort(std::vector const& _sorts) { - std::string ssort("("); - for (auto const& sort: _sorts) - ssort += toSmtLibSort(*sort) + " "; - ssort += ")"; - return ssort; + return m_smtlib2->toSmtLibSort(_sorts); } std::string CHCSmtLib2Interface::forall() @@ -142,7 +145,7 @@ std::string CHCSmtLib2Interface::forall() { solAssert(sort, ""); if (sort->kind != Kind::Function) - vars += " (" + name + " " + toSmtLibSort(*sort) + ")"; + vars += " (" + name + " " + toSmtLibSort(sort) + ")"; } vars += ")"; return vars; @@ -158,7 +161,7 @@ void CHCSmtLib2Interface::declareFunction(std::string const& _name, SortPointer auto fSort = std::dynamic_pointer_cast(_sort); smtAssert(fSort->codomain); std::string domain = toSmtLibSort(fSort->domain); - std::string codomain = toSmtLibSort(*fSort->codomain); + std::string codomain = toSmtLibSort(fSort->codomain); m_variables.insert(_name); write( "(declare-fun |" + @@ -221,5 +224,278 @@ std::string CHCSmtLib2Interface::createHeaderAndDeclarations() { } std::string CHCSmtLib2Interface::createQueryAssertion(std::string name) { - return "(assert\n(forall " + forall() + "\n" + "(=> " + name + " false)))"; + return "(assert\n(forall " + forall() + "\n" + "(=> " + name + " false)))"; +} + +class SMTLibTranslationContext +{ + CHCSmtLib2Interface const& m_chcInterface; + std::map m_knownVariables; + + static bool isNumber(std::string const& _expr) + { + return ranges::all_of(_expr, [](char c) { return isDigit(c) || c == '.'; }); + } + + +public: + explicit SMTLibTranslationContext(CHCSmtLib2Interface const& _chcInterface) : m_chcInterface(_chcInterface) + { + // fill user defined sorts and constructors + auto const& userSorts = m_chcInterface.smtlib2Interface()->userSorts(); + for (auto const& declaration: userSorts | ranges::views::values) + { + std::stringstream ss(declaration); + SMTLib2Parser parser(ss); + auto expr = parser.parseExpression(); + smtAssert(parser.isEOF()); + smtAssert(!isAtom(expr)); + auto const& args = asSubExpressions(expr); + smtAssert(args.size() == 3); + smtAssert(isAtom(args[0]) && asAtom(args[0]) == "declare-datatypes"); + // args[1] is the name of the type + // args[2] is the constructor with the members + smtAssert(!isAtom(args[2]) && asSubExpressions(args[2]).size() == 1 && !isAtom(asSubExpressions(args[2])[0])); + auto const& constructors = asSubExpressions(asSubExpressions(args[2])[0]); + smtAssert(constructors.size() == 1); + auto const& constructor = constructors[0]; + // constructor is a list: name + members + smtAssert(!isAtom(constructor)); + auto const& constructorArgs = asSubExpressions(constructor); + for (unsigned i = 1u; i < constructorArgs.size(); ++i) + { + auto const& carg = constructorArgs[i]; + smtAssert(!isAtom(carg) && asSubExpressions(carg).size() == 2); + auto const& nameSortPair = asSubExpressions(carg); + m_knownVariables.emplace(asAtom(nameSortPair[0]), toSort(nameSortPair[1])); + } + } + } + + void addVariableDeclaration(std::string name, SortPointer sort) + { + smtAssert(m_knownVariables.find(name) == m_knownVariables.end()); + m_knownVariables.emplace(std::move(name), std::move(sort)); + } + + std::optional lookupKnownTupleSort(std::string const& name) { + auto const& userSorts = m_chcInterface.sortNames(); + std::string quotedName = "|" + name + "|"; + auto it = ranges::find_if(userSorts, [&](auto const& entry) { return entry.second == quotedName; }); + if (it != userSorts.end() && it->first->kind == Kind::Tuple) + { + auto tupleSort = std::dynamic_pointer_cast(it->first); + smtAssert(tupleSort); + return tupleSort; + } + return {}; + } + + SortPointer toSort(SMTLib2Expression const& expr) + { + if (isAtom(expr)) + { + auto const& name = asAtom(expr); + if (name == "Int") + return SortProvider::sintSort; + if (name == "Bool") + return SortProvider::boolSort; + auto tupleSort = lookupKnownTupleSort(name); + if (tupleSort) + return tupleSort.value(); + } else { + auto const& args = asSubExpressions(expr); + if (asAtom(args[0]) == "Array") + { + smtAssert(args.size() == 3); + auto domainSort = toSort(args[1]); + auto codomainSort = toSort(args[2]); + return std::make_shared(std::move(domainSort), std::move(codomainSort)); + } + if (args.size() == 3 && isAtom(args[0]) && asAtom(args[0]) == "_" && isAtom(args[1]) && asAtom(args[1]) == "int2bv") + return std::make_shared(std::stoul(asAtom(args[2]))); + } + smtAssert(false, "Unknown sort encountered"); + } + + smtutil::Expression parseQuantifier( + std::string const& quantifierName, + std::vector const& varList, + SMTLib2Expression const& coreExpression + ) + { + std::vector> boundVariables; + for (auto const& sortedVar: varList) + { + smtAssert(!isAtom(sortedVar)); + auto varSortPair = asSubExpressions(sortedVar); + smtAssert(varSortPair.size() == 2); + boundVariables.emplace_back(asAtom(varSortPair[0]), toSort(varSortPair[1])); + } + for (auto const& [var, sort] : boundVariables) + { + smtAssert(m_knownVariables.find(var) == m_knownVariables.end()); // TODO: deal with shadowing? + m_knownVariables.emplace(var, sort); + } + auto core = toSMTUtilExpression(coreExpression); + for (auto const& [var, sort] : boundVariables) + { + smtAssert(m_knownVariables.find(var) != m_knownVariables.end()); + m_knownVariables.erase(var); + } + return Expression(quantifierName, {core}, SortProvider::boolSort); // TODO: what about the bound variables? + + } + + smtutil::Expression toSMTUtilExpression(SMTLib2Expression const& _expr) + { + return std::visit( + GenericVisitor{ + [&](std::string const& _atom) + { + if (_atom == "true" || _atom == "false") + return smtutil::Expression(_atom == "true"); + else if (isNumber(_atom)) + return smtutil::Expression(_atom, {}, SortProvider::sintSort); + else if (auto it = m_knownVariables.find(_atom); it != m_knownVariables.end()) + return smtutil::Expression(_atom, {}, it->second); + else // assume this is a predicate with sort bool; TODO: Context should be aware of predicates! + return smtutil::Expression(_atom, {}, SortProvider::boolSort); + }, + [&](std::vector const& _subExpr) + { + SortPointer sort; + std::vector arguments; + if (isAtom(_subExpr.front())) + { + std::string const& op = asAtom(_subExpr.front()); + if (op == "!") + { + // named term, we ignore the name + smtAssert(_subExpr.size() > 2); + return toSMTUtilExpression(_subExpr[1]); + } + if (op == "exists" || op == "forall") + { + smtAssert(_subExpr.size() == 3); + smtAssert(!isAtom(_subExpr[1])); + return parseQuantifier(op, asSubExpressions(_subExpr[1]), _subExpr[2]); + } + for (size_t i = 1; i < _subExpr.size(); i++) + arguments.emplace_back(toSMTUtilExpression(_subExpr[i])); + if (auto tupleSort = lookupKnownTupleSort(op); tupleSort) + { + auto sortSort = std::make_shared(tupleSort.value()); + return Expression::tuple_constructor(Expression(sortSort), arguments); + } + if (auto it = m_knownVariables.find(op); it != m_knownVariables.end()) + return smtutil::Expression(op, std::move(arguments), it->second); + else + { + std::set + boolOperators{"and", "or", "not", "=", "<", ">", "<=", ">=", "=>"}; + sort = contains(boolOperators, op) ? SortProvider::boolSort : arguments.back().sort; + return smtutil::Expression(op, std::move(arguments), std::move(sort)); + } + smtAssert(false, "Unhandled case in expression conversion"); + } + else + { + // check for const array + if (_subExpr.size() == 2 and !isAtom(_subExpr[0])) + { + auto const& typeArgs = asSubExpressions(_subExpr.front()); + if (typeArgs.size() == 3 && typeArgs[0].toString() == "as" + && typeArgs[1].toString() == "const") + { + auto arraySort = toSort(typeArgs[2]); + auto sortSort = std::make_shared(arraySort); + return smtutil::Expression:: + const_array(Expression(sortSort), toSMTUtilExpression(_subExpr[1])); + } + if (typeArgs.size() == 3 && typeArgs[0].toString() == "_" + && typeArgs[1].toString() == "int2bv") + { + auto bvSort = std::dynamic_pointer_cast(toSort(_subExpr[0])); + smtAssert(bvSort); + return smtutil::Expression::int2bv(toSMTUtilExpression(_subExpr[1]), bvSort->size); + } + if (typeArgs.size() == 4 && typeArgs[0].toString() == "_" + && typeArgs[1].toString() == "extract") + return smtutil::Expression( + "extract", + {toSMTUtilExpression(typeArgs[2]), toSMTUtilExpression(typeArgs[3])}, + SortProvider::bitVectorSort // TODO: Compute bit size properly? + ); + } + smtAssert(false, "Unhandled case in expression conversion"); + } + } + }, + _expr.data + ); + } +}; + + +#define precondition(CONDITION) if (!(CONDITION)) return {} +std::optional CHCSmtLib2Interface::invariantsFromSolverResponse(std::string const& _response) const +{ + std::stringstream ss(_response); + std::string answer; + ss >> answer; + precondition(answer == "sat"); + SMTLib2Parser parser(ss); + precondition(!parser.isEOF()); // There has to be a model + std::vector parsedOutput; + try + { + while (!parser.isEOF()) + parsedOutput.push_back(parser.parseExpression()); + } + catch(SMTLib2Parser::ParsingException&) + { + return {}; + } + smtAssert(parser.isEOF()); + precondition(!parsedOutput.empty()); + auto& commands = parsedOutput.size() == 1 ? asSubExpressions(parsedOutput[0]) : parsedOutput; + std::vector definitions; + for (auto& command: commands) + { + auto& args = asSubExpressions(command); + precondition(args.size() == 5); + // args[0] = "define-fun" + // args[1] = predicate name + // args[2] = formal arguments of the predicate + // args[3] = return sort + // args[4] = body of the predicate's interpretation + precondition(isAtom(args[0]) && asAtom(args[0]) == "define-fun"); + precondition(isAtom(args[1])); + precondition(!isAtom(args[2])); + precondition(isAtom(args[3]) && asAtom(args[3]) == "Bool"); + auto& interpretation = args[4]; +// inlineLetExpressions(interpretation); + SMTLibTranslationContext context(*this); + auto const& formalArguments = asSubExpressions(args[2]); + std::vector predicateArgs; + for (auto const& formalArgument: formalArguments) + { + precondition(!isAtom(formalArgument)); + auto const& nameSortPair = asSubExpressions(formalArgument); + precondition(nameSortPair.size() == 2); + precondition(isAtom(nameSortPair[0])); + SortPointer varSort = context.toSort(nameSortPair[1]); + context.addVariableDeclaration(asAtom(nameSortPair[0]), varSort); + Expression arg = context.toSMTUtilExpression(nameSortPair[0]); + predicateArgs.push_back(arg); + } + + auto parsedInterpretation = context.toSMTUtilExpression(interpretation); + + Expression predicate(asAtom(args[1]), predicateArgs, SortProvider::boolSort); + definitions.push_back(predicate == parsedInterpretation); + } + return Expression::mkAnd(std::move(definitions)); } +#undef precondition diff --git a/libsmtutil/CHCSmtLib2Interface.h b/libsmtutil/CHCSmtLib2Interface.h index 0f3a68ee405d..f7f656fd0b49 100644 --- a/libsmtutil/CHCSmtLib2Interface.h +++ b/libsmtutil/CHCSmtLib2Interface.h @@ -57,8 +57,10 @@ class CHCSmtLib2Interface: public CHCSolverInterface SMTLib2Interface* smtlib2Interface() const { return m_smtlib2.get(); } + auto const& sortNames() const { return m_smtlib2->sortNames(); } + private: - std::string toSmtLibSort(Sort const& _sort); + std::string toSmtLibSort(SortPointer _sort); std::string toSmtLibSort(std::vector const& _sort); void writeHeader(); @@ -74,6 +76,9 @@ class CHCSmtLib2Interface: public CHCSolverInterface /// Communicates with the solver via the callback. Throws SMTSolverError on error. std::string querySolver(std::string const& _input); + /// Translates CHC solver response with a model to our representation of invariants. Returns None on error. + std::optional invariantsFromSolverResponse(std::string const& response) const; + /// Used to access toSmtLibSort, SExpr, and handle variables. std::unique_ptr m_smtlib2; @@ -85,8 +90,6 @@ class CHCSmtLib2Interface: public CHCSolverInterface frontend::ReadCallback::Callback m_smtCallback; SMTSolverChoice m_enabledSolvers; - - std::map m_sortNames; }; } diff --git a/libsmtutil/CMakeLists.txt b/libsmtutil/CMakeLists.txt index af7f47b60c04..cb222e22c4a1 100644 --- a/libsmtutil/CMakeLists.txt +++ b/libsmtutil/CMakeLists.txt @@ -4,6 +4,8 @@ set(sources Exceptions.h SMTLib2Interface.cpp SMTLib2Interface.h + SMTLib2Parser.cpp + SMTLib2Parser.h SMTPortfolio.cpp SMTPortfolio.h SolverInterface.h diff --git a/libsmtutil/SMTLib2Interface.cpp b/libsmtutil/SMTLib2Interface.cpp index ac5645bf121b..12469a4ae05f 100644 --- a/libsmtutil/SMTLib2Interface.cpp +++ b/libsmtutil/SMTLib2Interface.cpp @@ -56,6 +56,7 @@ void SMTLib2Interface::reset() m_accumulatedOutput.emplace_back(); m_variables.clear(); m_userSorts.clear(); + m_sortNames.clear(); write("(set-option :produce-models true)"); if (m_queryTimeout) write("(set-option :timeout " + std::to_string(*m_queryTimeout) + ")"); @@ -81,7 +82,7 @@ void SMTLib2Interface::declareVariable(std::string const& _name, SortPointer con else if (!m_variables.count(_name)) { m_variables.emplace(_name, _sort); - write("(declare-fun |" + _name + "| () " + toSmtLibSort(*_sort) + ')'); + write("(declare-fun |" + _name + "| () " + toSmtLibSort(_sort) + ')'); } } @@ -94,7 +95,7 @@ void SMTLib2Interface::declareFunction(std::string const& _name, SortPointer con { auto const& fSort = std::dynamic_pointer_cast(_sort); std::string domain = toSmtLibSort(fSort->domain); - std::string codomain = toSmtLibSort(*fSort->codomain); + std::string codomain = toSmtLibSort(fSort->codomain); m_variables.emplace(_name, _sort); write( "(declare-fun |" + @@ -183,7 +184,7 @@ std::string SMTLib2Interface::toSExpr(Expression const& _expr) smtAssert(sortSort, ""); auto arraySort = std::dynamic_pointer_cast(sortSort->inner); smtAssert(arraySort, ""); - sexpr += "(as const " + toSmtLibSort(*arraySort) + ") "; + sexpr += "(as const " + toSmtLibSort(arraySort) + ") "; sexpr += toSExpr(_expr.arguments.at(1)); } else if (_expr.name == "tuple_get") @@ -212,25 +213,32 @@ std::string SMTLib2Interface::toSExpr(Expression const& _expr) return sexpr; } -std::string SMTLib2Interface::toSmtLibSort(Sort const& _sort) +std::string SMTLib2Interface::toSmtLibSort(solidity::smtutil::SortPointer _sort) { - switch (_sort.kind) + if (!m_sortNames.count(_sort)) + m_sortNames[_sort] = toSmtLibSortInternal(_sort); + return m_sortNames.at(_sort); +} + +std::string SMTLib2Interface::toSmtLibSortInternal(SortPointer _sort) +{ + switch (_sort->kind) { case Kind::Int: return "Int"; case Kind::Bool: return "Bool"; case Kind::BitVector: - return "(_ BitVec " + std::to_string(dynamic_cast(_sort).size) + ")"; + return "(_ BitVec " + std::to_string(dynamic_cast(*_sort).size) + ")"; case Kind::Array: { - auto const& arraySort = dynamic_cast(_sort); + auto const& arraySort = dynamic_cast(*_sort); smtAssert(arraySort.domain && arraySort.range, ""); - return "(Array " + toSmtLibSort(*arraySort.domain) + ' ' + toSmtLibSort(*arraySort.range) + ')'; + return "(Array " + toSmtLibSort(arraySort.domain) + ' ' + toSmtLibSort(arraySort.range) + ')'; } case Kind::Tuple: { - auto const& tupleSort = dynamic_cast(_sort); + auto const& tupleSort = dynamic_cast(*_sort); std::string tupleName = "|" + tupleSort.name + "|"; auto isName = [&](auto entry) { return entry.first == tupleName; }; if (ranges::find_if(m_userSorts, isName) == m_userSorts.end()) @@ -238,7 +246,7 @@ std::string SMTLib2Interface::toSmtLibSort(Sort const& _sort) std::string decl("(declare-datatypes ((" + tupleName + " 0)) (((" + tupleName); smtAssert(tupleSort.members.size() == tupleSort.components.size(), ""); for (unsigned i = 0; i < tupleSort.members.size(); ++i) - decl += " (|" + tupleSort.members.at(i) + "| " + toSmtLibSort(*tupleSort.components.at(i)) + ")"; + decl += " (|" + tupleSort.members.at(i) + "| " + toSmtLibSort(tupleSort.components.at(i)) + ")"; decl += "))))"; m_userSorts.emplace_back(tupleName, decl); write(decl); @@ -255,7 +263,7 @@ std::string SMTLib2Interface::toSmtLibSort(std::vector const& _sort { std::string ssort("("); for (auto const& sort: _sorts) - ssort += toSmtLibSort(*sort) + " "; + ssort += toSmtLibSort(sort) + " "; ssort += ")"; return ssort; } diff --git a/libsmtutil/SMTLib2Interface.h b/libsmtutil/SMTLib2Interface.h index 9ef8e94a8c0a..fbfde664d579 100644 --- a/libsmtutil/SMTLib2Interface.h +++ b/libsmtutil/SMTLib2Interface.h @@ -61,12 +61,13 @@ class SMTLib2Interface: public SolverInterface // Used by CHCSmtLib2Interface std::string toSExpr(Expression const& _expr); - std::string toSmtLibSort(Sort const& _sort); + std::string toSmtLibSort(SortPointer _sort); std::string toSmtLibSort(std::vector const& _sort); std::map variables() { return m_variables; } std::vector> const& userSorts() const { return m_userSorts; } + std::map const& sortNames() const { return m_sortNames; } std::string dumpQuery(std::vector const& _expressionsToEvaluate); @@ -81,6 +82,8 @@ class SMTLib2Interface: public SolverInterface /// Communicates with the solver via the callback. Throws SMTSolverError on error. std::string querySolver(std::string const& _input); + std::string toSmtLibSortInternal(SortPointer _sort); + std::vector m_accumulatedOutput; std::map m_variables; @@ -90,6 +93,10 @@ class SMTLib2Interface: public SolverInterface /// otherwise solvers cannot parse the queries. std::vector> m_userSorts; + /// Maps a user sort to SMT-LIB2 sort. + /// Remembers all declared sorts and is used as a cache as well. + std::map m_sortNames; + std::map m_queryResponses; std::vector m_unhandledQueries; diff --git a/libsmtutil/SMTLib2Parser.cpp b/libsmtutil/SMTLib2Parser.cpp new file mode 100644 index 000000000000..f3a3bd96a94c --- /dev/null +++ b/libsmtutil/SMTLib2Parser.cpp @@ -0,0 +1,97 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#include + +#include + +#include +#include + + +using namespace solidity::langutil; +using namespace solidity::smtutil; + +std::string SMTLib2Expression::toString() const { + return std::visit(solidity::util::GenericVisitor{ + [](std::string const& _sv) { return _sv; }, + [](std::vector const& _subExpr) { + std::vector formatted; + for (auto const& item: _subExpr) + formatted.emplace_back(item.toString()); + return "(" + solidity::util::joinHumanReadable(formatted, " ") + ")"; + } + }, data); +} + +SMTLib2Expression SMTLib2Parser::parseExpression() { + skipWhitespace(); + if (token() == '(') + { + advance(); + skipWhitespace(); + std::vector subExpressions; + while (token() != 0 && token() != ')') + { + subExpressions.emplace_back(parseExpression()); + skipWhitespace(); + } + if (token() != ')') + throw ParsingException{}; + // Simulate whitespace because we do not want to read the next token since it might block. + m_token = ' '; + return {std::move(subExpressions)}; + } else + return {parseToken()}; +} + +std::string SMTLib2Parser::parseToken() { + std::string result; + + skipWhitespace(); + bool isPipe = token() == '|'; + if (isPipe) + advance(); + while (token() != 0) + { + char c = token(); + if (isPipe && c == '|') + { + advance(); + break; + } else if (!isPipe && (isWhiteSpace(c) || c == '(' || c == ')')) + break; + result.push_back(c); + advance(); + } + return result; +} + +void SMTLib2Parser::advance() { + if (!m_input.good()) + throw ParsingException{}; + m_token = static_cast(m_input.get()); + if (token() == ';') + while (token() != '\n' && token() != 0) + m_token = static_cast(m_input.get()); +} + +void SMTLib2Parser::skipWhitespace() { + while (isWhiteSpace(token())) + advance(); +} diff --git a/libsmtutil/SMTLib2Parser.h b/libsmtutil/SMTLib2Parser.h new file mode 100644 index 000000000000..48eb76a1374e --- /dev/null +++ b/libsmtutil/SMTLib2Parser.h @@ -0,0 +1,96 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#pragma once + +#include + +#include +#include +#include +#include + +/** + * The following is a parser for SMT-LIB2 expressions developed originally by @chriseth as part of solsmt. + */ + +namespace solidity::smtutil +{ + +struct SMTLib2Expression { + using args_t = std::vector; + std::variant data; + + [[nodiscard]] std::string toString() const; +}; + +inline bool isAtom(SMTLib2Expression const& expr) +{ + return std::holds_alternative(expr.data); +} + +inline std::string const& asAtom(SMTLib2Expression const& expr) +{ + smtAssert(isAtom(expr)); + return std::get(expr.data); +} + +inline auto const& asSubExpressions(SMTLib2Expression const& expr) +{ + smtAssert(!isAtom(expr)); + return std::get(expr.data); +} + +inline auto& asSubExpressions(SMTLib2Expression& expr) +{ + smtAssert(!isAtom(expr)); + return std::get(expr.data); +} + +class SMTLib2Parser { +public: + class ParsingException {}; + + explicit SMTLib2Parser(std::istream& _input) : + m_input(_input), + m_token(static_cast(m_input.get())) {} + + SMTLib2Expression parseExpression(); + + bool isEOF() + { + skipWhitespace(); + return m_input.eof(); + } + +private: + std::string parseToken(); + + void skipWhitespace(); + + [[nodiscard]] char token() const + { + return m_token; + } + + void advance(); + + std::istream& m_input; + char m_token = 0; +}; +} diff --git a/libsmtutil/SolverInterface.h b/libsmtutil/SolverInterface.h index 82f81113358a..13803de6e91a 100644 --- a/libsmtutil/SolverInterface.h +++ b/libsmtutil/SolverInterface.h @@ -189,10 +189,7 @@ class Expression static Expression ite(Expression _condition, Expression _trueValue, Expression _falseValue) { - if (_trueValue.sort->kind == Kind::Int) - smtAssert(_trueValue.sort->kind == _falseValue.sort->kind, ""); - else - smtAssert(*_trueValue.sort == *_falseValue.sort, ""); + smtAssert(areCompatible(*_trueValue.sort, *_falseValue.sort)); SortPointer sort = _trueValue.sort; return Expression("ite", std::vector{ std::move(_condition), std::move(_trueValue), std::move(_falseValue) @@ -216,10 +213,7 @@ class Expression std::shared_ptr arraySort = std::dynamic_pointer_cast(_array.sort); smtAssert(arraySort, ""); smtAssert(_index.sort, ""); - if (arraySort->domain->kind == Kind::Int) - smtAssert(arraySort->domain->kind == _index.sort->kind, ""); - else - smtAssert(*arraySort->domain == *_index.sort, ""); + smtAssert(areCompatible(*arraySort->domain, *_index.sort)); return Expression( "select", std::vector{std::move(_array), std::move(_index)}, @@ -235,11 +229,8 @@ class Expression smtAssert(arraySort, ""); smtAssert(_index.sort, ""); smtAssert(_element.sort, ""); - smtAssert(*arraySort->domain == *_index.sort, ""); - if (arraySort->domain->kind == Kind::Int) - smtAssert(arraySort->range->kind == _element.sort->kind, ""); - else - smtAssert(*arraySort->range == *_element.sort, ""); + smtAssert(areCompatible(*arraySort->domain, *_index.sort)); + smtAssert(areCompatible(*arraySort->range, *_element.sort)); return Expression( "store", std::vector{std::move(_array), std::move(_index), std::move(_element)}, @@ -254,10 +245,7 @@ class Expression auto arraySort = std::dynamic_pointer_cast(sortSort->inner); smtAssert(sortSort && arraySort, ""); smtAssert(_value.sort, ""); - if (arraySort->domain->kind == Kind::Int) - smtAssert(arraySort->range->kind == _value.sort->kind, ""); - else - smtAssert(*arraySort->range == *_value.sort, ""); + smtAssert(areCompatible(*arraySort->range, *_value.sort)); return Expression( "const_array", std::vector{std::move(_sort), std::move(_value)}, @@ -501,6 +489,12 @@ class Expression SortPointer sort; private: + /// Helper method for checking sort compatibility when creating expressions + /// Signed and unsigned Int sorts are compatible even though they are not same + static bool areCompatible(Sort const& s1, Sort const& s2) + { + return s1.kind == Kind::Int ? s1.kind == s2.kind : s1 == s2; + } /// Manual constructors, should only be used by SolverInterface and this class itself. Expression(std::string _name, std::vector _arguments, Kind _kind): Expression(std::move(_name), std::move(_arguments), std::make_shared(_kind)) {} diff --git a/libsmtutil/Z3Interface.cpp b/libsmtutil/Z3Interface.cpp index a16e75668e40..4e1d1cec1236 100644 --- a/libsmtutil/Z3Interface.cpp +++ b/libsmtutil/Z3Interface.cpp @@ -169,6 +169,12 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr) smtAssert(sortSort, ""); return m_context.constant(n.c_str(), z3Sort(*sortSort->inner)); } + else if (n == "tuple_constructor") + { + auto constructor = z3::func_decl(m_context, Z3_get_tuple_sort_mk_decl(m_context, z3Sort(*_expr.sort))); + smtAssert(constructor.arity() == arguments.size()); + return constructor(); + } else try { @@ -386,6 +392,8 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr) kind == Z3_OP_RECURSIVE ) return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort())); + else if (kind == Z3_OP_CONCAT) + return Expression("concat", arguments, sort); smtAssert(false); diff --git a/libsolc/libsolc.h b/libsolc/libsolc.h index c5b3b3db732b..b259ed06a20c 100644 --- a/libsolc/libsolc.h +++ b/libsolc/libsolc.h @@ -45,7 +45,7 @@ extern "C" { /// @param o_error A pointer to an error message, if there is one. /// /// The file (as well as error) contents that is to be allocated by the callback -/// implementor must use the solidity_alloc() API to allocate its underlying +/// implementer must use the solidity_alloc() API to allocate its underlying /// storage. Ownership is then transferred to the compiler which will take care /// of the deallocation. /// diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index 1c7917d79fac..2fe6a95bf9b2 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -28,63 +28,69 @@ #include #include #include +#include namespace solidity::frontend { namespace { + /// Magic variables get negative ids for easy differentiation int magicVariableToID(std::string const& _name) { - if (_name == "abi") return -1; - else if (_name == "addmod") return -2; - else if (_name == "assert") return -3; - else if (_name == "block") return -4; - else if (_name == "blockhash") return -5; - else if (_name == "ecrecover") return -6; - else if (_name == "gasleft") return -7; - else if (_name == "keccak256") return -8; - else if (_name == "msg") return -15; - else if (_name == "mulmod") return -16; - else if (_name == "now") return -17; - else if (_name == "require") return -18; - else if (_name == "revert") return -19; - else if (_name == "ripemd160") return -20; - else if (_name == "selfdestruct") return -21; - else if (_name == "sha256") return -22; - else if (_name == "sha3") return -23; - else if (_name == "suicide") return -24; - else if (_name == "super") return -25; - else if (_name == "tx") return -26; - else if (_name == "type") return -27; - else if (_name == "this") return -28; - else if (_name == "verifyMintProof") return -29; - else if (_name == "verifyBurnProof") return -30; - else if (_name == "verifyTransferProof") return -31; - else if (_name == "pedersenHash") return -32; - else if (_name == "batchvalidatesign") return -33; - else if (_name == "validatemultisign") return -34; - else if (_name == "freeze") return -35; - else if (_name == "unfreeze") return -36; - else if (_name == "freezeExpireTime") return -37; - else if (_name == "withdrawreward") return -38; - else if (_name == "vote") return -39; - else if (_name == "rewardBalance") return -40; - else if (_name == "isSrCandidate") return -41; - else if (_name == "voteCount") return -42; - else if (_name == "totalVoteCount") return -43; - else if (_name == "receivedVoteCount") return -44; - else if (_name == "usedVoteCount") return -45; - else if (_name == "freezebalancev2") return -46; - else if (_name == "unfreezebalancev2") return -47; - else if (_name == "cancelallunfreezev2") return -48; - else if (_name == "withdrawexpireunfreeze") return -49; - else if (_name == "chain") return -50; - else if (_name == "getchainparameter") return -51; - else if (_name == "blobhash") return -52; - else - solAssert(false, "Unknown magic variable: \"" + _name + "\"."); + static std::unordered_map const magicVariables = { + {"abi", -1}, + {"addmod", -2}, + {"assert", -3}, + {"block", -4}, + {"blockhash", -5}, + {"ecrecover", -6}, + {"gasleft", -7}, + {"keccak256", -8}, + {"msg", -15}, + {"mulmod", -16}, + {"now", -17}, + {"require", -18}, + {"revert", -19}, + {"ripemd160", -20}, + {"selfdestruct", -21}, + {"sha256", -22}, + {"sha3", -23}, + {"suicide", -24}, + {"super", -25}, + {"tx", -26}, + {"type", -27}, + {"this", -28}, + {"verifyMintProof", -29}, + {"verifyBurnProof", -30}, + {"verifyTransferProof", -31}, + {"pedersenHash", -32}, + {"batchvalidatesign", -33}, + {"validatemultisign", -34}, + {"freeze", -35}, + {"unfreeze", -36}, + {"freezeExpireTime", -37}, + {"withdrawreward", -38}, + {"vote", -39}, + {"rewardBalance", -40}, + {"isSrCandidate", -41}, + {"voteCount", -42}, + {"totalVoteCount", -43}, + {"receivedVoteCount", -44}, + {"usedVoteCount", -45}, + {"freezebalancev2", -46}, + {"unfreezebalancev2", -47}, + {"cancelallunfreezev2", -48}, + {"withdrawexpireunfreeze", -49}, + {"chain", -50}, + {"getchainparameter", -51}, + {"blobhash", -52}, + }; + + if (auto id = magicVariables.find(_name); id != magicVariables.end()) + return id->second; + solAssert(false, "Unknown magic variable: \"" + _name + "\"."); } inline std::vector> constructMagicVariables(langutil::EVMVersion _evmVersion) @@ -107,6 +113,7 @@ inline std::vector> constructMag magicVarDecl("now", TypeProvider::uint256()), magicVarDecl("require", TypeProvider::function(strings{"bool"}, strings{}, FunctionType::Kind::Require, StateMutability::Pure)), magicVarDecl("require", TypeProvider::function(strings{"bool", "string memory"}, strings{}, FunctionType::Kind::Require, StateMutability::Pure)), + magicVarDecl("require", TypeProvider::function(TypePointers{TypeProvider::boolean(), TypeProvider::magic(MagicType::Kind::Error)}, TypePointers{}, strings{2, ""}, strings{}, FunctionType::Kind::Require, StateMutability::Pure)), magicVarDecl("revert", TypeProvider::function(strings(), strings(), FunctionType::Kind::Revert, StateMutability::Pure)), magicVarDecl("revert", TypeProvider::function(strings{"string memory"}, strings(), FunctionType::Kind::Revert, StateMutability::Pure)), magicVarDecl("ripemd160", TypeProvider::function(strings{"bytes memory"}, strings{"bytes20"}, FunctionType::Kind::RIPEMD160, StateMutability::Pure)), diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index fe3a59d0cc97..9731ef3cc624 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -103,6 +103,11 @@ bool PostTypeChecker::visit(FunctionCall const& _functionCall) return callVisit(_functionCall); } +void PostTypeChecker::endVisit(FunctionCall const& _functionCall) +{ + callEndVisit(_functionCall); +} + bool PostTypeChecker::visit(Identifier const& _identifier) { return callVisit(_identifier); @@ -304,6 +309,7 @@ struct ModifierContextChecker: public PostTypeChecker::Checker bool m_insideModifierInvocation = false; }; +// TODO: this should either be split into separate emit and error checkers, or at least renamed to include require struct EventOutsideEmitErrorOutsideRevertChecker: public PostTypeChecker::Checker { EventOutsideEmitErrorOutsideRevertChecker(ErrorReporter& _errorReporter): @@ -336,6 +342,11 @@ struct EventOutsideEmitErrorOutsideRevertChecker: public PostTypeChecker::Checke if (*_functionCall.annotation().kind == FunctionCallKind::FunctionCall) if (auto const* functionType = dynamic_cast(_functionCall.expression().annotation().type)) { + if (functionType->kind() == FunctionType::Kind::Require) + { + solAssert(!m_inRequire); + m_inRequire = true; + } // Check for event outside of emit statement if (!dynamic_cast(m_currentStatement) && functionType->kind() == FunctionType::Kind::Event) m_errorReporter.typeError( @@ -343,11 +354,11 @@ struct EventOutsideEmitErrorOutsideRevertChecker: public PostTypeChecker::Checke _functionCall.location(), "Event invocations have to be prefixed by \"emit\"." ); - else if (!dynamic_cast(m_currentStatement) && functionType->kind() == FunctionType::Kind::Error) + else if (!dynamic_cast(m_currentStatement) && !m_inRequire && functionType->kind() == FunctionType::Kind::Error) m_errorReporter.typeError( 7757_error, _functionCall.location(), - "Errors can only be used with revert statements: \"revert MyError();\"." + "Errors can only be used with revert statements: \"revert MyError(args);\", or require functions: \"require(condition, MyError(args))\"." ); } m_currentStatement = nullptr; @@ -355,8 +366,20 @@ struct EventOutsideEmitErrorOutsideRevertChecker: public PostTypeChecker::Checke return true; } + void endVisit(FunctionCall const& _functionCall) override + { + if (*_functionCall.annotation().kind == FunctionCallKind::FunctionCall) + if (auto const* functionType = dynamic_cast(_functionCall.expression().annotation().type)) + if (functionType->kind() == FunctionType::Kind::Require) + { + solAssert(m_inRequire); + m_inRequire = false; + } + } + private: Statement const* m_currentStatement = nullptr; + bool m_inRequire = false; }; struct NoVariablesInInterfaceChecker: public PostTypeChecker::Checker diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index 178130a35663..347f464eda04 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -87,6 +87,7 @@ class PostTypeChecker: private ASTConstVisitor void endVisit(RevertStatement const& _revert) override; bool visit(FunctionCall const& _functionCall) override; + void endVisit(FunctionCall const& _functionCall) override; bool visit(Identifier const& _identifier) override; bool visit(MemberAccess const& _identifier) override; diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 10c2c922ca47..563295e23c00 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -298,7 +298,8 @@ bool StaticAnalyzer::visit(BinaryOperation const& _operation) { if ( *_operation.rightExpression().annotation().isPure && - (_operation.getOperator() == Token::Div || _operation.getOperator() == Token::Mod) + (_operation.getOperator() == Token::Div || _operation.getOperator() == Token::Mod) && + ConstantEvaluator::evaluate(m_errorReporter, _operation.leftExpression()) ) if (auto rhs = ConstantEvaluator::evaluate(m_errorReporter, _operation.rightExpression())) if (rhs->value == 0) diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index ac23ca36a8f4..b083690cced6 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -300,7 +300,7 @@ bool SyntaxChecker::visit(Literal const& _literal) if (value.find("__") != ASTString::npos) { - m_errorReporter.syntaxError(2990_error, _literal.location(), "Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed."); + m_errorReporter.syntaxError(2990_error, _literal.location(), "Invalid use of underscores in number literal. Only one consecutive underscore between digits is allowed."); return true; } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index cac6b337c841..0802f5c22e95 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -116,7 +116,8 @@ void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment) TupleType const& lhsType = dynamic_cast(*type(_lhs)); TupleExpression const* lhsResolved = dynamic_cast(resolveOuterUnaryTuples(&_lhs)); - if (lhsType.components().size() != _rhs.components().size() || lhsResolved->components().size() != _rhs.components().size()) + solAssert(!lhsResolved || lhsResolved->components().size() == lhsType.components().size()); + if (lhsType.components().size() != _rhs.components().size()) { solAssert(m_errorReporter.hasErrors(), ""); return; @@ -3414,7 +3415,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) annotation.isPure = true; else if ( magicType->kind() == MagicType::Kind::MetaType && - (memberName == "min" || memberName == "max") + (memberName == "min" || memberName == "max") ) annotation.isPure = true; else if (magicType->kind() == MagicType::Kind::Block) @@ -3875,7 +3876,7 @@ void TypeChecker::endVisit(Literal const& _literal) 5145_error, _literal.location(), "Hexadecimal numbers cannot be used with unit denominations. " - "You can use an expression of the form \"0x1234 * 1 day\" instead." + "You can use an expression of the form \"0x1234 * 1 days\" instead." ); if (_literal.subDenomination() == Literal::SubDenomination::Year) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 502d0b2f8632..da2a3561787b 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -34,8 +34,7 @@ #include #include #include - -#include +#include #include #include diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index f7519250a3a8..81b3b8374697 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -65,8 +65,8 @@ struct ASTAnnotation struct DocTag { - std::string content; ///< The text content of the tag. - std::string paramName; ///< Only used for @param, stores the parameter name. + std::string content; ///< The text content of the tag. + std::string paramName; ///< Only used for @param, stores the parameter name. }; struct StructurallyDocumentedAnnotation diff --git a/libsolidity/ast/ASTJsonExporter.cpp b/libsolidity/ast/ASTJsonExporter.cpp index c54a2d013ad0..f94b91674bcb 100644 --- a/libsolidity/ast/ASTJsonExporter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -46,12 +46,13 @@ using namespace std::string_literals; using namespace solidity::langutil; +using namespace solidity; namespace { template typename C> -void addIfSet(std::vector>& _attributes, std::string const& _name, C const& _value) +void addIfSet(std::vector>& _attributes, std::string const& _name, C const& _value) { if constexpr (std::is_same_v, solidity::util::SetOnce>) { @@ -82,23 +83,23 @@ ASTJsonExporter::ASTJsonExporter(CompilerStack::State _stackState, std::map>&& _attributes + std::initializer_list>&& _attributes ) { ASTJsonExporter::setJsonNode( _node, _nodeName, - std::vector>(std::move(_attributes)) + std::vector>(std::move(_attributes)) ); } void ASTJsonExporter::setJsonNode( ASTNode const& _node, std::string const& _nodeType, - std::vector>&& _attributes + std::vector>&& _attributes ) { - m_currentValue = Json::objectValue; + m_currentValue = Json::object(); m_currentValue["id"] = nodeId(_node); m_currentValue["src"] = sourceLocationToString(_node.location()); if (auto const* documented = dynamic_cast(&_node)) @@ -126,12 +127,12 @@ std::string ASTJsonExporter::sourceLocationToString(SourceLocation const& _locat return std::to_string(_location.start) + ":" + std::to_string(length) + ":" + (sourceIndexOpt.has_value() ? std::to_string(sourceIndexOpt.value()) : "-1"); } -Json::Value ASTJsonExporter::sourceLocationsToJson(std::vector const& _sourceLocations) const +Json ASTJsonExporter::sourceLocationsToJson(std::vector const& _sourceLocations) const { - Json::Value locations = Json::arrayValue; + Json locations = Json::array(); for (SourceLocation const& location: _sourceLocations) - locations.append(sourceLocationToString(location)); + locations.emplace_back(sourceLocationToString(location)); return locations; } @@ -141,33 +142,33 @@ std::string ASTJsonExporter::namePathToString(std::vector const& _nam return boost::algorithm::join(_namePath, "."s); } -Json::Value ASTJsonExporter::typePointerToJson(Type const* _tp, bool _withoutDataLocation) +Json ASTJsonExporter::typePointerToJson(Type const* _tp, bool _withoutDataLocation) { - Json::Value typeDescriptions(Json::objectValue); - typeDescriptions["typeString"] = _tp ? Json::Value(_tp->toString(_withoutDataLocation)) : Json::nullValue; - typeDescriptions["typeIdentifier"] = _tp ? Json::Value(_tp->identifier()) : Json::nullValue; + Json typeDescriptions; + typeDescriptions["typeString"] = _tp ? Json(_tp->toString(_withoutDataLocation)) : Json(); + typeDescriptions["typeIdentifier"] = _tp ? Json(_tp->identifier()) : Json(); return typeDescriptions; } -Json::Value ASTJsonExporter::typePointerToJson(std::optional const& _tps) +Json ASTJsonExporter::typePointerToJson(std::optional const& _tps) { if (_tps) { - Json::Value arguments(Json::arrayValue); + Json arguments = Json::array(); for (auto const& tp: _tps->types) appendMove(arguments, typePointerToJson(tp)); return arguments; } else - return Json::nullValue; + return Json(); } void ASTJsonExporter::appendExpressionAttributes( - std::vector>& _attributes, + std::vector>& _attributes, ExpressionAnnotation const& _annotation ) { - std::vector> exprAttributes = { + std::vector> exprAttributes = { std::make_pair("typeDescriptions", typePointerToJson(_annotation.type)), std::make_pair("argumentTypes", typePointerToJson(_annotation.arguments)) }; @@ -182,18 +183,18 @@ void ASTJsonExporter::appendExpressionAttributes( _attributes += exprAttributes; } -Json::Value ASTJsonExporter::inlineAssemblyIdentifierToJson(std::pair _info) const +Json ASTJsonExporter::inlineAssemblyIdentifierToJson(std::pair _info) const { - Json::Value tuple(Json::objectValue); + Json tuple; tuple["src"] = sourceLocationToString(nativeLocationOf(*_info.first)); tuple["declaration"] = idOrNull(_info.second.declaration); - tuple["isSlot"] = Json::Value(_info.second.suffix == "slot"); - tuple["isOffset"] = Json::Value(_info.second.suffix == "offset"); + tuple["isSlot"] = Json(_info.second.suffix == "slot"); + tuple["isOffset"] = Json(_info.second.suffix == "offset"); if (!_info.second.suffix.empty()) - tuple["suffix"] = Json::Value(_info.second.suffix); + tuple["suffix"] = Json(_info.second.suffix); - tuple["valueSize"] = Json::Value(Json::LargestUInt(_info.second.valueSize)); + tuple["valueSize"] = Json(static_cast(_info.second.valueSize)); return tuple; } @@ -203,7 +204,7 @@ void ASTJsonExporter::print(std::ostream& _stream, ASTNode const& _node, util::J _stream << util::jsonPrint(toJson(_node), _format); } -Json::Value ASTJsonExporter::toJson(ASTNode const& _node) +Json ASTJsonExporter::toJson(ASTNode const& _node) { _node.accept(*this); return util::removeNullMembers(std::move(m_currentValue)); @@ -211,22 +212,22 @@ Json::Value ASTJsonExporter::toJson(ASTNode const& _node) bool ASTJsonExporter::visit(SourceUnit const& _node) { - std::vector> attributes = { - std::make_pair("license", _node.licenseString() ? Json::Value(*_node.licenseString()) : Json::nullValue), + std::vector> attributes = { + std::make_pair("license", _node.licenseString() ? Json(*_node.licenseString()) : Json()), std::make_pair("nodes", toJson(_node.nodes())), }; if (_node.experimentalSolidity()) - attributes.emplace_back("experimentalSolidity", Json::Value(_node.experimentalSolidity())); + attributes.emplace_back("experimentalSolidity", Json(_node.experimentalSolidity())); if (_node.annotation().exportedSymbols.set()) { - Json::Value exportedSymbols = Json::objectValue; + Json exportedSymbols = Json::object(); for (auto const& sym: *_node.annotation().exportedSymbols) { - exportedSymbols[sym.first] = Json::arrayValue; + exportedSymbols[sym.first] = Json::array(); for (Declaration const* overload: sym.second) - exportedSymbols[sym.first].append(nodeId(*overload)); + exportedSymbols[sym.first].emplace_back(nodeId(*overload)); } attributes.emplace_back("exportedSymbols", exportedSymbols); @@ -241,9 +242,9 @@ bool ASTJsonExporter::visit(SourceUnit const& _node) bool ASTJsonExporter::visit(PragmaDirective const& _node) { - Json::Value literals(Json::arrayValue); + Json literals = Json::array(); for (auto const& literal: _node.literals()) - literals.append(literal); + literals.emplace_back(literal); setJsonNode(_node, "PragmaDirective", { std::make_pair("literals", std::move(literals)) }); @@ -252,7 +253,7 @@ bool ASTJsonExporter::visit(PragmaDirective const& _node) bool ASTJsonExporter::visit(ImportDirective const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("file", _node.path()), std::make_pair("sourceUnit", idOrNull(_node.annotation().sourceUnit)), std::make_pair("scope", idOrNull(_node.scope())) @@ -261,17 +262,17 @@ bool ASTJsonExporter::visit(ImportDirective const& _node) addIfSet(attributes, "absolutePath", _node.annotation().absolutePath); attributes.emplace_back("unitAlias", _node.name()); - attributes.emplace_back("nameLocation", Json::Value(sourceLocationToString(_node.nameLocation()))); + attributes.emplace_back("nameLocation", Json(sourceLocationToString(_node.nameLocation()))); - Json::Value symbolAliases(Json::arrayValue); + Json symbolAliases = Json::array(); for (auto const& symbolAlias: _node.symbolAliases()) { - Json::Value tuple(Json::objectValue); + Json tuple; solAssert(symbolAlias.symbol, ""); tuple["foreign"] = toJson(*symbolAlias.symbol); - tuple["local"] = symbolAlias.alias ? Json::Value(*symbolAlias.alias) : Json::nullValue; + tuple["local"] = symbolAlias.alias ? Json(*symbolAlias.alias) : Json(); tuple["nameLocation"] = sourceLocationToString(_node.nameLocation()); - symbolAliases.append(tuple); + symbolAliases.emplace_back(tuple); } attributes.emplace_back("symbolAliases", std::move(symbolAliases)); setJsonNode(_node, "ImportDirective", std::move(attributes)); @@ -280,10 +281,10 @@ bool ASTJsonExporter::visit(ImportDirective const& _node) bool ASTJsonExporter::visit(ContractDefinition const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("contractKind", contractKind(_node.contractKind())), std::make_pair("abstract", _node.abstract()), std::make_pair("baseContracts", toJson(_node.baseContracts())), @@ -303,7 +304,7 @@ bool ASTJsonExporter::visit(ContractDefinition const& _node) if (!_node.annotation().internalFunctionIDs.empty()) { - Json::Value internalFunctionIDs(Json::objectValue); + Json internalFunctionIDs; for (auto const& [functionDefinition, internalFunctionID]: _node.annotation().internalFunctionIDs) internalFunctionIDs[std::to_string(functionDefinition->id())] = internalFunctionID; attributes.emplace_back("internalFunctionIDs", std::move(internalFunctionIDs)); @@ -315,10 +316,10 @@ bool ASTJsonExporter::visit(ContractDefinition const& _node) bool ASTJsonExporter::visit(IdentifierPath const& _node) { - Json::Value nameLocations = Json::arrayValue; + Json nameLocations = Json::array(); for (SourceLocation location: _node.pathLocations()) - nameLocations.append(sourceLocationToString(location)); + nameLocations.emplace_back(sourceLocationToString(location)); setJsonNode(_node, "IdentifierPath", { std::make_pair("name", namePathToString(_node.path())), @@ -332,23 +333,23 @@ bool ASTJsonExporter::visit(InheritanceSpecifier const& _node) { setJsonNode(_node, "InheritanceSpecifier", { std::make_pair("baseName", toJson(_node.name())), - std::make_pair("arguments", _node.arguments() ? toJson(*_node.arguments()) : Json::nullValue) + std::make_pair("arguments", _node.arguments() ? toJson(*_node.arguments()) : Json()) }); return false; } bool ASTJsonExporter::visit(UsingForDirective const& _node) { - std::vector> attributes = { - std::make_pair("typeName", _node.typeName() ? toJson(*_node.typeName()) : Json::nullValue) + std::vector> attributes = { + std::make_pair("typeName", _node.typeName() ? toJson(*_node.typeName()) : Json()) }; if (_node.usesBraces()) { - Json::Value functionList; + Json functionList = Json::array(); for (auto&& [function, op]: _node.functionsAndOperators()) { - Json::Value functionNode; + Json functionNode; if (!op.has_value()) functionNode["function"] = toJson(*function); else @@ -356,7 +357,7 @@ bool ASTJsonExporter::visit(UsingForDirective const& _node) functionNode["definition"] = toJson(*function); functionNode["operator"] = std::string(TokenTraits::toString(*op)); } - functionList.append(std::move(functionNode)); + functionList.emplace_back(std::move(functionNode)); } attributes.emplace_back("functionList", std::move(functionList)); } @@ -376,10 +377,10 @@ bool ASTJsonExporter::visit(UsingForDirective const& _node) bool ASTJsonExporter::visit(StructDefinition const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("visibility", Declaration::visibilityToString(_node.visibility())), std::make_pair("members", toJson(_node.members())), std::make_pair("scope", idOrNull(_node.scope())) @@ -394,10 +395,10 @@ bool ASTJsonExporter::visit(StructDefinition const& _node) bool ASTJsonExporter::visit(EnumDefinition const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("members", toJson(_node.members())) }; @@ -420,7 +421,7 @@ bool ASTJsonExporter::visit(EnumValue const& _node) bool ASTJsonExporter::visit(UserDefinedValueTypeDefinition const& _node) { solAssert(_node.underlyingType(), ""); - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), std::make_pair("underlyingType", toJson(*_node.underlyingType())) @@ -450,18 +451,18 @@ bool ASTJsonExporter::visit(OverrideSpecifier const& _node) bool ASTJsonExporter::visit(FunctionDefinition const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("kind", _node.isFree() ? "freeFunction" : TokenTraits::toString(_node.kind())), std::make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())), std::make_pair("virtual", _node.markedVirtual()), - std::make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json::nullValue), + std::make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json()), std::make_pair("parameters", toJson(_node.parameterList())), std::make_pair("returnParameters", toJson(*_node.returnParameterList())), std::make_pair("modifiers", toJson(_node.modifiers())), - std::make_pair("body", _node.isImplemented() ? toJson(_node.body()) : Json::nullValue), + std::make_pair("body", _node.isImplemented() ? toJson(_node.body()) : Json()), std::make_pair("implemented", _node.isImplemented()), std::make_pair("scope", idOrNull(_node.scope())) }; @@ -489,7 +490,7 @@ bool ASTJsonExporter::visit(FunctionDefinition const& _node) bool ASTJsonExporter::visit(VariableDeclaration const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), std::make_pair("typeName", toJson(_node.typeName())), @@ -497,9 +498,9 @@ bool ASTJsonExporter::visit(VariableDeclaration const& _node) std::make_pair("mutability", VariableDeclaration::mutabilityToString(_node.mutability())), std::make_pair("stateVariable", _node.isStateVariable()), std::make_pair("storageLocation", location(_node.referenceLocation())), - std::make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json::nullValue), + std::make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json()), std::make_pair("visibility", Declaration::visibilityToString(_node.visibility())), - std::make_pair("value", _node.value() ? toJson(*_node.value()) : Json::nullValue), + std::make_pair("value", _node.value() ? toJson(*_node.value()) : Json()), std::make_pair("scope", idOrNull(_node.scope())), std::make_pair("typeDescriptions", typePointerToJson(_node.annotation().type, true)) }; @@ -517,15 +518,15 @@ bool ASTJsonExporter::visit(VariableDeclaration const& _node) bool ASTJsonExporter::visit(ModifierDefinition const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("visibility", Declaration::visibilityToString(_node.visibility())), std::make_pair("parameters", toJson(_node.parameterList())), std::make_pair("virtual", _node.markedVirtual()), - std::make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json::nullValue), - std::make_pair("body", _node.isImplemented() ? toJson(_node.body()) : Json::nullValue) + std::make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json()), + std::make_pair("body", _node.isImplemented() ? toJson(_node.body()) : Json()) }; if (!_node.annotation().baseFunctions.empty()) attributes.emplace_back(std::make_pair("baseModifiers", getContainerIds(_node.annotation().baseFunctions, true))); @@ -535,9 +536,9 @@ bool ASTJsonExporter::visit(ModifierDefinition const& _node) bool ASTJsonExporter::visit(ModifierInvocation const& _node) { - std::vector> attributes{ + std::vector> attributes{ std::make_pair("modifierName", toJson(_node.name())), - std::make_pair("arguments", _node.arguments() ? toJson(*_node.arguments()) : Json::nullValue) + std::make_pair("arguments", _node.arguments() ? toJson(*_node.arguments()) : Json()) }; if (Declaration const* declaration = _node.name().annotation().referencedDeclaration) { @@ -553,10 +554,10 @@ bool ASTJsonExporter::visit(ModifierInvocation const& _node) bool ASTJsonExporter::visit(EventDefinition const& _node) { m_inEvent = true; - std::vector> _attributes = { + std::vector> _attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("parameters", toJson(_node.parameterList())), std::make_pair("anonymous", _node.isAnonymous()) }; @@ -573,10 +574,10 @@ bool ASTJsonExporter::visit(EventDefinition const& _node) bool ASTJsonExporter::visit(ErrorDefinition const& _node) { - std::vector> _attributes = { + std::vector> _attributes = { std::make_pair("name", _node.name()), std::make_pair("nameLocation", sourceLocationToString(_node.nameLocation())), - std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), + std::make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json()), std::make_pair("parameters", toJson(_node.parameterList())) }; if (m_stackState >= CompilerStack::State::AnalysisSuccessful) @@ -588,7 +589,7 @@ bool ASTJsonExporter::visit(ErrorDefinition const& _node) bool ASTJsonExporter::visit(ElementaryTypeName const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("name", _node.typeName().toString()), std::make_pair("typeDescriptions", typePointerToJson(_node.annotation().type, true)) }; @@ -648,7 +649,7 @@ bool ASTJsonExporter::visit(ArrayTypeName const& _node) bool ASTJsonExporter::visit(InlineAssembly const& _node) { - std::vector> externalReferences; + std::vector> externalReferences; for (auto const& it: _node.annotation().externalReferences) if (it.first) @@ -657,26 +658,26 @@ bool ASTJsonExporter::visit(InlineAssembly const& _node) inlineAssemblyIdentifierToJson(it) )); - Json::Value externalReferencesJson = Json::arrayValue; + Json externalReferencesJson = Json::array(); std::sort(externalReferences.begin(), externalReferences.end()); - for (Json::Value& it: externalReferences | ranges::views::values) - externalReferencesJson.append(std::move(it)); + for (Json& it: externalReferences | ranges::views::values) + externalReferencesJson.emplace_back(std::move(it)); - std::vector> attributes = { - std::make_pair("AST", Json::Value(yul::AsmJsonConverter(sourceIndexFromLocation(_node.location()))(_node.operations()))), + std::vector> attributes = { + std::make_pair("AST", Json(yul::AsmJsonConverter(sourceIndexFromLocation(_node.location()))(_node.operations()))), std::make_pair("externalReferences", std::move(externalReferencesJson)), std::make_pair("evmVersion", dynamic_cast(_node.dialect()).evmVersion().name()) }; if (_node.flags()) { - Json::Value flags(Json::arrayValue); + Json flags = Json::array(); for (auto const& flag: *_node.flags()) if (flag) - flags.append(*flag); + flags.emplace_back(*flag); else - flags.append(Json::nullValue); + flags.emplace_back(Json()); attributes.emplace_back(std::make_pair("flags", std::move(flags))); } setJsonNode(_node, "InlineAssembly", std::move(attributes)); @@ -743,7 +744,7 @@ bool ASTJsonExporter::visit(WhileStatement const& _node) bool ASTJsonExporter::visit(ForStatement const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("initializationExpression", toJsonOrNull(_node.initializationExpression())), std::make_pair("condition", toJsonOrNull(_node.condition())), std::make_pair("loopExpression", toJsonOrNull(_node.loopExpression())), @@ -802,7 +803,7 @@ bool ASTJsonExporter::visit(RevertStatement const& _node) bool ASTJsonExporter::visit(VariableDeclarationStatement const& _node) { - Json::Value varDecs(Json::arrayValue); + Json varDecs = Json::array(); for (auto const& v: _node.declarations()) appendMove(varDecs, idOrNull(v.get())); setJsonNode(_node, "VariableDeclarationStatement", { @@ -823,7 +824,7 @@ bool ASTJsonExporter::visit(ExpressionStatement const& _node) bool ASTJsonExporter::visit(Conditional const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("condition", toJson(_node.condition())), std::make_pair("trueExpression", toJson(_node.trueExpression())), std::make_pair("falseExpression", toJson(_node.falseExpression())) @@ -835,7 +836,7 @@ bool ASTJsonExporter::visit(Conditional const& _node) bool ASTJsonExporter::visit(Assignment const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("operator", TokenTraits::toString(_node.assignmentOperator())), std::make_pair("leftHandSide", toJson(_node.leftHandSide())), std::make_pair("rightHandSide", toJson(_node.rightHandSide())) @@ -847,8 +848,8 @@ bool ASTJsonExporter::visit(Assignment const& _node) bool ASTJsonExporter::visit(TupleExpression const& _node) { - std::vector> attributes = { - std::make_pair("isInlineArray", Json::Value(_node.isInlineArray())), + std::vector> attributes = { + std::make_pair("isInlineArray", Json(_node.isInlineArray())), std::make_pair("components", toJson(_node.components())), }; appendExpressionAttributes(attributes, _node.annotation()); @@ -858,7 +859,7 @@ bool ASTJsonExporter::visit(TupleExpression const& _node) bool ASTJsonExporter::visit(UnaryOperation const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("prefix", _node.isPrefixOperation()), std::make_pair("operator", TokenTraits::toString(_node.getOperator())), std::make_pair("subExpression", toJson(_node.subExpression())) @@ -873,7 +874,7 @@ bool ASTJsonExporter::visit(UnaryOperation const& _node) bool ASTJsonExporter::visit(BinaryOperation const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("operator", TokenTraits::toString(_node.getOperator())), std::make_pair("leftExpression", toJson(_node.leftExpression())), std::make_pair("rightExpression", toJson(_node.rightExpression())), @@ -889,10 +890,10 @@ bool ASTJsonExporter::visit(BinaryOperation const& _node) bool ASTJsonExporter::visit(FunctionCall const& _node) { - Json::Value names(Json::arrayValue); + Json names = Json::array(); for (auto const& name: _node.names()) - names.append(Json::Value(*name)); - std::vector> attributes = { + names.push_back(Json(*name)); + std::vector> attributes = { std::make_pair("expression", toJson(_node.expression())), std::make_pair("names", std::move(names)), std::make_pair("nameLocations", sourceLocationsToJson(_node.nameLocations())), @@ -913,11 +914,11 @@ bool ASTJsonExporter::visit(FunctionCall const& _node) bool ASTJsonExporter::visit(FunctionCallOptions const& _node) { - Json::Value names(Json::arrayValue); + Json names = Json::array(); for (auto const& name: _node.names()) - names.append(Json::Value(*name)); + names.emplace_back(Json(*name)); - std::vector> attributes = { + std::vector> attributes = { std::make_pair("expression", toJson(_node.expression())), std::make_pair("names", std::move(names)), std::make_pair("options", toJson(_node.options())), @@ -930,7 +931,7 @@ bool ASTJsonExporter::visit(FunctionCallOptions const& _node) bool ASTJsonExporter::visit(NewExpression const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("typeName", toJson(_node.typeName())) }; appendExpressionAttributes(attributes, _node.annotation()); @@ -940,9 +941,9 @@ bool ASTJsonExporter::visit(NewExpression const& _node) bool ASTJsonExporter::visit(MemberAccess const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("memberName", _node.memberName()), - std::make_pair("memberLocation", Json::Value(sourceLocationToString(_node.memberLocation()))), + std::make_pair("memberLocation", Json(sourceLocationToString(_node.memberLocation()))), std::make_pair("expression", toJson(_node.expression())), std::make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)), }; @@ -953,7 +954,7 @@ bool ASTJsonExporter::visit(MemberAccess const& _node) bool ASTJsonExporter::visit(IndexAccess const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("baseExpression", toJson(_node.baseExpression())), std::make_pair("indexExpression", toJsonOrNull(_node.indexExpression())), }; @@ -964,7 +965,7 @@ bool ASTJsonExporter::visit(IndexAccess const& _node) bool ASTJsonExporter::visit(IndexRangeAccess const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("baseExpression", toJson(_node.baseExpression())), std::make_pair("startExpression", toJsonOrNull(_node.startExpression())), std::make_pair("endExpression", toJsonOrNull(_node.endExpression())), @@ -976,9 +977,9 @@ bool ASTJsonExporter::visit(IndexRangeAccess const& _node) bool ASTJsonExporter::visit(Identifier const& _node) { - Json::Value overloads(Json::arrayValue); + Json overloads = Json::array(); for (auto const& dec: _node.annotation().overloadedDeclarations) - overloads.append(nodeId(*dec)); + overloads.emplace_back(nodeId(*dec)); setJsonNode(_node, "Identifier", { std::make_pair("name", _node.name()), std::make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)), @@ -991,7 +992,7 @@ bool ASTJsonExporter::visit(Identifier const& _node) bool ASTJsonExporter::visit(ElementaryTypeNameExpression const& _node) { - std::vector> attributes = { + std::vector> attributes = { std::make_pair("typeName", toJson(_node.type())) }; appendExpressionAttributes(attributes, _node.annotation()); @@ -1001,19 +1002,19 @@ bool ASTJsonExporter::visit(ElementaryTypeNameExpression const& _node) bool ASTJsonExporter::visit(Literal const& _node) { - Json::Value value{_node.value()}; + Json value = _node.value(); if (!util::validateUTF8(_node.value())) - value = Json::nullValue; + value = Json(); Token subdenomination = Token(_node.subDenomination()); - std::vector> attributes = { + std::vector> attributes = { std::make_pair("kind", literalTokenKind(_node.token())), std::make_pair("value", value), std::make_pair("hexValue", util::toHex(util::asBytes(_node.value()))), std::make_pair( "subdenomination", subdenomination == Token::Illegal ? - Json::nullValue : - Json::Value{TokenTraits::toString(subdenomination)} + Json() : + Json(TokenTraits::toString(subdenomination)) ) }; appendExpressionAttributes(attributes, _node.annotation()); @@ -1023,16 +1024,14 @@ bool ASTJsonExporter::visit(Literal const& _node) bool ASTJsonExporter::visit(StructuredDocumentation const& _node) { - Json::Value text{*_node.text()}; - std::vector> attributes = { + Json text = *_node.text(); + std::vector> attributes = { std::make_pair("text", text) }; setJsonNode(_node, "StructuredDocumentation", std::move(attributes)); return false; } - - void ASTJsonExporter::endVisit(EventDefinition const&) { m_inEvent = false; diff --git a/libsolidity/ast/ASTJsonExporter.h b/libsolidity/ast/ASTJsonExporter.h index ff3b94fa28de..c7933120a974 100644 --- a/libsolidity/ast/ASTJsonExporter.h +++ b/libsolidity/ast/ASTJsonExporter.h @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -60,16 +59,16 @@ class ASTJsonExporter: public ASTConstVisitor ); /// Output the json representation of the AST to _stream. void print(std::ostream& _stream, ASTNode const& _node, util::JsonFormat const& _format); - Json::Value toJson(ASTNode const& _node); + Json toJson(ASTNode const& _node); template - Json::Value toJson(std::vector> const& _nodes) + Json toJson(std::vector> const& _nodes) { - Json::Value ret(Json::arrayValue); + Json ret = Json::array(); for (auto const& n: _nodes) if (n) appendMove(ret, toJson(*n)); else - ret.append(Json::nullValue); + ret.emplace_back(Json()); return ret; } bool visit(SourceUnit const& _node) override; @@ -135,27 +134,27 @@ class ASTJsonExporter: public ASTConstVisitor void setJsonNode( ASTNode const& _node, std::string const& _nodeName, - std::initializer_list>&& _attributes + std::initializer_list>&& _attributes ); void setJsonNode( ASTNode const& _node, std::string const& _nodeName, - std::vector>&& _attributes + std::vector>&& _attributes ); /// Maps source location to an index, if source is valid and a mapping does exist, otherwise returns std::nullopt. std::optional sourceIndexFromLocation(langutil::SourceLocation const& _location) const; std::string sourceLocationToString(langutil::SourceLocation const& _location) const; - Json::Value sourceLocationsToJson(std::vector const& _sourceLocations) const; + Json sourceLocationsToJson(std::vector const& _sourceLocations) const; static std::string namePathToString(std::vector const& _namePath); - static Json::Value idOrNull(ASTNode const* _pt) + static Json idOrNull(ASTNode const* _pt) { - return _pt ? Json::Value(nodeId(*_pt)) : Json::nullValue; + return _pt ? Json(nodeId(*_pt)) : Json(); } - Json::Value toJsonOrNull(ASTNode const* _node) + Json toJsonOrNull(ASTNode const* _node) { - return _node ? toJson(*_node) : Json::nullValue; + return _node ? toJson(*_node) : Json(); } - Json::Value inlineAssemblyIdentifierToJson(std::pair _info) const; + Json inlineAssemblyIdentifierToJson(std::pair _info) const; static std::string location(VariableDeclaration::Location _location); static std::string contractKind(ContractKind _kind); static std::string functionCallKind(FunctionCallKind _kind); @@ -167,7 +166,7 @@ class ASTJsonExporter: public ASTConstVisitor return _node.id(); } template - static Json::Value getContainerIds(Container const& _container, bool _order = false) + static Json getContainerIds(Container const& _container, bool _order = false) { std::vector tmp; @@ -178,28 +177,27 @@ class ASTJsonExporter: public ASTConstVisitor } if (_order) std::sort(tmp.begin(), tmp.end()); - Json::Value json(Json::arrayValue); + Json json = Json::array(); for (int64_t val: tmp) - json.append(val); - + json.emplace_back(val); return json; } - static Json::Value typePointerToJson(Type const* _tp, bool _withoutDataLocation = false); - static Json::Value typePointerToJson(std::optional const& _tps); + static Json typePointerToJson(Type const* _tp, bool _withoutDataLocation = false); + static Json typePointerToJson(std::optional const& _tps); void appendExpressionAttributes( - std::vector> &_attributes, + std::vector> &_attributes, ExpressionAnnotation const& _annotation ); - static void appendMove(Json::Value& _array, Json::Value&& _value) + static void appendMove(Json& _array, Json&& _value) { - solAssert(_array.isArray(), ""); - _array.append(std::move(_value)); + solAssert(_array.is_array(), ""); + _array.emplace_back(std::move(_value)); } CompilerStack::State m_stackState = CompilerStack::State::Empty; ///< Used to only access information that already exists bool m_inEvent = false; ///< whether we are currently inside an event or not - Json::Value m_currentValue; + Json m_currentValue; std::map m_sourceIndices; }; diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 6e6dd9eb5eeb..5c1d4bdc0c30 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -43,9 +43,9 @@ namespace solidity::frontend using SourceLocation = langutil::SourceLocation; template -ASTPointer ASTJsonImporter::nullOrCast(Json::Value const& _json) +ASTPointer ASTJsonImporter::nullOrCast(Json const& _json) { - if (_json.isNull()) + if (_json.is_null()) return nullptr; else return std::dynamic_pointer_cast(convertJsonToASTNode(_json)); @@ -54,13 +54,13 @@ ASTPointer ASTJsonImporter::nullOrCast(Json::Value const& _json) // ============ public =========================== -std::map> ASTJsonImporter::jsonToSourceUnit(std::map const& _sourceList) +std::map> ASTJsonImporter::jsonToSourceUnit(std::map const& _sourceList) { for (auto const& src: _sourceList) m_sourceNames.emplace_back(std::make_shared(src.first)); for (auto const& srcPair: _sourceList) { - astAssert(!srcPair.second.isNull()); + astAssert(!srcPair.second.is_null()); astAssert(member(srcPair.second,"nodeType") == "SourceUnit", "The 'nodeType' of the highest node must be 'SourceUnit'."); m_sourceUnits[srcPair.first] = createSourceUnit(srcPair.second, srcPair.first); } @@ -71,11 +71,12 @@ std::map> ASTJsonImporter::jsonToSourceUnit( // =========== general creation functions ============== template -ASTPointer ASTJsonImporter::createASTNode(Json::Value const& _node, Args&&... _args) +ASTPointer ASTJsonImporter::createASTNode(Json const& _node, Args&&... _args) { - astAssert(member(_node, "id").isInt64(), "'id'-field must be 64bit integer."); + static_assert(std::is_same_v); + astAssert(member(_node, "id").is_number_integer(), "'id'-field must be 64bit integer."); - int64_t id = _node["id"].asInt64(); + int64_t id = static_cast(_node["id"]); astAssert(m_usedIDs.insert(id).second, "Found duplicate node ID!"); @@ -87,50 +88,50 @@ ASTPointer ASTJsonImporter::createASTNode(Json::Value const& _node, Args&&... return n; } -SourceLocation const ASTJsonImporter::createSourceLocation(Json::Value const& _node) +SourceLocation const ASTJsonImporter::createSourceLocation(Json const& _node) { - astAssert(member(_node, "src").isString(), "'src' must be a string"); + astAssert(member(_node, "src").is_string(), "'src' must be a string"); - return solidity::langutil::parseSourceLocation(_node["src"].asString(), m_sourceNames); + return solidity::langutil::parseSourceLocation(_node["src"].get(), m_sourceNames); } -std::optional> ASTJsonImporter::createSourceLocations(Json::Value const& _node) const +std::optional> ASTJsonImporter::createSourceLocations(Json const& _node) const { std::vector locations; - if (_node.isMember("nameLocations") && _node["nameLocations"].isArray()) + if (_node.contains("nameLocations") && _node["nameLocations"].is_array()) { for (auto const& val: _node["nameLocations"]) - locations.emplace_back(langutil::parseSourceLocation(val.asString(), m_sourceNames)); + locations.emplace_back(langutil::parseSourceLocation(val.get(), m_sourceNames)); return locations; } return std::nullopt; } -SourceLocation ASTJsonImporter::createNameSourceLocation(Json::Value const& _node) +SourceLocation ASTJsonImporter::createNameSourceLocation(Json const& _node) { - astAssert(member(_node, "nameLocation").isString(), "'nameLocation' must be a string"); + astAssert(member(_node, "nameLocation").is_string(), "'nameLocation' must be a string"); - return solidity::langutil::parseSourceLocation(_node["nameLocation"].asString(), m_sourceNames); + return solidity::langutil::parseSourceLocation(_node["nameLocation"].get(), m_sourceNames); } -SourceLocation ASTJsonImporter::createKeyNameSourceLocation(Json::Value const& _node) +SourceLocation ASTJsonImporter::createKeyNameSourceLocation(Json const& _node) { - astAssert(member(_node, "keyNameLocation").isString(), "'keyNameLocation' must be a string"); + astAssert(member(_node, "keyNameLocation").is_string(), "'keyNameLocation' must be a string"); - return solidity::langutil::parseSourceLocation(_node["keyNameLocation"].asString(), m_sourceNames); + return solidity::langutil::parseSourceLocation(_node["keyNameLocation"].get(), m_sourceNames); } -SourceLocation ASTJsonImporter::createValueNameSourceLocation(Json::Value const& _node) +SourceLocation ASTJsonImporter::createValueNameSourceLocation(Json const& _node) { - astAssert(member(_node, "valueNameLocation").isString(), "'valueNameLocation' must be a string"); + astAssert(member(_node, "valueNameLocation").is_string(), "'valueNameLocation' must be a string"); - return solidity::langutil::parseSourceLocation(_node["valueNameLocation"].asString(), m_sourceNames); + return solidity::langutil::parseSourceLocation(_node["valueNameLocation"].get(), m_sourceNames); } template -ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _node) +ASTPointer ASTJsonImporter::convertJsonToASTNode(Json const& _node) { ASTPointer ret = std::dynamic_pointer_cast(convertJsonToASTNode(_node)); astAssert(ret, "cast of converted json-node must not be nullptr"); @@ -138,10 +139,10 @@ ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _node) } -ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _json) +ASTPointer ASTJsonImporter::convertJsonToASTNode(Json const& _json) { - astAssert(_json["nodeType"].isString() && _json.isMember("id"), "JSON-Node needs to have 'nodeType' and 'id' fields."); - std::string nodeType = _json["nodeType"].asString(); + astAssert(_json["nodeType"].is_string() && _json.contains("id"), "JSON-Node needs to have 'nodeType' and 'id' fields."); + std::string nodeType = _json["nodeType"].get(); if (nodeType == "PragmaDirective") return createPragmaDirective(_json); if (nodeType == "ImportDirective") @@ -263,15 +264,15 @@ ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js // ============ functions to instantiate the AST-Nodes from Json-Nodes ============== -ASTPointer ASTJsonImporter::createSourceUnit(Json::Value const& _node, std::string const& _srcName) +ASTPointer ASTJsonImporter::createSourceUnit(Json const& _node, std::string const& _srcName) { std::optional license; - if (_node.isMember("license") && !_node["license"].isNull()) - license = _node["license"].asString(); + if (_node.contains("license") && !_node["license"].is_null()) + license = _node["license"].get(); bool experimentalSolidity = false; - if (_node.isMember("experimentalSolidity") && !_node["experimentalSolidity"].isNull()) - experimentalSolidity = _node["experimentalSolidity"].asBool(); + if (_node.contains("experimentalSolidity") && !_node["experimentalSolidity"].is_null()) + experimentalSolidity = _node["experimentalSolidity"].get(); std::vector> nodes; for (auto& child: member(_node, "nodes")) @@ -282,20 +283,20 @@ ASTPointer ASTJsonImporter::createSourceUnit(Json::Value const& _nod return tmp; } -ASTPointer ASTJsonImporter::createPragmaDirective(Json::Value const& _node) +ASTPointer ASTJsonImporter::createPragmaDirective(Json const& _node) { std::vector tokens; std::vector literals; for (auto const& lit: member(_node, "literals")) { - std::string l = lit.asString(); + std::string l = lit.get(); literals.push_back(l); tokens.push_back(scanSingleToken(l)); } return createASTNode(_node, tokens, literals); } -ASTPointer ASTJsonImporter::createImportDirective(Json::Value const& _node) +ASTPointer ASTJsonImporter::createImportDirective(Json const& _node) { ASTPointer unitAlias = memberAsASTString(_node, "unitAlias"); ASTPointer path = memberAsASTString(_node, "file"); @@ -303,11 +304,11 @@ ASTPointer ASTJsonImporter::createImportDirective(Json::Value c for (auto& tuple: member(_node, "symbolAliases")) { - astAssert(tuple["local"].isNull() || tuple["local"].isString(), "expected 'local' to be a string or null!"); + astAssert(tuple["local"].is_null() || tuple["local"].is_string(), "expected 'local' to be a string or null!"); symbolAliases.push_back({ createIdentifier(tuple["foreign"]), - tuple["local"].isNull() ? nullptr : std::make_shared(tuple["local"].asString()), + tuple["local"].is_null() ? nullptr : std::make_shared(tuple["local"].get()), createSourceLocation(tuple["foreign"])} ); } @@ -319,15 +320,15 @@ ASTPointer ASTJsonImporter::createImportDirective(Json::Value c std::move(symbolAliases) ); - astAssert(_node["absolutePath"].isString(), "Expected 'absolutePath' to be a string!"); + astAssert(_node["absolutePath"].is_string(), "Expected 'absolutePath' to be a string!"); - tmp->annotation().absolutePath = _node["absolutePath"].asString(); + tmp->annotation().absolutePath = _node["absolutePath"].get(); return tmp; } -ASTPointer ASTJsonImporter::createContractDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createContractDefinition(Json const& _node) { - astAssert(_node["name"].isString(), "Expected 'name' to be a string!"); + astAssert(_node["name"].is_string(), "Expected 'name' to be a string!"); std::vector> baseContracts; @@ -341,9 +342,9 @@ ASTPointer ASTJsonImporter::createContractDefinition(Json::V return createASTNode( _node, - std::make_shared(_node["name"].asString()), + std::make_shared(_node["name"].get()), createNameSourceLocation(_node), - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr, baseContracts, subNodes, contractKind(_node), @@ -351,14 +352,14 @@ ASTPointer ASTJsonImporter::createContractDefinition(Json::V ); } -ASTPointer ASTJsonImporter::createIdentifierPath(Json::Value const& _node) +ASTPointer ASTJsonImporter::createIdentifierPath(Json const& _node) { - astAssert(_node["name"].isString(), "Expected 'name' to be a string!"); + astAssert(_node["name"].is_string(), "Expected 'name' to be a string!"); std::vector namePath; std::vector namePathLocations; std::vector strs; - std::string nameString = member(_node, "name").asString(); + std::string nameString = member(_node, "name").get(); boost::algorithm::split(strs, nameString, boost::is_any_of(".")); astAssert(!strs.empty(), "Expected at least one element in IdentifierPath."); for (std::string s: strs) @@ -367,9 +368,9 @@ ASTPointer ASTJsonImporter::createIdentifierPath(Json::Value con namePath.emplace_back(s); } - if (_node.isMember("nameLocations") && _node["nameLocations"].isArray()) + if (_node.contains("nameLocations") && _node["nameLocations"].is_array()) for (auto const& val: _node["nameLocations"]) - namePathLocations.emplace_back(langutil::parseSourceLocation(val.asString(), m_sourceNames)); + namePathLocations.emplace_back(langutil::parseSourceLocation(val.get(), m_sourceNames)); else namePathLocations.resize(namePath.size()); @@ -385,7 +386,7 @@ ASTPointer ASTJsonImporter::createIdentifierPath(Json::Value con ); } -ASTPointer ASTJsonImporter::createInheritanceSpecifier(Json::Value const& _node) +ASTPointer ASTJsonImporter::createInheritanceSpecifier(Json const& _node) { std::vector> arguments; for (auto& arg: member(_node, "arguments")) @@ -393,36 +394,36 @@ ASTPointer ASTJsonImporter::createInheritanceSpecifier(Jso return createASTNode( _node, createIdentifierPath(member(_node, "baseName")), - member(_node, "arguments").isNull() ? nullptr : std::make_unique>>(arguments) + member(_node, "arguments").is_null() ? nullptr : std::make_unique>>(arguments) ); } -ASTPointer ASTJsonImporter::createUsingForDirective(Json::Value const& _node) +ASTPointer ASTJsonImporter::createUsingForDirective(Json const& _node) { std::vector> functions; std::vector> operators; - if (_node.isMember("libraryName")) + if (_node.contains("libraryName")) { - astAssert(!_node["libraryName"].isArray()); - astAssert(!_node["libraryName"]["operator"]); + astAssert(!_node["libraryName"].is_array()); + astAssert(!_node["libraryName"].contains("operator")); functions.emplace_back(createIdentifierPath(_node["libraryName"])); operators.emplace_back(std::nullopt); } - else if (_node.isMember("functionList")) - for (Json::Value const& function: _node["functionList"]) + else if (_node.contains("functionList")) + for (Json const& function: _node["functionList"]) { - if (function.isMember("function")) + if (function.contains("function")) { - astAssert(!function.isMember("operator")); - astAssert(!function.isMember("definition")); + astAssert(!function.contains("operator")); + astAssert(!function.contains("definition")); functions.emplace_back(createIdentifierPath(function["function"])); operators.emplace_back(std::nullopt); } else { - astAssert(function.isMember("operator")); - astAssert(function.isMember("definition")); + astAssert(function.contains("operator")); + astAssert(function.contains("definition")); Token const operatorName = scanSingleToken(function["operator"]); astAssert(util::contains(frontend::userDefinableOperators, operatorName)); @@ -436,13 +437,13 @@ ASTPointer ASTJsonImporter::createUsingForDirective(Json::Val _node, std::move(functions), std::move(operators), - !_node.isMember("libraryName"), - _node["typeName"].isNull() ? nullptr : convertJsonToASTNode(_node["typeName"]), + !_node.contains("libraryName"), + (_node.contains("typeName") && !_node["typeName"].is_null()) ? convertJsonToASTNode(_node["typeName"]) : nullptr, memberAsBool(_node, "global") ); } -ASTPointer ASTJsonImporter::createStructDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createStructDefinition(Json const& _node) { std::vector> members; for (auto& member: _node["members"]) @@ -452,11 +453,11 @@ ASTPointer ASTJsonImporter::createStructDefinition(Json::Value const& _ memberAsASTString(_node, "name"), createNameSourceLocation(_node), members, - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")) + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr ); } -ASTPointer ASTJsonImporter::createEnumDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createEnumDefinition(Json const& _node) { std::vector> members; for (auto& member: _node["members"]) @@ -466,11 +467,11 @@ ASTPointer ASTJsonImporter::createEnumDefinition(Json::Value con memberAsASTString(_node, "name"), createNameSourceLocation(_node), members, - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")) + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr ); } -ASTPointer ASTJsonImporter::createEnumValue(Json::Value const& _node) +ASTPointer ASTJsonImporter::createEnumValue(Json const& _node) { return createASTNode( _node, @@ -478,7 +479,7 @@ ASTPointer ASTJsonImporter::createEnumValue(Json::Value const& _node) ); } -ASTPointer ASTJsonImporter::createUserDefinedValueTypeDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createUserDefinedValueTypeDefinition(Json const& _node) { return createASTNode( _node, @@ -488,7 +489,7 @@ ASTPointer ASTJsonImporter::createUserDefinedVal ); } -ASTPointer ASTJsonImporter::createParameterList(Json::Value const& _node) +ASTPointer ASTJsonImporter::createParameterList(Json const& _node) { std::vector> parameters; for (auto& param: _node["parameters"]) @@ -499,12 +500,13 @@ ASTPointer ASTJsonImporter::createParameterList(Json::Value const ); } -ASTPointer ASTJsonImporter::createOverrideSpecifier(Json::Value const& _node) +ASTPointer ASTJsonImporter::createOverrideSpecifier(Json const& _node) { std::vector> overrides; - for (auto& param: _node["overrides"]) - overrides.push_back(createIdentifierPath(param)); + if ( _node.contains("overrides")) + for (auto& param: _node["overrides"]) + overrides.push_back(createIdentifierPath(param)); return createASTNode( _node, @@ -512,13 +514,13 @@ ASTPointer ASTJsonImporter::createOverrideSpecifier(Json::Val ); } -ASTPointer ASTJsonImporter::createFunctionDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createFunctionDefinition(Json const& _node) { - astAssert(_node["kind"].isString(), "Expected 'kind' to be a string!"); + astAssert(_node["kind"].is_string(), "Expected 'kind' to be a string!"); Token kind; bool freeFunction = false; - std::string kindStr = member(_node, "kind").asString(); + std::string kindStr = member(_node, "kind").get(); if (kindStr == "constructor") kind = Token::Constructor; @@ -555,8 +557,8 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V freeFunction, kind, memberAsBool(_node, "virtual"), - _node["overrides"].isNull() ? nullptr : createOverrideSpecifier(member(_node, "overrides")), - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), + (_node.contains("overrides") && !_node["overrides"].is_null()) ? createOverrideSpecifier(member(_node, "overrides")) : nullptr, + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr, createParameterList(member(_node, "parameters")), modifiers, createParameterList(member(_node, "returnParameters")), @@ -564,13 +566,13 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V ); } -ASTPointer ASTJsonImporter::createVariableDeclaration(Json::Value const& _node) +ASTPointer ASTJsonImporter::createVariableDeclaration(Json const& _node) { - astAssert(_node["name"].isString(), "Expected 'name' to be a string!"); + astAssert(_node["name"].is_string(), "Expected 'name' to be a string!"); VariableDeclaration::Mutability mutability{}; - astAssert(member(_node, "mutability").isString(), "'mutability' expected to be string."); - std::string const mutabilityStr = member(_node, "mutability").asString(); + astAssert(member(_node, "mutability").is_string(), "'mutability' expected to be string."); + std::string const mutabilityStr = member(_node, "mutability").get(); if (mutabilityStr == "constant") { mutability = VariableDeclaration::Mutability::Constant; @@ -590,33 +592,33 @@ ASTPointer ASTJsonImporter::createVariableDeclaration(Json: return createASTNode( _node, nullOrCast(member(_node, "typeName")), - std::make_shared(member(_node, "name").asString()), + std::make_shared(member(_node, "name").get()), createNameSourceLocation(_node), nullOrCast(member(_node, "value")), visibility(_node), - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), - _node.isMember("indexed") ? memberAsBool(_node, "indexed") : false, + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr, + (_node.contains("indexed") && !_node["indexed"].is_null()) ? memberAsBool(_node, "indexed") : false, mutability, - _node["overrides"].isNull() ? nullptr : createOverrideSpecifier(member(_node, "overrides")), + (_node.contains("overrides") && !_node["overrides"].is_null()) ? createOverrideSpecifier(member(_node, "overrides")) : nullptr, location(_node) ); } -ASTPointer ASTJsonImporter::createModifierDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createModifierDefinition(Json const& _node) { return createASTNode( _node, memberAsASTString(_node, "name"), createNameSourceLocation(_node), - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr, createParameterList(member(_node, "parameters")), memberAsBool(_node, "virtual"), - _node["overrides"].isNull() ? nullptr : createOverrideSpecifier(member(_node, "overrides")), - _node["body"].isNull() ? nullptr: createBlock(member(_node, "body"), false) + (_node.contains("overrides") && !_node["overrides"].is_null()) ? createOverrideSpecifier(member(_node, "overrides")) : nullptr, + (_node.contains("body") && !_node["body"].is_null()) ? createBlock(member(_node, "body"), false) : nullptr ); } -ASTPointer ASTJsonImporter::createModifierInvocation(Json::Value const& _node) +ASTPointer ASTJsonImporter::createModifierInvocation(Json const& _node) { std::vector> arguments; for (auto& arg: member(_node, "arguments")) @@ -624,53 +626,53 @@ ASTPointer ASTJsonImporter::createModifierInvocation(Json::V return createASTNode( _node, createIdentifierPath(member(_node, "modifierName")), - member(_node, "arguments").isNull() ? nullptr : std::make_unique>>(arguments) + member(_node, "arguments").is_null() ? nullptr : std::make_unique>>(arguments) ); } -ASTPointer ASTJsonImporter::createEventDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createEventDefinition(Json const& _node) { return createASTNode( _node, memberAsASTString(_node, "name"), createNameSourceLocation(_node), - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr, createParameterList(member(_node, "parameters")), memberAsBool(_node, "anonymous") ); } -ASTPointer ASTJsonImporter::createErrorDefinition(Json::Value const& _node) +ASTPointer ASTJsonImporter::createErrorDefinition(Json const& _node) { return createASTNode( _node, memberAsASTString(_node, "name"), createNameSourceLocation(_node), - _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), + (_node.contains("documentation") && !_node["documentation"].is_null()) ? createDocumentation(member(_node, "documentation")) : nullptr, createParameterList(member(_node, "parameters")) ); } -ASTPointer ASTJsonImporter::createElementaryTypeName(Json::Value const& _node) +ASTPointer ASTJsonImporter::createElementaryTypeName(Json const& _node) { unsigned short firstNum; unsigned short secondNum; - astAssert(_node["name"].isString(), "Expected 'name' to be a string!"); + astAssert(_node["name"].is_string(), "Expected 'name' to be a string!"); - std::string name = member(_node, "name").asString(); + std::string name = member(_node, "name").get(); Token token; std::tie(token, firstNum, secondNum) = TokenTraits::fromIdentifierOrKeyword(name); ElementaryTypeNameToken elem(token, firstNum, secondNum); std::optional mutability = {}; - if (_node.isMember("stateMutability")) + if (_node.contains("stateMutability")) mutability = stateMutability(_node); return createASTNode(_node, elem, mutability); } -ASTPointer ASTJsonImporter::createUserDefinedTypeName(Json::Value const& _node) +ASTPointer ASTJsonImporter::createUserDefinedTypeName(Json const& _node) { return createASTNode( _node, @@ -678,7 +680,7 @@ ASTPointer ASTJsonImporter::createUserDefinedTypeName(Json: ); } -ASTPointer ASTJsonImporter::createFunctionTypeName(Json::Value const& _node) +ASTPointer ASTJsonImporter::createFunctionTypeName(Json const& _node) { return createASTNode( _node, @@ -689,7 +691,7 @@ ASTPointer ASTJsonImporter::createFunctionTypeName(Json::Value ); } -ASTPointer ASTJsonImporter::createMapping(Json::Value const& _node) +ASTPointer ASTJsonImporter::createMapping(Json const& _node) { return createASTNode( _node, @@ -702,7 +704,7 @@ ASTPointer ASTJsonImporter::createMapping(Json::Value const& _node) ); } -ASTPointer ASTJsonImporter::createArrayTypeName(Json::Value const& _node) +ASTPointer ASTJsonImporter::createArrayTypeName(Json const& _node) { return createASTNode( _node, @@ -711,24 +713,24 @@ ASTPointer ASTJsonImporter::createArrayTypeName(Json::Value const ); } -ASTPointer ASTJsonImporter::createInlineAssembly(Json::Value const& _node) +ASTPointer ASTJsonImporter::createInlineAssembly(Json const& _node) { - astAssert(_node["evmVersion"].isString(), "Expected evmVersion to be a string!"); - auto evmVersion = langutil::EVMVersion::fromString(_node["evmVersion"].asString()); + astAssert(_node["evmVersion"].is_string(), "Expected evmVersion to be a string!"); + auto evmVersion = langutil::EVMVersion::fromString(_node["evmVersion"].get()); astAssert(evmVersion.has_value(), "Invalid EVM version!"); astAssert(m_evmVersion == evmVersion, "Imported tree evm version differs from configured evm version!"); yul::Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(evmVersion.value()); ASTPointer>> flags; - if (_node.isMember("flags")) + if (_node.contains("flags")) { flags = std::make_shared>>(); - Json::Value const& flagsNode = _node["flags"]; - astAssert(flagsNode.isArray(), "Assembly flags must be an array."); - for (Json::ArrayIndex i = 0; i < flagsNode.size(); ++i) + Json const& flagsNode = _node["flags"]; + astAssert(flagsNode.is_array(), "Assembly flags must be an array."); + for (auto const& flag: flagsNode) { - astAssert(flagsNode[i].isString(), "Assembly flag must be a string."); - flags->emplace_back(std::make_shared(flagsNode[i].asString())); + astAssert(flag.is_string(), "Assembly flag must be a string."); + flags->emplace_back(std::make_shared(flag.get())); } } std::shared_ptr operations = std::make_shared(yul::AsmJsonImporter(m_sourceNames).createBlock(member(_node, "AST"))); @@ -741,7 +743,7 @@ ASTPointer ASTJsonImporter::createInlineAssembly(Json::Value con ); } -ASTPointer ASTJsonImporter::createBlock(Json::Value const& _node, bool _unchecked) +ASTPointer ASTJsonImporter::createBlock(Json const& _node, bool _unchecked) { std::vector> statements; for (auto& stat: member(_node, "statements")) @@ -754,7 +756,7 @@ ASTPointer ASTJsonImporter::createBlock(Json::Value const& _node, bool _u ); } -ASTPointer ASTJsonImporter::createPlaceholderStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createPlaceholderStatement(Json const& _node) { return createASTNode( _node, @@ -762,7 +764,7 @@ ASTPointer ASTJsonImporter::createPlaceholderStatement(Jso ); } -ASTPointer ASTJsonImporter::createIfStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createIfStatement(Json const& _node) { return createASTNode( _node, @@ -773,7 +775,7 @@ ASTPointer ASTJsonImporter::createIfStatement(Json::Value const& _ ); } -ASTPointer ASTJsonImporter::createTryCatchClause(Json::Value const& _node) +ASTPointer ASTJsonImporter::createTryCatchClause(Json const& _node) { return createASTNode( _node, @@ -783,7 +785,7 @@ ASTPointer ASTJsonImporter::createTryCatchClause(Json::Value con ); } -ASTPointer ASTJsonImporter::createTryStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createTryStatement(Json const& _node) { std::vector> clauses; @@ -798,7 +800,7 @@ ASTPointer ASTJsonImporter::createTryStatement(Json::Value const& ); } -ASTPointer ASTJsonImporter::createWhileStatement(Json::Value const& _node, bool _isDoWhile=false) +ASTPointer ASTJsonImporter::createWhileStatement(Json const& _node, bool _isDoWhile=false) { return createASTNode( _node, @@ -809,7 +811,7 @@ ASTPointer ASTJsonImporter::createWhileStatement(Json::Value con ); } -ASTPointer ASTJsonImporter::createForStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createForStatement(Json const& _node) { return createASTNode( _node, @@ -821,7 +823,7 @@ ASTPointer ASTJsonImporter::createForStatement(Json::Value const& ); } -ASTPointer ASTJsonImporter::createContinue(Json::Value const& _node) +ASTPointer ASTJsonImporter::createContinue(Json const& _node) { return createASTNode( _node, @@ -829,7 +831,7 @@ ASTPointer ASTJsonImporter::createContinue(Json::Value const& _node) ); } -ASTPointer ASTJsonImporter::createBreak(Json::Value const& _node) +ASTPointer ASTJsonImporter::createBreak(Json const& _node) { return createASTNode( _node, @@ -837,7 +839,7 @@ ASTPointer ASTJsonImporter::createBreak(Json::Value const& _node) ); } -ASTPointer ASTJsonImporter::createReturn(Json::Value const& _node) +ASTPointer ASTJsonImporter::createReturn(Json const& _node) { return createASTNode( _node, @@ -846,7 +848,7 @@ ASTPointer ASTJsonImporter::createReturn(Json::Value const& _node) ); } -ASTPointer ASTJsonImporter::createThrow(Json::Value const& _node) +ASTPointer ASTJsonImporter::createThrow(Json const& _node) { return createASTNode( _node, @@ -854,7 +856,7 @@ ASTPointer ASTJsonImporter::createThrow(Json::Value const& _node) ); } -ASTPointer ASTJsonImporter::createEmitStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createEmitStatement(Json const& _node) { return createASTNode( _node, @@ -863,7 +865,7 @@ ASTPointer ASTJsonImporter::createEmitStatement(Json::Value const ); } -ASTPointer ASTJsonImporter::createRevertStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createRevertStatement(Json const& _node) { return createASTNode( _node, @@ -872,11 +874,11 @@ ASTPointer ASTJsonImporter::createRevertStatement(Json::Value c ); } -ASTPointer ASTJsonImporter::createVariableDeclarationStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createVariableDeclarationStatement(Json const& _node) { std::vector> variables; for (auto& var: member(_node, "declarations")) - variables.push_back(var.isNull() ? nullptr : createVariableDeclaration(var)); //unnamed components are empty pointers + variables.push_back(var.is_null() ? nullptr : createVariableDeclaration(var)); //unnamed components are empty pointers return createASTNode( _node, nullOrASTString(_node, "documentation"), @@ -885,7 +887,7 @@ ASTPointer ASTJsonImporter::createVariableDeclarat ); } -ASTPointer ASTJsonImporter::createExpressionStatement(Json::Value const& _node) +ASTPointer ASTJsonImporter::createExpressionStatement(Json const& _node) { return createASTNode( _node, @@ -894,7 +896,7 @@ ASTPointer ASTJsonImporter::createExpressionStatement(Json: ); } -ASTPointer ASTJsonImporter::createConditional(Json::Value const& _node) +ASTPointer ASTJsonImporter::createConditional(Json const& _node) { return createASTNode( _node, @@ -904,7 +906,7 @@ ASTPointer ASTJsonImporter::createConditional(Json::Value const& _ ); } -ASTPointer ASTJsonImporter::createAssignment(Json::Value const& _node) +ASTPointer ASTJsonImporter::createAssignment(Json const& _node) { return createASTNode( _node, @@ -914,7 +916,7 @@ ASTPointer ASTJsonImporter::createAssignment(Json::Value const& _no ); } -ASTPointer ASTJsonImporter::createTupleExpression(Json::Value const& _node) +ASTPointer ASTJsonImporter::createTupleExpression(Json const& _node) { std::vector> components; for (auto& comp: member(_node, "components")) @@ -926,7 +928,7 @@ ASTPointer ASTJsonImporter::createTupleExpression(Json::Value c ); } -ASTPointer ASTJsonImporter::createUnaryOperation(Json::Value const& _node) +ASTPointer ASTJsonImporter::createUnaryOperation(Json const& _node) { return createASTNode( _node, @@ -936,7 +938,7 @@ ASTPointer ASTJsonImporter::createUnaryOperation(Json::Value con ); } -ASTPointer ASTJsonImporter::createBinaryOperation(Json::Value const& _node) +ASTPointer ASTJsonImporter::createBinaryOperation(Json const& _node) { return createASTNode( _node, @@ -946,7 +948,7 @@ ASTPointer ASTJsonImporter::createBinaryOperation(Json::Value c ); } -ASTPointer ASTJsonImporter::createFunctionCall(Json::Value const& _node) +ASTPointer ASTJsonImporter::createFunctionCall(Json const& _node) { std::vector> arguments; for (auto& arg: member(_node, "arguments")) @@ -954,8 +956,8 @@ ASTPointer ASTJsonImporter::createFunctionCall(Json::Value const& std::vector> names; for (auto& name: member(_node, "names")) { - astAssert(name.isString(), "Expected 'names' members to be strings!"); - names.push_back(std::make_shared(name.asString())); + astAssert(name.is_string(), "Expected 'names' members to be strings!"); + names.push_back(std::make_shared(name.get())); } std::optional> sourceLocations = createSourceLocations(_node); @@ -971,7 +973,7 @@ ASTPointer ASTJsonImporter::createFunctionCall(Json::Value const& ); } -ASTPointer ASTJsonImporter::createFunctionCallOptions(Json::Value const& _node) +ASTPointer ASTJsonImporter::createFunctionCallOptions(Json const& _node) { std::vector> options; for (auto& option: member(_node, "options")) @@ -979,8 +981,8 @@ ASTPointer ASTJsonImporter::createFunctionCallOptions(Json: std::vector> names; for (auto& name: member(_node, "names")) { - astAssert(name.isString(), "Expected 'names' members to be strings!"); - names.push_back(std::make_shared(name.asString())); + astAssert(name.is_string(), "Expected 'names' members to be strings!"); + names.push_back(std::make_shared(name.get())); } return createASTNode( @@ -991,7 +993,7 @@ ASTPointer ASTJsonImporter::createFunctionCallOptions(Json: ); } -ASTPointer ASTJsonImporter::createNewExpression(Json::Value const& _node) +ASTPointer ASTJsonImporter::createNewExpression(Json const& _node) { return createASTNode( _node, @@ -999,11 +1001,11 @@ ASTPointer ASTJsonImporter::createNewExpression(Json::Value const ); } -ASTPointer ASTJsonImporter::createMemberAccess(Json::Value const& _node) +ASTPointer ASTJsonImporter::createMemberAccess(Json const& _node) { SourceLocation memberLocation; - if (member(_node, "memberLocation").isString()) - memberLocation = solidity::langutil::parseSourceLocation(_node["memberLocation"].asString(), m_sourceNames); + if (member(_node, "memberLocation").is_string()) + memberLocation = solidity::langutil::parseSourceLocation(_node["memberLocation"].get(), m_sourceNames); return createASTNode( _node, @@ -1013,7 +1015,7 @@ ASTPointer ASTJsonImporter::createMemberAccess(Json::Value const& ); } -ASTPointer ASTJsonImporter::createIndexAccess(Json::Value const& _node) +ASTPointer ASTJsonImporter::createIndexAccess(Json const& _node) { return createASTNode( _node, @@ -1022,7 +1024,7 @@ ASTPointer ASTJsonImporter::createIndexAccess(Json::Value const& _n ); } -ASTPointer ASTJsonImporter::createIndexRangeAccess(Json::Value const& _node) +ASTPointer ASTJsonImporter::createIndexRangeAccess(Json const& _node) { return createASTNode( _node, @@ -1032,12 +1034,12 @@ ASTPointer ASTJsonImporter::createIndexRangeAccess(Json::Value ); } -ASTPointer ASTJsonImporter::createIdentifier(Json::Value const& _node) +ASTPointer ASTJsonImporter::createIdentifier(Json const& _node) { return createASTNode(_node, memberAsASTString(_node, "name")); } -ASTPointer ASTJsonImporter::createElementaryTypeNameExpression(Json::Value const& _node) +ASTPointer ASTJsonImporter::createElementaryTypeNameExpression(Json const& _node) { return createASTNode( _node, @@ -1045,116 +1047,116 @@ ASTPointer ASTJsonImporter::createElementaryTypeNa ); } -ASTPointer ASTJsonImporter::createLiteral(Json::Value const& _node) +ASTPointer ASTJsonImporter::createLiteral(Json const& _node) { static std::string const valStr = "value"; static std::string const hexValStr = "hexValue"; - astAssert(member(_node, valStr).isString() || member(_node, hexValStr).isString(), "Literal-value is unset."); + astAssert(member(_node, valStr).is_string() || member(_node, hexValStr).is_string(), "Literal-value is unset."); - ASTPointer value = _node.isMember(hexValStr) ? - std::make_shared(util::asString(util::fromHex(_node[hexValStr].asString()))) : - std::make_shared(_node[valStr].asString()); + ASTPointer value = _node.contains(hexValStr) ? + std::make_shared(util::asString(util::fromHex(_node[hexValStr].get()))) : + std::make_shared(_node[valStr].get()); return createASTNode( _node, literalTokenKind(_node), value, - member(_node, "subdenomination").isNull() ? Literal::SubDenomination::None : subdenomination(_node) + member(_node, "subdenomination").is_null() ? Literal::SubDenomination::None : subdenomination(_node) ); } -ASTPointer ASTJsonImporter::createDocumentation(Json::Value const& _node) +ASTPointer ASTJsonImporter::createDocumentation(Json const& _node) { static std::string const textString = "text"; - astAssert(member(_node, textString).isString(), "'text' must be a string"); + astAssert(member(_node, textString).is_string(), "'text' must be a string"); return createASTNode( _node, - std::make_shared(_node[textString].asString()) + std::make_shared(_node[textString].get()) ); } // ===== helper functions ========== -Json::Value ASTJsonImporter::member(Json::Value const& _node, std::string const& _name) +Json ASTJsonImporter::member(Json const& _node, std::string const& _name) { - if (!_node.isMember(_name)) - return Json::nullValue; + if (!_node.contains(_name)) + return Json(); return _node[_name]; } -Token ASTJsonImporter::scanSingleToken(Json::Value const& _node) +Token ASTJsonImporter::scanSingleToken(Json const& _node) { - langutil::CharStream charStream(_node.asString(), ""); + langutil::CharStream charStream(_node.get(), ""); langutil::Scanner scanner{charStream}; astAssert(scanner.peekNextToken() == Token::EOS, "Token string is too long."); return scanner.currentToken(); } -ASTPointer ASTJsonImporter::nullOrASTString(Json::Value const& _json, std::string const& _name) +ASTPointer ASTJsonImporter::nullOrASTString(Json const& _json, std::string const& _name) { - return _json[_name].isString() ? memberAsASTString(_json, _name) : nullptr; + return (_json.contains(_name) && (_json[_name].is_string())) ? memberAsASTString(_json, _name) : nullptr; } -ASTPointer ASTJsonImporter::memberAsASTString(Json::Value const& _node, std::string const& _name) +ASTPointer ASTJsonImporter::memberAsASTString(Json const& _node, std::string const& _name) { - Json::Value value = member(_node, _name); - astAssert(value.isString(), "field " + _name + " must be of type string."); - return std::make_shared(_node[_name].asString()); + Json value = member(_node, _name); + astAssert(value.is_string(), "field " + _name + " must be of type string."); + return std::make_shared(_node[_name].get()); } -bool ASTJsonImporter::memberAsBool(Json::Value const& _node, std::string const& _name) +bool ASTJsonImporter::memberAsBool(Json const& _node, std::string const& _name) { - Json::Value value = member(_node, _name); - astAssert(value.isBool(), "field " + _name + " must be of type boolean."); - return _node[_name].asBool(); + Json value = member(_node, _name); + astAssert(value.is_boolean(), "field " + _name + " must be of type boolean."); + return _node[_name].get(); } // =========== JSON to definition helpers ======================= -ContractKind ASTJsonImporter::contractKind(Json::Value const& _node) +ContractKind ASTJsonImporter::contractKind(Json const& _node) { ContractKind kind; - astAssert(!member(_node, "contractKind").isNull(), "'Contract-kind' can not be null."); - if (_node["contractKind"].asString() == "interface") + astAssert(!member(_node, "contractKind").is_null(), "'Contract-kind' can not be null."); + if (_node["contractKind"].get() == "interface") kind = ContractKind::Interface; - else if (_node["contractKind"].asString() == "contract") + else if (_node["contractKind"].get() == "contract") kind = ContractKind::Contract; - else if (_node["contractKind"].asString() == "library") + else if (_node["contractKind"].get() == "library") kind = ContractKind::Library; else astAssert(false, "Unknown ContractKind"); return kind; } -Token ASTJsonImporter::literalTokenKind(Json::Value const& _node) +Token ASTJsonImporter::literalTokenKind(Json const& _node) { - astAssert(member(_node, "kind").isString(), "Token-'kind' expected to be a string."); + astAssert(member(_node, "kind").is_string(), "Token-'kind' expected to be a string."); Token tok; - if (_node["kind"].asString() == "number") + if (_node["kind"].get() == "number") tok = Token::Number; - else if (_node["kind"].asString() == "string") + else if (_node["kind"].get() == "string") tok = Token::StringLiteral; - else if (_node["kind"].asString() == "unicodeString") + else if (_node["kind"].get() == "unicodeString") tok = Token::UnicodeStringLiteral; - else if (_node["kind"].asString() == "hexString") + else if (_node["kind"].get() == "hexString") tok = Token::HexStringLiteral; - else if (_node["kind"].asString() == "bool") - tok = (member(_node, "value").asString() == "true") ? Token::TrueLiteral : Token::FalseLiteral; + else if (_node["kind"].get() == "bool") + tok = (member(_node, "value").get() == "true") ? Token::TrueLiteral : Token::FalseLiteral; else astAssert(false, "Unknown kind of literalString"); return tok; } -Visibility ASTJsonImporter::visibility(Json::Value const& _node) +Visibility ASTJsonImporter::visibility(Json const& _node) { - Json::Value visibility = member(_node, "visibility"); - astAssert(visibility.isString(), "'visibility' expected to be a string."); + Json visibility = member(_node, "visibility"); + astAssert(visibility.is_string(), "'visibility' expected to be a string."); - std::string const visibilityStr = visibility.asString(); + std::string const visibilityStr = visibility.get(); if (visibilityStr == "default") return Visibility::Default; @@ -1173,12 +1175,12 @@ Visibility ASTJsonImporter::visibility(Json::Value const& _node) util::unreachable(); } -VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node) +VariableDeclaration::Location ASTJsonImporter::location(Json const& _node) { - Json::Value storageLoc = member(_node, "storageLocation"); - astAssert(storageLoc.isString(), "'storageLocation' expected to be a string."); + Json storageLoc = member(_node, "storageLocation"); + astAssert(storageLoc.is_string(), "'storageLocation' expected to be a string."); - std::string const storageLocStr = storageLoc.asString(); + std::string const storageLocStr = storageLoc.get(); if (storageLocStr == "default") return VariableDeclaration::Location::Unspecified; @@ -1195,16 +1197,16 @@ VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node util::unreachable(); } -Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _node) +Literal::SubDenomination ASTJsonImporter::subdenomination(Json const& _node) { - Json::Value subDen = member(_node, "subdenomination"); + Json subDen = member(_node, "subdenomination"); - if (subDen.isNull()) + if (subDen.is_null()) return Literal::SubDenomination::None; - astAssert(subDen.isString(), "'subDenomination' expected to be string."); + astAssert(subDen.is_string(), "'subDenomination' expected to be string."); - std::string const subDenStr = subDen.asString(); + std::string const subDenStr = subDen.get(); if (subDenStr == "wei") return Literal::SubDenomination::Wei; @@ -1231,10 +1233,10 @@ Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _no util::unreachable(); } -StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node) +StateMutability ASTJsonImporter::stateMutability(Json const& _node) { - astAssert(member(_node, "stateMutability").isString(), "StateMutability' expected to be string."); - std::string const mutabilityStr = member(_node, "stateMutability").asString(); + astAssert(member(_node, "stateMutability").is_string(), "StateMutability' expected to be string."); + std::string const mutabilityStr = member(_node, "stateMutability").get(); if (mutabilityStr == "pure") return StateMutability::Pure; diff --git a/libsolidity/ast/ASTJsonImporter.h b/libsolidity/ast/ASTJsonImporter.h index b9a4d4950569..943415df93ca 100644 --- a/libsolidity/ast/ASTJsonImporter.h +++ b/libsolidity/ast/ASTJsonImporter.h @@ -24,8 +24,8 @@ #pragma once #include +#include #include -#include #include #include #include @@ -47,7 +47,7 @@ class ASTJsonImporter /// Converts the AST from JSON-format to ASTPointer /// @a _sourceList used to provide source names for the ASTs /// @returns map of sourcenames to their respective ASTs - std::map> jsonToSourceUnit(std::map const& _sourceList); + std::map> jsonToSourceUnit(std::map const& _sourceList); private: @@ -56,105 +56,105 @@ class ASTJsonImporter /// Sets the source location and nodeID /// @returns the ASTNode Object class of the respective JSON node, template - ASTPointer createASTNode(Json::Value const& _node, Args&&... _args); + ASTPointer createASTNode(Json const& _node, Args&&... _args); /// @returns the sourceLocation-object created from the string in the JSON node - langutil::SourceLocation const createSourceLocation(Json::Value const& _node); - std::optional> createSourceLocations(Json::Value const& _node) const; + langutil::SourceLocation const createSourceLocation(Json const& _node); + std::optional> createSourceLocations(Json const& _node) const; /// Creates an ASTNode for a given JSON-ast of unknown type /// @returns Pointer to a new created ASTNode - ASTPointer convertJsonToASTNode(Json::Value const& _ast); + ASTPointer convertJsonToASTNode(Json const& _ast); /// @returns a pointer to the more specific subclass of ASTNode /// as indicated by the nodeType field of the json template - ASTPointer convertJsonToASTNode(Json::Value const& _node); + ASTPointer convertJsonToASTNode(Json const& _node); - langutil::SourceLocation createNameSourceLocation(Json::Value const& _node); + langutil::SourceLocation createNameSourceLocation(Json const& _node); /// @returns source location of a mapping key name - langutil::SourceLocation createKeyNameSourceLocation(Json::Value const& _node); + langutil::SourceLocation createKeyNameSourceLocation(Json const& _node); /// @returns source location of a mapping value name - langutil::SourceLocation createValueNameSourceLocation(Json::Value const& _node); + langutil::SourceLocation createValueNameSourceLocation(Json const& _node); /// \defgroup nodeCreators JSON to AST-Nodes ///@{ - ASTPointer createSourceUnit(Json::Value const& _node, std::string const& _srcName); - ASTPointer createPragmaDirective(Json::Value const& _node); - ASTPointer createImportDirective(Json::Value const& _node); - ASTPointer createContractDefinition(Json::Value const& _node); - ASTPointer createIdentifierPath(Json::Value const& _node); - ASTPointer createInheritanceSpecifier(Json::Value const& _node); - ASTPointer createUsingForDirective(Json::Value const& _node); - ASTPointer createStructDefinition(Json::Value const& _node); - ASTPointer createEnumDefinition(Json::Value const& _node); - ASTPointer createEnumValue(Json::Value const& _node); - ASTPointer createUserDefinedValueTypeDefinition(Json::Value const& _node); - ASTPointer createParameterList(Json::Value const& _node); - ASTPointer createOverrideSpecifier(Json::Value const& _node); - ASTPointer createFunctionDefinition(Json::Value const& _node); - ASTPointer createVariableDeclaration(Json::Value const& _node); - ASTPointer createModifierDefinition(Json::Value const& _node); - ASTPointer createModifierInvocation(Json::Value const& _node); - ASTPointer createEventDefinition(Json::Value const& _node); - ASTPointer createErrorDefinition(Json::Value const& _node); - ASTPointer createElementaryTypeName(Json::Value const& _node); - ASTPointer createUserDefinedTypeName(Json::Value const& _node); - ASTPointer createFunctionTypeName(Json::Value const& _node); - ASTPointer createMapping(Json::Value const& _node); - ASTPointer createArrayTypeName(Json::Value const& _node); - ASTPointer createInlineAssembly(Json::Value const& _node); - ASTPointer createBlock(Json::Value const& _node, bool _unchecked); - ASTPointer createPlaceholderStatement(Json::Value const& _node); - ASTPointer createIfStatement(Json::Value const& _node); - ASTPointer createTryCatchClause(Json::Value const& _node); - ASTPointer createTryStatement(Json::Value const& _node); - ASTPointer createWhileStatement(Json::Value const& _node, bool _isDoWhile); - ASTPointer createForStatement(Json::Value const& _node); - ASTPointer createContinue(Json::Value const& _node); - ASTPointer createBreak(Json::Value const& _node); - ASTPointer createReturn(Json::Value const& _node); - ASTPointer createThrow(Json::Value const& _node); - ASTPointer createEmitStatement(Json::Value const& _node); - ASTPointer createRevertStatement(Json::Value const& _node); - ASTPointer createVariableDeclarationStatement(Json::Value const& _node); - ASTPointer createExpressionStatement(Json::Value const& _node); - ASTPointer createConditional(Json::Value const& _node); - ASTPointer createAssignment(Json::Value const& _node); - ASTPointer createTupleExpression(Json::Value const& _node); - ASTPointer createUnaryOperation(Json::Value const& _node); - ASTPointer createBinaryOperation(Json::Value const& _node); - ASTPointer createFunctionCall(Json::Value const& _node); - ASTPointer createFunctionCallOptions(Json::Value const& _node); - ASTPointer createNewExpression(Json::Value const& _node); - ASTPointer createMemberAccess(Json::Value const& _node); - ASTPointer createIndexAccess(Json::Value const& _node); - ASTPointer createIndexRangeAccess(Json::Value const& _node); - ASTPointer createIdentifier(Json::Value const& _node); - ASTPointer createElementaryTypeNameExpression(Json::Value const& _node); - ASTPointer createLiteral(Json::Value const& _node); - ASTPointer createDocumentation(Json::Value const& _node); + ASTPointer createSourceUnit(Json const& _node, std::string const& _srcName); + ASTPointer createPragmaDirective(Json const& _node); + ASTPointer createImportDirective(Json const& _node); + ASTPointer createContractDefinition(Json const& _node); + ASTPointer createIdentifierPath(Json const& _node); + ASTPointer createInheritanceSpecifier(Json const& _node); + ASTPointer createUsingForDirective(Json const& _node); + ASTPointer createStructDefinition(Json const& _node); + ASTPointer createEnumDefinition(Json const& _node); + ASTPointer createEnumValue(Json const& _node); + ASTPointer createUserDefinedValueTypeDefinition(Json const& _node); + ASTPointer createParameterList(Json const& _node); + ASTPointer createOverrideSpecifier(Json const& _node); + ASTPointer createFunctionDefinition(Json const& _node); + ASTPointer createVariableDeclaration(Json const& _node); + ASTPointer createModifierDefinition(Json const& _node); + ASTPointer createModifierInvocation(Json const& _node); + ASTPointer createEventDefinition(Json const& _node); + ASTPointer createErrorDefinition(Json const& _node); + ASTPointer createElementaryTypeName(Json const& _node); + ASTPointer createUserDefinedTypeName(Json const& _node); + ASTPointer createFunctionTypeName(Json const& _node); + ASTPointer createMapping(Json const& _node); + ASTPointer createArrayTypeName(Json const& _node); + ASTPointer createInlineAssembly(Json const& _node); + ASTPointer createBlock(Json const& _node, bool _unchecked); + ASTPointer createPlaceholderStatement(Json const& _node); + ASTPointer createIfStatement(Json const& _node); + ASTPointer createTryCatchClause(Json const& _node); + ASTPointer createTryStatement(Json const& _node); + ASTPointer createWhileStatement(Json const& _node, bool _isDoWhile); + ASTPointer createForStatement(Json const& _node); + ASTPointer createContinue(Json const& _node); + ASTPointer createBreak(Json const& _node); + ASTPointer createReturn(Json const& _node); + ASTPointer createThrow(Json const& _node); + ASTPointer createEmitStatement(Json const& _node); + ASTPointer createRevertStatement(Json const& _node); + ASTPointer createVariableDeclarationStatement(Json const& _node); + ASTPointer createExpressionStatement(Json const& _node); + ASTPointer createConditional(Json const& _node); + ASTPointer createAssignment(Json const& _node); + ASTPointer createTupleExpression(Json const& _node); + ASTPointer createUnaryOperation(Json const& _node); + ASTPointer createBinaryOperation(Json const& _node); + ASTPointer createFunctionCall(Json const& _node); + ASTPointer createFunctionCallOptions(Json const& _node); + ASTPointer createNewExpression(Json const& _node); + ASTPointer createMemberAccess(Json const& _node); + ASTPointer createIndexAccess(Json const& _node); + ASTPointer createIndexRangeAccess(Json const& _node); + ASTPointer createIdentifier(Json const& _node); + ASTPointer createElementaryTypeNameExpression(Json const& _node); + ASTPointer createLiteral(Json const& _node); + ASTPointer createDocumentation(Json const& _node); ///@} // =============== general helper functions =================== /// @returns the member of a given JSON object, throws if member does not exist - Json::Value member(Json::Value const& _node, std::string const& _name); + Json member(Json const& _node, std::string const& _name); /// @returns the appropriate TokenObject used in parsed Strings (pragma directive or operator) - Token scanSingleToken(Json::Value const& _node); + Token scanSingleToken(Json const& _node); template ///@returns nullptr or an ASTPointer cast to a specific Class - ASTPointer nullOrCast(Json::Value const& _json); + ASTPointer nullOrCast(Json const& _json); /// @returns nullptr or ASTString, given an JSON string or an empty field - ASTPointer nullOrASTString(Json::Value const& _json, std::string const& _name); + ASTPointer nullOrASTString(Json const& _json, std::string const& _name); // ============== JSON to definition helpers =============== /// \defgroup typeHelpers Json to ast-datatype helpers /// {@ - ASTPointer memberAsASTString(Json::Value const& _node, std::string const& _name); - bool memberAsBool(Json::Value const& _node, std::string const& _name); - Visibility visibility(Json::Value const& _node); - StateMutability stateMutability(Json::Value const& _node); - VariableDeclaration::Location location(Json::Value const& _node); - ContractKind contractKind(Json::Value const& _node); - Token literalTokenKind(Json::Value const& _node); - Literal::SubDenomination subdenomination(Json::Value const& _node); + ASTPointer memberAsASTString(Json const& _node, std::string const& _name); + bool memberAsBool(Json const& _node, std::string const& _name); + Visibility visibility(Json const& _node); + StateMutability stateMutability(Json const& _node); + VariableDeclaration::Location location(Json const& _node); + ContractKind contractKind(Json const& _node); + Token literalTokenKind(Json const& _node); + Literal::SubDenomination subdenomination(Json const& _node); ///@} // =========== member variables =============== diff --git a/libsolidity/ast/TypeProvider.cpp b/libsolidity/ast/TypeProvider.cpp index 98215b86ade5..8b8ef00cc3c7 100644 --- a/libsolidity/ast/TypeProvider.cpp +++ b/libsolidity/ast/TypeProvider.cpp @@ -146,12 +146,13 @@ std::array, 32> const TypeProvider::m_bytesM{{ {std::make_unique(32)} }}; -std::array, 5> const TypeProvider::m_magics{{ +std::array, 6> const TypeProvider::m_magics{{ {std::make_unique(MagicType::Kind::Chain)}, {std::make_unique(MagicType::Kind::Block)}, {std::make_unique(MagicType::Kind::Message)}, {std::make_unique(MagicType::Kind::Transaction)}, - {std::make_unique(MagicType::Kind::ABI)} + {std::make_unique(MagicType::Kind::ABI)}, + {std::make_unique(MagicType::Kind::Error)} // MetaType is stored separately }}; diff --git a/libsolidity/ast/TypeProvider.h b/libsolidity/ast/TypeProvider.h index 4e8b320101a9..0686fbfa87da 100644 --- a/libsolidity/ast/TypeProvider.h +++ b/libsolidity/ast/TypeProvider.h @@ -231,7 +231,7 @@ class TypeProvider static std::array, 32> const m_intM; static std::array, 32> const m_uintM; static std::array, 32> const m_bytesM; - static std::array, 5> const m_magics; ///< MagicType's except MetaType + static std::array, 6> const m_magics; ///< MagicType's except MetaType std::map, std::unique_ptr> m_ufixedMxN{}; std::map, std::unique_ptr> m_fixedMxN{}; diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 9b12913fd7cf..d7f79cbf5ba3 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1151,7 +1151,7 @@ BoolResult RationalNumberType::isExplicitlyConvertibleTo(Type const& _convertTo) if (category == Category::FixedBytes) return false; else if (auto addressType = dynamic_cast(&_convertTo)) - return (m_value == 0) || + return (m_value == 0) || ((addressType->stateMutability() != StateMutability::Payable) && !isNegative() && !isFractional() && @@ -3028,13 +3028,15 @@ FunctionType::FunctionType(ErrorDefinition const& _error): m_parameterTypes.push_back(var->annotation().type); } + m_returnParameterNames.push_back(""); + m_returnParameterTypes.push_back(TypeProvider::magic(MagicType::Kind::Error)); + solAssert( m_parameterNames.size() == m_parameterTypes.size(), "Parameter names list must match parameter types list!" ); solAssert( - m_returnParameterNames.size() == 0 && - m_returnParameterTypes.size() == 0, + m_returnParameterNames.size() == m_returnParameterTypes.size(), "" ); } @@ -4275,6 +4277,8 @@ std::string MagicType::richIdentifier() const case Kind::MetaType: solAssert(m_typeArgument, ""); return "t_magic_meta_type_" + m_typeArgument->richIdentifier(); + case Kind::Error: + return "t_error"; } return ""; } @@ -4390,6 +4394,8 @@ MemberList::MemberMap MagicType::nativeMembers(ASTNode const*) const FunctionType::Options::withArbitraryParameters() )} }); + case Kind::Error: + return {}; case Kind::MetaType: { solAssert( @@ -4455,6 +4461,8 @@ std::string MagicType::toString(bool _withoutDataLocation) const case Kind::MetaType: solAssert(m_typeArgument, ""); return "type(" + m_typeArgument->toString(_withoutDataLocation) + ")"; + case Kind::Error: + return "error"; } solAssert(false, "Unknown kind of magic."); return {}; diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 1c1fdb04db96..d0a53111a439 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -1703,6 +1703,8 @@ class ModuleType: public Type /** * Special type for magic variables (block, msg, tx, type(...)), similar to a struct but without any reference. + * + * It is also the type shared by all instances of all custom error types. */ class MagicType: public Type { @@ -1713,6 +1715,7 @@ class MagicType: public Type Message, ///< "msg" Transaction, ///< "tx" ABI, ///< "abi" + Error, ///< custom error instance MetaType ///< "type(...)" }; diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 9fd93707c69a..c539c3ac5c26 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1019,7 +1019,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) else { solAssert(paramTypes[arg - 1]->isValueType(), ""); - if (auto functionType = dynamic_cast(paramTypes[arg - 1])) + if (auto functionType = dynamic_cast(paramTypes[arg - 1])) { auto argumentType = dynamic_cast(arguments[arg-1]->annotation().type); @@ -1382,6 +1382,12 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) // function call. solAssert(arguments.size() == 2, ""); solAssert(function.kind() == FunctionType::Kind::Require, ""); + // Check if the function call matches ``require(bool, error)``, and throw an unimplemented error, + // as require with custom errors is not supported in legacy codegen. + auto const* magicType = dynamic_cast(arguments[1]->annotation().type); + if (magicType && magicType->kind() == MagicType::Kind::Error) + solUnimplemented("Require with a custom error is only available using the via-ir pipeline."); + if (m_context.revertStrings() == RevertStrings::Strip) { if (!*arguments.at(1)->annotation().isPure) diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 992630988761..ff4bddcf9626 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -31,11 +32,30 @@ #include #include +#include + using namespace solidity; using namespace solidity::util; using namespace solidity::frontend; using namespace std::string_literals; +namespace +{ + +std::optional staticEncodingSize(std::vector const& _parameterTypes) +{ + size_t encodedSize = 0; + for (auto* type: _parameterTypes) + { + if (type->isDynamicallyEncoded()) + return std::nullopt; + encodedSize += type->calldataHeadSize(); + } + return encodedSize; +} + +} + std::string YulUtilFunctions::identityFunction() { std::string functionName = "identity"; @@ -215,7 +235,62 @@ std::string YulUtilFunctions::copyLiteralToStorageFunction(std::string const& _l }); } -std::string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* _messageType) +std::string YulUtilFunctions::revertWithError( + std::string const& _signature, + std::vector const& _parameterTypes, + std::vector> const& _errorArguments, + std::string const& _posVar, + std::string const& _endVar +) +{ + solAssert((!_posVar.empty() && !_endVar.empty()) || (_posVar.empty() && _endVar.empty())); + bool const needsNewVariable = !_posVar.empty() && !_endVar.empty(); + bool needsAllocation = true; + + if (std::optional size = staticEncodingSize(_parameterTypes)) + if ( + ranges::all_of(_parameterTypes, [](auto const* type) { + solAssert(!dynamic_cast(type)); + return type && type->isValueType(); + }) + ) + { + constexpr size_t errorSelectorSize = 4; + needsAllocation = *size + errorSelectorSize > CompilerUtils::generalPurposeMemoryStart; + } + + Whiskers templ(R"({ + + let := () + + let := 0 + + mstore(, ) + let := (add(, 4) ) + revert(, sub(, )) + })"); + templ("pos", needsNewVariable ? _posVar : "memPtr"); + templ("end", needsNewVariable ? _endVar : "end"); + templ("hash", formatNumber(util::selectorFromSignatureU256(_signature))); + templ("needsAllocation", needsAllocation); + if (needsAllocation) + templ("allocateUnbounded", allocateUnboundedFunction()); + + std::vector errorArgumentVars; + std::vector errorArgumentTypes; + for (ASTPointer const& arg: _errorArguments) + { + errorArgumentVars += IRVariable(*arg).stackSlots(); + solAssert(arg->annotation().type); + errorArgumentTypes.push_back(arg->annotation().type); + } + templ("argumentVars", joinHumanReadablePrefixed(errorArgumentVars)); + templ("encode", ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector).tupleEncoder(errorArgumentTypes, _parameterTypes)); + + return templ.render(); +} + +std::string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* _messageType, ASTPointer _stringArgumentExpression) { std::string functionName = std::string(_assert ? "assert_helper" : "require_helper") + @@ -234,34 +309,60 @@ std::string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* ("functionName", functionName) .render(); - int const hashHeaderSize = 4; - u256 const errorHash = util::selectorFromSignatureU256("Error(string)"); + solAssert(_stringArgumentExpression, "Require with string must have a string argument"); + solAssert(_stringArgumentExpression->annotation().type); + std::vector functionParameterNames = IRVariable(*_stringArgumentExpression).stackSlots(); - std::string const encodeFunc = ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector) - .tupleEncoder( - {_messageType}, - {TypeProvider::stringMemory()} - ); + return Whiskers(R"( + function (condition ) { + if iszero(condition) + + } + )") + ("functionName", functionName) + ("revertWithError", revertWithError("Error(string)", {TypeProvider::stringMemory()}, {_stringArgumentExpression})) + ("functionParameterNames", joinHumanReadablePrefixed(functionParameterNames)) + .render(); + }); +} +std::string YulUtilFunctions::requireWithErrorFunction(FunctionCall const& errorConstructorCall) +{ + ErrorDefinition const* errorDefinition = dynamic_cast(ASTNode::referencedDeclaration(errorConstructorCall.expression())); + solAssert(errorDefinition); + + std::string const errorSignature = errorDefinition->functionType(true)->externalSignature(); + // Note that in most cases we'll always generate one function per error definition, + // because types in the constructor call will match the ones in the definition. The only + // exception are calls with types, where each instance has its own type (e.g. literals). + std::string functionName = "require_helper_t_error_" + std::to_string(errorDefinition->id()) + "_" + errorDefinition->name(); + for (ASTPointer const& argument: errorConstructorCall.sortedArguments()) + { + solAssert(argument->annotation().type); + functionName += ("_" + argument->annotation().type->identifier()); + } + + std::vector functionParameterNames; + for (ASTPointer const& arg: errorConstructorCall.sortedArguments()) + { + solAssert(arg->annotation().type); + if (arg->annotation().type->sizeOnStack() > 0) + functionParameterNames += IRVariable(*arg).stackSlots(); + } + + return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( - function (condition ) { - if iszero(condition) { - let memPtr := () - mstore(memPtr, ) - let end := (add(memPtr, ) ) - revert(memPtr, sub(end, memPtr)) - } + function (condition ) { + if iszero(condition) + } )") ("functionName", functionName) - ("allocateUnbounded", allocateUnboundedFunction()) - ("errorHash", formatNumber(errorHash)) - ("abiEncodeFunc", encodeFunc) - ("hashHeaderSize", std::to_string(hashHeaderSize)) - ("messageVars", - (_messageType->sizeOnStack() > 0 ? ", " : "") + - suffixedVariableNameList("message_", 1, 1 + _messageType->sizeOnStack()) - ) + ("functionParameterNames", joinHumanReadablePrefixed(functionParameterNames)) + // We're creating parameter names from the expressions passed into the constructor call, + // which will result in odd names like `expr_29` that would normally be used for locals. + // Note that this is the naming expected by `revertWithError()`. + ("revertWithError", revertWithError(errorSignature, errorDefinition->functionType(true)->parameterTypes(), errorConstructorCall.sortedArguments())) .render(); }); } diff --git a/libsolidity/codegen/YulUtilFunctions.h b/libsolidity/codegen/YulUtilFunctions.h index 7d736df5b3bc..a1b45b656f13 100644 --- a/libsolidity/codegen/YulUtilFunctions.h +++ b/libsolidity/codegen/YulUtilFunctions.h @@ -90,9 +90,29 @@ class YulUtilFunctions /// signature: (slot) -> std::string copyLiteralToStorageFunction(std::string const& _literal); + /// @returns statements to revert with an error. + /// Generates code to revert with an error. The error arguments are assumed to + /// be already evaluated and available in local IRVariables, but not yet + /// converted. + std::string revertWithError( + std::string const& _signature, + std::vector const& _parameterTypes, + std::vector> const& _errorArguments, + std::string const& _posVar = {}, + std::string const& _endVar = {} + ); + // @returns the name of a function that has the equivalent logic of an // `assert` or `require` call. - std::string requireOrAssertFunction(bool _assert, Type const* _messageType = nullptr); + std::string requireOrAssertFunction( + bool _assert, + Type const* _messageType = nullptr, + ASTPointer _stringArgumentExpression = nullptr + ); + + // @returns function that has equivalent logic of a require function, but with a custom + // error constructor parameter. + std::string requireWithErrorFunction(FunctionCall const& errorConstructorCall); /// @returns the name of a function that takes a (cleaned) value of the given value type and /// left-aligns it, usually for use in non-padded encoding. diff --git a/libsolidity/codegen/ir/Common.h b/libsolidity/codegen/ir/Common.h index 2484ad80914f..cf5bc69c7bea 100644 --- a/libsolidity/codegen/ir/Common.h +++ b/libsolidity/codegen/ir/Common.h @@ -81,7 +81,7 @@ std::string dispenseLocationComment(ASTNode const& _node, IRGenerationContext& _ } // Overloading std::less() makes it possible to use YulArity as a map key. We could define operator< -// instead but such an operator would be a bit ambiguous (e.g. YulArity{2, 2} would be be greater than +// instead but such an operator would be a bit ambiguous (e.g. YulArity{2, 2} would be greater than // YulArity{1, 10} in lexicographical order but the latter has greater total number of inputs and outputs). template<> struct std::less diff --git a/libsolidity/codegen/ir/IRGenerationContext.h b/libsolidity/codegen/ir/IRGenerationContext.h index a80a18a62a10..8e03a378b302 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.h +++ b/libsolidity/codegen/ir/IRGenerationContext.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace solidity::frontend { diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index 6096a98c192f..a344233ecffa 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -37,8 +37,7 @@ #include #include #include - -#include +#include #include #include diff --git a/libsolidity/codegen/ir/IRGenerator.h b/libsolidity/codegen/ir/IRGenerator.h index 9026954d6100..9f01b74fc246 100644 --- a/libsolidity/codegen/ir/IRGenerator.h +++ b/libsolidity/codegen/ir/IRGenerator.h @@ -23,6 +23,8 @@ #pragma once +#include + #include #include #include @@ -32,8 +34,6 @@ #include #include -#include - #include namespace solidity::frontend diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 2a22ce02faa2..a242b386f239 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -796,6 +796,17 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation) return false; } +void IRGeneratorForStatements::endVisit(RevertStatement const& _revertStatement) +{ + ErrorDefinition const* error = dynamic_cast(ASTNode::referencedDeclaration(_revertStatement.errorCall().expression())); + solAssert(error); + revertWithError( + error->functionType(true)->externalSignature(), + error->functionType(true)->parameterTypes(), + _revertStatement.errorCall().sortedArguments() + ); +} + bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp) { setLocation(_binOp); @@ -1114,17 +1125,6 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) appendCode() << templ.render(); break; } - case FunctionType::Kind::Error: - { - ErrorDefinition const* error = dynamic_cast(ASTNode::referencedDeclaration(_functionCall.expression())); - solAssert(error); - revertWithError( - error->functionType(true)->externalSignature(), - error->functionType(true)->parameterTypes(), - _functionCall.sortedArguments() - ); - break; - } case FunctionType::Kind::Wrap: case FunctionType::Kind::Unwrap: { @@ -1153,15 +1153,30 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) arguments.size() > 1 && m_context.revertStrings() != RevertStrings::Strip ? arguments[1]->annotation().type : nullptr; - std::string requireOrAssertFunction = m_utils.requireOrAssertFunction( - functionType->kind() == FunctionType::Kind::Assert, - messageArgumentType - ); - appendCode() << std::move(requireOrAssertFunction) << "(" << IRVariable(*arguments[0]).name(); - if (messageArgumentType && messageArgumentType->sizeOnStack() > 0) - appendCode() << ", " << IRVariable(*arguments[1]).commaSeparatedList(); - appendCode() << ")\n"; + auto const* magicType = dynamic_cast(messageArgumentType); + if (magicType && magicType->kind() == MagicType::Kind::Error) + { + auto const& errorConstructorCall = dynamic_cast(*arguments[1]); + appendCode() << m_utils.requireWithErrorFunction(errorConstructorCall) << "(" <annotation().type->sizeOnStack() > 0) + appendCode() << ", " << IRVariable(*argument).commaSeparatedList(); + appendCode() << ")\n"; + } + else + { + ASTPointer stringArgumentExpression = messageArgumentType ? arguments[1] : nullptr; + std::string requireOrAssertFunction = m_utils.requireOrAssertFunction( + functionType->kind() == FunctionType::Kind::Assert, + messageArgumentType, + stringArgumentExpression + ); + appendCode() << std::move(requireOrAssertFunction) << "(" << IRVariable(*arguments[0]).name(); + if (messageArgumentType && messageArgumentType->sizeOnStack() > 0) + appendCode() << ", " << IRVariable(*arguments[1]).commaSeparatedList(); + appendCode() << ")\n"; + } break; } @@ -1467,6 +1482,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) ")\n"; break; } + case FunctionType::Kind::Error: case FunctionType::Kind::MetaType: { break; @@ -3771,32 +3787,15 @@ void IRGeneratorForStatements::revertWithError( std::vector> const& _errorArguments ) { - Whiskers templ(R"({ - let := () - mstore(, ) - let := (add(, 4) ) - revert(, sub(, )) - })"); - templ("pos", m_context.newYulVariable()); - templ("end", m_context.newYulVariable()); - templ("hash", util::selectorFromSignatureU256(_signature).str()); - templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); - - std::vector errorArgumentVars; - std::vector errorArgumentTypes; - for (ASTPointer const& arg: _errorArguments) - { - errorArgumentVars += IRVariable(*arg).stackSlots(); - solAssert(arg->annotation().type); - errorArgumentTypes.push_back(arg->annotation().type); - } - templ("argumentVars", joinHumanReadablePrefixed(errorArgumentVars)); - templ("encode", m_context.abiFunctions().tupleEncoder(errorArgumentTypes, _parameterTypes)); - - appendCode() << templ.render(); + appendCode() << m_utils.revertWithError( + _signature, + _parameterTypes, + _errorArguments, + m_context.newYulVariable(), + m_context.newYulVariable() + ); } - bool IRGeneratorForStatements::visit(TryCatchClause const& _clause) { _clause.block().accept(*this); diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.h b/libsolidity/codegen/ir/IRGeneratorForStatements.h index f4ce2a7d00a1..15ef71f13844 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.h +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.h @@ -132,6 +132,7 @@ class IRGeneratorForStatements: public IRGeneratorForStatementsBase void endVisit(IndexRangeAccess const& _indexRangeAccess) override; void endVisit(Identifier const& _identifier) override; bool visit(Literal const& _literal) override; + void endVisit(RevertStatement const& _revertStatement) override; bool visit(TryStatement const& _tryStatement) override; bool visit(TryCatchClause const& _tryCatchClause) override; diff --git a/libsolidity/experimental/codegen/IRGenerator.cpp b/libsolidity/experimental/codegen/IRGenerator.cpp index 257bd2be16ba..40deb38c397e 100644 --- a/libsolidity/experimental/codegen/IRGenerator.cpp +++ b/libsolidity/experimental/codegen/IRGenerator.cpp @@ -52,14 +52,13 @@ IRGenerator::IRGenerator( DebugInfoSelection const&, CharStreamProvider const*, Analysis const& _analysis -) -: -m_evmVersion(_evmVersion), -m_eofVersion(_eofVersion), -// m_debugInfoSelection(_debugInfoSelection), -// m_soliditySourceProvider(_soliditySourceProvider), -m_env(_analysis.typeSystem().env().clone()), -m_context{_analysis, &m_env, {}, {}} +): + m_evmVersion(_evmVersion), + m_eofVersion(_eofVersion), + //m_debugInfoSelection(_debugInfoSelection), + //m_soliditySourceProvider(_soliditySourceProvider), + m_env(_analysis.typeSystem().env().clone()), + m_context{_analysis, &m_env, {}, {}} { } diff --git a/libsolidity/experimental/codegen/IRGenerator.h b/libsolidity/experimental/codegen/IRGenerator.h index cce8c730572b..5da6f9f6fd6a 100644 --- a/libsolidity/experimental/codegen/IRGenerator.h +++ b/libsolidity/experimental/codegen/IRGenerator.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include @@ -63,8 +63,8 @@ class IRGenerator langutil::EVMVersion const m_evmVersion; std::optional const m_eofVersion; OptimiserSettings const m_optimiserSettings; -// langutil::DebugInfoSelection m_debugInfoSelection = {}; -// langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr; + //langutil::DebugInfoSelection m_debugInfoSelection = {}; + //langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr; TypeEnvironment m_env; IRGenerationContext m_context; }; diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index b16182af8c88..97dd7050fef8 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -349,7 +349,7 @@ bool BMC::visit(WhileStatement const& _node) _node.body().accept(*this); popPathCondition(); - auto brokeInCurrentIteration = mergeVariablesFromLoopCheckpoints(); + auto brokeInCurrentIteration = mergeVariablesFromLoopCheckpoints(); // merges indices modified when accepting loop condition that no longer holds mergeVariables( @@ -414,7 +414,7 @@ bool BMC::visit(ForStatement const& _node) pushPathCondition(forCondition); _node.body().accept(*this); - auto brokeInCurrentIteration = mergeVariablesFromLoopCheckpoints(); + auto brokeInCurrentIteration = mergeVariablesFromLoopCheckpoints(); // accept loop expression if there was no break if (_node.loopExpression()) @@ -1050,6 +1050,12 @@ void BMC::checkDivByZero(BMCVerificationTarget& _target) void BMC::checkBalance(BMCVerificationTarget& _target) { solAssert(_target.type == VerificationTargetType::Balance, ""); + + if ( + m_solvedTargets.count(_target.expression) && + m_solvedTargets.at(_target.expression).count(VerificationTargetType::Balance) + ) + return; checkCondition( _target, _target.constraints && _target.value, diff --git a/libsolidity/formal/BMC.h b/libsolidity/formal/BMC.h index 9daa1683721c..1f97cbeef480 100644 --- a/libsolidity/formal/BMC.h +++ b/libsolidity/formal/BMC.h @@ -41,6 +41,7 @@ #include #include #include +#include using solidity::util::h256; diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index 2c9075abcc4a..b6ffd5954ffb 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -607,6 +607,22 @@ void CHC::endVisit(FunctionCall const& _funCall) SMTEncoder::endVisit(_funCall); unknownFunctionCall(_funCall); break; + case FunctionType::Kind::Send: + case FunctionType::Kind::Transfer: + { + auto value = _funCall.arguments().front(); + solAssert(value, ""); + smtutil::Expression thisBalance = state().balance(); + + verificationTargetEncountered( + &_funCall, + VerificationTargetType::Balance, + thisBalance < expr(*value) + ); + + SMTEncoder::endVisit(_funCall); + break; + } case FunctionType::Kind::KECCAK256: case FunctionType::Kind::ECRecover: case FunctionType::Kind::SHA256: @@ -2013,6 +2029,8 @@ std::pair CHC::targetDescription(CHCVerificationTarget con return {"Division by zero", 4281_error}; else if (_target.type == VerificationTargetType::Assert) return {"Assertion violation", 6328_error}; + else if (_target.type == VerificationTargetType::Balance) + return {"Insufficient funds", 8656_error}; else solAssert(false); } diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 5051220c005c..92ba938ba284 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -1302,8 +1302,27 @@ void SMTEncoder::addArrayLiteralAssertions( ) { m_context.addAssertion(_symArray.length() == _elementValues.size()); + + // Assert to the solver that _elementValues are exactly the elements at the beginning of the array. + // Since we create new symbolic representation for every array literal in the source file, we want to ensure that + // representations of two equal literals are also equal. For this reason we always start from constant-zero array. + // This ensures SMT-LIB arrays (which are infinite) are also equal beyond the length of the Solidity array literal. + auto type = _symArray.type(); + smtAssert(type); + auto valueType = [&]() { + if (auto const* arrayType = dynamic_cast(type)) + return arrayType->baseType(); + if (smt::isStringLiteral(*type)) + return TypeProvider::stringMemory()->baseType(); + smtAssert(false); + }(); + auto tupleSort = std::dynamic_pointer_cast(smt::smtSort(*type)); + auto sortSort = std::make_shared(tupleSort->components.front()); + smtutil::Expression arrayExpr = smtutil::Expression::const_array(smtutil::Expression(sortSort), smt::zeroValue(valueType)); + smtAssert(arrayExpr.sort->kind == smtutil::Kind::Array); for (size_t i = 0; i < _elementValues.size(); i++) - m_context.addAssertion(smtutil::Expression::select(_symArray.elements(), i) == _elementValues[i]); + arrayExpr = smtutil::Expression::store(arrayExpr, smtutil::Expression(i), _elementValues[i]); + m_context.addAssertion(_symArray.elements() == arrayExpr); } void SMTEncoder::bytesToFixedBytesAssertions( diff --git a/libsolidity/formal/SMTEncoder.h b/libsolidity/formal/SMTEncoder.h index be676930cab1..bea3a85ef9c8 100644 --- a/libsolidity/formal/SMTEncoder.h +++ b/libsolidity/formal/SMTEncoder.h @@ -277,7 +277,7 @@ class SMTEncoder: public ASTConstVisitor /// @returns a pair of expressions representing _left / _right and _left mod _right, respectively. /// Uses slack variables and additional constraints to express the results using only operations /// more friendly to the SMT solver (multiplication, addition, subtraction and comparison). - std::pair divModWithSlacks( + std::pair divModWithSlacks( smtutil::Expression _left, smtutil::Expression _right, IntegerType const& _type diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index cf6e863bbbf2..e06f4b5828cc 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -38,12 +38,14 @@ bool anyDataStoredInStorage(TypePointers const& _pointers) } } -Json::Value ABI::generate(ContractDefinition const& _contractDef) +Json ABI::generate(ContractDefinition const& _contractDef) { - auto compare = [](Json::Value const& _a, Json::Value const& _b) -> bool { - return std::make_tuple(_a["type"], _a["name"]) < std::make_tuple(_b["type"], _b["name"]); + auto compare = [](Json const& _a, Json const& _b) -> bool + { + return std::make_tuple(_a.value("type", Json()), _a.value("name", Json())) < + std::make_tuple(_b.value("type", Json()), _b.value("name", Json())); }; - std::multiset abi(compare); + std::multiset abi(compare); for (auto it: _contractDef.interfaceFunctions()) { @@ -55,7 +57,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) FunctionType const* externalFunctionType = it.second->interfaceFunctionType(); solAssert(!!externalFunctionType, ""); - Json::Value method{Json::objectValue}; + Json method; method["type"] = "function"; method["name"] = it.second->declaration().name(); method["stateMutability"] = stateMutabilityToString(externalFunctionType->stateMutability()); @@ -79,7 +81,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) FunctionType constrType(*constructor); FunctionType const* externalFunctionType = constrType.interfaceFunctionType(); solAssert(!!externalFunctionType, ""); - Json::Value method{Json::objectValue}; + Json method; method["type"] = "constructor"; method["stateMutability"] = stateMutabilityToString(externalFunctionType->stateMutability()); method["inputs"] = formatTypeList( @@ -95,25 +97,25 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) { auto const* externalFunctionType = FunctionType(*fallbackOrReceive).interfaceFunctionType(); solAssert(!!externalFunctionType, ""); - Json::Value method{Json::objectValue}; + Json method; method["type"] = TokenTraits::toString(fallbackOrReceive->kind()); method["stateMutability"] = stateMutabilityToString(externalFunctionType->stateMutability()); abi.emplace(std::move(method)); } for (auto const& it: _contractDef.interfaceEvents()) { - Json::Value event{Json::objectValue}; + Json event; event["type"] = "event"; event["name"] = it->name(); event["anonymous"] = it->isAnonymous(); - Json::Value params{Json::arrayValue}; + Json params = Json::array(); for (auto const& p: it->parameters()) { Type const* type = p->annotation().type->interfaceType(false); solAssert(type, ""); auto param = formatType(p->name(), *type, *p->annotation().type, false); param["indexed"] = p->isIndexed(); - params.append(std::move(param)); + params.emplace_back(param); } event["inputs"] = std::move(params); abi.emplace(std::move(event)); @@ -121,53 +123,53 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) for (ErrorDefinition const* error: _contractDef.interfaceErrors()) { - Json::Value errorJson{Json::objectValue}; + Json errorJson; errorJson["type"] = "error"; errorJson["name"] = error->name(); - errorJson["inputs"] = Json::arrayValue; + errorJson["inputs"] = Json::array(); for (auto const& p: error->parameters()) { Type const* type = p->annotation().type->interfaceType(false); solAssert(type, ""); - errorJson["inputs"].append( + errorJson["inputs"].emplace_back( formatType(p->name(), *type, *p->annotation().type, false) ); } abi.emplace(std::move(errorJson)); } - Json::Value abiJson{Json::arrayValue}; + Json abiJson = Json::array(); for (auto& f: abi) - abiJson.append(std::move(f)); + abiJson.emplace_back(std::move(f)); return abiJson; } -Json::Value ABI::formatTypeList( +Json ABI::formatTypeList( std::vector const& _names, std::vector const& _encodingTypes, std::vector const& _solidityTypes, bool _forLibrary ) { - Json::Value params{Json::arrayValue}; + Json params = Json::array(); solAssert(_names.size() == _encodingTypes.size(), "Names and types vector size does not match"); solAssert(_names.size() == _solidityTypes.size(), ""); for (unsigned i = 0; i < _names.size(); ++i) { solAssert(_encodingTypes[i], ""); - params.append(formatType(_names[i], *_encodingTypes[i], *_solidityTypes[i], _forLibrary)); + params.emplace_back(formatType(_names[i], *_encodingTypes[i], *_solidityTypes[i], _forLibrary)); } return params; } -Json::Value ABI::formatType( +Json ABI::formatType( std::string const& _name, Type const& _encodingType, Type const& _solidityType, bool _forLibrary ) { - Json::Value ret{Json::objectValue}; + Json ret; ret["name"] = _name; ret["internalType"] = _solidityType.toString(true); std::string suffix = (_forLibrary && _encodingType.dataStoredIn(DataLocation::Storage)) ? " storage" : ""; @@ -185,31 +187,31 @@ Json::Value ABI::formatType( else suffix = std::string("[") + arrayType->length().str() + "]"; solAssert(arrayType->baseType(), ""); - Json::Value subtype = formatType( + Json subtype = formatType( "", *arrayType->baseType(), *dynamic_cast(_solidityType).baseType(), _forLibrary ); - if (subtype.isMember("components")) + if (subtype.contains("components")) { - ret["type"] = subtype["type"].asString() + suffix; + ret["type"] = subtype["type"].get() + suffix; ret["components"] = subtype["components"]; } else - ret["type"] = subtype["type"].asString() + suffix; + ret["type"] = subtype["type"].get() + suffix; } } else if (StructType const* structType = dynamic_cast(&_encodingType)) { ret["type"] = "tuple"; - ret["components"] = Json::arrayValue; + ret["components"] = Json::array(); for (auto const& member: structType->members(nullptr)) { solAssert(member.type, ""); Type const* t = member.type->interfaceType(_forLibrary); solAssert(t, ""); - ret["components"].append(formatType(member.name, *t, *member.type, _forLibrary)); + ret["components"].emplace_back(formatType(member.name, *t, *member.type, _forLibrary)); } } else diff --git a/libsolidity/interface/ABI.h b/libsolidity/interface/ABI.h index e956614497db..22e306c4322b 100644 --- a/libsolidity/interface/ABI.h +++ b/libsolidity/interface/ABI.h @@ -21,7 +21,7 @@ #pragma once -#include +#include #include #include @@ -38,14 +38,14 @@ class ABI /// Get the ABI Interface of the contract /// @param _contractDef The contract definition /// @return A JSONrepresentation of the contract's ABI Interface - static Json::Value generate(ContractDefinition const& _contractDef); + static Json generate(ContractDefinition const& _contractDef); private: /// @returns a json value suitable for a list of types in function input or output /// parameters or other places. If @a _forLibrary is true, complex types are referenced /// by name, otherwise they are anonymously expanded. /// @a _solidityTypes is the list of original Solidity types where @a _encodingTypes is the list of /// ABI types used for the actual encoding. - static Json::Value formatTypeList( + static Json formatTypeList( std::vector const& _names, std::vector const& _encodingTypes, std::vector const& _solidityTypes, @@ -56,7 +56,7 @@ class ABI /// If it is possible to express the type as a single string, it is allowed to return a single string. /// @a _solidityType is the original Solidity type and @a _encodingTypes is the /// ABI type used for the actual encoding. - static Json::Value formatType( + static Json formatType( std::string const& _name, Type const& _encodingType, Type const& _solidityType, diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index daec0f1df651..195eae98121b 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -85,8 +85,6 @@ #include #include -#include - #include #include @@ -426,7 +424,7 @@ bool CompilerStack::parse() return true; } -void CompilerStack::importASTs(std::map const& _sources) +void CompilerStack::importASTs(std::map const& _sources) { if (m_stackState != Empty) solThrow(CompilerError, "Must call importASTs only before the SourcesSet state."); @@ -659,7 +657,7 @@ bool CompilerStack::analyzeLegacy(bool _noErrorsSoFar) m_modelCheckerSettings.solvers = ModelChecker::checkRequestedSolvers(m_modelCheckerSettings.solvers, m_errorReporter); if (auto* universalCallback = m_readFile.target()) if (m_modelCheckerSettings.solvers.eld) - universalCallback->smtCommand().setEldarica(m_modelCheckerSettings.timeout); + universalCallback->smtCommand().setEldarica(m_modelCheckerSettings.timeout, m_modelCheckerSettings.invariants != ModelCheckerInvariants::None()); } ModelChecker modelChecker(m_errorReporter, *this, m_smtlib2Responses, m_modelCheckerSettings, m_readFile); @@ -843,18 +841,18 @@ evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(std::string con return currentContract.evmRuntimeAssembly ? ¤tContract.evmRuntimeAssembly->items() : nullptr; } -Json::Value CompilerStack::generatedSources(std::string const& _contractName, bool _runtime) const +Json CompilerStack::generatedSources(std::string const& _contractName, bool _runtime) const { if (m_stackState != CompilationSuccessful) solThrow(CompilerError, "Compilation was not successful."); Contract const& c = contract(_contractName); - util::LazyInit const& sources = + util::LazyInit const& sources = _runtime ? c.runtimeGeneratedSources : c.generatedSources; return sources.init([&]{ - Json::Value sources{Json::arrayValue}; + Json sources = Json::array(); // If there is no compiler, then no bytecode was generated and thus no // sources were generated (or we compiled "via IR"). if (c.compiler) @@ -947,7 +945,7 @@ std::string const& CompilerStack::yulIR(std::string const& _contractName) const return contract(_contractName).yulIR; } -Json::Value const& CompilerStack::yulIRAst(std::string const& _contractName) const +Json const& CompilerStack::yulIRAst(std::string const& _contractName) const { if (m_stackState != CompilationSuccessful) solThrow(CompilerError, "Compilation was not successful."); @@ -965,7 +963,7 @@ std::string const& CompilerStack::yulIROptimized(std::string const& _contractNam return contract(_contractName).yulIROptimized; } -Json::Value const& CompilerStack::yulIROptimizedAst(std::string const& _contractName) const +Json const& CompilerStack::yulIROptimizedAst(std::string const& _contractName) const { if (m_stackState != CompilationSuccessful) solThrow(CompilerError, "Compilation was not successful."); @@ -1005,7 +1003,7 @@ std::string CompilerStack::assemblyString(std::string const& _contractName, Stri } /// TODO: cache the JSON -Json::Value CompilerStack::assemblyJSON(std::string const& _contractName) const +Json CompilerStack::assemblyJSON(std::string const& _contractName) const { if (m_stackState != CompilationSuccessful) solThrow(CompilerError, "Compilation was not successful."); @@ -1016,7 +1014,7 @@ Json::Value CompilerStack::assemblyJSON(std::string const& _contractName) const if (currentContract.evmAssembly) return currentContract.evmAssembly->assemblyJSON(sourceIndices()); else - return Json::Value(); + return Json(); } std::vector CompilerStack::sourceNames() const @@ -1035,7 +1033,7 @@ std::map CompilerStack::sourceIndices() const return indices; } -Json::Value const& CompilerStack::contractABI(std::string const& _contractName) const +Json const& CompilerStack::contractABI(std::string const& _contractName) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1043,7 +1041,7 @@ Json::Value const& CompilerStack::contractABI(std::string const& _contractName) return contractABI(contract(_contractName)); } -Json::Value const& CompilerStack::contractABI(Contract const& _contract) const +Json const& CompilerStack::contractABI(Contract const& _contract) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1054,7 +1052,7 @@ Json::Value const& CompilerStack::contractABI(Contract const& _contract) const return _contract.abi.init([&]{ return ABI::generate(*_contract.contract); }); } -Json::Value const& CompilerStack::storageLayout(std::string const& _contractName) const +Json const& CompilerStack::storageLayout(std::string const& _contractName) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1062,7 +1060,7 @@ Json::Value const& CompilerStack::storageLayout(std::string const& _contractName return storageLayout(contract(_contractName)); } -Json::Value const& CompilerStack::storageLayout(Contract const& _contract) const +Json const& CompilerStack::storageLayout(Contract const& _contract) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1073,7 +1071,7 @@ Json::Value const& CompilerStack::storageLayout(Contract const& _contract) const return _contract.storageLayout.init([&]{ return StorageLayout().generate(*_contract.contract); }); } -Json::Value const& CompilerStack::natspecUser(std::string const& _contractName) const +Json const& CompilerStack::natspecUser(std::string const& _contractName) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1081,7 +1079,7 @@ Json::Value const& CompilerStack::natspecUser(std::string const& _contractName) return natspecUser(contract(_contractName)); } -Json::Value const& CompilerStack::natspecUser(Contract const& _contract) const +Json const& CompilerStack::natspecUser(Contract const& _contract) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1092,7 +1090,7 @@ Json::Value const& CompilerStack::natspecUser(Contract const& _contract) const return _contract.userDocumentation.init([&]{ return Natspec::userDocumentation(*_contract.contract); }); } -Json::Value const& CompilerStack::natspecDev(std::string const& _contractName) const +Json const& CompilerStack::natspecDev(std::string const& _contractName) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1100,7 +1098,7 @@ Json::Value const& CompilerStack::natspecDev(std::string const& _contractName) c return natspecDev(contract(_contractName)); } -Json::Value const& CompilerStack::natspecDev(Contract const& _contract) const +Json const& CompilerStack::natspecDev(Contract const& _contract) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); @@ -1112,16 +1110,16 @@ Json::Value const& CompilerStack::natspecDev(Contract const& _contract) const return _contract.devDocumentation.init([&]{ return Natspec::devDocumentation(*_contract.contract); }); } -Json::Value CompilerStack::interfaceSymbols(std::string const& _contractName) const +Json CompilerStack::interfaceSymbols(std::string const& _contractName) const { if (m_stackState < AnalysisSuccessful) solThrow(CompilerError, "Analysis was not successful."); solUnimplementedAssert(!isExperimentalSolidity()); - Json::Value interfaceSymbols(Json::objectValue); + Json interfaceSymbols; // Always have a methods object - interfaceSymbols["methods"] = Json::objectValue; + interfaceSymbols["methods"] = Json::object(); for (auto const& it: contractDefinition(_contractName).interfaceFunctions()) interfaceSymbols["methods"][it.second->externalSignature()] = it.first.hex(); @@ -1650,7 +1648,7 @@ CompilerStack::Source const& CompilerStack::source(std::string const& _sourceNam std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR) const { - Json::Value meta{Json::objectValue}; + Json meta; meta["version"] = 1; std::string sourceType; switch (m_compilationSourceType) @@ -1671,7 +1669,7 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR for (auto const sourceUnit: _contract.contract->sourceUnit().referencedSourceUnits(true)) referencedSources.insert(*sourceUnit->annotation().path); - meta["sources"] = Json::objectValue; + meta["sources"] = Json::object(); for (auto const& s: m_sources) { if (!referencedSources.count(s.first)) @@ -1685,15 +1683,15 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR meta["sources"][s.first]["content"] = s.second.charStream->source(); else { - meta["sources"][s.first]["urls"] = Json::arrayValue; - meta["sources"][s.first]["urls"].append("bzz-raw://" + util::toHex(s.second.swarmHash().asBytes())); - meta["sources"][s.first]["urls"].append(s.second.ipfsUrl()); + meta["sources"][s.first]["urls"] = Json::array(); + meta["sources"][s.first]["urls"].emplace_back("bzz-raw://" + util::toHex(s.second.swarmHash().asBytes())); + meta["sources"][s.first]["urls"].emplace_back(s.second.ipfsUrl()); } } - static_assert(sizeof(m_optimiserSettings.expectedExecutionsPerDeployment) <= sizeof(Json::LargestUInt), "Invalid word size."); - solAssert(static_cast(m_optimiserSettings.expectedExecutionsPerDeployment) < std::numeric_limits::max(), ""); - meta["settings"]["optimizer"]["runs"] = Json::Value(Json::LargestUInt(m_optimiserSettings.expectedExecutionsPerDeployment)); + static_assert(sizeof(m_optimiserSettings.expectedExecutionsPerDeployment) <= sizeof(Json::number_integer_t), "Invalid word size."); + solAssert(static_cast(m_optimiserSettings.expectedExecutionsPerDeployment) < std::numeric_limits::max(), ""); + meta["settings"]["optimizer"]["runs"] = Json::number_integer_t(m_optimiserSettings.expectedExecutionsPerDeployment); /// Backwards compatibility: If set to one of the default settings, do not provide details. OptimiserSettings settingsWithoutRuns = m_optimiserSettings; @@ -1705,7 +1703,7 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR meta["settings"]["optimizer"]["enabled"] = true; else { - Json::Value details{Json::objectValue}; + Json details = Json::object(); details["orderLiterals"] = m_optimiserSettings.runOrderLiterals; details["inliner"] = m_optimiserSettings.runInliner; @@ -1718,17 +1716,14 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR details["yul"] = m_optimiserSettings.runYulOptimiser; if (m_optimiserSettings.runYulOptimiser) { - details["yulDetails"] = Json::objectValue; + details["yulDetails"] = Json::object(); details["yulDetails"]["stackAllocation"] = m_optimiserSettings.optimizeStackAllocation; details["yulDetails"]["optimizerSteps"] = m_optimiserSettings.yulOptimiserSteps + ":" + m_optimiserSettings.yulOptimiserCleanupSteps; } - else if ( - OptimiserSuite::isEmptyOptimizerSequence(m_optimiserSettings.yulOptimiserSteps) && - OptimiserSuite::isEmptyOptimizerSequence(m_optimiserSettings.yulOptimiserCleanupSteps) - ) + else if (OptimiserSuite::isEmptyOptimizerSequence(m_optimiserSettings.yulOptimiserSteps + ":" + m_optimiserSettings.yulOptimiserCleanupSteps)) { solAssert(m_optimiserSettings.optimizeStackAllocation == false); - details["yulDetails"] = Json::objectValue; + details["yulDetails"] = Json::object(); details["yulDetails"]["optimizerSteps"] = ":"; } else @@ -1761,14 +1756,14 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] = *_contract.contract->annotation().canonicalName; - meta["settings"]["remappings"] = Json::arrayValue; + meta["settings"]["remappings"] = Json::array(); std::set remappings; for (auto const& r: m_importRemapper.remappings()) remappings.insert(r.context + ":" + r.prefix + "=" + r.target); for (auto const& r: remappings) - meta["settings"]["remappings"].append(r); + meta["settings"]["remappings"].emplace_back(r); - meta["settings"]["libraries"] = Json::objectValue; + meta["settings"]["libraries"] = Json::object(); for (auto const& library: m_libraries) meta["settings"]["libraries"][library.first] = "0x" + util::toHex(library.second.asBytes()); @@ -1900,17 +1895,17 @@ bytes CompilerStack::createCBORMetadata(Contract const& _contract, bool _forIR) namespace { -Json::Value gasToJson(GasEstimator::GasConsumption const& _gas) +Json gasToJson(GasEstimator::GasConsumption const& _gas) { if (_gas.isInfinite) - return Json::Value("infinite"); + return Json("infinite"); else - return Json::Value(util::toString(_gas.value)); + return Json(util::toString(_gas.value)); } } -Json::Value CompilerStack::gasEstimates(std::string const& _contractName) const +Json CompilerStack::gasEstimates(std::string const& _contractName) const { if (m_stackState != CompilationSuccessful) solThrow(CompilerError, "Compilation was not successful."); @@ -1918,18 +1913,18 @@ Json::Value CompilerStack::gasEstimates(std::string const& _contractName) const solUnimplementedAssert(!isExperimentalSolidity()); if (!assemblyItems(_contractName) && !runtimeAssemblyItems(_contractName)) - return Json::Value(); + return Json(); using Gas = GasEstimator::GasConsumption; GasEstimator gasEstimator(m_evmVersion); - Json::Value output(Json::objectValue); + Json output = Json::object(); if (evmasm::AssemblyItems const* items = assemblyItems(_contractName)) { Gas executionGas = gasEstimator.functionalEstimation(*items); Gas codeDepositGas{evmasm::GasMeter::dataGas(runtimeObject(_contractName).bytecode, false, m_evmVersion)}; - Json::Value creation(Json::objectValue); + Json creation = Json::object(); creation["codeDepositCost"] = gasToJson(codeDepositGas); creation["executionCost"] = gasToJson(executionGas); /// TODO: implement + overload to avoid the need of += @@ -1942,7 +1937,7 @@ Json::Value CompilerStack::gasEstimates(std::string const& _contractName) const { /// External functions ContractDefinition const& contract = contractDefinition(_contractName); - Json::Value externalFunctions(Json::objectValue); + Json externalFunctions = Json::object(); for (auto it: contract.interfaceFunctions()) { std::string sig = it.second->externalSignature(); @@ -1959,7 +1954,7 @@ Json::Value CompilerStack::gasEstimates(std::string const& _contractName) const output["external"] = externalFunctions; /// Internal functions - Json::Value internalFunctions(Json::objectValue); + Json internalFunctions = Json::object(); for (auto const& it: contract.definedFunctions()) { /// Exclude externally visible functions, constructor, fallback and receive ether function diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 57d30e602d1d..ef76764faf70 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -47,8 +47,7 @@ #include #include #include - -#include +#include #include #include @@ -221,7 +220,7 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac /// Imports given SourceUnits so they can be analyzed. Leads to the same internal state as parse(). /// Will throw errors if the import fails - void importASTs(std::map const& _sources); + void importASTs(std::map const& _sources); /// Performs the analysis steps (imports, scopesetting, syntaxCheck, referenceResolving, /// typechecking, staticAnalysis) on previously parsed sources. @@ -277,13 +276,13 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac std::string const& yulIR(std::string const& _contractName) const; /// @returns the IR representation of a contract AST in format. - Json::Value const& yulIRAst(std::string const& _contractName) const; + Json const& yulIRAst(std::string const& _contractName) const; /// @returns the optimized IR representation of a contract. std::string const& yulIROptimized(std::string const& _contractName) const; /// @returns the optimized IR representation of a contract AST in JSON format. - Json::Value const& yulIROptimizedAst(std::string const& _contractName) const; + Json const& yulIROptimizedAst(std::string const& _contractName) const; /// @returns the assembled object for a contract. virtual evmasm::LinkerObject const& object(std::string const& _contractName) const override; @@ -299,7 +298,7 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac /// @returns an array containing all utility sources generated during compilation. /// Format: [ { name: string, id: number, language: "Yul", contents: string }, ... ] - Json::Value generatedSources(std::string const& _contractName, bool _runtime = false) const; + Json generatedSources(std::string const& _contractName, bool _runtime = false) const; /// @returns the string that provides a mapping between bytecode and sourcecode or a nullptr /// if the contract does not (yet) have bytecode. @@ -317,26 +316,26 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac /// @returns a JSON representation of the assembly. /// @arg _sourceCodes is the map of input files to source code strings /// Prerequisite: Successful compilation. - virtual Json::Value assemblyJSON(std::string const& _contractName) const override; + virtual Json assemblyJSON(std::string const& _contractName) const override; /// @returns a JSON representing the contract ABI. /// Prerequisite: Successful call to parse or compile. - Json::Value const& contractABI(std::string const& _contractName) const; + Json const& contractABI(std::string const& _contractName) const; /// @returns a JSON representing the storage layout of the contract. /// Prerequisite: Successful call to parse or compile. - Json::Value const& storageLayout(std::string const& _contractName) const; + Json const& storageLayout(std::string const& _contractName) const; /// @returns a JSON representing the contract's user documentation. /// Prerequisite: Successful call to parse or compile. - Json::Value const& natspecUser(std::string const& _contractName) const; + Json const& natspecUser(std::string const& _contractName) const; /// @returns a JSON representing the contract's developer documentation. /// Prerequisite: Successful call to parse or compile. - Json::Value const& natspecDev(std::string const& _contractName) const; + Json const& natspecDev(std::string const& _contractName) const; /// @returns a JSON object with the three members ``methods``, ``events``, ``errors``. Each is a map, mapping identifiers (hashes) to function names. - Json::Value interfaceSymbols(std::string const& _contractName) const; + Json interfaceSymbols(std::string const& _contractName) const; /// @returns the Contract Metadata matching the pipeline selected using the viaIR setting. std::string const& metadata(std::string const& _contractName) const { return metadata(contract(_contractName)); } @@ -350,7 +349,7 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac bytes cborMetadata(std::string const& _contractName, bool _forIR) const; /// @returns a JSON representing the estimated gas usage for contract creation, internal and external functions - Json::Value gasEstimates(std::string const& _contractName) const; + Json gasEstimates(std::string const& _contractName) const; /// Changes the format of the metadata appended at the end of the bytecode. void setMetadataFormat(MetadataFormat _metadataFormat) { m_metadataFormat = _metadataFormat; } @@ -390,15 +389,15 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac evmasm::LinkerObject runtimeObject; ///< Runtime object. std::string yulIR; ///< Yul IR code. std::string yulIROptimized; ///< Optimized Yul IR code. - Json::Value yulIRAst; ///< JSON AST of Yul IR code. - Json::Value yulIROptimizedAst; ///< JSON AST of optimized Yul IR code. + Json yulIRAst; ///< JSON AST of Yul IR code. + Json yulIROptimizedAst; ///< JSON AST of optimized Yul IR code. util::LazyInit metadata; ///< The metadata json that will be hashed into the chain. - util::LazyInit abi; - util::LazyInit storageLayout; - util::LazyInit userDocumentation; - util::LazyInit devDocumentation; - util::LazyInit generatedSources; - util::LazyInit runtimeGeneratedSources; + util::LazyInit abi; + util::LazyInit storageLayout; + util::LazyInit userDocumentation; + util::LazyInit devDocumentation; + util::LazyInit generatedSources; + util::LazyInit runtimeGeneratedSources; mutable std::optional sourceMapping; mutable std::optional runtimeSourceMapping; }; @@ -479,19 +478,19 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac /// @returns the contract ABI as a JSON object. /// This will generate the JSON object and store it in the Contract object if it is not present yet. - Json::Value const& contractABI(Contract const&) const; + Json const& contractABI(Contract const&) const; /// @returns the storage layout of the contract as a JSON object. /// This will generate the JSON object and store it in the Contract object if it is not present yet. - Json::Value const& storageLayout(Contract const&) const; + Json const& storageLayout(Contract const&) const; /// @returns the Natspec User documentation as a JSON object. /// This will generate the JSON object and store it in the Contract object if it is not present yet. - Json::Value const& natspecUser(Contract const&) const; + Json const& natspecUser(Contract const&) const; /// @returns the Natspec Developer documentation as a JSON object. /// This will generate the JSON object and store it in the Contract object if it is not present yet. - Json::Value const& natspecDev(Contract const&) const; + Json const& natspecDev(Contract const&) const; /// @returns the Contract Metadata matching the pipeline selected using the viaIR setting. /// This will generate the metadata and store it in the Contract object if it is not present yet. diff --git a/libsolidity/interface/FileReader.cpp b/libsolidity/interface/FileReader.cpp index 4197780e65b2..158d4dd2c95c 100644 --- a/libsolidity/interface/FileReader.cpp +++ b/libsolidity/interface/FileReader.cpp @@ -271,7 +271,7 @@ boost::filesystem::path FileReader::normalizeCLIPathForVFS( // If the path is on the same drive as the working dir, for portability we prefer not to // include the root name. Do this only for non-UNC paths - my experiments show that on Windows - // when the working dir is an UNC path, / does not not actually refer to the root of the UNC path. + // when the working dir is an UNC path, / does not actually refer to the root of the UNC path. boost::filesystem::path normalizedRootPath = normalizeCLIRootPathForVFS(normalizedPath, canonicalWorkDir); diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 539a3573f50b..a0da7b54bb5e 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -33,13 +33,13 @@ using namespace solidity; using namespace solidity::frontend; -Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) +Json Natspec::userDocumentation(ContractDefinition const& _contractDef) { - Json::Value doc{Json::objectValue}; + Json doc; - doc["version"] = Json::Value(c_natspecVersion); - doc["kind"] = Json::Value("user"); - doc["methods"] = Json::objectValue; + doc["version"] = Json(c_natspecVersion); + doc["kind"] = Json("user"); + doc["methods"] = Json::object(); auto constructorDefinition(_contractDef.constructor()); if (constructorDefinition) @@ -48,15 +48,15 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) if (!value.empty()) { // add the constructor, only if we have any documentation to add - Json::Value user{Json::objectValue}; - user["notice"] = Json::Value(value); + Json user; + user["notice"] = Json(value); doc["methods"]["constructor"] = user; } } std::string notice = extractDoc(_contractDef.annotation().docTags, "notice"); if (!notice.empty()) - doc["notice"] = Json::Value(notice); + doc["notice"] = Json(notice); for (auto const& it: _contractDef.interfaceFunctions()) if (it.second->hasDeclaration()) @@ -88,21 +88,21 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) std::string value = extractDoc(error->annotation().docTags, "notice"); if (!value.empty()) { - Json::Value errorDoc{Json::objectValue}; + Json errorDoc; errorDoc["notice"] = value; - doc["errors"][error->functionType(true)->externalSignature()].append(std::move(errorDoc)); + doc["errors"][error->functionType(true)->externalSignature()].emplace_back(std::move(errorDoc)); } } return doc; } -Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) +Json Natspec::devDocumentation(ContractDefinition const& _contractDef) { - Json::Value doc = extractCustomDoc(_contractDef.annotation().docTags); + Json doc = extractCustomDoc(_contractDef.annotation().docTags); - doc["version"] = Json::Value(c_natspecVersion); - doc["kind"] = Json::Value("dev"); + doc["version"] = Json(c_natspecVersion); + doc["kind"] = Json("dev"); auto author = extractDoc(_contractDef.annotation().docTags, "author"); if (!author.empty()) @@ -112,13 +112,13 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) doc["title"] = title; auto dev = extractDoc(_contractDef.annotation().docTags, "dev"); if (!dev.empty()) - doc["details"] = Json::Value(dev); + doc["details"] = Json(dev); - doc["methods"] = Json::objectValue; + doc["methods"] = Json::object(); auto constructorDefinition(_contractDef.constructor()); if (constructorDefinition) { - Json::Value constructor(devDocumentation(constructorDefinition->annotation().docTags)); + Json constructor(devDocumentation(constructorDefinition->annotation().docTags)); if (!constructor.empty()) // add the constructor, only if we have any documentation to add doc["methods"]["constructor"] = constructor; @@ -130,9 +130,9 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) continue; if (auto fun = dynamic_cast(&it.second->declaration())) { - Json::Value method(devDocumentation(fun->annotation().docTags)); + Json method(devDocumentation(fun->annotation().docTags)); // add the function, only if we have any documentation to add - Json::Value jsonReturn = extractReturnParameterDocs( + Json jsonReturn = extractReturnParameterDocs( fun->annotation().docTags, fun->functionType(false)->returnParameterNames() ); @@ -150,7 +150,7 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) if (auto devDoc = devDocumentation(varDecl->annotation().docTags); !devDoc.empty()) doc["stateVariables"][varDecl->name()] = devDoc; - auto const assignIfNotEmpty = [&](std::string const& _name, Json::Value const& _content) + auto const assignIfNotEmpty = [&](std::string const& _name, Json const& _content) { if (!_content.empty()) doc["stateVariables"][varDecl->name()][_name] = _content; @@ -171,14 +171,14 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) doc["events"][event->functionType(true)->externalSignature()] = devDoc; for (auto const& error: _contractDef.interfaceErrors()) if (auto devDoc = devDocumentation(error->annotation().docTags); !devDoc.empty()) - doc["errors"][error->functionType(true)->externalSignature()].append(devDoc); + doc["errors"][error->functionType(true)->externalSignature()].emplace_back(devDoc); return doc; } -Json::Value Natspec::extractReturnParameterDocs(std::multimap const& _tags, std::vector const& _returnParameterNames) +Json Natspec::extractReturnParameterDocs(std::multimap const& _tags, std::vector const& _returnParameterNames) { - Json::Value jsonReturn{Json::objectValue}; + Json jsonReturn; auto returnDocs = _tags.equal_range("return"); if (!_returnParameterNames.empty()) @@ -199,7 +199,7 @@ Json::Value Natspec::extractReturnParameterDocs(std::multimap const& _tags, return value; } -Json::Value Natspec::extractCustomDoc(std::multimap const& _tags) +Json Natspec::extractCustomDoc(std::multimap const& _tags) { std::map concatenated; for (auto const& [tag, value]: _tags) @@ -224,28 +224,28 @@ Json::Value Natspec::extractCustomDoc(std::multimap const& concatenated[tag] += value.content; // We do not want to create an object if there are no custom tags found. if (concatenated.empty()) - return Json::nullValue; - Json::Value result{Json::objectValue}; + return Json(); + Json result; for (auto& [tag, value]: concatenated) result[tag] = std::move(value); return result; } -Json::Value Natspec::devDocumentation(std::multimap const& _tags) +Json Natspec::devDocumentation(std::multimap const& _tags) { - Json::Value json = extractCustomDoc(_tags); + Json json = extractCustomDoc(_tags); auto dev = extractDoc(_tags, "dev"); if (!dev.empty()) - json["details"] = Json::Value(dev); + json["details"] = Json(dev); auto author = extractDoc(_tags, "author"); if (!author.empty()) json["author"] = author; - Json::Value params(Json::objectValue); + Json params; auto paramRange = _tags.equal_range("param"); for (auto i = paramRange.first; i != paramRange.second; ++i) - params[i->second.paramName] = Json::Value(i->second.content); + params[i->second.paramName] = Json(i->second.content); if (!params.empty()) json["params"] = params; diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index e75485097def..994f1350cb87 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -26,10 +26,10 @@ #pragma once -#include +#include +#include #include #include -#include namespace solidity::frontend { @@ -46,32 +46,32 @@ class Natspec /// Get the User documentation of the contract /// @param _contractDef The contract definition /// @return A JSON representation of the contract's user documentation - static Json::Value userDocumentation(ContractDefinition const& _contractDef); + static Json userDocumentation(ContractDefinition const& _contractDef); /// Generates the Developer's documentation of the contract /// @param _contractDef The contract definition /// @return A JSON representation /// of the contract's developer documentation - static Json::Value devDocumentation(ContractDefinition const& _contractDef); + static Json devDocumentation(ContractDefinition const& _contractDef); private: /// @returns concatenation of all content under the given tag name. static std::string extractDoc(std::multimap const& _tags, std::string const& _name); /// Extract all custom tags from @a _tags. - static Json::Value extractCustomDoc(std::multimap const& _tags); + static Json extractCustomDoc(std::multimap const& _tags); /// Helper-function that will create a json object with dev specific annotations, if present. /// @param _tags docTags that are used. /// @return A JSON representation /// of the contract's developer documentation - static Json::Value devDocumentation(std::multimap const& _tags); + static Json devDocumentation(std::multimap const& _tags); /// Helper-function that will create a json object for the "returns" field for a given function definition. /// @param _tags docTags that are used. /// @param _returnParameterNames names of the return parameters /// @return A JSON representation /// of a method's return notice documentation - static Json::Value extractReturnParameterDocs(std::multimap const& _tags, std::vector const& _returnParameterNames); + static Json extractReturnParameterDocs(std::multimap const& _tags, std::vector const& _returnParameterNames); /// Temporary function until https://github.com/ethereum/solidity/issues/11114 is implemented. /// @return all events defined in the contract and its base contracts and all events diff --git a/libsolidity/interface/OptimiserSettings.h b/libsolidity/interface/OptimiserSettings.h index 46683088a042..1ca46ccbc260 100644 --- a/libsolidity/interface/OptimiserSettings.h +++ b/libsolidity/interface/OptimiserSettings.h @@ -43,23 +43,25 @@ struct OptimiserSettings { static char constexpr DefaultYulOptimiserSteps[] = "dhfoDgvulfnTUtnIf" // None of these can make stack problems worse - "[" - "xa[r]EscLM" // Turn into SSA and simplify - "cCTUtTOntnfDIul" // Perform structural simplification - "Lcul" // Simplify again - "Vcul [j]" // Reverse SSA - - // should have good "compilability" property here. - - "Tpeul" // Run functional expression inliner - "xa[rul]" // Prune a bit more in SSA - "xa[r]cL" // Turn into SSA again and simplify - "gvif" // Run full inliner - "CTUca[r]LSsTFOtfDnca[r]Iulc" // SSA plus simplify - "]" + + "xa[r]EscLM" // Turn into SSA and simplify + "Vcul [j]" // Reverse SSA + + // should have good "compilability" property here. + + "Trpeul" // Run functional expression inliner + "xa[r]cL" // Turn into SSA again and simplify + "gvifM" // Run full inliner + "CTUca[r]LSsTFOtfDnca[r]Iulc" // SSA plus simplify + + "scCTUt" + "gvifM" // Run full inliner + "x[scCTUt] TOntnfDIul" // Perform structural simplification + "gvifM" // Run full inliner + "jmul[jul] VcTOcul jmul"; // Make source short and pretty - static char constexpr DefaultYulOptimiserCleanupSteps[] = "fDnTOcmu"; + static char constexpr DefaultYulOptimiserCleanupSteps[] = "fDnTOcmuO"; /// No optimisations at all - not recommended. static OptimiserSettings none() diff --git a/libsolidity/interface/SMTSolverCommand.cpp b/libsolidity/interface/SMTSolverCommand.cpp index 8ef36cb75189..7d814cd9c3c4 100644 --- a/libsolidity/interface/SMTSolverCommand.cpp +++ b/libsolidity/interface/SMTSolverCommand.cpp @@ -37,7 +37,7 @@ using solidity::util::errinfo_comment; namespace solidity::frontend { -void SMTSolverCommand::setEldarica(std::optional timeoutInMilliseconds) +void SMTSolverCommand::setEldarica(std::optional timeoutInMilliseconds, bool computeInvariants) { m_arguments.clear(); m_solverCmd = "eld"; @@ -47,6 +47,8 @@ void SMTSolverCommand::setEldarica(std::optional timeoutInMillisec timeoutInSeconds = timeoutInSeconds == 0 ? 1 : timeoutInSeconds; m_arguments.push_back("-t:" + std::to_string(timeoutInSeconds)); } + if (computeInvariants) + m_arguments.emplace_back("-ssol"); } ReadCallback::Result SMTSolverCommand::solve(std::string const& _kind, std::string const& _query) diff --git a/libsolidity/interface/SMTSolverCommand.h b/libsolidity/interface/SMTSolverCommand.h index 1d1201e49062..665c19c1b767 100644 --- a/libsolidity/interface/SMTSolverCommand.h +++ b/libsolidity/interface/SMTSolverCommand.h @@ -36,7 +36,7 @@ class SMTSolverCommand return [this](std::string const& _kind, std::string const& _query) { return solve(_kind, _query); }; } - void setEldarica(std::optional timeoutInMilliseconds); + void setEldarica(std::optional timeoutInMilliseconds, bool computeInvariants); private: /// The name of the solver's binary. diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 85a5a5d232e5..a54a9aa10720 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -54,64 +54,64 @@ using namespace std::string_literals; namespace { -Json::Value formatError( +Json formatError( Error::Type _type, std::string const& _component, std::string const& _message, std::string const& _formattedMessage = "", - Json::Value const& _sourceLocation = Json::Value(), - Json::Value const& _secondarySourceLocation = Json::Value() + Json const& _sourceLocation = Json(), + Json const& _secondarySourceLocation = Json() ) { - Json::Value error{Json::objectValue}; + Json error; error["type"] = Error::formatErrorType(_type); error["component"] = _component; error["severity"] = Error::formatErrorSeverityLowercase(Error::errorSeverity(_type)); error["message"] = _message; error["formattedMessage"] = (_formattedMessage.length() > 0) ? _formattedMessage : _message; - if (_sourceLocation.isObject()) + if (_sourceLocation.is_object()) error["sourceLocation"] = _sourceLocation; - if (_secondarySourceLocation.isArray()) + if (_secondarySourceLocation.is_array()) error["secondarySourceLocations"] = _secondarySourceLocation; return error; } -Json::Value formatFatalError(Error::Type _type, std::string const& _message) +Json formatFatalError(Error::Type _type, std::string const& _message) { - Json::Value output{Json::objectValue}; - output["errors"] = Json::arrayValue; - output["errors"].append(formatError(_type, "general", _message)); + Json output; + output["errors"] = Json::array(); + output["errors"].emplace_back(formatError(_type, "general", _message)); return output; } -Json::Value formatSourceLocation(SourceLocation const* location) +Json formatSourceLocation(SourceLocation const* location) { if (!location || !location->sourceName) - return Json::nullValue; + return Json(); - Json::Value sourceLocation{Json::objectValue}; + Json sourceLocation; sourceLocation["file"] = *location->sourceName; sourceLocation["start"] = location->start; sourceLocation["end"] = location->end; return sourceLocation; } -Json::Value formatSecondarySourceLocation(SecondarySourceLocation const* _secondaryLocation) +Json formatSecondarySourceLocation(SecondarySourceLocation const* _secondaryLocation) { if (!_secondaryLocation) - return Json::nullValue; + return Json(); - Json::Value secondarySourceLocation{Json::arrayValue}; + Json secondarySourceLocation = Json::array(); for (auto const& location: _secondaryLocation->infos) { - Json::Value msg = formatSourceLocation(&location.second); + Json msg = formatSourceLocation(&location.second); msg["message"] = location.first; - secondarySourceLocation.append(msg); + secondarySourceLocation.emplace_back(msg); } return secondarySourceLocation; } -Json::Value formatErrorWithException( +Json formatErrorWithException( CharStreamProvider const& _charStreamProvider, util::Exception const& _exception, Error::Type _type, @@ -134,7 +134,7 @@ Json::Value formatErrorWithException( else message = _message; - Json::Value error = formatError( + Json error = formatError( _type, _component, message, @@ -149,13 +149,13 @@ Json::Value formatErrorWithException( return error; } -std::map> requestedContractNames(Json::Value const& _outputSelection) +std::map> requestedContractNames(Json const& _outputSelection) { std::map> contracts; - for (auto const& sourceName: _outputSelection.getMemberNames()) + for (auto const& [sourceName, _]: _outputSelection.items()) { std::string key = (sourceName == "*") ? "" : sourceName; - for (auto const& contractName: _outputSelection[sourceName].getMemberNames()) + for (auto const& [contractName, _]: _outputSelection[sourceName].items()) { std::string value = (contractName == "*") ? "" : contractName; contracts[key].insert(value); @@ -177,12 +177,12 @@ bool hashMatchesContent(std::string const& _hash, std::string const& _content) } } -bool isArtifactRequested(Json::Value const& _outputSelection, std::string const& _artifact, bool _wildcardMatchesExperimental) +bool isArtifactRequested(Json const& _outputSelection, std::string const& _artifact, bool _wildcardMatchesExperimental) { static std::set experimental{"ir", "irAst", "irOptimized", "irOptimizedAst"}; for (auto const& selectedArtifactJson: _outputSelection) { - std::string const& selectedArtifact = selectedArtifactJson.asString(); + std::string const& selectedArtifact = selectedArtifactJson.get(); if ( _artifact == selectedArtifact || boost::algorithm::starts_with(_artifact, selectedArtifact + ".") @@ -211,13 +211,13 @@ bool isArtifactRequested(Json::Value const& _outputSelection, std::string const& /// /// @TODO optimise this. Perhaps flatten the structure upfront. /// -bool isArtifactRequested(Json::Value const& _outputSelection, std::string const& _file, std::string const& _contract, std::string const& _artifact, bool _wildcardMatchesExperimental) +bool isArtifactRequested(Json const& _outputSelection, std::string const& _file, std::string const& _contract, std::string const& _artifact, bool _wildcardMatchesExperimental) { - if (!_outputSelection.isObject()) + if (!_outputSelection.is_object()) return false; for (auto const& file: { _file, std::string("*") }) - if (_outputSelection.isMember(file) && _outputSelection[file].isObject()) + if (_outputSelection.contains(file) && _outputSelection[file].is_object()) { /// For SourceUnit-level targets (such as AST) only allow empty name, otherwise /// for Contract-level targets try both contract name and wildcard @@ -226,8 +226,8 @@ bool isArtifactRequested(Json::Value const& _outputSelection, std::string const& contracts.emplace_back("*"); for (auto const& contract: contracts) if ( - _outputSelection[file].isMember(contract) && - _outputSelection[file][contract].isArray() && + _outputSelection[file].contains(contract) && + _outputSelection[file][contract].is_array() && isArtifactRequested(_outputSelection[file][contract], _artifact, _wildcardMatchesExperimental) ) return true; @@ -236,7 +236,7 @@ bool isArtifactRequested(Json::Value const& _outputSelection, std::string const& return false; } -bool isArtifactRequested(Json::Value const& _outputSelection, std::string const& _file, std::string const& _contract, std::vector const& _artifacts, bool _wildcardMatchesExperimental) +bool isArtifactRequested(Json const& _outputSelection, std::string const& _file, std::string const& _contract, std::vector const& _artifacts, bool _wildcardMatchesExperimental) { for (auto const& artifact: _artifacts) if (isArtifactRequested(_outputSelection, _file, _contract, artifact, _wildcardMatchesExperimental)) @@ -255,9 +255,9 @@ std::vector evmObjectComponents(std::string const& _objectKind) } /// @returns true if any binary was requested, i.e. we actually have to perform compilation. -bool isBinaryRequested(Json::Value const& _outputSelection) +bool isBinaryRequested(Json const& _outputSelection) { - if (!_outputSelection.isObject()) + if (!_outputSelection.is_object()) return false; // This does not include "evm.methodIdentifiers" on purpose! @@ -276,9 +276,9 @@ bool isBinaryRequested(Json::Value const& _outputSelection) } /// @returns true if EVM bytecode was requested, i.e. we have to run the old code generator. -bool isEvmBytecodeRequested(Json::Value const& _outputSelection) +bool isEvmBytecodeRequested(Json const& _outputSelection) { - if (!_outputSelection.isObject()) + if (!_outputSelection.is_object()) return false; static std::vector const outputsThatRequireEvmBinaries = std::vector{ @@ -296,9 +296,9 @@ bool isEvmBytecodeRequested(Json::Value const& _outputSelection) /// @returns true if any Yul IR was requested. Note that as an exception, '*' does not /// yet match "ir", "irAst", "irOptimized" or "irOptimizedAst" -bool isIRRequested(Json::Value const& _outputSelection) +bool isIRRequested(Json const& _outputSelection) { - if (!_outputSelection.isObject()) + if (!_outputSelection.is_object()) return false; for (auto const& fileRequests: _outputSelection) @@ -315,9 +315,9 @@ bool isIRRequested(Json::Value const& _outputSelection) return false; } -Json::Value formatLinkReferences(std::map const& linkReferences) +Json formatLinkReferences(std::map const& linkReferences) { - Json::Value ret{Json::objectValue}; + Json ret = Json::object(); for (auto const& ref: linkReferences) { @@ -329,14 +329,14 @@ Json::Value formatLinkReferences(std::map const& linkRefere std::string file = (colon != std::string::npos ? fullname.substr(0, colon) : ""); std::string name = (colon != std::string::npos ? fullname.substr(colon + 1) : fullname); - Json::Value fileObject = ret.get(file, Json::objectValue); - Json::Value libraryArray = fileObject.get(name, Json::arrayValue); + Json fileObject = ret.value(file, Json::object()); + Json libraryArray = fileObject.value(name, Json::array()); - Json::Value entry{Json::objectValue}; - entry["start"] = Json::UInt(ref.first); + Json entry; + entry["start"] = Json(ref.first); entry["length"] = 20; - libraryArray.append(entry); + libraryArray.emplace_back(entry); fileObject[name] = libraryArray; ret[file] = fileObject; } @@ -344,20 +344,20 @@ Json::Value formatLinkReferences(std::map const& linkRefere return ret; } -Json::Value formatImmutableReferences(std::map>> const& _immutableReferences) +Json formatImmutableReferences(std::map>> const& _immutableReferences) { - Json::Value ret{Json::objectValue}; + Json ret = Json::object(); for (auto const& immutableReference: _immutableReferences) { auto const& [identifier, byteOffsets] = immutableReference.second; - Json::Value array(Json::arrayValue); + Json array = Json::array(); for (size_t byteOffset: byteOffsets) { - Json::Value byteRange{Json::objectValue}; - byteRange["start"] = Json::UInt(byteOffset); - byteRange["length"] = Json::UInt(32); // immutable references are currently always 32 bytes wide - array.append(byteRange); + Json byteRange; + byteRange["start"] = Json::number_unsigned_t(byteOffset); + byteRange["length"] = Json::number_unsigned_t(32); // immutable references are currently always 32 bytes wide + array.emplace_back(byteRange); } ret[identifier] = array; } @@ -365,16 +365,16 @@ Json::Value formatImmutableReferences(std::map const& _artifactRequested ) { - Json::Value output{Json::objectValue}; + Json output; if (_artifactRequested("object")) output["object"] = _object.toHex(); if (_artifactRequested("opcodes")) @@ -392,84 +392,89 @@ Json::Value collectEVMObject( return output; } -std::optional checkKeys(Json::Value const& _input, std::set const& _keys, std::string const& _name) +std::optional checkKeys(Json const& _input, std::set const& _keys, std::string const& _name) { - if (!!_input && !_input.isObject()) + if (!_input.empty() && !_input.is_object()) return formatFatalError(Error::Type::JSONError, "\"" + _name + "\" must be an object"); - for (auto const& member: _input.getMemberNames()) + for (auto const& [member, _]: _input.items()) if (!_keys.count(member)) return formatFatalError(Error::Type::JSONError, "Unknown key \"" + member + "\""); return std::nullopt; } -std::optional checkRootKeys(Json::Value const& _input) +std::optional checkRootKeys(Json const& _input) { static std::set keys{"auxiliaryInput", "language", "settings", "sources"}; return checkKeys(_input, keys, "root"); } -std::optional checkSourceKeys(Json::Value const& _input, std::string const& _name) +std::optional checkSourceKeys(Json const& _input, std::string const& _name) { static std::set keys{"content", "keccak256", "urls"}; return checkKeys(_input, keys, "sources." + _name); } -std::optional checkAuxiliaryInputKeys(Json::Value const& _input) +std::optional checkAuxiliaryInputKeys(Json const& _input) { static std::set keys{"smtlib2responses"}; return checkKeys(_input, keys, "auxiliaryInput"); } -std::optional checkSettingsKeys(Json::Value const& _input) +std::optional checkSettingsKeys(Json const& _input) { static std::set keys{"debug", "evmVersion", "libraries", "metadata", "modelChecker", "optimizer", "outputSelection", "remappings", "stopAfter", "viaIR"}; return checkKeys(_input, keys, "settings"); } -std::optional checkModelCheckerSettingsKeys(Json::Value const& _input) +std::optional checkModelCheckerSettingsKeys(Json const& _input) { static std::set keys{"bmcLoopIterations", "contracts", "divModNoSlacks", "engine", "extCalls", "invariants", "printQuery", "showProvedSafe", "showUnproved", "showUnsupported", "solvers", "targets", "timeout"}; return checkKeys(_input, keys, "modelChecker"); } -std::optional checkOptimizerKeys(Json::Value const& _input) +std::optional checkOptimizerKeys(Json const& _input) { static std::set keys{"details", "enabled", "runs"}; return checkKeys(_input, keys, "settings.optimizer"); } -std::optional checkOptimizerDetailsKeys(Json::Value const& _input) +std::optional checkOptimizerDetailsKeys(Json const& _input) { static std::set keys{"peephole", "inliner", "jumpdestRemover", "orderLiterals", "deduplicate", "cse", "constantOptimizer", "yul", "yulDetails", "simpleCounterForLoopUncheckedIncrement"}; return checkKeys(_input, keys, "settings.optimizer.details"); } -std::optional checkOptimizerDetail(Json::Value const& _details, std::string const& _name, bool& _setting) +std::optional checkOptimizerDetail(Json const& _details, std::string const& _name, bool& _setting) { - if (_details.isMember(_name)) + if (_details.contains(_name)) { - if (!_details[_name].isBool()) + if (!_details[_name].is_boolean()) return formatFatalError(Error::Type::JSONError, "\"settings.optimizer.details." + _name + "\" must be Boolean"); - _setting = _details[_name].asBool(); + _setting = _details[_name].get(); } return {}; } -std::optional checkOptimizerDetailSteps(Json::Value const& _details, std::string const& _name, std::string& _optimiserSetting, std::string& _cleanupSetting, bool _runYulOptimizer) +std::optional checkOptimizerDetailSteps(Json const& _details, std::string const& _name, std::string& _optimiserSetting, std::string& _cleanupSetting, bool _runYulOptimizer) { - if (_details.isMember(_name)) + if (_details.contains(_name)) { - if (_details[_name].isString()) + if (_details[_name].is_string()) { - std::string const fullSequence = _details[_name].asString(); + std::string const fullSequence = _details[_name].get(); if (!_runYulOptimizer && !OptimiserSuite::isEmptyOptimizerSequence(fullSequence)) - return formatFatalError(Error::Type::JSONError, "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted."); + { + std::string errorMessage = + "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted." + " Note that the empty optimizer sequence is properly denoted by \":\"."; + return formatFatalError(Error::Type::JSONError, errorMessage); + } try { - yul::OptimiserSuite::validateSequence(_details[_name].asString()); + yul::OptimiserSuite::validateSequence(_details[_name].get()); } catch (yul::OptimizerException const& _exception) { @@ -494,43 +499,39 @@ std::optional checkOptimizerDetailSteps(Json::Value const& _details return {}; } -std::optional checkMetadataKeys(Json::Value const& _input) +std::optional checkMetadataKeys(Json const& _input) { - if (_input.isObject()) + if (_input.is_object()) { - if (_input.isMember("appendCBOR") && !_input["appendCBOR"].isBool()) + if (_input.contains("appendCBOR") && !_input["appendCBOR"].is_boolean()) return formatFatalError(Error::Type::JSONError, "\"settings.metadata.appendCBOR\" must be Boolean"); - if (_input.isMember("useLiteralContent") && !_input["useLiteralContent"].isBool()) + if (_input.contains("useLiteralContent") && !_input["useLiteralContent"].is_boolean()) return formatFatalError(Error::Type::JSONError, "\"settings.metadata.useLiteralContent\" must be Boolean"); static std::set hashes{"ipfs", "bzzr1", "none"}; - if (_input.isMember("bytecodeHash") && !hashes.count(_input["bytecodeHash"].asString())) + if (_input.contains("bytecodeHash") && !hashes.count(_input["bytecodeHash"].get())) return formatFatalError(Error::Type::JSONError, "\"settings.metadata.bytecodeHash\" must be \"ipfs\", \"bzzr1\" or \"none\""); } static std::set keys{"appendCBOR", "useLiteralContent", "bytecodeHash"}; return checkKeys(_input, keys, "settings.metadata"); } -std::optional checkOutputSelection(Json::Value const& _outputSelection) +std::optional checkOutputSelection(Json const& _outputSelection) { - if (!!_outputSelection && !_outputSelection.isObject()) + if (!_outputSelection.empty() && !_outputSelection.is_object()) return formatFatalError(Error::Type::JSONError, "\"settings.outputSelection\" must be an object"); - for (auto const& sourceName: _outputSelection.getMemberNames()) + for (auto const& [sourceName, sourceVal]: _outputSelection.items()) { - auto const& sourceVal = _outputSelection[sourceName]; - - if (!sourceVal.isObject()) + if (!sourceVal.is_object()) return formatFatalError( Error::Type::JSONError, "\"settings.outputSelection." + sourceName + "\" must be an object" ); - for (auto const& contractName: sourceVal.getMemberNames()) + for (auto const& [contractName, contractVal]: sourceVal.items()) { - auto const& contractVal = sourceVal[contractName]; - - if (!contractVal.isArray()) + if (!contractVal.is_array()) return formatFatalError( Error::Type::JSONError, "\"settings.outputSelection." + @@ -541,7 +542,7 @@ std::optional checkOutputSelection(Json::Value const& _outputSelect ); for (auto const& output: contractVal) - if (!output.isString()) + if (!output.is_string()) return formatFatalError( Error::Type::JSONError, "\"settings.outputSelection." + @@ -558,32 +559,32 @@ std::optional checkOutputSelection(Json::Value const& _outputSelect /// Validates the optimizer settings and returns them in a parsed object. /// On error returns the json-formatted error message. -std::variant parseOptimizerSettings(Json::Value const& _jsonInput) +std::variant parseOptimizerSettings(Json const& _jsonInput) { if (auto result = checkOptimizerKeys(_jsonInput)) return *result; OptimiserSettings settings = OptimiserSettings::minimal(); - if (_jsonInput.isMember("enabled")) + if (_jsonInput.contains("enabled")) { - if (!_jsonInput["enabled"].isBool()) + if (!_jsonInput["enabled"].is_boolean()) return formatFatalError(Error::Type::JSONError, "The \"enabled\" setting must be a Boolean."); - if (_jsonInput["enabled"].asBool()) + if (_jsonInput["enabled"].get()) settings = OptimiserSettings::standard(); } - if (_jsonInput.isMember("runs")) + if (_jsonInput.contains("runs")) { - if (!_jsonInput["runs"].isUInt()) + if (!_jsonInput["runs"].is_number_unsigned()) return formatFatalError(Error::Type::JSONError, "The \"runs\" setting must be an unsigned number."); - settings.expectedExecutionsPerDeployment = _jsonInput["runs"].asUInt(); + settings.expectedExecutionsPerDeployment = _jsonInput["runs"].get(); } - if (_jsonInput.isMember("details")) + if (_jsonInput.contains("details")) { - Json::Value const& details = _jsonInput["details"]; + Json const& details = _jsonInput["details"]; if (auto result = checkOptimizerDetailsKeys(details)) return *result; @@ -606,7 +607,7 @@ std::variant parseOptimizerSettings(Json::Value if (auto error = checkOptimizerDetail(details, "simpleCounterForLoopUncheckedIncrement", settings.simpleCounterForLoopUncheckedIncrement)) return *error; settings.optimizeStackAllocation = settings.runYulOptimiser; - if (details.isMember("yulDetails")) + if (details.contains("yulDetails")) { if (!settings.runYulOptimiser) { @@ -630,45 +631,46 @@ std::variant parseOptimizerSettings(Json::Value } -std::variant StandardCompiler::parseInput(Json::Value const& _input) +std::variant StandardCompiler::parseInput(Json const& _input) { InputsAndSettings ret; - if (!_input.isObject()) + if (!_input.is_object()) return formatFatalError(Error::Type::JSONError, "Input is not a JSON object."); if (auto result = checkRootKeys(_input)) return *result; - ret.language = _input["language"].asString(); + ret.language = _input.value("language", ""); - Json::Value const& sources = _input["sources"]; + Json const& sources = _input.value("sources", Json()); - if (!sources.isObject() && !sources.isNull()) + if (!sources.is_object() && !sources.is_null()) return formatFatalError(Error::Type::JSONError, "\"sources\" is not a JSON object."); if (sources.empty()) return formatFatalError(Error::Type::JSONError, "No input sources specified."); - ret.errors = Json::arrayValue; + ret.errors = Json::array(); + ret.sources = Json::object(); if (ret.language == "Solidity" || ret.language == "Yul") { - for (auto const& sourceName: sources.getMemberNames()) + for (auto const& [sourceName, sourceValue]: sources.items()) { std::string hash; - if (auto result = checkSourceKeys(sources[sourceName], sourceName)) + if (auto result = checkSourceKeys(sourceValue, sourceName)) return *result; - if (sources[sourceName]["keccak256"].isString()) - hash = sources[sourceName]["keccak256"].asString(); + if (sourceValue.contains("keccak256") && sourceValue["keccak256"].is_string()) + hash = sourceValue["keccak256"].get(); - if (sources[sourceName]["content"].isString()) + if (sourceValue.contains("content") && sourceValue["content"].is_string()) { - std::string content = sources[sourceName]["content"].asString(); + std::string content = sourceValue["content"].get(); if (!hash.empty() && !hashMatchesContent(hash, content)) - ret.errors.append(formatError( + ret.errors.emplace_back(formatError( Error::Type::IOError, "general", "Mismatch between content and supplied hash for \"" + sourceName + "\"" @@ -676,7 +678,7 @@ std::variant StandardCompiler: else ret.sources[sourceName] = content; } - else if (sources[sourceName]["urls"].isArray()) + else if (sourceValue["urls"].is_array()) { if (!m_readFile) return formatFatalError( @@ -686,18 +688,18 @@ std::variant StandardCompiler: std::vector failures; bool found = false; - for (auto const& url: sources[sourceName]["urls"]) + for (auto const& url: sourceValue["urls"]) { - if (!url.isString()) + if (!url.is_string()) return formatFatalError(Error::Type::JSONError, "URL must be a string."); - ReadCallback::Result result = m_readFile(ReadCallback::kindString(ReadCallback::Kind::ReadFile), url.asString()); + ReadCallback::Result result = m_readFile(ReadCallback::kindString(ReadCallback::Kind::ReadFile), url.get()); if (result.success) { if (!hash.empty() && !hashMatchesContent(hash, result.responseOrErrorMessage)) - ret.errors.append(formatError( + ret.errors.emplace_back(formatError( Error::Type::IOError, "general", - "Mismatch between content and supplied hash for \"" + sourceName + "\" at \"" + url.asString() + "\"" + "Mismatch between content and supplied hash for \"" + sourceName + "\" at \"" + url.get() + "\"" )); else { @@ -708,14 +710,14 @@ std::variant StandardCompiler: } else failures.push_back( - "Cannot import url (\"" + url.asString() + "\"): " + result.responseOrErrorMessage + "Cannot import url (\"" + url.get() + "\"): " + result.responseOrErrorMessage ); } for (auto const& failure: failures) { /// If the import succeeded, let mark all the others as warnings, otherwise all of them are errors. - ret.errors.append(formatError( + ret.errors.emplace_back(formatError( found ? Error::Type::Warning : Error::Type::IOError, "general", failure @@ -728,25 +730,25 @@ std::variant StandardCompiler: } else if (ret.language == "SolidityAST") { - for (auto const& sourceName: sources.getMemberNames()) - ret.sources[sourceName] = util::jsonCompactPrint(sources[sourceName]); + for (auto const& [sourceName, sourceValue]: sources.items()) + ret.sources[sourceName] = util::jsonCompactPrint(sourceValue); } else if (ret.language == "EVMAssembly") { - for (std::string const& sourceName: sources.getMemberNames()) + for (auto const& [sourceName, sourceValue]: sources.items()) { - solAssert(sources.isMember(sourceName)); + solAssert(sources.contains(sourceName)); if ( - !sources[sourceName].isMember("assemblyJson") || - !sources[sourceName]["assemblyJson"].isObject() || - sources[sourceName].size() != 1 + !sourceValue.contains("assemblyJson") || + !sourceValue["assemblyJson"].is_object() || + sourceValue.size() != 1 ) return formatFatalError( Error::Type::JSONError, "Invalid input source specified. Expected exactly one object, named 'assemblyJson', inside $.sources." + sourceName ); - ret.jsonSources[sourceName] = sources[sourceName]["assemblyJson"]; + ret.jsonSources[sourceName] = sourceValue["assemblyJson"]; } if (ret.jsonSources.size() != 1) return formatFatalError( @@ -754,20 +756,20 @@ std::variant StandardCompiler: "EVMAssembly import only supports exactly one input file." ); } - Json::Value const& auxInputs = _input["auxiliaryInput"]; + Json const& auxInputs = _input.value("auxiliaryInput", Json::object()); if (auto result = checkAuxiliaryInputKeys(auxInputs)) return *result; - if (!!auxInputs) + if (!auxInputs.empty()) { - Json::Value const& smtlib2Responses = auxInputs["smtlib2responses"]; - if (!!smtlib2Responses) + Json const& smtlib2Responses = auxInputs.value("smtlib2responses", Json::object()); + if (!smtlib2Responses.empty()) { - if (!smtlib2Responses.isObject()) + if (!smtlib2Responses.is_object()) return formatFatalError(Error::Type::JSONError, "\"auxiliaryInput.smtlib2responses\" must be an object."); - for (auto const& hashString: smtlib2Responses.getMemberNames()) + for (auto const& [hashString, response]: smtlib2Responses.items()) { util::h256 hash; try @@ -779,49 +781,49 @@ std::variant StandardCompiler: return formatFatalError(Error::Type::JSONError, "Invalid hex encoding of SMTLib2 auxiliary input."); } - if (!smtlib2Responses[hashString].isString()) + if (!response.is_string()) return formatFatalError( Error::Type::JSONError, "\"smtlib2Responses." + hashString + "\" must be a string." ); - ret.smtLib2Responses[hash] = smtlib2Responses[hashString].asString(); + ret.smtLib2Responses[hash] = response.get(); } } } - Json::Value const& settings = _input.get("settings", Json::Value()); + Json const& settings = _input.value("settings", Json::object()); if (auto result = checkSettingsKeys(settings)) return *result; - if (settings.isMember("stopAfter")) + if (settings.contains("stopAfter")) { - if (!settings["stopAfter"].isString()) + if (!settings["stopAfter"].is_string()) return formatFatalError(Error::Type::JSONError, "\"settings.stopAfter\" must be a string."); - if (settings["stopAfter"].asString() != "parsing") + if (settings["stopAfter"].get() != "parsing") return formatFatalError(Error::Type::JSONError, "Invalid value for \"settings.stopAfter\". Only valid value is \"parsing\"."); ret.stopAfter = CompilerStack::State::Parsed; } - if (settings.isMember("viaIR")) + if (settings.contains("viaIR")) { - if (!settings["viaIR"].isBool()) + if (!settings["viaIR"].is_boolean()) return formatFatalError(Error::Type::JSONError, "\"settings.viaIR\" must be a Boolean."); - ret.viaIR = settings["viaIR"].asBool(); + ret.viaIR = settings["viaIR"].get(); } - if (settings.isMember("evmVersion")) + if (settings.contains("evmVersion")) { - if (!settings["evmVersion"].isString()) + if (!settings["evmVersion"].is_string()) return formatFatalError(Error::Type::JSONError, "evmVersion must be a string."); - std::optional version = langutil::EVMVersion::fromString(settings["evmVersion"].asString()); + std::optional version = langutil::EVMVersion::fromString(settings["evmVersion"].get()); if (!version) return formatFatalError(Error::Type::JSONError, "Invalid EVM version requested."); if (version < EVMVersion::constantinople()) - ret.errors.append(formatError( + ret.errors.emplace_back(formatError( Error::Type::Warning, "general", "Support for EVM versions older than constantinople is deprecated and will be removed in the future." @@ -829,26 +831,26 @@ std::variant StandardCompiler: ret.evmVersion = *version; } - if (settings.isMember("eofVersion")) + if (settings.contains("eofVersion")) { - if (!settings["eofVersion"].isUInt()) + if (!settings["eofVersion"].is_number_unsigned()) return formatFatalError(Error::Type::JSONError, "eofVersion must be an unsigned integer."); - auto eofVersion = settings["evmVersion"].asUInt(); + auto eofVersion = settings["evmVersion"].get(); if (eofVersion != 1) return formatFatalError(Error::Type::JSONError, "Invalid EOF version requested."); ret.eofVersion = 1; } - if (settings.isMember("debug")) + if (settings.contains("debug")) { if (auto result = checkKeys(settings["debug"], {"revertStrings", "debugInfo"}, "settings.debug")) return *result; - if (settings["debug"].isMember("revertStrings")) + if (settings["debug"].contains("revertStrings")) { - if (!settings["debug"]["revertStrings"].isString()) + if (!settings["debug"]["revertStrings"].is_string()) return formatFatalError(Error::Type::JSONError, "settings.debug.revertStrings must be a string."); - std::optional revertStrings = revertStringsFromString(settings["debug"]["revertStrings"].asString()); + std::optional revertStrings = revertStringsFromString(settings["debug"]["revertStrings"].get()); if (!revertStrings) return formatFatalError(Error::Type::JSONError, "Invalid value for settings.debug.revertStrings."); if (*revertStrings == RevertStrings::VerboseDebug) @@ -859,14 +861,14 @@ std::variant StandardCompiler: ret.revertStrings = *revertStrings; } - if (settings["debug"].isMember("debugInfo")) + if (settings["debug"].contains("debugInfo")) { - if (!settings["debug"]["debugInfo"].isArray()) + if (!settings["debug"]["debugInfo"].is_array()) return formatFatalError(Error::Type::JSONError, "settings.debug.debugInfo must be an array."); std::vector components; - for (Json::Value const& arrayValue: settings["debug"]["debugInfo"]) - components.push_back(arrayValue.asString()); + for (Json const& arrayValue: settings["debug"]["debugInfo"]) + components.push_back(arrayValue.get()); std::optional debugInfoSelection = DebugInfoSelection::fromComponents( components, @@ -885,41 +887,40 @@ std::variant StandardCompiler: } } - if (settings.isMember("remappings") && !settings["remappings"].isArray()) + if (settings.contains("remappings") && !settings["remappings"].is_array()) return formatFatalError(Error::Type::JSONError, "\"settings.remappings\" must be an array of strings."); - for (auto const& remapping: settings.get("remappings", Json::Value())) + for (auto const& remapping: settings.value("remappings", Json::object())) { - if (!remapping.isString()) + if (!remapping.is_string()) return formatFatalError(Error::Type::JSONError, "\"settings.remappings\" must be an array of strings"); - if (auto r = ImportRemapper::parseRemapping(remapping.asString())) + if (auto r = ImportRemapper::parseRemapping(remapping.get())) ret.remappings.emplace_back(std::move(*r)); else - return formatFatalError(Error::Type::JSONError, "Invalid remapping: \"" + remapping.asString() + "\""); + return formatFatalError(Error::Type::JSONError, "Invalid remapping: \"" + remapping.get() + "\""); } - if (settings.isMember("optimizer")) + if (settings.contains("optimizer")) { auto optimiserSettings = parseOptimizerSettings(settings["optimizer"]); - if (std::holds_alternative(optimiserSettings)) - return std::get(std::move(optimiserSettings)); // was an error + if (std::holds_alternative(optimiserSettings)) + return std::get(std::move(optimiserSettings)); // was an error else ret.optimiserSettings = std::get(std::move(optimiserSettings)); } - Json::Value jsonLibraries = settings.get("libraries", Json::Value(Json::objectValue)); - if (!jsonLibraries.isObject()) + Json const& jsonLibraries = settings.value("libraries", Json::object()); + if (!jsonLibraries.is_object()) return formatFatalError(Error::Type::JSONError, "\"libraries\" is not a JSON object."); - for (auto const& sourceName: jsonLibraries.getMemberNames()) + for (auto const& [sourceName, jsonSourceName]: jsonLibraries.items()) { - auto const& jsonSourceName = jsonLibraries[sourceName]; - if (!jsonSourceName.isObject()) + if (!jsonSourceName.is_object()) return formatFatalError(Error::Type::JSONError, "Library entry is not a JSON object."); - for (auto const& library: jsonSourceName.getMemberNames()) + for (auto const& [library, libraryValue]: jsonSourceName.items()) { - if (!jsonSourceName[library].isString()) + if (!libraryValue.is_string()) return formatFatalError(Error::Type::JSONError, "Library address must be a string."); - std::string address = jsonSourceName[library].asString(); + std::string address = libraryValue.get(); if (!boost::starts_with(address, "0x")) return formatFatalError( @@ -947,21 +948,24 @@ std::variant StandardCompiler: } } - Json::Value metadataSettings = settings.get("metadata", Json::Value()); + Json const& metadataSettings = settings.value("metadata", Json::object()); if (auto result = checkMetadataKeys(metadataSettings)) return *result; solAssert(CompilerStack::defaultMetadataFormat() != CompilerStack::MetadataFormat::NoMetadata, ""); ret.metadataFormat = - metadataSettings.get("appendCBOR", Json::Value(true)).asBool() ? + metadataSettings.value("appendCBOR", Json(true)) ? CompilerStack::defaultMetadataFormat() : CompilerStack::MetadataFormat::NoMetadata; - ret.metadataLiteralSources = metadataSettings.get("useLiteralContent", Json::Value(false)).asBool(); - if (metadataSettings.isMember("bytecodeHash")) + ret.metadataLiteralSources = + metadataSettings.contains("useLiteralContent") && + metadataSettings["useLiteralContent"].is_boolean() && + metadataSettings["useLiteralContent"].get(); + if (metadataSettings.contains("bytecodeHash")) { - auto metadataHash = metadataSettings["bytecodeHash"].asString(); + auto metadataHash = metadataSettings["bytecodeHash"].get(); ret.metadataHash = metadataHash == "ipfs" ? CompilerStack::MetadataHash::IPFS : @@ -977,12 +981,12 @@ std::variant StandardCompiler: ); } - Json::Value outputSelection = settings.get("outputSelection", Json::Value()); + Json const& outputSelection = settings.value("outputSelection", Json::object()); if (auto jsonError = checkOutputSelection(outputSelection)) return *jsonError; - ret.outputSelection = std::move(outputSelection); + ret.outputSelection = outputSelection; if (ret.stopAfter != CompilerStack::State::CompilationSuccessful && isBinaryRequested(ret.outputSelection)) return formatFatalError( @@ -990,34 +994,33 @@ std::variant StandardCompiler: "Requested output selection conflicts with \"settings.stopAfter\"." ); - Json::Value const& modelCheckerSettings = settings.get("modelChecker", Json::Value()); + Json const& modelCheckerSettings = settings.value("modelChecker", Json::object()); if (auto result = checkModelCheckerSettingsKeys(modelCheckerSettings)) return *result; - if (modelCheckerSettings.isMember("contracts")) + if (modelCheckerSettings.contains("contracts")) { auto const& sources = modelCheckerSettings["contracts"]; - if (!sources.isObject() && !sources.isNull()) + if (!sources.is_object() && !sources.is_null()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.contracts is not a JSON object."); std::map> sourceContracts; - for (auto const& source: sources.getMemberNames()) + for (auto const& [source, contracts]: sources.items()) { if (source.empty()) return formatFatalError(Error::Type::JSONError, "Source name cannot be empty."); - auto const& contracts = sources[source]; - if (!contracts.isArray()) + if (!contracts.is_array()) return formatFatalError(Error::Type::JSONError, "Source contracts must be an array."); for (auto const& contract: contracts) { - if (!contract.isString()) + if (!contract.is_string()) return formatFatalError(Error::Type::JSONError, "Every contract in settings.modelChecker.contracts must be a string."); - if (contract.asString().empty()) + if (contract.get().empty()) return formatFatalError(Error::Type::JSONError, "Contract name cannot be empty."); - sourceContracts[source].insert(contract.asString()); + sourceContracts[source].insert(contract.get()); } if (sourceContracts[source].empty()) @@ -1026,56 +1029,56 @@ std::variant StandardCompiler: ret.modelCheckerSettings.contracts = {std::move(sourceContracts)}; } - if (modelCheckerSettings.isMember("divModNoSlacks")) + if (modelCheckerSettings.contains("divModNoSlacks")) { auto const& divModNoSlacks = modelCheckerSettings["divModNoSlacks"]; - if (!divModNoSlacks.isBool()) + if (!divModNoSlacks.is_boolean()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.divModNoSlacks must be a Boolean."); - ret.modelCheckerSettings.divModNoSlacks = divModNoSlacks.asBool(); + ret.modelCheckerSettings.divModNoSlacks = divModNoSlacks.get(); } - if (modelCheckerSettings.isMember("engine")) + if (modelCheckerSettings.contains("engine")) { - if (!modelCheckerSettings["engine"].isString()) + if (!modelCheckerSettings["engine"].is_string()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.engine must be a string."); - std::optional engine = ModelCheckerEngine::fromString(modelCheckerSettings["engine"].asString()); + std::optional engine = ModelCheckerEngine::fromString(modelCheckerSettings["engine"].get()); if (!engine) return formatFatalError(Error::Type::JSONError, "Invalid model checker engine requested."); ret.modelCheckerSettings.engine = *engine; } - if (modelCheckerSettings.isMember("bmcLoopIterations")) + if (modelCheckerSettings.contains("bmcLoopIterations")) { if (!ret.modelCheckerSettings.engine.bmc) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.bmcLoopIterations requires the BMC engine to be enabled."); - if (modelCheckerSettings["bmcLoopIterations"].isUInt()) - ret.modelCheckerSettings.bmcLoopIterations = modelCheckerSettings["bmcLoopIterations"].asUInt(); + if (modelCheckerSettings["bmcLoopIterations"].is_number_unsigned()) + ret.modelCheckerSettings.bmcLoopIterations = modelCheckerSettings["bmcLoopIterations"].get(); else return formatFatalError(Error::Type::JSONError, "settings.modelChecker.bmcLoopIterations must be an unsigned integer."); } - if (modelCheckerSettings.isMember("extCalls")) + if (modelCheckerSettings.contains("extCalls")) { - if (!modelCheckerSettings["extCalls"].isString()) + if (!modelCheckerSettings["extCalls"].is_string()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.extCalls must be a string."); - std::optional extCalls = ModelCheckerExtCalls::fromString(modelCheckerSettings["extCalls"].asString()); + std::optional extCalls = ModelCheckerExtCalls::fromString(modelCheckerSettings["extCalls"].get()); if (!extCalls) return formatFatalError(Error::Type::JSONError, "Invalid model checker extCalls requested."); ret.modelCheckerSettings.externalCalls = *extCalls; } - if (modelCheckerSettings.isMember("invariants")) + if (modelCheckerSettings.contains("invariants")) { auto const& invariantsArray = modelCheckerSettings["invariants"]; - if (!invariantsArray.isArray()) + if (!invariantsArray.is_array()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.invariants must be an array."); ModelCheckerInvariants invariants; for (auto const& i: invariantsArray) { - if (!i.isString()) + if (!i.is_string()) return formatFatalError(Error::Type::JSONError, "Every invariant type in settings.modelChecker.invariants must be a string."); - if (!invariants.setFromString(i.asString())) + if (!invariants.setFromString(i.get())) return formatFatalError(Error::Type::JSONError, "Invalid model checker invariants requested."); } @@ -1085,72 +1088,72 @@ std::variant StandardCompiler: ret.modelCheckerSettings.invariants = invariants; } - if (modelCheckerSettings.isMember("showProvedSafe")) + if (modelCheckerSettings.contains("showProvedSafe")) { auto const& showProvedSafe = modelCheckerSettings["showProvedSafe"]; - if (!showProvedSafe.isBool()) + if (!showProvedSafe.is_boolean()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.showProvedSafe must be a Boolean value."); - ret.modelCheckerSettings.showProvedSafe = showProvedSafe.asBool(); + ret.modelCheckerSettings.showProvedSafe = showProvedSafe.get(); } - if (modelCheckerSettings.isMember("showUnproved")) + if (modelCheckerSettings.contains("showUnproved")) { auto const& showUnproved = modelCheckerSettings["showUnproved"]; - if (!showUnproved.isBool()) + if (!showUnproved.is_boolean()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.showUnproved must be a Boolean value."); - ret.modelCheckerSettings.showUnproved = showUnproved.asBool(); + ret.modelCheckerSettings.showUnproved = showUnproved.get(); } - if (modelCheckerSettings.isMember("showUnsupported")) + if (modelCheckerSettings.contains("showUnsupported")) { auto const& showUnsupported = modelCheckerSettings["showUnsupported"]; - if (!showUnsupported.isBool()) + if (!showUnsupported.is_boolean()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.showUnsupported must be a Boolean value."); - ret.modelCheckerSettings.showUnsupported = showUnsupported.asBool(); + ret.modelCheckerSettings.showUnsupported = showUnsupported.get(); } - if (modelCheckerSettings.isMember("solvers")) + if (modelCheckerSettings.contains("solvers")) { auto const& solversArray = modelCheckerSettings["solvers"]; - if (!solversArray.isArray()) + if (!solversArray.is_array()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.solvers must be an array."); smtutil::SMTSolverChoice solvers; for (auto const& s: solversArray) { - if (!s.isString()) + if (!s.is_string()) return formatFatalError(Error::Type::JSONError, "Every target in settings.modelChecker.solvers must be a string."); - if (!solvers.setSolver(s.asString())) + if (!solvers.setSolver(s.get())) return formatFatalError(Error::Type::JSONError, "Invalid model checker solvers requested."); } ret.modelCheckerSettings.solvers = solvers; } - if (modelCheckerSettings.isMember("printQuery")) + if (modelCheckerSettings.contains("printQuery")) { auto const& printQuery = modelCheckerSettings["printQuery"]; - if (!printQuery.isBool()) + if (!printQuery.is_boolean()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.printQuery must be a Boolean value."); if (!(ret.modelCheckerSettings.solvers == smtutil::SMTSolverChoice::SMTLIB2())) return formatFatalError(Error::Type::JSONError, "Only SMTLib2 solver can be enabled to print queries"); - ret.modelCheckerSettings.printQuery = printQuery.asBool(); + ret.modelCheckerSettings.printQuery = printQuery.get(); } - if (modelCheckerSettings.isMember("targets")) + if (modelCheckerSettings.contains("targets")) { auto const& targetsArray = modelCheckerSettings["targets"]; - if (!targetsArray.isArray()) + if (!targetsArray.is_array()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.targets must be an array."); ModelCheckerTargets targets; for (auto const& t: targetsArray) { - if (!t.isString()) + if (!t.is_string()) return formatFatalError(Error::Type::JSONError, "Every target in settings.modelChecker.targets must be a string."); - if (!targets.setFromString(t.asString())) + if (!targets.setFromString(t.get())) return formatFatalError(Error::Type::JSONError, "Invalid model checker targets requested."); } @@ -1160,45 +1163,45 @@ std::variant StandardCompiler: ret.modelCheckerSettings.targets = targets; } - if (modelCheckerSettings.isMember("timeout")) + if (modelCheckerSettings.contains("timeout")) { - if (!modelCheckerSettings["timeout"].isUInt()) + if (!modelCheckerSettings["timeout"].is_number_unsigned()) return formatFatalError(Error::Type::JSONError, "settings.modelChecker.timeout must be an unsigned integer."); - ret.modelCheckerSettings.timeout = modelCheckerSettings["timeout"].asUInt(); + ret.modelCheckerSettings.timeout = modelCheckerSettings["timeout"].get(); } return {std::move(ret)}; } -std::map StandardCompiler::parseAstFromInput(StringMap const& _sources) +std::map StandardCompiler::parseAstFromInput(StringMap const& _sources) { - std::map sourceJsons; + std::map sourceJsons; for (auto const& [sourceName, sourceCode]: _sources) { - Json::Value ast; + Json ast; astAssert(util::jsonParseStrict(sourceCode, ast), "Input file could not be parsed to JSON"); - std::string astKey = ast.isMember("ast") ? "ast" : "AST"; + std::string astKey = ast.contains("ast") ? "ast" : "AST"; - astAssert(ast.isMember(astKey), "astkey is not member"); - astAssert(ast[astKey]["nodeType"].asString() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); + astAssert(ast.contains(astKey), "astkey is not member"); + astAssert(ast[astKey]["nodeType"].get() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); astAssert(sourceJsons.count(sourceName) == 0, "All sources must have unique names"); sourceJsons.emplace(sourceName, std::move(ast[astKey])); } return sourceJsons; } -Json::Value StandardCompiler::importEVMAssembly(StandardCompiler::InputsAndSettings _inputsAndSettings) +Json StandardCompiler::importEVMAssembly(StandardCompiler::InputsAndSettings _inputsAndSettings) { solAssert(_inputsAndSettings.language == "EVMAssembly"); solAssert(_inputsAndSettings.sources.empty()); solAssert(_inputsAndSettings.jsonSources.size() == 1); if (!isBinaryRequested(_inputsAndSettings.outputSelection)) - return Json::objectValue; + return Json::object(); evmasm::EVMAssemblyStack stack(_inputsAndSettings.evmVersion); std::string const& sourceName = _inputsAndSettings.jsonSources.begin()->first; // result of structured binding can only be used within lambda from C++20 on. - Json::Value const& sourceJson = _inputsAndSettings.jsonSources.begin()->second; + Json const& sourceJson = _inputsAndSettings.jsonSources.begin()->second; try { stack.analyze(sourceName, sourceJson); @@ -1221,11 +1224,11 @@ Json::Value StandardCompiler::importEVMAssembly(StandardCompiler::InputsAndSetti ); } if (!stack.compilationSuccessful()) - return Json::objectValue; + return Json::object(); // EVM bool const wildcardMatchesExperimental = false; - Json::Value evmData = Json::objectValue; + Json evmData; if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "evm.assembly", wildcardMatchesExperimental)) evmData["assembly"] = stack.assemblyString(sourceName, {}); if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "evm.legacyAssembly", wildcardMatchesExperimental)) @@ -1279,18 +1282,18 @@ Json::Value StandardCompiler::importEVMAssembly(StandardCompiler::InputsAndSetti } ); - Json::Value contractData = Json::objectValue; + Json contractData; if (!evmData.empty()) contractData["evm"] = evmData; - Json::Value contractsOutput = Json::objectValue; + Json contractsOutput; contractsOutput[sourceName][""] = contractData; - Json::Value output = Json::objectValue; + Json output; output["contracts"] = contractsOutput; return util::removeNullMembers(output); } -Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSettings _inputsAndSettings) +Json StandardCompiler::compileSolidity(StandardCompiler::InputsAndSettings _inputsAndSettings) { solAssert(_inputsAndSettings.jsonSources.empty()); @@ -1318,7 +1321,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting compilerStack.enableEvmBytecodeGeneration(isEvmBytecodeRequested(_inputsAndSettings.outputSelection)); compilerStack.enableIRGeneration(isIRRequested(_inputsAndSettings.outputSelection)); - Json::Value errors = std::move(_inputsAndSettings.errors); + Json errors = std::move(_inputsAndSettings.errors); bool const binariesRequested = isBinaryRequested(_inputsAndSettings.outputSelection); @@ -1330,7 +1333,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting { compilerStack.importASTs(parseAstFromInput(sourceList)); if (!compilerStack.analyze()) - errors.append(formatError(Error::Type::FatalError, "general", "Analysis of the AST failed.")); + errors.emplace_back(formatError(Error::Type::FatalError, "general", "Analysis of the AST failed.")); if (binariesRequested) compilerStack.compile(); } @@ -1347,7 +1350,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting compilerStack.parseAndAnalyze(_inputsAndSettings.stopAfter); for (auto const& error: compilerStack.errors()) - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, *error, error->type(), @@ -1360,7 +1363,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting /// This is only thrown in a very few locations. catch (Error const& _error) { - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, _error, _error.type(), @@ -1371,7 +1374,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting /// This should not be leaked from compile(). catch (FatalError const& _exception) { - errors.append(formatError( + errors.emplace_back(formatError( Error::Type::FatalError, "general", "Uncaught fatal error: " + boost::diagnostic_information(_exception) @@ -1379,7 +1382,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (CompilerError const& _exception) { - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, _exception, Error::Type::CompilerError, @@ -1389,7 +1392,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (InternalCompilerError const& _exception) { - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, _exception, Error::Type::InternalCompilerError, @@ -1399,7 +1402,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (UnimplementedFeatureError const& _exception) { - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, _exception, Error::Type::UnimplementedFeatureError, @@ -1409,7 +1412,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (yul::YulException const& _exception) { - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, _exception, Error::Type::YulException, @@ -1419,7 +1422,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (smtutil::SMTLogicError const& _exception) { - errors.append(formatErrorWithException( + errors.emplace_back(formatErrorWithException( compilerStack, _exception, Error::Type::SMTLogicException, @@ -1429,7 +1432,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (util::Exception const& _exception) { - errors.append(formatError( + errors.emplace_back(formatError( Error::Type::Exception, "general", "Exception during compilation: " + boost::diagnostic_information(_exception) @@ -1437,7 +1440,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (std::exception const& _exception) { - errors.append(formatError( + errors.emplace_back(formatError( Error::Type::Exception, "general", "Unknown exception during compilation: " + boost::diagnostic_information(_exception) @@ -1445,7 +1448,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } catch (...) { - errors.append(formatError( + errors.emplace_back(formatError( Error::Type::Exception, "general", "Unknown exception during compilation: " + boost::current_exception_diagnostic_information() @@ -1468,7 +1471,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting ) return formatFatalError(Error::Type::InternalCompilerError, "No error reported, but compilation failed."); - Json::Value output = Json::objectValue; + Json output; if (errors.size() > 0) output["errors"] = std::move(errors); @@ -1479,21 +1482,21 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting bool const wildcardMatchesExperimental = false; - output["sources"] = Json::objectValue; + output["sources"] = Json::object(); unsigned sourceIndex = 0; // NOTE: A case that will pass `parsingSuccess && !analysisFailed` but not `analysisSuccess` is // stopAfter: parsing with no parsing errors. if (parsingSuccess && !analysisFailed) for (std::string const& sourceName: compilerStack.sourceNames()) { - Json::Value sourceResult = Json::objectValue; + Json sourceResult; sourceResult["id"] = sourceIndex++; if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "ast", wildcardMatchesExperimental)) sourceResult["ast"] = ASTJsonExporter(compilerStack.state(), compilerStack.sourceIndices()).toJson(compilerStack.ast(sourceName)); output["sources"][sourceName] = sourceResult; } - Json::Value contractsOutput = Json::objectValue; + Json contractsOutput; for (std::string const& contractName: analysisSuccess ? compilerStack.contractNames() : std::vector()) { size_t colon = contractName.rfind(':'); @@ -1502,7 +1505,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting std::string name = contractName.substr(colon + 1); // ABI, storage layout, documentation and metadata - Json::Value contractData(Json::objectValue); + Json contractData; if (isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "abi", wildcardMatchesExperimental)) contractData["abi"] = compilerStack.contractABI(contractName); if (isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "storageLayout", false)) @@ -1525,7 +1528,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting contractData["irOptimizedAst"] = compilerStack.yulIROptimizedAst(contractName); // EVM - Json::Value evmData(Json::objectValue); + Json evmData; if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "evm.assembly", wildcardMatchesExperimental)) evmData["assembly"] = compilerStack.assemblyString(contractName, sourceList); if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "evm.legacyAssembly", wildcardMatchesExperimental)) @@ -1584,8 +1587,8 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting if (!contractData.empty()) { - if (!contractsOutput.isMember(file)) - contractsOutput[file] = Json::objectValue; + if (!contractsOutput.contains(file)) + contractsOutput[file] = Json::object(); contractsOutput[file][name] = contractData; } } @@ -1596,16 +1599,16 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting } -Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) +Json StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) { solAssert(_inputsAndSettings.jsonSources.empty()); - Json::Value output = Json::objectValue; + Json output; output["errors"] = std::move(_inputsAndSettings.errors); if (_inputsAndSettings.sources.size() != 1) { - output["errors"].append(formatError( + output["errors"].emplace_back(formatError( Error::Type::JSONError, "general", "Yul mode only supports exactly one input file." @@ -1614,7 +1617,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) } if (!_inputsAndSettings.smtLib2Responses.empty()) { - output["errors"].append(formatError( + output["errors"].emplace_back(formatError( Error::Type::JSONError, "general", "Yul mode does not support smtlib2responses." @@ -1623,7 +1626,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) } if (!_inputsAndSettings.remappings.empty()) { - output["errors"].append(formatError( + output["errors"].emplace_back(formatError( Error::Type::JSONError, "general", "Field \"settings.remappings\" cannot be used for Yul." @@ -1632,7 +1635,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) } if (_inputsAndSettings.revertStrings != RevertStrings::Default) { - output["errors"].append(formatError( + output["errors"].emplace_back(formatError( Error::Type::JSONError, "general", "Field \"settings.debug.revertStrings\" cannot be used for Yul." @@ -1655,7 +1658,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) // Inconsistent state - stop here to receive error reports from users if (!stack.parseAndAnalyze(sourceName, sourceContents) && stack.errors().empty()) { - output["errors"].append(formatError( + output["errors"].emplace_back(formatError( Error::Type::InternalCompilerError, "general", "No error reported, but compilation failed." @@ -1669,7 +1672,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) { auto err = std::dynamic_pointer_cast(error); - output["errors"].append(formatErrorWithException( + output["errors"].emplace_back(formatErrorWithException( stack, *error, err->type(), @@ -1688,7 +1691,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, contractName, "ast", wildcardMatchesExperimental)) { - Json::Value sourceResult = Json::objectValue; + Json sourceResult; sourceResult["id"] = 0; sourceResult["ast"] = stack.astJson(); output["sources"][sourceName] = sourceResult; @@ -1720,7 +1723,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) _inputsAndSettings.evmVersion, *o.bytecode, o.sourceMappings.get(), - Json::arrayValue, + Json::array(), isDeployed, [&, kind = kind](std::string const& _element) { return isArtifactRequested( _inputsAndSettings.outputSelection, @@ -1740,16 +1743,15 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) return output; } - -Json::Value StandardCompiler::compile(Json::Value const& _input) noexcept +Json StandardCompiler::compile(Json const& _input) noexcept { YulStringRepository::reset(); try { auto parsed = parseInput(_input); - if (std::holds_alternative(parsed)) - return std::get(std::move(parsed)); + if (std::holds_alternative(parsed)) + return std::get(std::move(parsed)); InputsAndSettings settings = std::get(std::move(parsed)); if (settings.language == "Solidity") return compileSolidity(std::move(settings)); @@ -1762,13 +1764,29 @@ Json::Value StandardCompiler::compile(Json::Value const& _input) noexcept else return formatFatalError(Error::Type::JSONError, "Only \"Solidity\", \"Yul\", \"SolidityAST\" or \"EVMAssembly\" is supported as a language."); } - catch (Json::LogicError const& _exception) + catch (Json::parse_error const& _exception) + { + return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON parse_error exception: ") + util::removeNlohmannInternalErrorIdentifier(_exception.what())); + } + catch (Json::invalid_iterator const& _exception) { - return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON logic exception: ") + _exception.what()); + return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON invalid_iterator exception: ") + util::removeNlohmannInternalErrorIdentifier(_exception.what())); } - catch (Json::RuntimeError const& _exception) + catch (Json::type_error const& _exception) { - return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON runtime exception: ") + _exception.what()); + return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON type_error exception: ") + util::removeNlohmannInternalErrorIdentifier(_exception.what())); + } + catch (Json::out_of_range const& _exception) + { + return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON out_of_range exception: ") + util::removeNlohmannInternalErrorIdentifier(_exception.what())); + } + catch (Json::other_error const& _exception) + { + return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON other_error exception: ") + util::removeNlohmannInternalErrorIdentifier(_exception.what())); + } + catch (Json::exception const& _exception) + { + return formatFatalError(Error::Type::InternalCompilerError, std::string("JSON runtime exception: ") + util::removeNlohmannInternalErrorIdentifier(_exception.what())); } catch (util::Exception const& _exception) { @@ -1782,7 +1800,7 @@ Json::Value StandardCompiler::compile(Json::Value const& _input) noexcept std::string StandardCompiler::compile(std::string const& _input) noexcept { - Json::Value input; + Json input; std::string errors; try { @@ -1791,12 +1809,15 @@ std::string StandardCompiler::compile(std::string const& _input) noexcept } catch (...) { - return "{\"errors\":[{\"type\":\"JSONError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Error parsing input JSON.\"}]}"; + if (errors.empty()) + return "{\"errors\":[{\"type\":\"JSONError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Error parsing input JSON.\"}]}"; + else + return "{\"errors\":[{\"type\":\"JSONError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Error parsing input JSON: " + errors + "\"}]}"; } - // cout << "Input: " << input.toStyledString() << endl; - Json::Value output = compile(input); - // cout << "Output: " << output.toStyledString() << endl; +// std::cout << "Input: " << solidity::util::jsonPrettyPrint(input) << std::endl; + Json output = compile(input); +// std::cout << "Output: " << solidity::util::jsonPrettyPrint(output) << std::endl; try { @@ -1808,24 +1829,25 @@ std::string StandardCompiler::compile(std::string const& _input) noexcept } } -Json::Value StandardCompiler::formatFunctionDebugData( +Json StandardCompiler::formatFunctionDebugData( std::map const& _debugInfo ) { - Json::Value ret(Json::objectValue); + static_assert(std::is_same_v); + Json ret = Json::object(); for (auto const& [name, info]: _debugInfo) { - Json::Value fun; + Json fun = Json::object(); if (info.sourceID) - fun["id"] = Json::UInt64(*info.sourceID); + fun["id"] = Json::number_unsigned_t(*info.sourceID); else - fun["id"] = Json::nullValue; + fun["id"] = Json(); if (info.bytecodeOffset) - fun["entryPoint"] = Json::UInt64(*info.bytecodeOffset); + fun["entryPoint"] = Json::number_unsigned_t(*info.bytecodeOffset); else - fun["entryPoint"] = Json::nullValue; - fun["parameterSlots"] = Json::UInt64(info.params); - fun["returnSlots"] = Json::UInt64(info.returns); + fun["entryPoint"] = Json(); + fun["parameterSlots"] = Json::number_unsigned_t(info.params); + fun["returnSlots"] = Json::number_unsigned_t(info.returns); ret[name] = std::move(fun); } diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index 03bdc7f12bd2..590d96b9c191 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -58,12 +58,12 @@ class StandardCompiler /// Sets all input parameters according to @a _input which conforms to the standardized input /// format, performs compilation and returns a standardized output. - Json::Value compile(Json::Value const& _input) noexcept; + Json compile(Json const& _input) noexcept; /// Parses input as JSON and performs the above processing steps, returning a serialized JSON /// output. Parsing errors are returned as regular errors. std::string compile(std::string const& _input) noexcept; - static Json::Value formatFunctionDebugData( + static Json formatFunctionDebugData( std::map const& _debugInfo ); @@ -71,10 +71,10 @@ class StandardCompiler struct InputsAndSettings { std::string language; - Json::Value errors; + Json errors; CompilerStack::State stopAfter = CompilerStack::State::CompilationSuccessful; std::map sources; - std::map jsonSources; + std::map jsonSources; std::map smtLib2Responses; langutil::EVMVersion evmVersion; std::optional eofVersion; @@ -86,19 +86,19 @@ class StandardCompiler bool metadataLiteralSources = false; CompilerStack::MetadataFormat metadataFormat = CompilerStack::defaultMetadataFormat(); CompilerStack::MetadataHash metadataHash = CompilerStack::MetadataHash::IPFS; - Json::Value outputSelection; + Json outputSelection; ModelCheckerSettings modelCheckerSettings = ModelCheckerSettings{}; bool viaIR = false; }; /// Parses the input json (and potentially invokes the read callback) and either returns /// it in condensed form or an error as a json object. - std::variant parseInput(Json::Value const& _input); + std::variant parseInput(Json const& _input); - std::map parseAstFromInput(StringMap const& _sources); - Json::Value importEVMAssembly(InputsAndSettings _inputsAndSettings); - Json::Value compileSolidity(InputsAndSettings _inputsAndSettings); - Json::Value compileYul(InputsAndSettings _inputsAndSettings); + std::map parseAstFromInput(StringMap const& _sources); + Json importEVMAssembly(InputsAndSettings _inputsAndSettings); + Json compileSolidity(InputsAndSettings _inputsAndSettings); + Json compileYul(InputsAndSettings _inputsAndSettings); ReadCallback::Callback m_readFile; diff --git a/libsolidity/interface/StorageLayout.cpp b/libsolidity/interface/StorageLayout.cpp index 8e1d0eed101d..7f344f6edf65 100644 --- a/libsolidity/interface/StorageLayout.cpp +++ b/libsolidity/interface/StorageLayout.cpp @@ -23,7 +23,7 @@ using namespace solidity; using namespace solidity::frontend; -Json::Value StorageLayout::generate(ContractDefinition const& _contractDef) +Json StorageLayout::generate(ContractDefinition const& _contractDef) { solAssert(!m_contract, ""); m_contract = &_contractDef; @@ -34,19 +34,19 @@ Json::Value StorageLayout::generate(ContractDefinition const& _contractDef) auto contractType = dynamic_cast(typeType->actualType()); solAssert(contractType, ""); - Json::Value variables(Json::arrayValue); + Json variables = Json::array(); for (auto [var, slot, offset]: contractType->stateVariables()) - variables.append(generate(*var, slot, offset)); + variables.emplace_back(generate(*var, slot, offset)); - Json::Value layout; + Json layout; layout["storage"] = std::move(variables); layout["types"] = std::move(m_types); return layout; } -Json::Value StorageLayout::generate(VariableDeclaration const& _var, u256 const& _slot, unsigned _offset) +Json StorageLayout::generate(VariableDeclaration const& _var, u256 const& _slot, unsigned _offset) { - Json::Value varEntry; + Json varEntry; Type const* varType = _var.type(); varEntry["label"] = _var.name(); @@ -63,22 +63,22 @@ Json::Value StorageLayout::generate(VariableDeclaration const& _var, u256 const& void StorageLayout::generate(Type const* _type) { - if (m_types.isMember(typeKeyName(_type))) + if (m_types.contains(typeKeyName(_type))) return; // Register it now to cut recursive visits. - Json::Value& typeInfo = m_types[typeKeyName(_type)]; + Json& typeInfo = m_types[typeKeyName(_type)]; typeInfo["label"] = _type->toString(true); typeInfo["numberOfBytes"] = u256(_type->storageBytes() * _type->storageSize()).str(); if (auto structType = dynamic_cast(_type)) { - Json::Value members(Json::arrayValue); + Json members = Json::array(); auto const& structDef = structType->structDefinition(); for (auto const& member: structDef.members()) { auto const& offsets = structType->storageOffsetsOfMember(member->name()); - members.append(generate(*member, offsets.first, offsets.second)); + members.emplace_back(generate(*member, offsets.first, offsets.second)); } typeInfo["members"] = std::move(members); typeInfo["encoding"] = "inplace"; @@ -108,7 +108,7 @@ void StorageLayout::generate(Type const* _type) typeInfo["encoding"] = "inplace"; } - solAssert(typeInfo.isMember("encoding"), ""); + solAssert(typeInfo.contains("encoding"), ""); } std::string StorageLayout::typeKeyName(Type const* _type) diff --git a/libsolidity/interface/StorageLayout.h b/libsolidity/interface/StorageLayout.h index ffe8e6b5a0c6..b0b2d70b6df5 100644 --- a/libsolidity/interface/StorageLayout.h +++ b/libsolidity/interface/StorageLayout.h @@ -21,11 +21,10 @@ #pragma once +#include #include #include -#include - namespace solidity::frontend { @@ -35,11 +34,11 @@ class StorageLayout /// Generates the storage layout of the contract /// @param _contractDef The contract definition /// @return A JSON representation of the contract's storage layout. - Json::Value generate(ContractDefinition const& _contractDef); + Json generate(ContractDefinition const& _contractDef); private: /// Generates the JSON information for a variable and its storage location. - Json::Value generate(VariableDeclaration const& _var, u256 const& _slot, unsigned _offset); + Json generate(VariableDeclaration const& _var, u256 const& _slot, unsigned _offset); /// Generates the JSON information for @param _type void generate(Type const* _type); @@ -47,7 +46,7 @@ class StorageLayout /// The key for the JSON object describing a type. std::string typeKeyName(Type const* _type); - Json::Value m_types; + Json m_types; /// Current analyzed contract ContractDefinition const* m_contract = nullptr; diff --git a/libsolidity/lsp/DocumentHoverHandler.cpp b/libsolidity/lsp/DocumentHoverHandler.cpp index 39d1d72c331c..e5991b765a66 100644 --- a/libsolidity/lsp/DocumentHoverHandler.cpp +++ b/libsolidity/lsp/DocumentHoverHandler.cpp @@ -55,7 +55,7 @@ struct MarkdownBuilder } -void DocumentHoverHandler::operator()(MessageID _id, Json::Value const& _args) +void DocumentHoverHandler::operator()(MessageID _id, Json const& _args) { auto const [sourceUnitName, lineColumn] = HandlerBase(*this).extractSourceUnitNameAndLineColumn(_args); auto const [sourceNode, sourceOffset] = m_server.astNodeAndOffsetAtSourceLocation(sourceUnitName, lineColumn); @@ -108,11 +108,11 @@ void DocumentHoverHandler::operator()(MessageID _id, Json::Value const& _args) if (tooltipText.empty()) { - client().reply(_id, Json::nullValue); + client().reply(_id, Json()); return; } - Json::Value reply = Json::objectValue; + Json reply; reply["range"] = rangeToHighlight; reply["contents"]["kind"] = "markdown"; reply["contents"]["value"] = std::move(tooltipText); diff --git a/libsolidity/lsp/DocumentHoverHandler.h b/libsolidity/lsp/DocumentHoverHandler.h index 9bb4084c261e..e35e856098f0 100644 --- a/libsolidity/lsp/DocumentHoverHandler.h +++ b/libsolidity/lsp/DocumentHoverHandler.h @@ -26,7 +26,7 @@ class DocumentHoverHandler: public HandlerBase public: using HandlerBase::HandlerBase; - void operator()(MessageID, Json::Value const&); + void operator()(MessageID, Json const&); }; } diff --git a/libsolidity/lsp/GotoDefinition.cpp b/libsolidity/lsp/GotoDefinition.cpp index 136e4d7c391b..07b0c6f0be3c 100644 --- a/libsolidity/lsp/GotoDefinition.cpp +++ b/libsolidity/lsp/GotoDefinition.cpp @@ -31,7 +31,7 @@ using namespace solidity::frontend; using namespace solidity::langutil; using namespace solidity::lsp; -void GotoDefinition::operator()(MessageID _id, Json::Value const& _args) +void GotoDefinition::operator()(MessageID _id, Json const& _args) { auto const [sourceUnitName, lineColumn] = extractSourceUnitNameAndLineColumn(_args); @@ -58,8 +58,8 @@ void GotoDefinition::operator()(MessageID _id, Json::Value const& _args) locations.emplace_back(SourceLocation{0, 0, std::make_shared(path)}); } - Json::Value reply = Json::arrayValue; + Json reply = Json::array(); for (SourceLocation const& location: locations) - reply.append(toJson(location)); + reply.emplace_back(toJson(location)); client().reply(_id, reply); } diff --git a/libsolidity/lsp/GotoDefinition.h b/libsolidity/lsp/GotoDefinition.h index 453da3f1561c..4ffd64e7ff22 100644 --- a/libsolidity/lsp/GotoDefinition.h +++ b/libsolidity/lsp/GotoDefinition.h @@ -25,7 +25,7 @@ class GotoDefinition: public HandlerBase public: explicit GotoDefinition(LanguageServer& _server): HandlerBase(_server) {} - void operator()(MessageID, Json::Value const&); + void operator()(MessageID, Json const&); }; } diff --git a/libsolidity/lsp/HandlerBase.cpp b/libsolidity/lsp/HandlerBase.cpp index a23e43a83ce1..c49bce1dd697 100644 --- a/libsolidity/lsp/HandlerBase.cpp +++ b/libsolidity/lsp/HandlerBase.cpp @@ -29,8 +29,9 @@ using namespace solidity::langutil; using namespace solidity::lsp; using namespace solidity::util; +using namespace solidity; -Json::Value HandlerBase::toRange(SourceLocation const& _location) const +Json HandlerBase::toRange(SourceLocation const& _location) const { if (!_location.hasText()) return toJsonRange({}, {}); @@ -42,18 +43,18 @@ Json::Value HandlerBase::toRange(SourceLocation const& _location) const return toJsonRange(start, end); } -Json::Value HandlerBase::toJson(SourceLocation const& _location) const +Json HandlerBase::toJson(SourceLocation const& _location) const { solAssert(_location.sourceName); - Json::Value item = Json::objectValue; + Json item; item["uri"] = fileRepository().sourceUnitNameToUri(*_location.sourceName); item["range"] = toRange(_location); return item; } -std::pair HandlerBase::extractSourceUnitNameAndLineColumn(Json::Value const& _args) const +std::pair HandlerBase::extractSourceUnitNameAndLineColumn(Json const& _args) const { - std::string const uri = _args["textDocument"]["uri"].asString(); + std::string const uri = _args["textDocument"]["uri"].get(); std::string const sourceUnitName = fileRepository().uriToSourceUnitName(uri); if (!fileRepository().sourceUnits().count(sourceUnitName)) BOOST_THROW_EXCEPTION( diff --git a/libsolidity/lsp/HandlerBase.h b/libsolidity/lsp/HandlerBase.h index e2ccb88d82ec..718d15c5f631 100644 --- a/libsolidity/lsp/HandlerBase.h +++ b/libsolidity/lsp/HandlerBase.h @@ -38,12 +38,12 @@ class HandlerBase public: explicit HandlerBase(LanguageServer& _server): m_server{_server} {} - Json::Value toRange(langutil::SourceLocation const& _location) const; - Json::Value toJson(langutil::SourceLocation const& _location) const; + Json toRange(langutil::SourceLocation const& _location) const; + Json toJson(langutil::SourceLocation const& _location) const; /// @returns source unit name and the line column position as extracted /// from the JSON-RPC parameters. - std::pair extractSourceUnitNameAndLineColumn(Json::Value const& _params) const; + std::pair extractSourceUnitNameAndLineColumn(Json const& _params) const; langutil::CharStreamProvider const& charStreamProvider() const noexcept { return m_server.compilerStack(); } FileRepository& fileRepository() const noexcept { return m_server.fileRepository(); } diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 2b8b62706d50..d726139e3a73 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -52,6 +52,7 @@ using namespace std::placeholders; using namespace solidity::lsp; using namespace solidity::langutil; using namespace solidity::frontend; +using namespace solidity; namespace fs = boost::filesystem; @@ -85,44 +86,44 @@ int toDiagnosticSeverity(Error::Type _errorType) return -1; } -Json::Value semanticTokensLegend() +Json semanticTokensLegend() { - Json::Value legend = Json::objectValue; + Json legend; // NOTE! The (alphabetical) order and items must match exactly the items of // their respective enum class members. - Json::Value tokenTypes = Json::arrayValue; - tokenTypes.append("class"); - tokenTypes.append("comment"); - tokenTypes.append("enum"); - tokenTypes.append("enumMember"); - tokenTypes.append("event"); - tokenTypes.append("function"); - tokenTypes.append("interface"); - tokenTypes.append("keyword"); - tokenTypes.append("macro"); - tokenTypes.append("method"); - tokenTypes.append("modifier"); - tokenTypes.append("number"); - tokenTypes.append("operator"); - tokenTypes.append("parameter"); - tokenTypes.append("property"); - tokenTypes.append("std::string"); - tokenTypes.append("struct"); - tokenTypes.append("type"); - tokenTypes.append("typeParameter"); - tokenTypes.append("variable"); + Json tokenTypes = Json::array(); + tokenTypes.emplace_back("class"); + tokenTypes.emplace_back("comment"); + tokenTypes.emplace_back("enum"); + tokenTypes.emplace_back("enumMember"); + tokenTypes.emplace_back("event"); + tokenTypes.emplace_back("function"); + tokenTypes.emplace_back("interface"); + tokenTypes.emplace_back("keyword"); + tokenTypes.emplace_back("macro"); + tokenTypes.emplace_back("method"); + tokenTypes.emplace_back("modifier"); + tokenTypes.emplace_back("number"); + tokenTypes.emplace_back("operator"); + tokenTypes.emplace_back("parameter"); + tokenTypes.emplace_back("property"); + tokenTypes.emplace_back("std::string"); + tokenTypes.emplace_back("struct"); + tokenTypes.emplace_back("type"); + tokenTypes.emplace_back("typeParameter"); + tokenTypes.emplace_back("variable"); legend["tokenTypes"] = tokenTypes; - Json::Value tokenModifiers = Json::arrayValue; - tokenModifiers.append("abstract"); - tokenModifiers.append("declaration"); - tokenModifiers.append("definition"); - tokenModifiers.append("deprecated"); - tokenModifiers.append("documentation"); - tokenModifiers.append("modification"); - tokenModifiers.append("readonly"); + Json tokenModifiers = Json::array(); + tokenModifiers.emplace_back("abstract"); + tokenModifiers.emplace_back("declaration"); + tokenModifiers.emplace_back("definition"); + tokenModifiers.emplace_back("deprecated"); + tokenModifiers.emplace_back("documentation"); + tokenModifiers.emplace_back("modification"); + tokenModifiers.emplace_back("readonly"); legend["tokenModifiers"] = tokenModifiers; return legend; @@ -138,7 +139,7 @@ LanguageServer::LanguageServer(Transport& _transport): {"exit", [this](auto, auto) { m_state = (m_state == State::ShutdownRequested ? State::ExitRequested : State::ExitWithoutShutdown); }}, {"initialize", std::bind(&LanguageServer::handleInitialize, this, _1, _2)}, {"initialized", std::bind(&LanguageServer::handleInitialized, this, _1, _2)}, - {"$/setTrace", [this](auto, Json::Value const& args) { setTrace(args["value"]); }}, + {"$/setTrace", [this](auto, Json const& args) { setTrace(args["value"]); }}, {"shutdown", [this](auto, auto) { m_state = State::ShutdownRequested; }}, {"textDocument/definition", GotoDefinition(*this) }, {"textDocument/didOpen", std::bind(&LanguageServer::handleTextDocumentDidOpen, this, _2)}, @@ -155,17 +156,17 @@ LanguageServer::LanguageServer(Transport& _transport): { } -Json::Value LanguageServer::toRange(SourceLocation const& _location) +Json LanguageServer::toRange(SourceLocation const& _location) { return HandlerBase(*this).toRange(_location); } -Json::Value LanguageServer::toJson(SourceLocation const& _location) +Json LanguageServer::toJson(SourceLocation const& _location) { return HandlerBase(*this).toJson(_location); } -void LanguageServer::changeConfiguration(Json::Value const& _settings) +void LanguageServer::changeConfiguration(Json const& _settings) { // The settings item: "file-load-strategy" (enum) defaults to "project-directory" if not (or not correctly) set. // It can be overridden during client's handshake or at runtime, as usual. @@ -176,9 +177,9 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings) // // If this value is set to "directly-opened-and-on-import", then only currently directly opened files and // those files being imported directly or indirectly will be included in operations. - if (_settings["file-load-strategy"]) + if (_settings.contains("file-load-strategy")) { - auto const text = _settings["file-load-strategy"].asString(); + auto const text = _settings["file-load-strategy"].get(); if (text == "project-directory") m_fileLoadStrategy = FileLoadStrategy::ProjectDirectory; else if (text == "directly-opened-and-on-import") @@ -188,18 +189,18 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings) } m_settingsObject = _settings; - Json::Value jsonIncludePaths = _settings["include-paths"]; + Json jsonIncludePaths = _settings.contains("include-paths") ? _settings["include-paths"] : Json::object(); - if (jsonIncludePaths) + if (!jsonIncludePaths.empty()) { int typeFailureCount = 0; - if (jsonIncludePaths.isArray()) + if (jsonIncludePaths.is_array()) { std::vector includePaths; - for (Json::Value const& jsonPath: jsonIncludePaths) + for (Json const& jsonPath: jsonIncludePaths) { - if (jsonPath.isString()) - includePaths.emplace_back(boost::filesystem::path(jsonPath.asString())); + if (jsonPath.is_string()) + includePaths.emplace_back(jsonPath.get()); else typeFailureCount++; } @@ -274,11 +275,11 @@ void LanguageServer::compileAndUpdateDiagnostics() // These are the source units we will sent diagnostics to the client for sure, // even if it is just to clear previous diagnostics. - std::map diagnosticsBySourceUnit; + std::map diagnosticsBySourceUnit; for (std::string const& sourceUnitName: m_fileRepository.sourceUnits() | ranges::views::keys) - diagnosticsBySourceUnit[sourceUnitName] = Json::arrayValue; + diagnosticsBySourceUnit[sourceUnitName] = Json::array(); for (std::string const& sourceUnitName: m_nonemptyDiagnostics) - diagnosticsBySourceUnit[sourceUnitName] = Json::arrayValue; + diagnosticsBySourceUnit[sourceUnitName] = Json::array(); for (std::shared_ptr const& error: m_compilerStack.errors()) { @@ -287,10 +288,10 @@ void LanguageServer::compileAndUpdateDiagnostics() // LSP only has diagnostics applied to individual files. continue; - Json::Value jsonDiag; + Json jsonDiag; jsonDiag["source"] = "solc"; jsonDiag["severity"] = toDiagnosticSeverity(error->type()); - jsonDiag["code"] = Json::UInt64{error->errorId().error}; + jsonDiag["code"] = Json(error->errorId().error); std::string message = Error::formatErrorType(error->type()) + ":"; if (std::string const* comment = error->comment()) message += " " + *comment; @@ -300,26 +301,26 @@ void LanguageServer::compileAndUpdateDiagnostics() if (auto const* secondary = error->secondarySourceLocation()) for (auto&& [secondaryMessage, secondaryLocation]: secondary->infos) { - Json::Value jsonRelated; + Json jsonRelated; jsonRelated["message"] = secondaryMessage; jsonRelated["location"] = toJson(secondaryLocation); - jsonDiag["relatedInformation"].append(jsonRelated); + jsonDiag["relatedInformation"].emplace_back(jsonRelated); } - diagnosticsBySourceUnit[*location->sourceName].append(jsonDiag); + diagnosticsBySourceUnit[*location->sourceName].emplace_back(jsonDiag); } if (m_client.traceValue() != TraceValue::Off) { - Json::Value extra; - extra["openFileCount"] = Json::UInt64(diagnosticsBySourceUnit.size()); + Json extra; + extra["openFileCount"] = Json(diagnosticsBySourceUnit.size()); m_client.trace("Number of currently open files: " + std::to_string(diagnosticsBySourceUnit.size()), extra); } m_nonemptyDiagnostics.clear(); for (auto&& [sourceUnitName, diagnostics]: diagnosticsBySourceUnit) { - Json::Value params; + Json params; params["uri"] = m_fileRepository.sourceUnitNameToUri(sourceUnitName); if (!diagnostics.empty()) m_nonemptyDiagnostics.insert(sourceUnitName); @@ -335,14 +336,15 @@ bool LanguageServer::run() MessageID id; try { - std::optional const jsonMessage = m_client.receive(); + std::optional const jsonMessage = m_client.receive(); if (!jsonMessage) continue; - if ((*jsonMessage)["method"].isString()) + if ((*jsonMessage).contains("method") && (*jsonMessage)["method"].is_string()) { - std::string const methodName = (*jsonMessage)["method"].asString(); - id = (*jsonMessage)["id"]; + std::string const methodName = (*jsonMessage)["method"].get(); + if ((*jsonMessage).contains("id")) + id = (*jsonMessage)["id"]; lspDebug(fmt::format("received method call: {}", methodName)); if (auto handler = util::valueOrDefault(m_handlers, methodName)) @@ -353,7 +355,7 @@ bool LanguageServer::run() else m_client.error({}, ErrorCode::ParseError, "\"method\" has to be a string."); } - catch (Json::Exception const&) + catch (Json::exception const&) { m_client.error(id, ErrorCode::InvalidParams, "JSON object access error. Most likely due to a badly formatted JSON request message."s); } @@ -378,7 +380,7 @@ void LanguageServer::requireServerInitialized() ); } -void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) +void LanguageServer::handleInitialize(MessageID _id, Json const& _args) { lspRequire( m_state == State::Started, @@ -391,9 +393,9 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) // The default of FileReader is to use `.`, but the path from where the LSP was started // should not matter. std::string rootPath("/"); - if (Json::Value uri = _args["rootUri"]) + if (_args.contains("rootUri") && _args["rootUri"].is_string()) { - rootPath = uri.asString(); + rootPath = _args["rootUri"].get(); lspRequire( boost::starts_with(rootPath, "file://"), ErrorCode::InvalidParams, @@ -401,17 +403,17 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) ); rootPath = stripFileUriSchemePrefix(rootPath); } - else if (Json::Value rootPath = _args["rootPath"]) - rootPath = rootPath.asString(); + else if (_args.contains("rootPath")) + rootPath = _args["rootPath"].get(); - if (_args["trace"]) + if (_args.contains("trace")) setTrace(_args["trace"]); m_fileRepository = FileRepository(rootPath, {}); - if (_args["initializationOptions"].isObject()) + if (_args.contains("initializationOptions") && _args["initializationOptions"].is_object()) changeConfiguration(_args["initializationOptions"]); - Json::Value replyArgs; + Json replyArgs; replyArgs["serverInfo"]["name"] = "solc"; replyArgs["serverInfo"]["version"] = std::string(VersionNumber); replyArgs["capabilities"]["definitionProvider"] = true; @@ -427,44 +429,49 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) m_client.reply(_id, std::move(replyArgs)); } -void LanguageServer::handleInitialized(MessageID, Json::Value const&) +void LanguageServer::handleInitialized(MessageID, Json const&) { if (m_fileLoadStrategy == FileLoadStrategy::ProjectDirectory) compileAndUpdateDiagnostics(); } -void LanguageServer::semanticTokensFull(MessageID _id, Json::Value const& _args) +void LanguageServer::semanticTokensFull(MessageID _id, Json const& _args) { - auto uri = _args["textDocument"]["uri"]; + if (_args.contains("textDocument") && _args["textDocument"].contains("uri")) + { + auto uri = _args["textDocument"]["uri"]; - compile(); + compile(); - auto const sourceName = m_fileRepository.uriToSourceUnitName(uri.as()); - SourceUnit const& ast = m_compilerStack.ast(sourceName); - m_compilerStack.charStream(sourceName); - Json::Value data = SemanticTokensBuilder().build(ast, m_compilerStack.charStream(sourceName)); + auto const sourceName = m_fileRepository.uriToSourceUnitName(uri.get()); + SourceUnit const& ast = m_compilerStack.ast(sourceName); + m_compilerStack.charStream(sourceName); + Json data = SemanticTokensBuilder().build(ast, m_compilerStack.charStream(sourceName)); - Json::Value reply = Json::objectValue; - reply["data"] = data; + Json reply; + reply["data"] = data; - m_client.reply(_id, std::move(reply)); + m_client.reply(_id, std::move(reply)); + } + else + m_client.error(_id, ErrorCode::InvalidParams, "Invalid parameter: textDocument.uri expected."); } -void LanguageServer::handleWorkspaceDidChangeConfiguration(Json::Value const& _args) +void LanguageServer::handleWorkspaceDidChangeConfiguration(Json const& _args) { requireServerInitialized(); - if (_args["settings"].isObject()) + if (_args.contains("settings") && _args["settings"].is_object()) changeConfiguration(_args["settings"]); } -void LanguageServer::setTrace(Json::Value const& _args) +void LanguageServer::setTrace(Json const& _args) { - if (!_args.isString()) + if (!_args.is_string()) // Simply ignore invalid parameter. return; - std::string const stringValue = _args.asString(); + std::string const stringValue = _args.get(); if (stringValue == "off") m_client.setTrace(TraceValue::Off); else if (stringValue == "messages") @@ -473,78 +480,90 @@ void LanguageServer::setTrace(Json::Value const& _args) m_client.setTrace(TraceValue::Verbose); } -void LanguageServer::handleTextDocumentDidOpen(Json::Value const& _args) +void LanguageServer::handleTextDocumentDidOpen(Json const& _args) { requireServerInitialized(); lspRequire( - _args["textDocument"], + _args.contains("textDocument"), ErrorCode::RequestFailed, "Text document parameter missing." ); - std::string text = _args["textDocument"]["text"].asString(); - std::string uri = _args["textDocument"]["uri"].asString(); - m_openFiles.insert(uri); - m_fileRepository.setSourceByUri(uri, std::move(text)); - compileAndUpdateDiagnostics(); + if (_args["textDocument"].contains("text") && _args["textDocument"].contains("uri")) + { + std::string text = _args["textDocument"]["text"].get(); + std::string uri = _args["textDocument"]["uri"].get(); + m_openFiles.insert(uri); + m_fileRepository.setSourceByUri(uri, std::move(text)); + compileAndUpdateDiagnostics(); + } } -void LanguageServer::handleTextDocumentDidChange(Json::Value const& _args) +void LanguageServer::handleTextDocumentDidChange(Json const& _args) { requireServerInitialized(); - std::string const uri = _args["textDocument"]["uri"].asString(); - - for (Json::Value jsonContentChange: _args["contentChanges"]) + if (_args.contains("textDocument") && _args["textDocument"].contains("uri")) { - lspRequire( - jsonContentChange.isObject(), - ErrorCode::RequestFailed, - "Invalid content reference." - ); - - std::string const sourceUnitName = m_fileRepository.uriToSourceUnitName(uri); - lspRequire( - m_fileRepository.sourceUnits().count(sourceUnitName), - ErrorCode::RequestFailed, - "Unknown file: " + uri - ); + std::string const uri = _args["textDocument"]["uri"].get(); - std::string text = jsonContentChange["text"].asString(); - if (jsonContentChange["range"].isObject()) // otherwise full content update - { - std::optional change = parseRange(m_fileRepository, sourceUnitName, jsonContentChange["range"]); - lspRequire( - change && change->hasText(), - ErrorCode::RequestFailed, - "Invalid source range: " + util::jsonCompactPrint(jsonContentChange["range"]) - ); + if (_args.contains("contentChanges")) + for (auto const& [_, jsonContentChange]: _args["contentChanges"].items()) + { + lspRequire(jsonContentChange.is_object(), ErrorCode::RequestFailed, "Invalid content reference."); + + std::string const sourceUnitName = m_fileRepository.uriToSourceUnitName(uri); + lspRequire( + m_fileRepository.sourceUnits().count(sourceUnitName), + ErrorCode::RequestFailed, + "Unknown file: " + uri); + + if (jsonContentChange.contains("text")) + { + std::string text = jsonContentChange["text"].get(); + if (jsonContentChange.contains("range") + && jsonContentChange["range"].is_object()) // otherwise full content update + { + std::optional change + = parseRange(m_fileRepository, sourceUnitName, jsonContentChange["range"]); + lspRequire( + change && change->hasText(), + ErrorCode::RequestFailed, + "Invalid source range: " + util::jsonCompactPrint(jsonContentChange["range"])); + + std::string buffer = m_fileRepository.sourceUnits().at(sourceUnitName); + buffer.replace( + static_cast(change->start), + static_cast(change->end - change->start), + std::move(text)); + text = std::move(buffer); + } + m_fileRepository.setSourceByUri(uri, std::move(text)); + } + } - std::string buffer = m_fileRepository.sourceUnits().at(sourceUnitName); - buffer.replace(static_cast(change->start), static_cast(change->end - change->start), std::move(text)); - text = std::move(buffer); - } - m_fileRepository.setSourceByUri(uri, std::move(text)); + compileAndUpdateDiagnostics(); } - - compileAndUpdateDiagnostics(); } -void LanguageServer::handleTextDocumentDidClose(Json::Value const& _args) +void LanguageServer::handleTextDocumentDidClose(Json const& _args) { requireServerInitialized(); lspRequire( - _args["textDocument"], + _args.contains("textDocument"), ErrorCode::RequestFailed, "Text document parameter missing." ); - std::string uri = _args["textDocument"]["uri"].asString(); - m_openFiles.erase(uri); + if (_args["textDocument"].contains("uri")) + { + std::string uri = _args["textDocument"]["uri"].get(); + m_openFiles.erase(uri); - compileAndUpdateDiagnostics(); + compileAndUpdateDiagnostics(); + } } ASTNode const* LanguageServer::astNodeAtSourceLocation(std::string const& _sourceUnitName, LineColumn const& _filePos) diff --git a/libsolidity/lsp/LanguageServer.h b/libsolidity/lsp/LanguageServer.h index d80f8e879c7a..4bea5809fa45 100644 --- a/libsolidity/lsp/LanguageServer.h +++ b/libsolidity/lsp/LanguageServer.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -85,29 +85,29 @@ class LanguageServer /// Checks if the server is initialized (to be used by messages that need it to be initialized). /// Reports an error and returns false if not. void requireServerInitialized(); - void handleInitialize(MessageID _id, Json::Value const& _args); - void handleInitialized(MessageID _id, Json::Value const& _args); - void handleWorkspaceDidChangeConfiguration(Json::Value const& _args); - void setTrace(Json::Value const& _args); - void handleTextDocumentDidOpen(Json::Value const& _args); - void handleTextDocumentDidChange(Json::Value const& _args); - void handleTextDocumentDidClose(Json::Value const& _args); - void handleRename(Json::Value const& _args); - void handleGotoDefinition(MessageID _id, Json::Value const& _args); - void semanticTokensFull(MessageID _id, Json::Value const& _args); + void handleInitialize(MessageID _id, Json const& _args); + void handleInitialized(MessageID _id, Json const& _args); + void handleWorkspaceDidChangeConfiguration(Json const& _args); + void setTrace(Json const& _args); + void handleTextDocumentDidOpen(Json const& _args); + void handleTextDocumentDidChange(Json const& _args); + void handleTextDocumentDidClose(Json const& _args); + void handleRename(Json const& _args); + void handleGotoDefinition(MessageID _id, Json const& _args); + void semanticTokensFull(MessageID _id, Json const& _args); /// Invoked when the server user-supplied configuration changes (initiated by the client). - void changeConfiguration(Json::Value const&); + void changeConfiguration(Json const&); /// Compile everything until after analysis phase. void compile(); std::vector allSolidityFilesFromProject() const; - using MessageHandler = std::function; + using MessageHandler = std::function; - Json::Value toRange(langutil::SourceLocation const& _location); - Json::Value toJson(langutil::SourceLocation const& _location); + Json toRange(langutil::SourceLocation const& _location); + Json toJson(langutil::SourceLocation const& _location); // LSP related member fields @@ -127,7 +127,7 @@ class LanguageServer frontend::CompilerStack m_compilerStack; /// User-supplied custom configuration settings (such as EVM version). - Json::Value m_settingsObject; + Json m_settingsObject; }; } diff --git a/libsolidity/lsp/RenameSymbol.cpp b/libsolidity/lsp/RenameSymbol.cpp index 75f032fcca47..497ee50fb451 100644 --- a/libsolidity/lsp/RenameSymbol.cpp +++ b/libsolidity/lsp/RenameSymbol.cpp @@ -47,11 +47,11 @@ CallableDeclaration const* extractCallableDeclaration(FunctionCall const& _funct } -void RenameSymbol::operator()(MessageID _id, Json::Value const& _args) +void RenameSymbol::operator()(MessageID _id, Json const& _args) { auto const&& [sourceUnitName, lineColumn] = extractSourceUnitNameAndLineColumn(_args); - std::string const newName = _args["newName"].asString(); - std::string const uri = _args["textDocument"]["uri"].asString(); + std::string const newName = _args["newName"].get(); + std::string const uri = _args["textDocument"]["uri"].get(); ASTNode const* sourceNode = m_server.astNodeAtSourceLocation(sourceUnitName, lineColumn); @@ -90,10 +90,10 @@ void RenameSymbol::operator()(MessageID _id, Json::Value const& _args) // Apply changes in reverse order (will iterate in reverse) sort(m_locations.begin(), m_locations.end()); - Json::Value reply = Json::objectValue; - reply["changes"] = Json::objectValue; + Json reply; + reply["changes"] = Json::object(); - Json::Value edits = Json::arrayValue; + Json edits = Json::array(); for (auto i = m_locations.rbegin(); i != m_locations.rend(); i++) { @@ -105,16 +105,16 @@ void RenameSymbol::operator()(MessageID _id, Json::Value const& _args) buffer.replace((size_t)i->start, (size_t)(i->end - i->start), newName); fileRepository().setSourceByUri(uri, std::move(buffer)); - Json::Value edit = Json::objectValue; + Json edit; edit["range"] = toRange(*i); edit["newText"] = newName; // Record changes for the client - edits.append(edit); + edits.emplace_back(edit); if (i + 1 == m_locations.rend() || (i + 1)->sourceName != i->sourceName) { reply["changes"][uri] = edits; - edits = Json::arrayValue; + edits = Json::array(); // Reset. } } diff --git a/libsolidity/lsp/RenameSymbol.h b/libsolidity/lsp/RenameSymbol.h index cafa8c067a25..c4a2ac98f359 100644 --- a/libsolidity/lsp/RenameSymbol.h +++ b/libsolidity/lsp/RenameSymbol.h @@ -27,7 +27,7 @@ class RenameSymbol: public HandlerBase public: explicit RenameSymbol(LanguageServer& _server): HandlerBase(_server) {} - void operator()(MessageID, Json::Value const&); + void operator()(MessageID, Json const&); protected: // Nested class because otherwise `RenameSymbol` couldn't be easily used // with LanguageServer::m_handlers as `ASTConstVisitor` deletes required diff --git a/libsolidity/lsp/SemanticTokensBuilder.cpp b/libsolidity/lsp/SemanticTokensBuilder.cpp index 2f44354184ef..be0796860cb9 100644 --- a/libsolidity/lsp/SemanticTokensBuilder.cpp +++ b/libsolidity/lsp/SemanticTokensBuilder.cpp @@ -70,7 +70,7 @@ SemanticTokenType semanticTokenTypeForExpression(frontend::Type const* _type) } // end namespace -Json::Value SemanticTokensBuilder::build(SourceUnit const& _sourceUnit, CharStream const& _charStream) +Json SemanticTokensBuilder::build(SourceUnit const& _sourceUnit, CharStream const& _charStream) { reset(&_charStream); _sourceUnit.accept(*this); @@ -79,7 +79,7 @@ Json::Value SemanticTokensBuilder::build(SourceUnit const& _sourceUnit, CharStre void SemanticTokensBuilder::reset(CharStream const* _charStream) { - m_encodedTokens = Json::arrayValue; + m_encodedTokens = Json::array(); m_charStream = _charStream; m_lastLine = 0; m_lastStartChar = 0; @@ -120,14 +120,14 @@ void SemanticTokensBuilder::encode( lspDebug(fmt::format("encode [{}:{}..{}] {}", line, startChar, length, static_cast(_tokenType))); - m_encodedTokens.append(line - m_lastLine); + m_encodedTokens.emplace_back(line - m_lastLine); if (line == m_lastLine) - m_encodedTokens.append(startChar - m_lastStartChar); + m_encodedTokens.emplace_back(startChar - m_lastStartChar); else - m_encodedTokens.append(startChar); - m_encodedTokens.append(length); - m_encodedTokens.append(static_cast(_tokenType)); - m_encodedTokens.append(static_cast(_modifiers)); + m_encodedTokens.emplace_back(startChar); + m_encodedTokens.emplace_back(length); + m_encodedTokens.emplace_back(static_cast(_tokenType)); + m_encodedTokens.emplace_back(static_cast(_modifiers)); m_lastLine = line; m_lastStartChar = startChar; diff --git a/libsolidity/lsp/SemanticTokensBuilder.h b/libsolidity/lsp/SemanticTokensBuilder.h index ca3c48d1c68d..3facb99e2bae 100644 --- a/libsolidity/lsp/SemanticTokensBuilder.h +++ b/libsolidity/lsp/SemanticTokensBuilder.h @@ -17,7 +17,7 @@ // SPDX-License-Identifier: GPL-3.0 #include #include -#include +#include #include @@ -87,7 +87,7 @@ constexpr SemanticTokenModifiers operator|(SemanticTokenModifiers a, SemanticTok class SemanticTokensBuilder: public frontend::ASTConstVisitor { public: - Json::Value build(frontend::SourceUnit const& _sourceUnit, langutil::CharStream const& _charStream); + Json build(frontend::SourceUnit const& _sourceUnit, langutil::CharStream const& _charStream); void reset(langutil::CharStream const* _charStream); void encode( @@ -114,7 +114,7 @@ class SemanticTokensBuilder: public frontend::ASTConstVisitor bool visit(frontend::VariableDeclaration const&) override; private: - Json::Value m_encodedTokens; + Json m_encodedTokens; langutil::CharStream const* m_charStream; int m_lastLine; int m_lastStartChar; diff --git a/libsolidity/lsp/Transport.cpp b/libsolidity/lsp/Transport.cpp index 7f8eb2283488..743ad6d66955 100644 --- a/libsolidity/lsp/Transport.cpp +++ b/libsolidity/lsp/Transport.cpp @@ -38,9 +38,10 @@ #endif using namespace solidity::lsp; +using namespace solidity; // {{{ Transport -std::optional Transport::receive() +std::optional Transport::receive() { auto const headers = parseHeaders(); if (!headers) @@ -57,10 +58,10 @@ std::optional Transport::receive() std::string const data = readBytes(stoul(headers->at("content-length"))); - Json::Value jsonMessage; + Json jsonMessage; std::string jsonParsingErrors; solidity::util::jsonParseStrict(data, jsonMessage, &jsonParsingErrors); - if (!jsonParsingErrors.empty() || !jsonMessage || !jsonMessage.isObject()) + if (!jsonParsingErrors.empty() || jsonMessage.empty() || !jsonMessage.is_object()) { error({}, ErrorCode::ParseError, "Could not parse RPC JSON payload. " + jsonParsingErrors); return std::nullopt; @@ -69,12 +70,12 @@ std::optional Transport::receive() return {std::move(jsonMessage)}; } -void Transport::trace(std::string _message, Json::Value _extra) +void Transport::trace(std::string _message, Json _extra) { if (m_logTrace != TraceValue::Off) { - Json::Value params; - if (_extra.isObject()) + Json params; + if (_extra.is_object()) params = std::move(_extra); params["message"] = std::move(_message); notify("$/logTrace", std::move(params)); @@ -103,34 +104,34 @@ std::optional> Transport::parseHeaders() return {std::move(headers)}; } -void Transport::notify(std::string _method, Json::Value _message) +void Transport::notify(std::string _method, Json _message) { - Json::Value json; + Json json; json["method"] = std::move(_method); json["params"] = std::move(_message); send(std::move(json)); } -void Transport::reply(MessageID _id, Json::Value _message) +void Transport::reply(MessageID _id, Json _message) { - Json::Value json; + Json json; json["result"] = std::move(_message); send(std::move(json), _id); } void Transport::error(MessageID _id, ErrorCode _code, std::string _message) { - Json::Value json; + Json json; json["error"]["code"] = static_cast(_code); json["error"]["message"] = std::move(_message); send(std::move(json), _id); } -void Transport::send(Json::Value _json, MessageID _id) +void Transport::send(Json _json, MessageID _id) { - solAssert(_json.isObject()); + solAssert(_json.is_object()); _json["jsonrpc"] = "2.0"; - if (_id != Json::nullValue) + if (_id != Json()) _json["id"] = _id; // Trailing CRLF only for easier readability. diff --git a/libsolidity/lsp/Transport.h b/libsolidity/lsp/Transport.h index e3b03bcc7f2f..e76cb5f7da5d 100644 --- a/libsolidity/lsp/Transport.h +++ b/libsolidity/lsp/Transport.h @@ -18,8 +18,7 @@ #pragma once #include - -#include +#include #include #include @@ -32,7 +31,7 @@ namespace solidity::lsp { -using MessageID = Json::Value; +using MessageID = Json; enum class TraceValue { @@ -98,14 +97,14 @@ class Transport public: virtual ~Transport() = default; - std::optional receive(); - void notify(std::string _method, Json::Value _params); - void reply(MessageID _id, Json::Value _result); + std::optional receive(); + void notify(std::string _method, Json _params); + void reply(MessageID _id, Json _result); void error(MessageID _id, ErrorCode _code, std::string _message); virtual bool closed() const noexcept = 0; - void trace(std::string _message, Json::Value _extra = Json::nullValue); + void trace(std::string _message, Json _extra = Json{}); TraceValue traceValue() const noexcept { return m_logTrace; } void setTrace(TraceValue _value) noexcept { m_logTrace = _value; } @@ -135,7 +134,7 @@ class Transport /// Sends an arbitrary raw message to the client. /// /// Used by the notify/reply/error function family. - virtual void send(Json::Value _message, MessageID _id = Json::nullValue); + virtual void send(Json _message, MessageID _id = Json{}); }; /** diff --git a/libsolidity/lsp/Utils.cpp b/libsolidity/lsp/Utils.cpp index 85e27a4fda5f..7667ce688ecd 100644 --- a/libsolidity/lsp/Utils.cpp +++ b/libsolidity/lsp/Utils.cpp @@ -31,26 +31,26 @@ namespace solidity::lsp using namespace frontend; using namespace langutil; -std::optional parseLineColumn(Json::Value const& _lineColumn) +std::optional parseLineColumn(Json const& _lineColumn) { - if (_lineColumn.isObject() && _lineColumn["line"].isInt() && _lineColumn["character"].isInt()) - return LineColumn{_lineColumn["line"].asInt(), _lineColumn["character"].asInt()}; + if (_lineColumn.is_object() && _lineColumn["line"].is_number_integer() && _lineColumn["character"].is_number_integer()) + return LineColumn{_lineColumn["line"].get(), _lineColumn["character"].get()}; else return std::nullopt; } -Json::Value toJson(LineColumn const& _pos) +Json toJson(LineColumn const& _pos) { - Json::Value json = Json::objectValue; + Json json; json["line"] = std::max(_pos.line, 0); json["character"] = std::max(_pos.column, 0); return json; } -Json::Value toJsonRange(LineColumn const& _start, LineColumn const& _end) +Json toJsonRange(LineColumn const& _start, LineColumn const& _end) { - Json::Value json; + Json json; json["start"] = toJson(_start); json["end"] = toJson(_end); return json; @@ -86,7 +86,7 @@ std::optional declarationLocation(Declaration const* _declaratio std::optional parsePosition( FileRepository const& _fileRepository, std::string const& _sourceUnitName, - Json::Value const& _position + Json const& _position ) { if (!_fileRepository.sourceUnits().count(_sourceUnitName)) @@ -101,9 +101,9 @@ std::optional parsePosition( return std::nullopt; } -std::optional parseRange(FileRepository const& _fileRepository, std::string const& _sourceUnitName, Json::Value const& _range) +std::optional parseRange(FileRepository const& _fileRepository, std::string const& _sourceUnitName, Json const& _range) { - if (!_range.isObject()) + if (!_range.is_object()) return std::nullopt; std::optional start = parsePosition(_fileRepository, _sourceUnitName, _range["start"]); std::optional end = parsePosition(_fileRepository, _sourceUnitName, _range["end"]); diff --git a/libsolidity/lsp/Utils.h b/libsolidity/lsp/Utils.h index c6d40213e6d3..318cdc87d6fc 100644 --- a/libsolidity/lsp/Utils.h +++ b/libsolidity/lsp/Utils.h @@ -44,16 +44,16 @@ namespace solidity::lsp class FileRepository; -std::optional parseLineColumn(Json::Value const& _lineColumn); -Json::Value toJson(langutil::LineColumn const& _pos); -Json::Value toJsonRange(langutil::LineColumn const& _start, langutil::LineColumn const& _end); +std::optional parseLineColumn(Json const& _lineColumn); +Json toJson(langutil::LineColumn const& _pos); +Json toJsonRange(langutil::LineColumn const& _start, langutil::LineColumn const& _end); /// @returns the source location given a source unit name and an LSP Range object, /// or nullopt on failure. std::optional parsePosition( FileRepository const& _fileRepository, std::string const& _sourceUnitName, - Json::Value const& _position + Json const& _position ); /// @returns the source location given a source unit name and an LSP Range object, @@ -61,7 +61,7 @@ std::optional parsePosition( std::optional parseRange( FileRepository const& _fileRepository, std::string const& _sourceUnitName, - Json::Value const& _range + Json const& _range ); /// Strips the file:// URI prefix off the given path, if present, diff --git a/libsolutil/CMakeLists.txt b/libsolutil/CMakeLists.txt index f97d61b671c1..0fdb23b0445f 100644 --- a/libsolutil/CMakeLists.txt +++ b/libsolutil/CMakeLists.txt @@ -43,7 +43,7 @@ set(sources ) add_library(solutil ${sources}) -target_link_libraries(solutil PUBLIC jsoncpp Boost::boost Boost::filesystem Boost::system range-v3 fmt::fmt-header-only) +target_link_libraries(solutil PUBLIC Boost::boost Boost::filesystem Boost::system range-v3 fmt::fmt-header-only nlohmann-json) target_include_directories(solutil PUBLIC "${PROJECT_SOURCE_DIR}") add_dependencies(solutil solidity_BuildInfo.h) diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index f3c168e6510b..de6873845dea 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -343,6 +343,49 @@ void joinMap(std::map& _a, std::map&& _b, F _conflictSolver) } } +template +class UniqueVector +{ +public: + std::vector const& contents() const { return m_contents; } + size_t size() const { return m_contents.size(); } + bool empty() const { return m_contents.empty(); } + auto begin() const { return m_contents.begin(); } + auto end() const { return m_contents.end(); } + void clear() { m_contents.clear(); } + bool contains(T const& _value) const + { + return std::find(m_contents.begin(), m_contents.end(), _value) != m_contents.end(); + } + + void pushBack(T _value) + { + if (!contains(_value)) + m_contents.emplace_back(std::move(_value)); + } + + void pushBack(UniqueVector const& _values) + { + for (auto&& value: _values) + pushBack(value); + } + + void removeAll(std::vector const& _values) + { + for (auto const& value: _values) + m_contents.erase(std::find(m_contents.begin(), m_contents.end(), value)); + } + +private: + std::vector m_contents; +}; + +template +void swap(UniqueVector& _lhs, UniqueVector& _rhs) +{ + std::swap(_lhs.contents(), _rhs.contents()); +} + namespace detail { diff --git a/libsolutil/Exceptions.h b/libsolutil/Exceptions.h index 9d73a0012eb4..7dd9b6769ad4 100644 --- a/libsolutil/Exceptions.h +++ b/libsolutil/Exceptions.h @@ -76,6 +76,7 @@ DEV_SIMPLE_EXCEPTION(FileNotFound); DEV_SIMPLE_EXCEPTION(NotAFile); DEV_SIMPLE_EXCEPTION(DataTooLong); DEV_SIMPLE_EXCEPTION(StringTooLong); +DEV_SIMPLE_EXCEPTION(InvalidType); // error information to be added to exceptions using errinfo_comment = boost::error_info; diff --git a/libsolutil/FixedHash.h b/libsolutil/FixedHash.h index c4c72e9eb78a..3aa248480839 100644 --- a/libsolutil/FixedHash.h +++ b/libsolutil/FixedHash.h @@ -159,7 +159,7 @@ class FixedHash bytes asBytes() const { return bytes(data(), data() + N); } private: - std::array m_data; ///< The binary data. + std::array m_data; ///< The binary data. }; /// Stream I/O for the FixedHash class. diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index ea75ada0f79f..055024edb3d0 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -22,18 +22,17 @@ #include -#include +#include -#include +#include #include -#include -#include +#ifdef STRICT_NLOHMANN_JSON_VERSION_CHECK static_assert( - (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 3), - "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.3." -); + (NLOHMANN_JSON_VERSION_MAJOR == 3) && (NLOHMANN_JSON_VERSION_MINOR == 11) && (NLOHMANN_JSON_VERSION_PATCH == 3), + "Unexpected nlohmann-json version. Expecting 3.11.3."); +#endif namespace solidity::util { @@ -41,116 +40,147 @@ namespace solidity::util namespace { -/// StreamWriterBuilder that can be constructed with specific settings -class StreamWriterBuilder: public Json::StreamWriterBuilder +/// Takes a JSON value (@ _json) and removes all its members with value 'null' recursively. +void removeNullMembersHelper(Json& _json) { -public: - explicit StreamWriterBuilder(std::map const& _settings) + if (_json.is_array()) { - for (auto const& iter: _settings) - this->settings_[iter.first] = iter.second; + for (auto& child: _json) + removeNullMembersHelper(child); } -}; - -/// CharReaderBuilder with strict-mode settings -class StrictModeCharReaderBuilder: public Json::CharReaderBuilder -{ -public: - StrictModeCharReaderBuilder() + else if (_json.is_object()) { - Json::CharReaderBuilder::strictMode(&this->settings_); + for (auto it = _json.begin(); it != _json.end();) + { + if (it->is_null()) + it = _json.erase(it); + else + { + removeNullMembersHelper(*it); + ++it; + } + } } -}; - -/// Serialise the JSON object (@a _input) with specific builder (@a _builder) -/// \param _input JSON input string -/// \param _builder StreamWriterBuilder that is used to create new Json::StreamWriter -/// \return serialized json object -std::string print(Json::Value const& _input, Json::StreamWriterBuilder const& _builder) -{ - std::stringstream stream; - std::unique_ptr writer(_builder.newStreamWriter()); - writer->write(_input, &stream); - return stream.str(); } -/// Parse a JSON string (@a _input) with specified builder (@ _builder) and writes resulting JSON object to (@a _json) -/// \param _builder CharReaderBuilder that is used to create new Json::CharReaders -/// \param _input JSON input string -/// \param _json [out] resulting JSON object -/// \param _errs [out] Formatted error messages -/// \return \c true if the document was successfully parsed, \c false if an error occurred. -bool parse(Json::CharReaderBuilder& _builder, std::string const& _input, Json::Value& _json, std::string* _errs) +std::string escapeNewlinesAndTabsWithinStringLiterals(std::string const& _json) { - std::unique_ptr reader(_builder.newCharReader()); - return reader->parse(_input.c_str(), _input.c_str() + _input.length(), &_json, _errs); -} + std::stringstream fixed; + bool inQuotes = false; + for (size_t i = 0; i < _json.size(); ++i) + { + char c = _json[i]; -/// Takes a JSON value (@ _json) and removes all its members with value 'null' recursively. -void removeNullMembersHelper(Json::Value& _json) -{ - if (_json.type() == Json::ValueType::arrayValue) - for (auto& child: _json) - removeNullMembersHelper(child); - else if (_json.type() == Json::ValueType::objectValue) - for (auto const& key: _json.getMemberNames()) + // Originally we had just this here: + // if (c == '"' && (i == 0 || _json[i - 1] != '\\')) + // inQuotes = !inQuotes; + // However, this is not working if the escape character itself was escaped. e.g. "\n\r'\"\\". + + if (c == '"') + { + size_t backslashCount = 0; + size_t j = i; + while (j > 0 && _json[j - 1] == '\\') + { + backslashCount++; + j--; + } + if (backslashCount % 2 == 0) + { + inQuotes = !inQuotes; + fixed << c; + continue; + } + } + + if (inQuotes) { - Json::Value& value = _json[key]; - if (value.isNull()) - _json.removeMember(key); + if (c == '\n') + fixed << "\\n"; + else if (c == '\t') + fixed << "\\t"; else - removeNullMembersHelper(value); + fixed << c; } + else + fixed << c; + } + return fixed.str(); } } // end anonymous namespace -Json::Value removeNullMembers(Json::Value _json) +Json removeNullMembers(Json _json) { removeNullMembersHelper(_json); return _json; } -std::string jsonPrettyPrint(Json::Value const& _input) +std::string removeNlohmannInternalErrorIdentifier(std::string const& _input) { - return jsonPrint(_input, JsonFormat{ JsonFormat::Pretty }); + std::string result = _input; + std::size_t startPos = result.find('['); + std::size_t endPos = result.find(']', startPos); + + if (startPos != std::string::npos && endPos != std::string::npos) + result.erase(startPos, endPos - startPos + 1); + + return boost::trim_copy(result); } -std::string jsonCompactPrint(Json::Value const& _input) +std::string jsonPrettyPrint(Json const& _input) { return jsonPrint(_input, JsonFormat{JsonFormat::Pretty}); } + +std::string jsonCompactPrint(Json const& _input) { return jsonPrint(_input, JsonFormat{JsonFormat::Compact}); } + +std::string jsonPrint(Json const& _input, JsonFormat const& _format) { - return jsonPrint(_input, JsonFormat{ JsonFormat::Compact }); + // NOTE: -1 here means no new lines (it is also the default setting) + std::string dumped = _input.dump( + /* indent */ (_format.format == JsonFormat::Pretty) ? static_cast(_format.indent) : -1, + /* indent_char */ ' ', + /* ensure_ascii */ true + ); + + return dumped; } -std::string jsonPrint(Json::Value const& _input, JsonFormat const& _format) +bool jsonParseStrict(std::string const& _input, Json& _json, std::string* _errs /* = nullptr */) { - std::map settings; - if (_format.format == JsonFormat::Pretty) + try { - settings["indentation"] = std::string(_format.indent, ' '); - settings["enableYAMLCompatibility"] = true; + _json = Json::parse( + // TODO: remove this in the next breaking release? + escapeNewlinesAndTabsWithinStringLiterals(_input), + /* callback */ nullptr, + /* allow exceptions */ true, + /* ignore_comments */true + ); + _errs = {}; + return true; + } + catch (Json::parse_error const& e) + { + if (_errs) + { + std::stringstream escaped; + for (char c: removeNlohmannInternalErrorIdentifier(e.what())) + if (std::isprint(c)) + escaped << c; + else + escaped << "\\x" + toHex(static_cast(c)); + *_errs = escaped.str(); + } + return false; } - else - settings["indentation"] = ""; - StreamWriterBuilder writerBuilder(settings); - std::string result = print(_input, writerBuilder); - if (_format.format == JsonFormat::Pretty) - boost::replace_all(result, " \n", "\n"); - return result; -} - -bool jsonParseStrict(std::string const& _input, Json::Value& _json, std::string* _errs /* = nullptr */) -{ - static StrictModeCharReaderBuilder readerBuilder; - return parse(readerBuilder, _input, _json, _errs); } -std::optional jsonValueByPath(Json::Value const& _node, std::string_view _jsonPath) +std::optional jsonValueByPath(Json const& _node, std::string_view _jsonPath) { - if (!_node.isObject() || _jsonPath.empty()) + if (!_node.is_object() || _jsonPath.empty()) return {}; std::string memberName = std::string(_jsonPath.substr(0, _jsonPath.find_first_of('.'))); - if (!_node.isMember(memberName)) + if (!_node.contains(memberName)) return {}; if (memberName == _jsonPath) diff --git a/libsolutil/JSON.h b/libsolutil/JSON.h index f368739e1a99..2cdac70c7857 100644 --- a/libsolutil/JSON.h +++ b/libsolutil/JSON.h @@ -23,17 +23,26 @@ #pragma once -#include +#include +#include #include #include #include +#include + +namespace solidity +{ + +using Json = nlohmann::json; + +} // namespace solidity namespace solidity::util { /// Removes members with null value recursively from (@a _json). -Json::Value removeNullMembers(Json::Value _json); +Json removeNullMembers(Json _json); /// JSON printing format. struct JsonFormat @@ -54,27 +63,29 @@ struct JsonFormat }; /// Serialise the JSON object (@a _input) with indentation -std::string jsonPrettyPrint(Json::Value const& _input); +std::string jsonPrettyPrint(Json const& _input); /// Serialise the JSON object (@a _input) without indentation -std::string jsonCompactPrint(Json::Value const& _input); +std::string jsonCompactPrint(Json const& _input); /// Serialise the JSON object (@a _input) using specified format (@a _format) -std::string jsonPrint(Json::Value const& _input, JsonFormat const& _format); +std::string jsonPrint(Json const& _input, JsonFormat const& _format); /// Parse a JSON string (@a _input) with enabled strict-mode and writes resulting JSON object to (@a _json) /// \param _input JSON input string /// \param _json [out] resulting JSON object /// \param _errs [out] Formatted error messages /// \return \c true if the document was successfully parsed, \c false if an error occurred. -bool jsonParseStrict(std::string const& _input, Json::Value& _json, std::string* _errs = nullptr); +bool jsonParseStrict(std::string const& _input, Json& _json, std::string* _errs = nullptr); /// Retrieves the value specified by @p _jsonPath by from a series of nested JSON dictionaries. /// @param _jsonPath A dot-separated series of dictionary keys. /// @param _node The node representing the start of the path. /// @returns The value of the last key on the path. @a nullptr if any node on the path descends /// into something that is not a dictionary or the key is not present. -std::optional jsonValueByPath(Json::Value const& _node, std::string_view _jsonPath); +std::optional jsonValueByPath(Json const& _node, std::string_view _jsonPath); + +std::string removeNlohmannInternalErrorIdentifier(std::string const& _input); namespace detail { @@ -82,60 +93,95 @@ namespace detail template struct helper; -template +template struct helper_impl { - static bool isOfType(Json::Value const& _input) + static bool isOfType(Json const& _input) { return (_input.*checkMember)(); } - static T get(Json::Value const& _input) + static T get(Json const& _input) { + assertThrow(isOfType(_input), InvalidType, ""); return (_input.*convertMember)(); } - static T getOrDefault(Json::Value const& _input, T _default = {}) + static T getOrDefault(Json const& _input, std::string const& _name, T _default = {}) { T result = _default; - if (isOfType(_input)) - result = (_input.*convertMember)(); + if (_input.contains(_name) && isOfType(_input[_name])) + result = (_input[_name].*convertMember)(); return result; } }; -template<> struct helper: helper_impl {}; -template<> struct helper: helper_impl {}; -template<> struct helper: helper_impl {}; -template<> struct helper: helper_impl {}; -template<> struct helper: helper_impl {}; -template<> struct helper: helper_impl {}; -template<> struct helper: helper_impl {}; +template +struct helper_impl_with_range_check +{ + static bool isOfType(Json const& _input) + { + if ( (_input.*checkMember)()) + { + T value = (_input.*convertMember)(); + return (value >= std::numeric_limits::min() && value <= std::numeric_limits::max()); + } + return false; + } + + static RT get(Json const& _input) + { + assertThrow(isOfType(_input), InvalidType, ""); + return static_cast((_input.*convertMember)()); + } + + static RT getOrDefault(Json const& _input, std::string const& _name, RT _default = {}) + { + RT value = _default; + if (_input.contains(_name) && isOfType(_input[_name])) + value = static_cast((_input[_name].*convertMember)()); + return value; + } +}; + +template<> struct helper: helper_impl> {}; +template<> struct helper: helper_impl> {}; +template<> struct helper: helper_impl> {}; +template<> struct helper: helper_impl> {}; +template<> struct helper: helper_impl> {}; + +template<> struct helper: helper_impl_with_range_check> {}; +template<> struct helper: helper_impl_with_range_check> {}; +template<> struct helper: helper_impl_with_range_check> {}; +template<> struct helper: helper_impl_with_range_check> {}; +template<> struct helper: helper_impl_with_range_check> {}; +template<> struct helper: helper_impl_with_range_check> {}; +template<> struct helper: helper_impl_with_range_check> {}; } // namespace detail template -bool isOfType(Json::Value const& _input) +bool isOfType(Json const& _input) { return detail::helper::isOfType(_input); } template -bool isOfTypeIfExists(Json::Value const& _input, std::string const& _name) +bool isOfTypeIfExists(Json const& _input, std::string const& _name) { - if (_input.isMember(_name)) + if (_input.contains(_name)) return isOfType(_input[_name]); return true; } template -T get(Json::Value const& _input) +T get(Json const& _input) { return detail::helper::get(_input); } template -T getOrDefault(Json::Value const& _input, T _default = {}) +T getOrDefault(Json const& _input, std::string const& _name, T _default = {}) { - return detail::helper::getOrDefault(_input, _default); + return detail::helper::getOrDefault(_input, _name, _default); } } // namespace solidity::util diff --git a/libsolutil/Keccak256.cpp b/libsolutil/Keccak256.cpp index c54dedabeb8f..9cf716354a9b 100644 --- a/libsolutil/Keccak256.cpp +++ b/libsolutil/Keccak256.cpp @@ -35,7 +35,7 @@ namespace * * A single-file implementation of SHA-3 and SHAKE. * - * Implementor: David Leon Gil + * implementer: David Leon Gil * License: CC0, attribution kindly requested. Blame taken too, * but not liability. */ diff --git a/libsolutil/Result.h b/libsolutil/Result.h index ca9563947729..bf6bde84b6ea 100644 --- a/libsolutil/Result.h +++ b/libsolutil/Result.h @@ -30,9 +30,9 @@ namespace solidity::util /// /// Result check() /// { -/// if (false) -/// return Result::err("Error message.") -/// return true; +/// if (false) +/// return Result::err("Error message.") +/// return true; /// } /// diff --git a/libstdlib/CMakeLists.txt b/libstdlib/CMakeLists.txt index 65a3a1cda16b..b6b22832d6e6 100644 --- a/libstdlib/CMakeLists.txt +++ b/libstdlib/CMakeLists.txt @@ -1,18 +1,18 @@ # This will re-generate the headers if any file within src was modified. -set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/stdlib/src/) +set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/) set(STDLIB stub) set(GENERATED_STDLIB_HEADERS) foreach(src IN LISTS STDLIB) - set(STDLIB_FILE ${PROJECT_SOURCE_DIR}/libstdlib/src/${src}.sol) + set(STDLIB_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/${src}.sol) file(READ ${STDLIB_FILE} STDLIB_FILE_CONTENT HEX) string(REGEX MATCHALL ".." STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") list(REMOVE_ITEM STDLIB_FILE_CONTENT "0d") string(REGEX REPLACE ";" ",\n\t0x" STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_CONTENT "0x${STDLIB_FILE_CONTENT}") set(STDLIB_FILE_NAME ${src}) - configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.src.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) list(APPEND GENERATED_STDLIB_HEADERS ${PROJECT_BINARY_DIR}/include/libstdlib/${src}.h) endforeach() -configure_file("${PROJECT_SOURCE_DIR}/libstdlib/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.h.in" ${PROJECT_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) diff --git a/libyul/AsmJsonConverter.cpp b/libyul/AsmJsonConverter.cpp index bf2468b4e4bb..a89e4967aa4e 100644 --- a/libyul/AsmJsonConverter.cpp +++ b/libyul/AsmJsonConverter.cpp @@ -29,25 +29,25 @@ namespace solidity::yul { -Json::Value AsmJsonConverter::operator()(Block const& _node) const +Json AsmJsonConverter::operator()(Block const& _node) const { - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulBlock"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulBlock"); ret["statements"] = vectorOfVariantsToJson(_node.statements); return ret; } -Json::Value AsmJsonConverter::operator()(TypedName const& _node) const +Json AsmJsonConverter::operator()(TypedName const& _node) const { yulAssert(!_node.name.empty(), "Invalid variable name."); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulTypedName"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulTypedName"); ret["name"] = _node.name.str(); ret["type"] = _node.type.str(); return ret; } -Json::Value AsmJsonConverter::operator()(Literal const& _node) const +Json AsmJsonConverter::operator()(Literal const& _node) const { - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulLiteral"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulLiteral"); switch (_node.kind) { case LiteralKind::Number: @@ -71,94 +71,92 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const return ret; } -Json::Value AsmJsonConverter::operator()(Identifier const& _node) const +Json AsmJsonConverter::operator()(Identifier const& _node) const { yulAssert(!_node.name.empty(), "Invalid identifier"); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulIdentifier"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulIdentifier"); ret["name"] = _node.name.str(); return ret; } -Json::Value AsmJsonConverter::operator()(Assignment const& _node) const +Json AsmJsonConverter::operator()(Assignment const& _node) const { yulAssert(_node.variableNames.size() >= 1, "Invalid assignment syntax"); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulAssignment"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulAssignment"); for (auto const& var: _node.variableNames) - ret["variableNames"].append((*this)(var)); - ret["value"] = _node.value ? std::visit(*this, *_node.value) : Json::nullValue; + ret["variableNames"].emplace_back((*this)(var)); + ret["value"] = _node.value ? std::visit(*this, *_node.value) : Json(); return ret; } -Json::Value AsmJsonConverter::operator()(FunctionCall const& _node) const +Json AsmJsonConverter::operator()(FunctionCall const& _node) const { - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulFunctionCall"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulFunctionCall"); ret["functionName"] = (*this)(_node.functionName); ret["arguments"] = vectorOfVariantsToJson(_node.arguments); return ret; } -Json::Value AsmJsonConverter::operator()(ExpressionStatement const& _node) const +Json AsmJsonConverter::operator()(ExpressionStatement const& _node) const { - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulExpressionStatement"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulExpressionStatement"); ret["expression"] = std::visit(*this, _node.expression); return ret; } -Json::Value AsmJsonConverter::operator()(VariableDeclaration const& _node) const +Json AsmJsonConverter::operator()(VariableDeclaration const& _node) const { - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulVariableDeclaration"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulVariableDeclaration"); for (auto const& var: _node.variables) - ret["variables"].append((*this)(var)); - - ret["value"] = _node.value ? std::visit(*this, *_node.value) : Json::nullValue; - + ret["variables"].emplace_back((*this)(var)); + ret["value"] = _node.value ? std::visit(*this, *_node.value) : Json(); return ret; } -Json::Value AsmJsonConverter::operator()(FunctionDefinition const& _node) const +Json AsmJsonConverter::operator()(FunctionDefinition const& _node) const { yulAssert(!_node.name.empty(), "Invalid function name."); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulFunctionDefinition"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulFunctionDefinition"); ret["name"] = _node.name.str(); for (auto const& var: _node.parameters) - ret["parameters"].append((*this)(var)); + ret["parameters"].emplace_back((*this)(var)); for (auto const& var: _node.returnVariables) - ret["returnVariables"].append((*this)(var)); + ret["returnVariables"].emplace_back((*this)(var)); ret["body"] = (*this)(_node.body); return ret; } -Json::Value AsmJsonConverter::operator()(If const& _node) const +Json AsmJsonConverter::operator()(If const& _node) const { yulAssert(_node.condition, "Invalid if condition."); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulIf"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulIf"); ret["condition"] = std::visit(*this, *_node.condition); ret["body"] = (*this)(_node.body); return ret; } -Json::Value AsmJsonConverter::operator()(Switch const& _node) const +Json AsmJsonConverter::operator()(Switch const& _node) const { yulAssert(_node.expression, "Invalid expression pointer."); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulSwitch"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulSwitch"); ret["expression"] = std::visit(*this, *_node.expression); for (auto const& var: _node.cases) - ret["cases"].append((*this)(var)); + ret["cases"].emplace_back((*this)(var)); return ret; } -Json::Value AsmJsonConverter::operator()(Case const& _node) const +Json AsmJsonConverter::operator()(Case const& _node) const { - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulCase"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulCase"); ret["value"] = _node.value ? (*this)(*_node.value) : "default"; ret["body"] = (*this)(_node.body); return ret; } -Json::Value AsmJsonConverter::operator()(ForLoop const& _node) const +Json AsmJsonConverter::operator()(ForLoop const& _node) const { yulAssert(_node.condition, "Invalid for loop condition."); - Json::Value ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulForLoop"); + Json ret = createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulForLoop"); ret["pre"] = (*this)(_node.pre); ret["condition"] = std::visit(*this, *_node.condition); ret["post"] = (*this)(_node.post); @@ -166,24 +164,24 @@ Json::Value AsmJsonConverter::operator()(ForLoop const& _node) const return ret; } -Json::Value AsmJsonConverter::operator()(Break const& _node) const +Json AsmJsonConverter::operator()(Break const& _node) const { return createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulBreak"); } -Json::Value AsmJsonConverter::operator()(Continue const& _node) const +Json AsmJsonConverter::operator()(Continue const& _node) const { return createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulContinue"); } -Json::Value AsmJsonConverter::operator()(Leave const& _node) const +Json AsmJsonConverter::operator()(Leave const& _node) const { return createAstNode(originLocationOf(_node), nativeLocationOf(_node), "YulLeave"); } -Json::Value AsmJsonConverter::createAstNode(langutil::SourceLocation const& _originLocation, langutil::SourceLocation const& _nativeLocation, std::string _nodeType) const +Json AsmJsonConverter::createAstNode(langutil::SourceLocation const& _originLocation, langutil::SourceLocation const& _nativeLocation, std::string _nodeType) const { - Json::Value ret{Json::objectValue}; + Json ret; ret["nodeType"] = std::move(_nodeType); auto srcLocation = [&](int start, int end) -> std::string { @@ -196,11 +194,11 @@ Json::Value AsmJsonConverter::createAstNode(langutil::SourceLocation const& _ori } template -Json::Value AsmJsonConverter::vectorOfVariantsToJson(std::vector const& _vec) const +Json AsmJsonConverter::vectorOfVariantsToJson(std::vector const& _vec) const { - Json::Value ret{Json::arrayValue}; + Json ret = Json::array(); for (auto const& var: _vec) - ret.append(std::visit(*this, var)); + ret.emplace_back(std::visit(*this, var)); return ret; } diff --git a/libyul/AsmJsonConverter.h b/libyul/AsmJsonConverter.h index 236ecbba579c..9c4b5d5e8ebc 100644 --- a/libyul/AsmJsonConverter.h +++ b/libyul/AsmJsonConverter.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -36,35 +36,35 @@ namespace solidity::yul /** * Converter of the yul AST into JSON format */ -class AsmJsonConverter: public boost::static_visitor +class AsmJsonConverter: public boost::static_visitor { public: /// Create a converter to JSON for any block of inline assembly /// @a _sourceIndex to be used to abbreviate source name in the source locations explicit AsmJsonConverter(std::optional _sourceIndex): m_sourceIndex(_sourceIndex) {} - Json::Value operator()(Block const& _node) const; - Json::Value operator()(TypedName const& _node) const; - Json::Value operator()(Literal const& _node) const; - Json::Value operator()(Identifier const& _node) const; - Json::Value operator()(Assignment const& _node) const; - Json::Value operator()(VariableDeclaration const& _node) const; - Json::Value operator()(FunctionDefinition const& _node) const; - Json::Value operator()(FunctionCall const& _node) const; - Json::Value operator()(If const& _node) const; - Json::Value operator()(Switch const& _node) const; - Json::Value operator()(Case const& _node) const; - Json::Value operator()(ForLoop const& _node) const; - Json::Value operator()(Break const& _node) const; - Json::Value operator()(Continue const& _node) const; - Json::Value operator()(Leave const& _node) const; - Json::Value operator()(ExpressionStatement const& _node) const; - Json::Value operator()(Label const& _node) const; + Json operator()(Block const& _node) const; + Json operator()(TypedName const& _node) const; + Json operator()(Literal const& _node) const; + Json operator()(Identifier const& _node) const; + Json operator()(Assignment const& _node) const; + Json operator()(VariableDeclaration const& _node) const; + Json operator()(FunctionDefinition const& _node) const; + Json operator()(FunctionCall const& _node) const; + Json operator()(If const& _node) const; + Json operator()(Switch const& _node) const; + Json operator()(Case const& _node) const; + Json operator()(ForLoop const& _node) const; + Json operator()(Break const& _node) const; + Json operator()(Continue const& _node) const; + Json operator()(Leave const& _node) const; + Json operator()(ExpressionStatement const& _node) const; + Json operator()(Label const& _node) const; private: - Json::Value createAstNode(langutil::SourceLocation const& _originLocation, langutil::SourceLocation const& _nativeLocation, std::string _nodeType) const; + Json createAstNode(langutil::SourceLocation const& _originLocation, langutil::SourceLocation const& _nativeLocation, std::string _nodeType) const; template - Json::Value vectorOfVariantsToJson(std::vector const& vec) const; + Json vectorOfVariantsToJson(std::vector const& vec) const; std::optional const m_sourceIndex; }; diff --git a/libyul/AsmJsonImporter.cpp b/libyul/AsmJsonImporter.cpp index 190dcda21d05..41e065853517 100644 --- a/libyul/AsmJsonImporter.cpp +++ b/libyul/AsmJsonImporter.cpp @@ -41,15 +41,15 @@ namespace solidity::yul using SourceLocation = langutil::SourceLocation; -SourceLocation const AsmJsonImporter::createSourceLocation(Json::Value const& _node) +SourceLocation const AsmJsonImporter::createSourceLocation(Json const& _node) { - yulAssert(member(_node, "src").isString(), "'src' must be a string"); + yulAssert(member(_node, "src").is_string(), "'src' must be a string"); - return solidity::langutil::parseSourceLocation(_node["src"].asString(), m_sourceNames); + return solidity::langutil::parseSourceLocation(_node["src"].get(), m_sourceNames); } template -T AsmJsonImporter::createAsmNode(Json::Value const& _node) +T AsmJsonImporter::createAsmNode(Json const& _node) { T r; SourceLocation nativeLocation = createSourceLocation(_node); @@ -61,26 +61,26 @@ T AsmJsonImporter::createAsmNode(Json::Value const& _node) return r; } -Json::Value AsmJsonImporter::member(Json::Value const& _node, std::string const& _name) +Json AsmJsonImporter::member(Json const& _node, std::string const& _name) { - if (!_node.isMember(_name)) - return Json::nullValue; + if (!_node.contains(_name)) + return Json(); return _node[_name]; } -TypedName AsmJsonImporter::createTypedName(Json::Value const& _node) +TypedName AsmJsonImporter::createTypedName(Json const& _node) { auto typedName = createAsmNode(_node); - typedName.type = YulString{member(_node, "type").asString()}; - typedName.name = YulString{member(_node, "name").asString()}; + typedName.type = YulString{member(_node, "type").get()}; + typedName.name = YulString{member(_node, "name").get()}; return typedName; } -Statement AsmJsonImporter::createStatement(Json::Value const& _node) +Statement AsmJsonImporter::createStatement(Json const& _node) { - Json::Value jsonNodeType = member(_node, "nodeType"); - yulAssert(jsonNodeType.isString(), "Expected \"nodeType\" to be of type string!"); - std::string nodeType = jsonNodeType.asString(); + Json jsonNodeType = member(_node, "nodeType"); + yulAssert(jsonNodeType.is_string(), "Expected \"nodeType\" to be of type string!"); + std::string nodeType = jsonNodeType.get(); yulAssert(nodeType.substr(0, 3) == "Yul", "Invalid nodeType prefix"); nodeType = nodeType.substr(3); @@ -114,11 +114,11 @@ Statement AsmJsonImporter::createStatement(Json::Value const& _node) util::unreachable(); } -Expression AsmJsonImporter::createExpression(Json::Value const& _node) +Expression AsmJsonImporter::createExpression(Json const& _node) { - Json::Value jsonNodeType = member(_node, "nodeType"); - yulAssert(jsonNodeType.isString(), "Expected \"nodeType\" to be of type string!"); - std::string nodeType = jsonNodeType.asString(); + Json jsonNodeType = member(_node, "nodeType"); + yulAssert(jsonNodeType.is_string(), "Expected \"nodeType\" to be of type string!"); + std::string nodeType = jsonNodeType.get(); yulAssert(nodeType.substr(0, 3) == "Yul", "Invalid nodeType prefix"); nodeType = nodeType.substr(3); @@ -136,7 +136,7 @@ Expression AsmJsonImporter::createExpression(Json::Value const& _node) util::unreachable(); } -std::vector AsmJsonImporter::createExpressionVector(Json::Value const& _array) +std::vector AsmJsonImporter::createExpressionVector(Json const& _array) { std::vector ret; for (auto& var: _array) @@ -144,7 +144,7 @@ std::vector AsmJsonImporter::createExpressionVector(Json::Value cons return ret; } -std::vector AsmJsonImporter::createStatementVector(Json::Value const& _array) +std::vector AsmJsonImporter::createStatementVector(Json const& _array) { std::vector ret; for (auto& var: _array) @@ -152,25 +152,25 @@ std::vector AsmJsonImporter::createStatementVector(Json::Value const& return ret; } -Block AsmJsonImporter::createBlock(Json::Value const& _node) +Block AsmJsonImporter::createBlock(Json const& _node) { auto block = createAsmNode(_node); block.statements = createStatementVector(_node["statements"]); return block; } -Literal AsmJsonImporter::createLiteral(Json::Value const& _node) +Literal AsmJsonImporter::createLiteral(Json const& _node) { auto lit = createAsmNode(_node); - std::string kind = member(_node, "kind").asString(); + std::string kind = member(_node, "kind").get(); - solAssert(member(_node, "hexValue").isString() || member(_node, "value").isString(), ""); - if (_node.isMember("hexValue")) - lit.value = YulString{util::asString(util::fromHex(member(_node, "hexValue").asString()))}; + solAssert(member(_node, "hexValue").is_string() || member(_node, "value").is_string(), ""); + if (_node.contains("hexValue")) + lit.value = YulString{util::asString(util::fromHex(member(_node, "hexValue").get()))}; else - lit.value = YulString{member(_node, "value").asString()}; + lit.value = YulString{member(_node, "value").get()}; - lit.type= YulString{member(_node, "type").asString()}; + lit.type= YulString{member(_node, "type").get()}; if (kind == "number") { @@ -207,23 +207,23 @@ Literal AsmJsonImporter::createLiteral(Json::Value const& _node) return lit; } -Leave AsmJsonImporter::createLeave(Json::Value const& _node) +Leave AsmJsonImporter::createLeave(Json const& _node) { return createAsmNode(_node); } -Identifier AsmJsonImporter::createIdentifier(Json::Value const& _node) +Identifier AsmJsonImporter::createIdentifier(Json const& _node) { auto identifier = createAsmNode(_node); - identifier.name = YulString(member(_node, "name").asString()); + identifier.name = YulString(member(_node, "name").get()); return identifier; } -Assignment AsmJsonImporter::createAssignment(Json::Value const& _node) +Assignment AsmJsonImporter::createAssignment(Json const& _node) { auto assignment = createAsmNode(_node); - if (_node.isMember("variableNames")) + if (_node.contains("variableNames")) for (auto const& var: member(_node, "variableNames")) assignment.variableNames.emplace_back(createIdentifier(var)); @@ -231,7 +231,7 @@ Assignment AsmJsonImporter::createAssignment(Json::Value const& _node) return assignment; } -FunctionCall AsmJsonImporter::createFunctionCall(Json::Value const& _node) +FunctionCall AsmJsonImporter::createFunctionCall(Json const& _node) { auto functionCall = createAsmNode(_node); @@ -243,35 +243,35 @@ FunctionCall AsmJsonImporter::createFunctionCall(Json::Value const& _node) return functionCall; } -ExpressionStatement AsmJsonImporter::createExpressionStatement(Json::Value const& _node) +ExpressionStatement AsmJsonImporter::createExpressionStatement(Json const& _node) { auto statement = createAsmNode(_node); statement.expression = createExpression(member(_node, "expression")); return statement; } -VariableDeclaration AsmJsonImporter::createVariableDeclaration(Json::Value const& _node) +VariableDeclaration AsmJsonImporter::createVariableDeclaration(Json const& _node) { auto varDec = createAsmNode(_node); for (auto const& var: member(_node, "variables")) varDec.variables.emplace_back(createTypedName(var)); - if (_node.isMember("value")) + if (_node.contains("value")) varDec.value = std::make_unique(createExpression(member(_node, "value"))); return varDec; } -FunctionDefinition AsmJsonImporter::createFunctionDefinition(Json::Value const& _node) +FunctionDefinition AsmJsonImporter::createFunctionDefinition(Json const& _node) { auto funcDef = createAsmNode(_node); - funcDef.name = YulString{member(_node, "name").asString()}; + funcDef.name = YulString{member(_node, "name").get()}; - if (_node.isMember("parameters")) + if (_node.contains("parameters")) for (auto const& var: member(_node, "parameters")) funcDef.parameters.emplace_back(createTypedName(var)); - if (_node.isMember("returnVariables")) + if (_node.contains("returnVariables")) for (auto const& var: member(_node, "returnVariables")) funcDef.returnVariables.emplace_back(createTypedName(var)); @@ -279,7 +279,7 @@ FunctionDefinition AsmJsonImporter::createFunctionDefinition(Json::Value const& return funcDef; } -If AsmJsonImporter::createIf(Json::Value const& _node) +If AsmJsonImporter::createIf(Json const& _node) { auto ifStatement = createAsmNode(_node); ifStatement.condition = std::make_unique(createExpression(member(_node, "condition"))); @@ -287,19 +287,19 @@ If AsmJsonImporter::createIf(Json::Value const& _node) return ifStatement; } -Case AsmJsonImporter::createCase(Json::Value const& _node) +Case AsmJsonImporter::createCase(Json const& _node) { auto caseStatement = createAsmNode(_node); auto const& value = member(_node, "value"); - if (value.isString()) - yulAssert(value.asString() == "default", "Expected default case"); + if (value.is_string()) + yulAssert(value.get() == "default", "Expected default case"); else caseStatement.value = std::make_unique(createLiteral(value)); caseStatement.body = createBlock(member(_node, "body")); return caseStatement; } -Switch AsmJsonImporter::createSwitch(Json::Value const& _node) +Switch AsmJsonImporter::createSwitch(Json const& _node) { auto switchStatement = createAsmNode(_node); switchStatement.expression = std::make_unique(createExpression(member(_node, "expression"))); @@ -308,7 +308,7 @@ Switch AsmJsonImporter::createSwitch(Json::Value const& _node) return switchStatement; } -ForLoop AsmJsonImporter::createForLoop(Json::Value const& _node) +ForLoop AsmJsonImporter::createForLoop(Json const& _node) { auto forLoop = createAsmNode(_node); forLoop.pre = createBlock(member(_node, "pre")); @@ -318,12 +318,12 @@ ForLoop AsmJsonImporter::createForLoop(Json::Value const& _node) return forLoop; } -Break AsmJsonImporter::createBreak(Json::Value const& _node) +Break AsmJsonImporter::createBreak(Json const& _node) { return createAsmNode(_node); } -Continue AsmJsonImporter::createContinue(Json::Value const& _node) +Continue AsmJsonImporter::createContinue(Json const& _node) { return createAsmNode(_node); } diff --git a/libyul/AsmJsonImporter.h b/libyul/AsmJsonImporter.h index 506352fa4811..87933761a654 100644 --- a/libyul/AsmJsonImporter.h +++ b/libyul/AsmJsonImporter.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include @@ -41,36 +41,36 @@ class AsmJsonImporter explicit AsmJsonImporter(std::vector> const& _sourceNames): m_sourceNames(_sourceNames) {} - yul::Block createBlock(Json::Value const& _node); + yul::Block createBlock(Json const& _node); private: - langutil::SourceLocation const createSourceLocation(Json::Value const& _node); + langutil::SourceLocation const createSourceLocation(Json const& _node); template - T createAsmNode(Json::Value const& _node); + T createAsmNode(Json const& _node); /// helper function to access member functions of the JSON /// and throw an error if it does not exist - Json::Value member(Json::Value const& _node, std::string const& _name); + Json member(Json const& _node, std::string const& _name); - yul::Statement createStatement(Json::Value const& _node); - yul::Expression createExpression(Json::Value const& _node); - std::vector createStatementVector(Json::Value const& _array); - std::vector createExpressionVector(Json::Value const& _array); + yul::Statement createStatement(Json const& _node); + yul::Expression createExpression(Json const& _node); + std::vector createStatementVector(Json const& _array); + std::vector createExpressionVector(Json const& _array); - yul::TypedName createTypedName(Json::Value const& _node); - yul::Literal createLiteral(Json::Value const& _node); - yul::Leave createLeave(Json::Value const& _node); - yul::Identifier createIdentifier(Json::Value const& _node); - yul::Assignment createAssignment(Json::Value const& _node); - yul::FunctionCall createFunctionCall(Json::Value const& _node); - yul::ExpressionStatement createExpressionStatement(Json::Value const& _node); - yul::VariableDeclaration createVariableDeclaration(Json::Value const& _node); - yul::FunctionDefinition createFunctionDefinition(Json::Value const& _node); - yul::If createIf(Json::Value const& _node); - yul::Case createCase(Json::Value const& _node); - yul::Switch createSwitch(Json::Value const& _node); - yul::ForLoop createForLoop(Json::Value const& _node); - yul::Break createBreak(Json::Value const& _node); - yul::Continue createContinue(Json::Value const& _node); + yul::TypedName createTypedName(Json const& _node); + yul::Literal createLiteral(Json const& _node); + yul::Leave createLeave(Json const& _node); + yul::Identifier createIdentifier(Json const& _node); + yul::Assignment createAssignment(Json const& _node); + yul::FunctionCall createFunctionCall(Json const& _node); + yul::ExpressionStatement createExpressionStatement(Json const& _node); + yul::VariableDeclaration createVariableDeclaration(Json const& _node); + yul::FunctionDefinition createFunctionDefinition(Json const& _node); + yul::If createIf(Json const& _node); + yul::Case createCase(Json const& _node); + yul::Switch createSwitch(Json const& _node); + yul::ForLoop createForLoop(Json const& _node); + yul::Break createBreak(Json const& _node); + yul::Continue createContinue(Json const& _node); std::vector> const& m_sourceNames; }; diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 0d3d66c8e5f2..260cb733011f 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -75,27 +75,27 @@ std::string Object::toString( return useSrcComment + "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}"; } -Json::Value Data::toJson() const +Json Data::toJson() const { - Json::Value ret{Json::objectValue}; + Json ret; ret["nodeType"] = "YulData"; ret["value"] = util::toHex(data); return ret; } -Json::Value Object::toJson() const +Json Object::toJson() const { yulAssert(code, "No code"); - Json::Value codeJson{Json::objectValue}; + Json codeJson; codeJson["nodeType"] = "YulCode"; codeJson["block"] = AsmJsonConverter(0 /* sourceIndex */)(*code); - Json::Value subObjectsJson{Json::arrayValue}; + Json subObjectsJson = Json::array(); for (std::shared_ptr const& subObject: subObjects) - subObjectsJson.append(subObject->toJson()); + subObjectsJson.emplace_back(subObject->toJson()); - Json::Value ret{Json::objectValue}; + Json ret; ret["nodeType"] = "YulObject"; ret["name"] = name.str(); ret["code"] = codeJson; diff --git a/libyul/Object.h b/libyul/Object.h index 5f88d3bc7ff6..54a8080d08c0 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -28,11 +28,11 @@ #include #include +#include #include #include #include -#include namespace solidity::yul { @@ -58,7 +58,7 @@ struct ObjectNode langutil::DebugInfoSelection const& _debugInfoSelection, langutil::CharStreamProvider const* _soliditySourceProvider ) const = 0; - virtual Json::Value toJson() const = 0; + virtual Json toJson() const = 0; }; /** @@ -75,7 +75,7 @@ struct Data: public ObjectNode langutil::DebugInfoSelection const& _debugInfoSelection, langutil::CharStreamProvider const* _soliditySourceProvider ) const override; - Json::Value toJson() const override; + Json toJson() const override; }; @@ -98,7 +98,7 @@ struct Object: public ObjectNode langutil::CharStreamProvider const* _soliditySourceProvider = nullptr ) const; /// @returns a compact JSON representation of the AST. - Json::Value toJson() const; + Json toJson() const; /// @returns the set of names of data objects accessible from within the code of /// this object, including the name of object itself /// Handles all names containing dots as reserved identifiers, not accessible as data. diff --git a/libyul/YulStack.cpp b/libyul/YulStack.cpp index 6c89cadbdfd9..a4341cba308c 100644 --- a/libyul/YulStack.cpp +++ b/libyul/YulStack.cpp @@ -312,7 +312,7 @@ std::string YulStack::print( return m_parserResult->toString(&languageToDialect(m_language, m_evmVersion), m_debugInfoSelection, _soliditySourceProvider) + "\n"; } -Json::Value YulStack::astJson() const +Json YulStack::astJson() const { yulAssert(m_parserResult, ""); yulAssert(m_parserResult->code, ""); diff --git a/libyul/YulStack.h b/libyul/YulStack.h index 700fd2b3baa3..27f530b44c4a 100644 --- a/libyul/YulStack.h +++ b/libyul/YulStack.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -33,8 +34,6 @@ #include -#include - #include #include @@ -132,7 +131,7 @@ class YulStack: public langutil::CharStreamProvider std::string print( langutil::CharStreamProvider const* _soliditySourceProvider = nullptr ) const; - Json::Value astJson() const; + Json astJson() const; /// Return the parsed and analyzed object. std::shared_ptr parserResult() const; diff --git a/libyul/YulString.h b/libyul/YulString.h index 5522e34849a4..7dbaf1b84a03 100644 --- a/libyul/YulString.h +++ b/libyul/YulString.h @@ -66,7 +66,7 @@ class YulStringRepository return Handle{id, h}; } - std::string const& idToString(size_t _id) const { return *m_strings.at(_id); } + std::string const& idToString(size_t _id) const { return *m_strings.at(_id); } static std::uint64_t hash(std::string const& v) { diff --git a/libyul/backends/evm/ControlFlowGraphBuilder.cpp b/libyul/backends/evm/ControlFlowGraphBuilder.cpp index 4b0da1e80d91..f048e5717e10 100644 --- a/libyul/backends/evm/ControlFlowGraphBuilder.cpp +++ b/libyul/backends/evm/ControlFlowGraphBuilder.cpp @@ -103,7 +103,7 @@ void markRecursiveCalls(CFG& _cfg) _addChild(_conditionalJump.nonZero); }, [&](CFG::BasicBlock::FunctionReturn const&) {}, - [&](CFG::BasicBlock::Terminated const&) {}, + [&](CFG::BasicBlock::Terminated const&) {}, }, _block->exit); }); return calls; diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index b857c41e79f3..d15267b1a25a 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -287,15 +287,15 @@ std::map createBuiltins(langutil::EVMVersion _ 3, 0, SideEffects{ - false, // movable - true, // movableApartFromEffects - false, // canBeRemoved - false, // canBeRemovedIfNotMSize - true, // cannotLoop - SideEffects::None, // otherState - SideEffects::None, // storage - SideEffects::Write, // memory - SideEffects::None // transientStorage + false, // movable + true, // movableApartFromEffects + false, // canBeRemoved + false, // canBeRemovedIfNotMSize + true, // cannotLoop + SideEffects::None, // otherState + SideEffects::None, // storage + SideEffects::Write, // memory + SideEffects::None // transientStorage }, {}, []( @@ -311,15 +311,15 @@ std::map createBuiltins(langutil::EVMVersion _ 3, 0, SideEffects{ - false, // movable - false, // movableApartFromEffects - false, // canBeRemoved - false, // canBeRemovedIfNotMSize - true, // cannotLoop - SideEffects::None, // otherState - SideEffects::None, // storage - SideEffects::Write, // memory - SideEffects::None // transientStorage + false, // movable + false, // movableApartFromEffects + false, // canBeRemoved + false, // canBeRemovedIfNotMSize + true, // cannotLoop + SideEffects::None, // otherState + SideEffects::None, // storage + SideEffects::Write, // memory + SideEffects::None // transientStorage }, {std::nullopt, LiteralKind::String, std::nullopt}, []( diff --git a/libyul/backends/evm/StackLayoutGenerator.cpp b/libyul/backends/evm/StackLayoutGenerator.cpp index 88190b45b3fc..954c9f2af7af 100644 --- a/libyul/backends/evm/StackLayoutGenerator.cpp +++ b/libyul/backends/evm/StackLayoutGenerator.cpp @@ -539,7 +539,7 @@ void StackLayoutGenerator::stitchConditionalJumps(CFG::BasicBlock const& _block) _addChild(_conditionalJump.zero); _addChild(_conditionalJump.nonZero); }, - [&](CFG::BasicBlock::FunctionReturn const&) {}, + [&](CFG::BasicBlock::FunctionReturn const&) {}, [&](CFG::BasicBlock::Terminated const&) { }, }, _block->exit); }); @@ -771,7 +771,7 @@ void StackLayoutGenerator::fillInJunk(CFG::BasicBlock const& _block, CFG::Functi yulAssert(util::contains(m_currentFunctionInfo->returnVariables, std::get(_slot))); // Strictly speaking the cost of the PUSH0 depends on the targeted EVM version, but the difference // will not matter here. - opGas += evmasm::GasMeter::runGas(evmasm::pushInstruction(0), langutil::EVMVersion());; + opGas += evmasm::GasMeter::runGas(evmasm::pushInstruction(0), langutil::EVMVersion()); } } }; diff --git a/libyul/optimiser/ExpressionJoiner.h b/libyul/optimiser/ExpressionJoiner.h index eb22ad79fbdb..3a1fdf743579 100644 --- a/libyul/optimiser/ExpressionJoiner.h +++ b/libyul/optimiser/ExpressionJoiner.h @@ -91,9 +91,9 @@ class ExpressionJoiner: public ASTModifier bool isLatestStatementVarDeclJoinable(Identifier const& _identifier); private: - Block* m_currentBlock = nullptr; ///< Pointer to current block holding the statement being visited. - size_t m_latestStatementInBlock = 0; ///< Offset to m_currentBlock's statements of the last visited statement. - std::map m_references; ///< Holds reference counts to all variable declarations in current block. + Block* m_currentBlock = nullptr; ///< Pointer to current block holding the statement being visited. + size_t m_latestStatementInBlock = 0; ///< Offset to m_currentBlock's statements of the last visited statement. + std::map m_references; ///< Holds reference counts to all variable declarations in current block. }; } diff --git a/libyul/optimiser/KnowledgeBase.h b/libyul/optimiser/KnowledgeBase.h index 258f85f5cddf..f83c5ac66105 100644 --- a/libyul/optimiser/KnowledgeBase.h +++ b/libyul/optimiser/KnowledgeBase.h @@ -62,11 +62,11 @@ class KnowledgeBase public: /// Constructor for arbitrary value callback that allows for variable values /// to change in between calls to functions of this class. - KnowledgeBase(std::function _variableValues): + explicit KnowledgeBase(std::function _variableValues): m_variableValues(std::move(_variableValues)) {} /// Constructor to use if source code is in SSA form and values are constant. - KnowledgeBase(std::map const& _ssaValues); + explicit KnowledgeBase(std::map const& _ssaValues); bool knownToBeDifferent(YulString _a, YulString _b); std::optional differenceIfKnownConstant(YulString _a, YulString _b); diff --git a/libyul/optimiser/SSAReverser.h b/libyul/optimiser/SSAReverser.h index bb6e98bc8ded..675c5c4afff0 100644 --- a/libyul/optimiser/SSAReverser.h +++ b/libyul/optimiser/SSAReverser.h @@ -30,42 +30,42 @@ class AssignmentCounter; * * In particular, the SSA transform will rewrite * - * a := E + * a := E * * to * - * let a_1 := E - * a := a_1 + * let a_1 := E + * a := a_1 * * To undo this kind of transformation, the SSAReverser changes this back to * - * a := E - * let a_1 := a + * a := E + * let a_1 := a * - * In the special case - * let a := E - * a := a + * In the special case + * let a := E + * a := a * - * the redundant assignment "a := a" is removed. + * the redundant assignment "a := a" is removed. * * * Secondly, the SSA transform will rewrite * - * let a := E + * let a := E * to * - * let a_1 := E - * let a := a_1 + * let a_1 := E + * let a := a_1 * * To undo this kind of transformation, the SSAReverser changes this back to * - * let a := E - * let a_1 := a + * let a := E + * let a_1 := a * - * After that the CSE can replace references of a_1 by references to a, - * after which the unused pruner can remove the declaration of a_1. + * After that the CSE can replace references of a_1 by references to a, + * after which the unused pruner can remove the declaration of a_1. * - * Prerequisites: Disambiguator + * Prerequisites: Disambiguator * */ class SSAReverser: public ASTModifier diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp index 675d21acc343..dba2f6f04610 100644 --- a/libyul/optimiser/SSATransform.cpp +++ b/libyul/optimiser/SSATransform.cpp @@ -166,8 +166,8 @@ class IntroduceControlFlowSSA: public ASTModifier std::set const& m_variablesToReplace; /// Variables (that are to be replaced) currently in scope. std::set m_variablesInScope; - /// Set of variables that do not have a specific value. - std::set m_variablesToReassign; + /// Variables that do not have a specific value. + util::UniqueVector m_variablesToReassign; TypeInfo const& m_typeInfo; }; @@ -175,14 +175,14 @@ void IntroduceControlFlowSSA::operator()(FunctionDefinition& _function) { std::set varsInScope; std::swap(varsInScope, m_variablesInScope); - std::set toReassign; + util::UniqueVector toReassign; std::swap(toReassign, m_variablesToReassign); for (auto const& param: _function.parameters) if (m_variablesToReplace.count(param.name)) { m_variablesInScope.insert(param.name); - m_variablesToReassign.insert(param.name); + m_variablesToReassign.pushBack(param.name); } ASTModifier::operator()(_function); @@ -196,8 +196,8 @@ void IntroduceControlFlowSSA::operator()(ForLoop& _for) yulAssert(_for.pre.statements.empty(), "For loop init rewriter not run."); for (auto const& var: assignedVariableNames(_for.body) + assignedVariableNames(_for.post)) - if (m_variablesInScope.count(var)) - m_variablesToReassign.insert(var); + if (util::contains(m_variablesInScope,var)) + m_variablesToReassign.pushBack(var); (*this)(_for.body); (*this)(_for.post); @@ -207,26 +207,26 @@ void IntroduceControlFlowSSA::operator()(Switch& _switch) { yulAssert(m_variablesToReassign.empty(), ""); - std::set toReassign; + util::UniqueVector toReassign; for (auto& c: _switch.cases) { (*this)(c.body); - toReassign += m_variablesToReassign; + toReassign.pushBack(m_variablesToReassign); } - m_variablesToReassign += toReassign; + m_variablesToReassign.pushBack(toReassign); } void IntroduceControlFlowSSA::operator()(Block& _block) { - std::set variablesDeclaredHere; - std::set assignedVariables; + util::UniqueVector variablesDeclaredHere; + util::UniqueVector assignedVariables; util::iterateReplacing( _block.statements, [&](Statement& _s) -> std::optional> { - std::vector toPrepend; + std::vector toPrepend; for (YulString toReassign: m_variablesToReassign) { YulString newName = m_nameDispenser.newName(toReassign); @@ -235,7 +235,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block) {TypedName{debugDataOf(_s), newName, m_typeInfo.typeOfVariable(toReassign)}}, std::make_unique(Identifier{debugDataOf(_s), toReassign}) }); - assignedVariables.insert(toReassign); + assignedVariables.pushBack(toReassign); } m_variablesToReassign.clear(); @@ -245,7 +245,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block) for (auto const& var: varDecl.variables) if (m_variablesToReplace.count(var.name)) { - variablesDeclaredHere.insert(var.name); + variablesDeclaredHere.pushBack(var.name); m_variablesInScope.insert(var.name); } } @@ -254,7 +254,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block) Assignment& assignment = std::get(_s); for (auto const& var: assignment.variableNames) if (m_variablesToReplace.count(var.name)) - assignedVariables.insert(var.name); + assignedVariables.pushBack(var.name); } else visit(_s); @@ -268,9 +268,10 @@ void IntroduceControlFlowSSA::operator()(Block& _block) } } ); - m_variablesToReassign += assignedVariables; - m_variablesInScope -= variablesDeclaredHere; - m_variablesToReassign -= variablesDeclaredHere; + + m_variablesToReassign.pushBack(assignedVariables); + m_variablesInScope -= variablesDeclaredHere.contents(); + m_variablesToReassign.removeAll(variablesDeclaredHere.contents()); } /** diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 545ae4de06d7..83bc0370092b 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -77,6 +77,8 @@ #include #include +#include +#include #include #include @@ -385,21 +387,9 @@ void OptimiserSuite::validateSequence(std::string_view _stepAbbreviations) bool OptimiserSuite::isEmptyOptimizerSequence(std::string const& _sequence) { - size_t delimiterCount{0}; - for (char const step: _sequence) - switch (step) - { - case ':': - if (++delimiterCount > 1) - return false; - break; - case ' ': - case '\n': - break; - default: - return false; - } - return true; + return + ranges::count(_sequence, ':') == 1 && + ranges::none_of(_sequence, [](auto _step) { return _step != ':' && _step != ' ' && _step != '\n'; }); } void OptimiserSuite::runSequence(std::string_view _stepAbbreviations, Block& _ast, bool _repeatUntilStable) @@ -472,7 +462,9 @@ void OptimiserSuite::runSequence(std::string_view _stepAbbreviations, Block& _as subsequences.push_back({subsequence, true}); } - size_t codeSize = 0; + // NOTE: If _repeatUntilStable is false, the value will not be used so do not calculate it. + size_t codeSize = (_repeatUntilStable ? CodeSize::codeSizeIncludingFunctions(_ast) : 0); + for (size_t round = 0; round < MaxRounds; ++round) { for (auto const& [subsequence, repeat]: subsequences) diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 1b780a4276b6..dc862b1f7efc 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -33,9 +33,9 @@ if (( $# != 0 )); then params="$(printf "%q " "${@}")" fi -# solbuildpackpusher/solidity-buildpack-deps:emscripten-16 +# solbuildpackpusher/solidity-buildpack-deps:emscripten-17 # NOTE: Without `safe.directory` git would assume it's not safe to operate on /root/project since it's owned by a different user. # See https://github.blog/2022-04-12-git-security-vulnerability-announced/ docker run -v "$(pwd):/root/project" -w /root/project \ - solbuildpackpusher/solidity-buildpack-deps@sha256:19fcb5ac029bbc27ec36e10f7d14ea224d8010145f9690562ef084fd16146b0c \ + solbuildpackpusher/solidity-buildpack-deps@sha256:c57f2bfb8c15d70fe290629358dd1c73dc126e3760f443b54764797556b887d4 \ /bin/bash -c "git config --global --add safe.directory /root/project && ./scripts/ci/build_emscripten.sh ${params}" diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 3c9acf86ca74..dbe470c1aeb1 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -20,40 +20,6 @@ EXCLUDE_FILES=( EXCLUDE_FILES_JOINED=$(printf "%s\|" "${EXCLUDE_FILES[@]}") EXCLUDE_FILES_JOINED=${EXCLUDE_FILES_JOINED%??} -NAMESPACE_STD_FREE_FILES=( - libevmasm/* - liblangutil/* - libsmtutil/* - libsolc/* - libsolidity/analysis/* - libsolidity/ast/* - libsolidity/codegen/ir/* - libsolidity/codegen/* - libsolidity/experimental/* - libsolidity/formal/* - libsolidity/interface/* - libsolidity/lsp/* - libsolidity/parsing/* - libsolutil/* - libyul/* - libyul/backends/evm/* - libyul/optimiser/* - solc/* - test/* - test/contracts/* - test/libevmasm/* - test/liblangutil/* - test/libsolutil/* - test/libsolidity/* - test/libsolidity/analysis/* - test/libsolidity/interface/* - test/libsolidity/util/* - test/libyul/* - test/solc/* - test/tools/yulInterpreter/* - test/yulPhaser/* -) - ( REPO_ROOT="$(dirname "$0")"/.. cd "$REPO_ROOT" || exit 1 @@ -100,9 +66,7 @@ FORMATERROR=$( # std namespace usage, test directory must also be covered. FORMATSTDERROR=$( ( - # make sure `using namespace std` is not used in INCLUDE_DIRECTORIES - # shellcheck disable=SC2068,SC2068 - grep -nIE -d skip "using namespace std;" ${NAMESPACE_STD_FREE_FILES[@]} + git grep -nIE "using namespace std;" -- '*.h' '*.cpp' ) || true ) diff --git a/scripts/common.sh b/scripts/common.sh index d149253bf71f..81dd2ec491a8 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -324,3 +324,25 @@ function gnu_grep grep "$@" fi } + +function time_to_json_file +{ + local output_file="$1" + local cmd=("${@:2}") + (( $# >= 2 )) || assertFail + + # $TIMEFORMAT is the format used by built-in `time`. Description is in `man bash`. + local original_timeformat="$TIMEFORMAT" + TIMEFORMAT='{"real": %R, "user": %U, "sys": %S}' + + # We temporarily use descriptors 3 and 4 to preserve stdout and stderr of the original command. + # This allows us to store `time`'s own stderr in a file. Then we restore initial descriptors. + { + { + time { "${cmd[@]}" 1>&3 2>&4; } + } 2> "$output_file" + } 3>&1 4>&2 + + # Restore original format so that it does not spill outside of the function. + TIMEFORMAT="$original_timeformat" +} diff --git a/scripts/common/cmdline_helpers.py b/scripts/common/cmdline_helpers.py index ede9f9385549..822cf7f85806 100644 --- a/scripts/common/cmdline_helpers.py +++ b/scripts/common/cmdline_helpers.py @@ -11,10 +11,12 @@ from bytecodecompare.prepare_report import parse_cli_output -DEFAULT_PREAMBLE = dedent(""" +DEFAULT_PREAMBLE = dedent( + """ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.0; -""") +""" +) def inside_temporary_dir(prefix): @@ -22,8 +24,10 @@ def inside_temporary_dir(prefix): Creates a temporary directory, enters the directory and executes the function inside it. Restores the previous working directory after executing the function. """ + def tmp_dir_decorator(fn): previous_dir = os.getcwd() + def f(*args, **kwargs): try: tmp_dir = mkdtemp(prefix=prefix) @@ -33,35 +37,49 @@ def f(*args, **kwargs): return result finally: os.chdir(previous_dir) + return f + return tmp_dir_decorator -def solc_bin_report(solc_binary: str, input_files: List[Path], via_ir: bool) -> FileReport: +def solc_bin_report( + solc_binary: str, + input_files: List[Path], + via_ir: bool, + optimize: bool = False, + yul_optimizations: Optional[str] = None, +) -> FileReport: """ Runs the solidity compiler binary """ output = subprocess.check_output( - [solc_binary, '--bin'] + - input_files + - (['--via-ir'] if via_ir else []), - encoding='utf8', + [solc_binary, "--bin"] + + input_files + + (["--via-ir"] if via_ir else []) + + (["--optimize"] if optimize else []) + + (["--yul-optimizations", yul_optimizations] if yul_optimizations else []), + encoding="utf8", ) - return parse_cli_output('', output, 0) + return parse_cli_output("", output, 0) -def save_bytecode(bytecode_path: Path, reports: FileReport, contract: Optional[str] = None): - with open(bytecode_path, 'w', encoding='utf8') as f: +def save_bytecode( + bytecode_path: Path, reports: FileReport, contract: Optional[str] = None +): + with open(bytecode_path, "w", encoding="utf8") as f: for report in reports.contract_reports: if contract is None or report.contract_name == contract: - bytecode = report.bytecode if report.bytecode is not None else '' - f.write(f'{report.contract_name}: {bytecode}\n') + bytecode = ( + report.bytecode if report.bytecode is not None else "" + ) + f.write(f"{report.contract_name}: {bytecode}\n") def add_preamble(source_path: Path, preamble: str = DEFAULT_PREAMBLE): - for source in source_path.glob('**/*.sol'): - with open(source, 'r+', encoding='utf8') as f: + for source in source_path.glob("**/*.sol"): + with open(source, "r+", encoding="utf8") as f: content = f.read() f.seek(0, 0) f.write(preamble + content) diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index 1ea8c0b570f6..4af1cf586a47 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -29,17 +29,6 @@ REPO_ROOT="$(dirname "$0")"/.. then cp prerelease.txt "$SOLDIR/" fi - # Add dependencies - mkdir -p "$SOLDIR/deps/downloads/" 2>/dev/null || true - jsoncpp_version="1.9.3" - jsoncpp_package_path="$SOLDIR/deps/downloads/jsoncpp-${jsoncpp_version}.tar.gz" - jsoncpp_sha256=8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d - wget -O "$jsoncpp_package_path" "https://github.com/open-source-parsers/jsoncpp/archive/${jsoncpp_version}.tar.gz" - if ! [ "$(sha256sum "$jsoncpp_package_path")" = "${jsoncpp_sha256} ${jsoncpp_package_path}" ] - then - >&2 echo "ERROR: Downloaded jsoncpp source package has wrong checksum." - exit 1 - fi mkdir -p "$REPO_ROOT/upload" tar --owner 0 --group 0 -czf "$REPO_ROOT/upload/solidity_$versionstring.tar.gz" -C "$TEMPDIR" "solidity_$versionstring" rm -r "$TEMPDIR" diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index 67cb15ce8a2c..016cd5d21e01 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -9,10 +9,10 @@ ## This requires the following entries in /etc/dput.cf: ## ## [cpp-build-deps] -## fqdn = ppa.launchpad.net -## method = ftp -## incoming = ~ethereum/cpp-build-deps -## login = anonymous +## fqdn = ppa.launchpad.net +## method = ftp +## incoming = ~ethereum/cpp-build-deps +## login = anonymous ## ## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL ## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of @@ -41,7 +41,7 @@ sourcePPAConfig # Sanity check checkDputEntries "\[cpp-build-deps\]" -DISTRIBUTIONS="focal jammy lunar mantic" +DISTRIBUTIONS="focal jammy mantic noble" for distribution in $DISTRIBUTIONS do diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 index 6ff8d1bd43ec..815c93ee84b5 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 @@ -22,26 +22,54 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="21" +LABEL version="23" ARG DEBIAN_FRONTEND=noninteractive RUN set -ex; \ - dist=$(grep DISTRIB_CODENAME /etc/lsb-release | cut -d= -f2); \ - echo "deb http://ppa.launchpad.net/ethereum/cpp-build-deps/ubuntu $dist main" >> /etc/apt/sources.list ; \ - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1c52189c923f6ca9 ; \ + dist=$(grep DISTRIB_CODENAME /etc/lsb-release | cut -d= -f2); \ + echo "deb http://ppa.launchpad.net/ethereum/cpp-build-deps/ubuntu $dist main" >> /etc/apt/sources.list ; \ + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1c52189c923f6ca9 ; \ apt-get update; \ apt-get install -qqy --no-install-recommends \ - build-essential sudo \ - software-properties-common \ - cmake ninja-build \ - libboost-filesystem-dev libboost-test-dev libboost-system-dev \ + build-essential \ + cmake \ + jq \ + libboost-filesystem-dev \ libboost-program-options-dev \ - libcvc4-dev libz3-static-dev z3-static jq \ - ; \ - apt-get install -qy python3-pip python3-sphinx; \ - pip3 install codecov; \ - rm -rf /var/lib/apt/lists/* + libboost-system-dev \ + libboost-test-dev \ + libcvc4-dev \ + libz3-static-dev \ + lsof \ + ninja-build \ + python3-pip \ + python3-sphinx \ + software-properties-common \ + sudo \ + z3-static; \ + pip3 install \ + codecov \ + colorama \ + deepdiff \ + parsec \ + pygments-lexer-solidity \ + pylint \ + requests \ + tabulate \ + z3-solver; + +# Eldarica +RUN set -ex; \ + apt-get update; \ + apt-get install -qqy \ + openjdk-11-jre \ + unzip; \ + eldarica_version="2.1"; \ + wget "https://github.com/uuverifiers/eldarica/releases/download/v${eldarica_version}/eldarica-bin-${eldarica_version}.zip" -O /opt/eld_binaries.zip; \ + test "$(sha256sum /opt/eld_binaries.zip)" = "0ac43f45c0925383c9d2077f62bbb515fd792375f3b2b101b30c9e81dcd7785c /opt/eld_binaries.zip"; \ + unzip /opt/eld_binaries.zip -d /opt; \ + rm -f /opt/eld_binaries.zip; FROM base AS libraries @@ -57,3 +85,5 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include +COPY --from=libraries /opt/eldarica /opt/eldarica +ENV PATH="$PATH:/opt/eldarica" diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204 index 6908811f925f..254e83b4cfc7 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204 @@ -22,26 +22,57 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:jammy AS base -LABEL version="6" +LABEL version="8" ARG DEBIAN_FRONTEND=noninteractive RUN set -ex; \ - dist=$(grep DISTRIB_CODENAME /etc/lsb-release | cut -d= -f2); \ - echo "deb http://ppa.launchpad.net/ethereum/cpp-build-deps/ubuntu $dist main" >> /etc/apt/sources.list ; \ - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1c52189c923f6ca9 ; \ + dist=$(grep DISTRIB_CODENAME /etc/lsb-release | cut -d= -f2); \ + echo "deb http://ppa.launchpad.net/ethereum/cpp-build-deps/ubuntu $dist main" >> /etc/apt/sources.list ; \ + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1c52189c923f6ca9 ; \ apt-get update; \ apt-get install -qqy --no-install-recommends \ - build-essential sudo \ - software-properties-common \ - cmake ninja-build \ - libboost-filesystem-dev libboost-test-dev libboost-system-dev \ + build-essential \ + cmake \ + jq \ + libboost-filesystem-dev \ libboost-program-options-dev \ - libcvc4-dev libz3-static-dev z3-static jq \ - libcln-dev zip locales-all; \ - apt-get install -qy python3-pip python3-sphinx; \ - pip3 install codecov; \ - rm -rf /var/lib/apt/lists/* + libboost-system-dev \ + libboost-test-dev \ + libcln-dev \ + libcvc4-dev \ + libz3-static-dev \ + locales-all \ + lsof \ + ninja-build \ + python3-pip \ + python3-sphinx \ + software-properties-common \ + sudo \ + z3-static \ + zip; \ + pip3 install \ + codecov \ + colorama \ + deepdiff \ + parsec \ + pygments-lexer-solidity \ + pylint \ + requests \ + tabulate \ + z3-solver; + +# Eldarica +RUN set -ex; \ + apt-get update; \ + apt-get install -qqy \ + openjdk-11-jre \ + unzip; \ + eldarica_version="2.1"; \ + wget "https://github.com/uuverifiers/eldarica/releases/download/v${eldarica_version}/eldarica-bin-${eldarica_version}.zip" -O /opt/eld_binaries.zip; \ + test "$(sha256sum /opt/eld_binaries.zip)" = "0ac43f45c0925383c9d2077f62bbb515fd792375f3b2b101b30c9e81dcd7785c /opt/eld_binaries.zip"; \ + unzip /opt/eld_binaries.zip -d /opt; \ + rm -f /opt/eld_binaries.zip; FROM base AS libraries @@ -61,3 +92,5 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include +COPY --from=libraries /opt/eldarica /opt/eldarica +ENV PATH="$PATH:/opt/eldarica" diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang index a14bdc113817..af6155b6e0a0 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:jammy AS base -LABEL version="5" +LABEL version="7" ARG DEBIAN_FRONTEND=noninteractive @@ -32,15 +32,44 @@ RUN set -ex; \ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1c52189c923f6ca9 ; \ apt-get update; \ apt-get install -qqy --no-install-recommends \ - build-essential sudo \ - software-properties-common \ - cmake ninja-build \ - libboost-filesystem-dev libboost-test-dev libboost-system-dev \ - libboost-program-options-dev \ + build-essential \ clang \ - libz3-static-dev z3-static jq \ - libcln-dev; \ - rm -rf /var/lib/apt/lists/* + cmake \ + jq \ + lsof \ + libboost-filesystem-dev \ + libboost-program-options-dev \ + libboost-system-dev \ + libboost-test-dev \ + libcln-dev \ + libz3-static-dev \ + ninja-build \ + python3-pip \ + software-properties-common \ + sudo \ + z3-static; \ + pip3 install \ + codecov \ + colorama \ + deepdiff \ + parsec \ + pygments-lexer-solidity \ + pylint \ + requests \ + tabulate \ + z3-solver; + +# Eldarica +RUN set -ex; \ + apt-get update; \ + apt-get install -qy \ + openjdk-11-jre \ + unzip; \ + eldarica_version="2.1"; \ + wget "https://github.com/uuverifiers/eldarica/releases/download/v${eldarica_version}/eldarica-bin-${eldarica_version}.zip" -O /opt/eld_binaries.zip; \ + test "$(sha256sum /opt/eld_binaries.zip)" = "0ac43f45c0925383c9d2077f62bbb515fd792375f3b2b101b30c9e81dcd7785c /opt/eld_binaries.zip"; \ + unzip /opt/eld_binaries.zip -d /opt; \ + rm -f /opt/eld_binaries.zip; FROM base AS libraries @@ -63,3 +92,5 @@ FROM base COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include +COPY --from=libraries /opt/eldarica /opt/eldarica +ENV PATH="$PATH:/opt/eldarica" diff --git a/scripts/externalTests/common.sh b/scripts/externalTests/common.sh index 8bc9bdf7bd40..2983b30c296a 100644 --- a/scripts/externalTests/common.sh +++ b/scripts/externalTests/common.sh @@ -505,14 +505,14 @@ function compile_and_run_test [[ $preset != *" "* ]] || assertFail "Preset names must not contain spaces." printLog "Running compile function..." - time $compile_fn - $verify_fn "$SOLCVERSION_SHORT" "$SOLCVERSION" + time_to_json_file "$(compilation_time_report_path "$preset")" "$compile_fn" + "$verify_fn" "$SOLCVERSION_SHORT" "$SOLCVERSION" if [[ "$COMPILE_ONLY" == 1 || " $compile_only_presets " == *" $preset "* ]]; then printLog "Skipping test function..." else printLog "Running test function..." - $test_fn + "$test_fn" fi } @@ -572,6 +572,13 @@ function gas_report_path echo "${DIR}/gas-report-${preset}.rst" } +function compilation_time_report_path +{ + local preset="$1" + + echo "${DIR}/compilation-time-report-${preset}.json" +} + function gas_report_to_json { cat - | "${REPO_ROOT}/scripts/externalTests/parse_eth_gas_report.py" | jq '{gas: .}' @@ -679,5 +686,6 @@ function store_benchmark_report "bytecode_size_json_from_${framework}_artifacts" | combine_artifact_json project_info_json "$project_url" + echo "{\"compilation_time\": $(cat "$(compilation_time_report_path "$preset")")}" } | jq --slurp "{\"${project_name}\": {\"${preset}\": add}}" --indent 4 --sort-keys > "$output_file" } diff --git a/scripts/gas_diff_stats.py b/scripts/gas_diff_stats.py index e593bb9a9746..ecb4cc912a4e 100755 --- a/scripts/gas_diff_stats.py +++ b/scripts/gas_diff_stats.py @@ -1,26 +1,20 @@ #!/usr/bin/env python3 -"""A script to collect gas statistics and print it. +"""Summarizes gas differences from semantic test diff. -Useful to summarize gas differences to semantic tests for a PR / branch. +The script collects all gas differences present in git diff of semantic tests +and summarizes them in the form of a table that's ready to post in a GitHub comment. +Only changes that are already committed are taken into account. +Changes that are only staged or not staged or committed at all are ignored. -Dependencies: Parsec (https://pypi.org/project/parsec/) and Tabulate -(https://pypi.org/project/tabulate/) - - pip install parsec tabulate - -Run from root project dir. - - python3 scripts/gas_diff_stats.py - -Note that the changes to semantic tests have to be committed. - -Assumes that there is a remote named ``origin`` pointing to the Solidity github -repository. The changes are compared against ``origin/develop``. +Useful for reviewing the gas impact of a specific PR / branch. +Instead of tediously going through each individual change, it's recommended to review the table. +Dependencies: parsec, tabulate """ import subprocess import sys +from argparse import ArgumentParser, RawDescriptionHelpFormatter from pathlib import Path from enum import Enum from parsec import generate, ParseError, regex, string, optional @@ -105,11 +99,11 @@ def collect_statistics(lines) -> (int, int, int, int, int, int): for _codegen_kind in codegen_kinds ) -def semantictest_statistics(): +def semantictest_statistics(base_branch: str): """Prints the tabulated statistics that can be pasted in github.""" def parse_git_diff(fname): diff_output = subprocess.check_output( - ["git", "diff", "--unified=0", "origin/develop", "HEAD", fname], + ["git", "diff", "--unified=0", base_branch, "HEAD", fname], universal_newlines=True ).splitlines() if len(diff_output) == 0: @@ -170,8 +164,17 @@ def stat(old, new): print("No differences found.") def main(): + parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter) + parser.add_argument( + '--base', + dest='base_branch', + default='origin/develop', + help='The base branch to diff against. default: origin/develop', + ) + options = parser.parse_args() + try: - semantictest_statistics() + semantictest_statistics(options.base_branch) except subprocess.CalledProcessError as exception: sys.exit(f"Error in the git diff:\n{exception.output}") except ParseError as exception: diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index 252fd4c49c64..0e4eb7ed4d92 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -23,22 +23,22 @@ ## Additionally the following entries in /etc/dput.cf are required: ## ## [ethereum-dev] -## fqdn = ppa.launchpad.net -## method = ftp -## incoming = ~ethereum/ethereum-dev -## login = anonymous +## fqdn = ppa.launchpad.net +## method = ftp +## incoming = ~ethereum/ethereum-dev +## login = anonymous ## ## [ethereum] -## fqdn = ppa.launchpad.net -## method = ftp -## incoming = ~ethereum/ethereum -## login = anonymous +## fqdn = ppa.launchpad.net +## method = ftp +## incoming = ~ethereum/ethereum +## login = anonymous ## ## [ethereum-static] -## fqdn = ppa.launchpad.net -## method = ftp -## incoming = ~ethereum/ethereum-static -## login = anonymous +## fqdn = ppa.launchpad.net +## method = ftp +## incoming = ~ethereum/ethereum-static +## login = anonymous ## ############################################################################## @@ -68,7 +68,7 @@ packagename=solc # This needs to be a still active release static_build_distribution=focal -DISTRIBUTIONS="focal jammy lunar mantic" +DISTRIBUTIONS="focal jammy mantic noble" if is_release then @@ -125,7 +125,8 @@ mv solidity solc # Fetch dependencies mkdir -p ./solc/deps/downloads/ 2>/dev/null || true -wget -O ./solc/deps/downloads/jsoncpp-1.9.3.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz +mkdir -p ./solc/deps/nlohmann/nlohmann/ 2>/dev/null || true +wget -O ./solc/deps/nlohmann/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.11.3/json.hpp wget -O ./solc/deps/downloads/range-v3-0.12.0.tar.gz https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz wget -O ./solc/deps/downloads/fmt-9.1.0.tar.gz https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz @@ -210,8 +211,8 @@ export DH_OPTIONS override_dh_auto_test: #override_dh_installdocs: -# make -C docs html -# dh_installdocs docs/_build/html +# make -C docs html +# dh_installdocs docs/_build/html override_dh_shlibdeps: dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 640dffa05683..28503c417cf7 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -353,23 +353,23 @@ void CommandLineInterface::handleSignatureHashes(std::string const& _contract) if (!m_options.compiler.outputs.signatureHashes) return; - Json::Value interfaceSymbols = m_compiler->interfaceSymbols(_contract); + Json interfaceSymbols = m_compiler->interfaceSymbols(_contract); std::string out = "Function signatures:\n"; - for (auto const& name: interfaceSymbols["methods"].getMemberNames()) - out += interfaceSymbols["methods"][name].asString() + ": " + name + "\n"; + for (auto const& [name, value]: interfaceSymbols["methods"].items()) + out += value.get() + ": " + name + "\n"; - if (interfaceSymbols.isMember("errors")) + if (interfaceSymbols.contains("errors")) { out += "\nError signatures:\n"; - for (auto const& name: interfaceSymbols["errors"].getMemberNames()) - out += interfaceSymbols["errors"][name].asString() + ": " + name + "\n"; + for (auto const& [name, value]: interfaceSymbols["errors"].items()) + out += value.get() + ": " + name + "\n"; } - if (interfaceSymbols.isMember("events")) + if (interfaceSymbols.contains("events")) { out += "\nEvent signatures:\n"; - for (auto const& name: interfaceSymbols["events"].getMemberNames()) - out += interfaceSymbols["events"][name].asString() + ": " + name + "\n"; + for (auto const& [name, value]: interfaceSymbols["events"].items()) + out += value.get() + ": " + name + "\n"; } if (!m_options.output.dir.empty()) @@ -467,40 +467,40 @@ void CommandLineInterface::handleGasEstimation(std::string const& _contract) { solAssert(CompilerInputModes.count(m_options.input.mode) == 1); - Json::Value estimates = m_compiler->gasEstimates(_contract); + Json estimates = m_compiler->gasEstimates(_contract); sout() << "Gas estimation:" << std::endl; - if (estimates["creation"].isObject()) + if (estimates["creation"].is_object()) { - Json::Value creation = estimates["creation"]; + Json creation = estimates["creation"]; sout() << "construction:" << std::endl; - sout() << " " << creation["executionCost"].asString(); - sout() << " + " << creation["codeDepositCost"].asString(); - sout() << " = " << creation["totalCost"].asString() << std::endl; + sout() << " " << creation["executionCost"].get(); + sout() << " + " << creation["codeDepositCost"].get(); + sout() << " = " << creation["totalCost"].get() << std::endl; } - if (estimates["external"].isObject()) + if (estimates["external"].is_object()) { - Json::Value externalFunctions = estimates["external"]; + Json externalFunctions = estimates["external"]; sout() << "external:" << std::endl; - for (auto const& name: externalFunctions.getMemberNames()) + for (auto const& [name, value]: externalFunctions.items()) { if (name.empty()) sout() << " fallback:\t"; else sout() << " " << name << ":\t"; - sout() << externalFunctions[name].asString() << std::endl; + sout() << value.get() << std::endl; } } - if (estimates["internal"].isObject()) + if (estimates["internal"].is_object()) { - Json::Value internalFunctions = estimates["internal"]; + Json internalFunctions = estimates["internal"]; sout() << "internal:" << std::endl; - for (auto const& name: internalFunctions.getMemberNames()) + for (auto const& [name, value]: internalFunctions.items()) { sout() << " " << name << ":\t"; - sout() << internalFunctions[name].asString() << std::endl; + sout() << value.get() << std::endl; } } } @@ -613,27 +613,27 @@ void CommandLineInterface::readInputFiles() solThrow(CommandLineValidationError, "All specified input files either do not exist or are not regular files."); } -std::map CommandLineInterface::parseAstFromInput() +std::map CommandLineInterface::parseAstFromInput() { solAssert(m_options.input.mode == InputMode::CompilerWithASTImport); - std::map sourceJsons; + std::map sourceJsons; std::map tmpSources; for (SourceCode const& sourceCode: m_fileReader.sourceUnits() | ranges::views::values) { - Json::Value ast; + Json ast; astAssert(jsonParseStrict(sourceCode, ast), "Input file could not be parsed to JSON"); - astAssert(ast.isMember("sources"), "Invalid Format for import-JSON: Must have 'sources'-object"); + astAssert(ast.contains("sources"), "Invalid Format for import-JSON: Must have 'sources'-object"); - for (auto& src: ast["sources"].getMemberNames()) + for (auto const& [src, value]: ast["sources"].items()) { - std::string astKey = ast["sources"][src].isMember("ast") ? "ast" : "AST"; + std::string astKey = value.contains("ast") ? "ast" : "AST"; - astAssert(ast["sources"][src].isMember(astKey), "astkey is not member"); - astAssert(ast["sources"][src][astKey]["nodeType"].asString() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); + astAssert(ast["sources"][src].contains(astKey), "astkey is not member"); + astAssert(ast["sources"][src][astKey]["nodeType"].get() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); astAssert(sourceJsons.count(src) == 0, "All sources must have unique names"); - sourceJsons.emplace(src, std::move(ast["sources"][src][astKey])); + sourceJsons.emplace(src, std::move(value[astKey])); tmpSources[src] = util::jsonCompactPrint(ast); } } @@ -942,16 +942,16 @@ void CommandLineInterface::handleCombinedJSON() if (!m_options.compiler.combinedJsonRequests.has_value()) return; - Json::Value output(Json::objectValue); + Json output; output[g_strVersion] = frontend::VersionString; std::vector contracts = m_assemblyStack->contractNames(); if (!contracts.empty()) - output[g_strContracts] = Json::Value(Json::objectValue); + output[g_strContracts] = Json::object(); for (std::string const& contractName: contracts) { - Json::Value& contractData = output[g_strContracts][contractName] = Json::objectValue; + Json& contractData = output[g_strContracts][contractName] = Json::object(); // NOTE: The state checks here are more strict that in Standard JSON. There we allow // requesting certain outputs even if compilation fails as long as analysis went ok. @@ -1013,19 +1013,19 @@ void CommandLineInterface::handleCombinedJSON() if (needsSourceList) { // Indices into this array are used to abbreviate source names in source locations. - output[g_strSourceList] = Json::Value(Json::arrayValue); + output[g_strSourceList] = Json::array(); for (auto const& source: m_assemblyStack->sourceNames()) - output[g_strSourceList].append(source); + output[g_strSourceList].emplace_back(source); } if (m_options.compiler.combinedJsonRequests->ast) { solAssert(m_compiler); - output[g_strSources] = Json::Value(Json::objectValue); + output[g_strSources] = Json::object(); for (auto const& sourceCode: m_fileReader.sourceUnits()) { - output[g_strSources][sourceCode.first] = Json::Value(Json::objectValue); + output[g_strSources][sourceCode.first] = Json::object(); output[g_strSources][sourceCode.first]["AST"] = ASTJsonExporter( m_compiler->state(), m_compiler->sourceIndices() diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index 1fb4ac00bcb1..bcebcbcfd3be 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -120,7 +120,7 @@ class CommandLineInterface /// such that they can be imported into the compiler (importASTs()) /// (produced by --combined-json ast /// or standard-json output - std::map parseAstFromInput(); + std::map parseAstFromInput(); /// Create a file in the given directory /// @arg _fileName the name of the file diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 95479690c1e9..0aa14e3bcadd 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -1229,8 +1229,15 @@ void CommandLineParser::processArgs() if (m_args.count(g_strYulOptimizations)) { OptimiserSettings optimiserSettings = m_options.optimiserSettings(); - if (!optimiserSettings.runYulOptimiser && !OptimiserSuite::isEmptyOptimizerSequence(m_args[g_strYulOptimizations].as())) - solThrow(CommandLineValidationError, "--" + g_strYulOptimizations + " is invalid with a non-empty sequence if Yul optimizer is disabled."); + if ( + !optimiserSettings.runYulOptimiser && + !OptimiserSuite::isEmptyOptimizerSequence(m_args[g_strYulOptimizations].as()) + ) + solThrow( + CommandLineValidationError, + "--" + g_strYulOptimizations + " is invalid with a non-empty sequence if Yul optimizer is disabled." + " Note that the empty optimizer sequence is properly denoted by \":\"." + ); try { diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 2243758356db..4ab9b2b08d7e 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -191,7 +191,7 @@ void EVMHost::newTransactionFrame() for (auto& [slot, value]: account.storage) { value.access_status = EVMC_ACCESS_COLD; // Clear EIP-2929 storage access indicator - value.original = value.current; // Clear EIP-2200 dirty slot + value.original = value.current; // Clear EIP-2200 dirty slot } // Clear transient storage according to EIP 1153 diff --git a/test/InteractiveTests.h b/test/InteractiveTests.h index 2519fa86f488..42e20d7e3919 100644 --- a/test/InteractiveTests.h +++ b/test/InteractiveTests.h @@ -61,27 +61,27 @@ struct Testsuite /// Array of testsuits that can be run interactively as well as automatically Testsuite const g_interactiveTestsuites[] = { /* - Title Path Subpath SMT NeedsVM Creator function */ - {"Yul Optimizer", "libyul", "yulOptimizerTests", false, false, &yul::test::YulOptimizerTest::create}, - {"Yul Interpreter", "libyul", "yulInterpreterTests", false, false, &yul::test::YulInterpreterTest::create}, - {"Yul Object Compiler", "libyul", "objectCompiler", false, false, &yul::test::ObjectCompilerTest::create}, - {"Yul Control Flow Graph", "libyul", "yulControlFlowGraph", false, false, &yul::test::ControlFlowGraphTest::create}, - {"Yul Stack Layout", "libyul", "yulStackLayout", false, false, &yul::test::StackLayoutGeneratorTest::create}, - {"Yul Stack Shuffling", "libyul", "yulStackShuffling", false, false, &yul::test::StackShufflingTest::create}, - {"Control Flow Side Effects", "libyul", "controlFlowSideEffects", false, false, &yul::test::ControlFlowSideEffectsTest::create}, - {"Function Side Effects", "libyul", "functionSideEffects", false, false, &yul::test::FunctionSideEffects::create}, - {"Yul Syntax", "libyul", "yulSyntaxTests", false, false, &yul::test::SyntaxTest::create}, - {"EVM Code Transform", "libyul", "evmCodeTransform", false, false, &yul::test::EVMCodeTransformTest::create, {"nooptions"}}, - {"Syntax", "libsolidity", "syntaxTests", false, false, &SyntaxTest::create}, - {"Semantic", "libsolidity", "semanticTests", false, true, &SemanticTest::create}, - {"JSON AST", "libsolidity", "ASTJSON", false, false, &ASTJSONTest::create}, - {"JSON ABI", "libsolidity", "ABIJson", false, false, &ABIJsonTest::create}, - {"JSON Natspec", "libsolidity", "natspecJSON", false, false, &NatspecJSONTest::create}, - {"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SMTCheckerTest::create}, - {"Gas Estimates", "libsolidity", "gasTests", false, false, &GasTest::create}, - {"Memory Guard", "libsolidity", "memoryGuardTests", false, false, &MemoryGuardTest::create}, - {"AST Properties", "libsolidity", "astPropertyTests", false, false, &ASTPropertyTest::create}, - {"Function Dependency Graph", "libsolidity", "functionDependencyGraphTests", false, false, &FunctionDependencyGraphTest::create}, + Title Path Subpath SMT NeedsVM Creator function */ + {"Yul Optimizer", "libyul", "yulOptimizerTests", false, false, &yul::test::YulOptimizerTest::create}, + {"Yul Interpreter", "libyul", "yulInterpreterTests", false, false, &yul::test::YulInterpreterTest::create}, + {"Yul Object Compiler", "libyul", "objectCompiler", false, false, &yul::test::ObjectCompilerTest::create}, + {"Yul Control Flow Graph", "libyul", "yulControlFlowGraph", false, false, &yul::test::ControlFlowGraphTest::create}, + {"Yul Stack Layout", "libyul", "yulStackLayout", false, false, &yul::test::StackLayoutGeneratorTest::create}, + {"Yul Stack Shuffling", "libyul", "yulStackShuffling", false, false, &yul::test::StackShufflingTest::create}, + {"Control Flow Side Effects", "libyul", "controlFlowSideEffects", false, false, &yul::test::ControlFlowSideEffectsTest::create}, + {"Function Side Effects", "libyul", "functionSideEffects", false, false, &yul::test::FunctionSideEffects::create}, + {"Yul Syntax", "libyul", "yulSyntaxTests", false, false, &yul::test::SyntaxTest::create}, + {"EVM Code Transform", "libyul", "evmCodeTransform", false, false, &yul::test::EVMCodeTransformTest::create, {"nooptions"}}, + {"Syntax", "libsolidity", "syntaxTests", false, false, &SyntaxTest::create}, + {"Semantic", "libsolidity", "semanticTests", false, true, &SemanticTest::create}, + {"JSON AST", "libsolidity", "ASTJSON", false, false, &ASTJSONTest::create}, + {"JSON ABI", "libsolidity", "ABIJson", false, false, &ABIJsonTest::create}, + {"JSON Natspec", "libsolidity", "natspecJSON", false, false, &NatspecJSONTest::create}, + {"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SMTCheckerTest::create}, + {"Gas Estimates", "libsolidity", "gasTests", false, false, &GasTest::create}, + {"Memory Guard", "libsolidity", "memoryGuardTests", false, false, &MemoryGuardTest::create}, + {"AST Properties", "libsolidity", "astPropertyTests", false, false, &ASTPropertyTest::create}, + {"Function Dependency Graph", "libsolidity", "functionDependencyGraphTests", false, false, &FunctionDependencyGraphTest::create}, }; } diff --git a/test/Metadata.cpp b/test/Metadata.cpp index 2fea65c65be0..cdfcdfb19c48 100644 --- a/test/Metadata.cpp +++ b/test/Metadata.cpp @@ -172,33 +172,33 @@ std::optional> parseCBORMetadata(bytes const& bool isValidMetadata(std::string const& _serialisedMetadata) { - Json::Value metadata; + Json metadata; if (!util::jsonParseStrict(_serialisedMetadata, metadata)) return false; return isValidMetadata(metadata); } -bool isValidMetadata(Json::Value const& _metadata) +bool isValidMetadata(Json const& _metadata) { if ( - !_metadata.isObject() || - !_metadata.isMember("version") || - !_metadata.isMember("language") || - !_metadata.isMember("compiler") || - !_metadata.isMember("settings") || - !_metadata.isMember("sources") || - !_metadata.isMember("output") || - !_metadata["settings"].isMember("evmVersion") || - !_metadata["settings"].isMember("metadata") || - !_metadata["settings"]["metadata"].isMember("bytecodeHash") + !_metadata.is_object() || + !_metadata.contains("version") || + !_metadata.contains("language") || + !_metadata.contains("compiler") || + !_metadata.contains("settings") || + !_metadata.contains("sources") || + !_metadata.contains("output") || + !_metadata["settings"].contains("evmVersion") || + !_metadata["settings"].contains("metadata") || + !_metadata["settings"]["metadata"].contains("bytecodeHash") ) return false; - if (!_metadata["version"].isNumeric() || _metadata["version"] != 1) + if (!_metadata["version"].is_number() || _metadata["version"] != 1) return false; - if (!_metadata["language"].isString() || _metadata["language"].asString() != "Solidity") + if (!_metadata["language"].is_string() || _metadata["language"].get() != "Solidity") return false; /// @TODO add more strict checks diff --git a/test/Metadata.h b/test/Metadata.h index 86b43e245f18..f3dae0cbdea0 100644 --- a/test/Metadata.h +++ b/test/Metadata.h @@ -53,6 +53,6 @@ std::optional> parseCBORMetadata(bytes const& bool isValidMetadata(std::string const& _serialisedMetadata); /// Expects a deserialised metadata JSON and returns true if the content is valid metadata. -bool isValidMetadata(Json::Value const& _metadata); +bool isValidMetadata(Json const& _metadata); } // end namespaces diff --git a/test/benchmarks/run.sh b/test/benchmarks/run.sh index ef1c146f00c8..1784b3700bde 100755 --- a/test/benchmarks/run.sh +++ b/test/benchmarks/run.sh @@ -26,10 +26,17 @@ set -euo pipefail REPO_ROOT=$(cd "$(dirname "$0")/../../" && pwd) SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build} +# shellcheck source=scripts/common.sh +source "${REPO_ROOT}/scripts/common.sh" +# shellcheck source=scripts/common_cmdline.sh +source "${REPO_ROOT}/scripts/common_cmdline.sh" + +(( $# <= 1 )) || fail "Too many arguments. Usage: run.sh []" + +solc="${1:-${SOLIDITY_BUILD_DIR}/solc/solc}" +command_available "$solc" --version + output_dir=$(mktemp -d -t solc-benchmark-XXXXXX) -result_legacy_file="${output_dir}/benchmark-legacy.txt" -result_via_ir_file="${output_dir}/benchmark-via-ir.txt" -warnings_and_errors_file="${output_dir}/benchmark-warn-err.txt" function cleanup() { rm -r "${output_dir}" @@ -38,38 +45,50 @@ function cleanup() { trap cleanup SIGINT SIGTERM -solc="${SOLIDITY_BUILD_DIR}/solc/solc" -benchmarks_dir="${REPO_ROOT}/test/benchmarks" -benchmarks=("chains.sol" "OptimizorClub.sol" "verifier.sol") -time_bin_path=$(type -P time) +function bytecode_size { + local bytecode_chars + bytecode_chars=$(stripCLIDecorations | stripEmptyLines | wc --chars) + echo $(( bytecode_chars / 2 )) +} -for input_file in "${benchmarks[@]}" -do - input_path="${benchmarks_dir}/${input_file}" +function benchmark_contract { + local pipeline="$1" + local input_path="$2" - solc_command_legacy=("${solc}" --optimize --bin --color "${input_path}") - solc_command_via_ir=("${solc}" --via-ir --optimize --bin --color "${input_path}") + local solc_command=("${solc}" --optimize --bin --color "${input_path}") + [[ $pipeline == via-ir ]] && solc_command+=(--via-ir) + local time_args=(--output "${output_dir}/time-and-status-${pipeline}.txt" --quiet --format '%e s | %x') - # Legacy can fail. - "${time_bin_path}" --output "${result_legacy_file}" --format "%e" "${solc_command_legacy[@]}" >/dev/null 2>>"${warnings_and_errors_file}" - "${time_bin_path}" --output "${result_via_ir_file}" --format "%e" "${solc_command_via_ir[@]}" >/dev/null 2>>"${warnings_and_errors_file}" + # NOTE: Legacy pipeline may fail with "Stack too deep" in some cases. That's fine. + "$time_bin_path" \ + "${time_args[@]}" \ + "${solc_command[@]}" \ + > "${output_dir}/bytecode-${pipeline}.bin" \ + 2>> "${output_dir}/benchmark-warn-err.txt" || [[ $pipeline == legacy ]] - time_legacy=$(<"${result_legacy_file}") - time_via_ir=$(<"${result_via_ir_file}") + printf '| %-20s | %s | %7d bytes | %20s |\n' \ + '`'"$input_file"'`' \ + "$pipeline" \ + "$(bytecode_size < "${output_dir}/bytecode-${pipeline}.bin")" \ + "$(< "${output_dir}/time-and-status-${pipeline}.txt")" +} + +benchmarks=("verifier.sol" "OptimizorClub.sol" "chains.sol") +time_bin_path=$(type -P time) + +echo "| File | Pipeline | Bytecode size | Time | Exit code |" +echo "|----------------------|----------|--------------:|---------:|----------:|" - echo "=======================================================" - echo " ${input_file}" - echo "-------------------------------------------------------" - echo "legacy pipeline took ${time_legacy} seconds to execute." - echo "via-ir pipeline took ${time_via_ir} seconds to execute." - echo "=======================================================" +for input_file in "${benchmarks[@]}" +do + benchmark_contract legacy "${REPO_ROOT}/test/benchmarks/${input_file}" + benchmark_contract via-ir "${REPO_ROOT}/test/benchmarks/${input_file}" done echo echo "=======================================================" echo "Warnings and errors generated during run:" echo "=======================================================" -echo "$(<"${warnings_and_errors_file}")" +echo "$(< "${output_dir}/benchmark-warn-err.txt")" cleanup - diff --git a/test/cmdlineTests/abi_via_ir/output b/test/cmdlineTests/abi_via_ir/output index daf18f3497a7..56ba01a4a248 100644 --- a/test/cmdlineTests/abi_via_ir/output +++ b/test/cmdlineTests/abi_via_ir/output @@ -3,8 +3,7 @@ Contract JSON ABI [ { - "inputs": - [ + "inputs": [ { "internalType": "uint256", "name": "z", @@ -20,8 +19,7 @@ Contract JSON ABI "type": "error" }, { - "inputs": - [ + "inputs": [ { "internalType": "uint256", "name": "z", @@ -32,8 +30,7 @@ Contract JSON ABI "type": "error" }, { - "inputs": - [ + "inputs": [ { "internalType": "uint256", "name": "r", @@ -45,8 +42,7 @@ Contract JSON ABI }, { "anonymous": true, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", @@ -59,8 +55,7 @@ Contract JSON ABI }, { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", @@ -73,8 +68,7 @@ Contract JSON ABI }, { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", @@ -86,11 +80,9 @@ Contract JSON ABI "type": "event" }, { - "inputs": - [ + "inputs": [ { - "components": - [ + "components": [ { "internalType": "uint256", "name": "x", @@ -113,8 +105,7 @@ Contract JSON ABI Contract JSON ABI [ { - "inputs": - [ + "inputs": [ { "internalType": "uint256", "name": "r", @@ -125,8 +116,7 @@ Contract JSON ABI "type": "error" }, { - "inputs": - [ + "inputs": [ { "internalType": "uint256", "name": "u", @@ -138,8 +128,7 @@ Contract JSON ABI }, { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", @@ -152,8 +141,7 @@ Contract JSON ABI }, { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", diff --git a/test/cmdlineTests/asm_json/output b/test/cmdlineTests/asm_json/output index f6a0a4b19053..38d9c9fdf5fe 100644 --- a/test/cmdlineTests/asm_json/output +++ b/test/cmdlineTests/asm_json/output @@ -2,8 +2,7 @@ ======= asm_json/input.sol:C ======= EVM assembly: { - ".code": - [ + ".code": [ { "begin": 60, "end": 160, @@ -140,13 +139,10 @@ EVM assembly: "source": 0 } ], - ".data": - { - "0": - { + ".data": { + "0": { ".auxdata": "", - ".code": - [ + ".code": [ { "begin": 60, "end": 160, @@ -1570,8 +1566,7 @@ EVM assembly: ] } }, - "sourceList": - [ + "sourceList": [ "asm_json/input.sol", "#utility.yul" ] diff --git a/test/cmdlineTests/ast_compact_json_with_base_path/output b/test/cmdlineTests/ast_compact_json_with_base_path/output index 5c5c6ffd5123..c61502020765 100644 --- a/test/cmdlineTests/ast_compact_json_with_base_path/output +++ b/test/cmdlineTests/ast_compact_json_with_base_path/output @@ -4,22 +4,18 @@ JSON AST (compact format): ======= ast_compact_json_with_base_path/c.sol ======= { "absolutePath": "ast_compact_json_with_base_path/c.sol", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 4, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" @@ -35,8 +31,7 @@ JSON AST (compact format): "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", @@ -54,22 +49,18 @@ JSON AST (compact format): ======= ast_compact_json_with_base_path/input.sol ======= { "absolutePath": "ast_compact_json_with_base_path/input.sol", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 3, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" diff --git a/test/cmdlineTests/ast_ir/output b/test/cmdlineTests/ast_ir/output index cca31349e868..c68c77872969 100644 --- a/test/cmdlineTests/ast_ir/output +++ b/test/cmdlineTests/ast_ir/output @@ -1,19 +1,14 @@ IR AST: { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "59:790:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "118:2:0", @@ -23,8 +18,7 @@ IR AST: "value": "64" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "134:3:0", @@ -34,8 +28,7 @@ IR AST: "value": "128" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "122:11:0", "nodeType": "YulIdentifier", @@ -46,8 +39,7 @@ IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "111:6:0", "nodeType": "YulIdentifier", @@ -62,19 +54,15 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "163:83:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb", "nativeSrc": "165:77:0", "nodeType": "YulIdentifier", @@ -90,11 +78,9 @@ IR AST: } ] }, - "condition": - { + "condition": { "arguments": [], - "functionName": - { + "functionName": { "name": "callvalue", "nativeSrc": "151:9:0", "nodeType": "YulIdentifier", @@ -109,11 +95,9 @@ IR AST: "src": "60:13:0" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "constructor_C_2", "nativeSrc": "256:15:0", "nodeType": "YulIdentifier", @@ -131,11 +115,9 @@ IR AST: "nativeSrc": "283:30:0", "nodeType": "YulVariableDeclaration", "src": "60:13:0", - "value": - { + "value": { "arguments": [], - "functionName": - { + "functionName": { "name": "allocate_unbounded", "nativeSrc": "293:18:0", "nodeType": "YulIdentifier", @@ -145,8 +127,7 @@ IR AST: "nodeType": "YulFunctionCall", "src": "60:13:0" }, - "variables": - [ + "variables": [ { "name": "_1", "nativeSrc": "287:2:0", @@ -157,10 +138,8 @@ IR AST: ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "331:2:0", @@ -168,8 +147,7 @@ IR AST: "src": "60:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -180,8 +158,7 @@ IR AST: "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "dataoffset", "nativeSrc": "335:10:0", "nodeType": "YulIdentifier", @@ -192,8 +169,7 @@ IR AST: "src": "60:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -204,8 +180,7 @@ IR AST: "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "363:8:0", "nodeType": "YulIdentifier", @@ -216,8 +191,7 @@ IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "codecopy", "nativeSrc": "322:8:0", "nodeType": "YulIdentifier", @@ -232,10 +206,8 @@ IR AST: "src": "60:13:0" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "405:2:0", @@ -243,8 +215,7 @@ IR AST: "src": "60:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -255,8 +226,7 @@ IR AST: "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "409:8:0", "nodeType": "YulIdentifier", @@ -267,8 +237,7 @@ IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "return", "nativeSrc": "398:6:0", "nodeType": "YulIdentifier", @@ -283,21 +252,17 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "484:43:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "498:19:0", "nodeType": "YulAssignment", "src": "60:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "514:2:0", @@ -307,8 +272,7 @@ IR AST: "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "508:5:0", "nodeType": "YulIdentifier", @@ -318,8 +282,7 @@ IR AST: "nodeType": "YulFunctionCall", "src": "60:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "498:6:0", @@ -333,8 +296,7 @@ IR AST: "name": "allocate_unbounded", "nativeSrc": "444:83:0", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "477:6:0", @@ -346,18 +308,14 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "626:36:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "647:1:0", @@ -375,8 +333,7 @@ IR AST: "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "640:6:0", "nodeType": "YulIdentifier", @@ -398,8 +355,7 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "741:59:0", "nodeType": "YulBlock", "src": "60:13:0", @@ -416,23 +372,17 @@ IR AST: }, "name": "C_2", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "929:588:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "996:2:0", @@ -442,8 +392,7 @@ IR AST: "value": "64" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "1012:3:0", @@ -453,8 +402,7 @@ IR AST: "value": "128" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "1000:11:0", "nodeType": "YulIdentifier", @@ -465,8 +413,7 @@ IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "989:6:0", "nodeType": "YulIdentifier", @@ -481,11 +428,9 @@ IR AST: "src": "60:13:0" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74", "nativeSrc": "1031:77:0", "nodeType": "YulIdentifier", @@ -500,21 +445,17 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "1177:77:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "1195:44:0", "nodeType": "YulAssignment", "src": "60:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "1228:3:0", @@ -530,8 +471,7 @@ IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "shr", "nativeSrc": "1224:3:0", "nodeType": "YulIdentifier", @@ -541,8 +481,7 @@ IR AST: "nodeType": "YulFunctionCall", "src": "60:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "newValue", "nativeSrc": "1195:8:0", @@ -556,8 +495,7 @@ IR AST: "name": "shift_right_224_unsigned", "nativeSrc": "1124:130:0", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "value", "nativeSrc": "1158:5:0", @@ -566,8 +504,7 @@ IR AST: "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "newValue", "nativeSrc": "1168:8:0", @@ -579,21 +516,17 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "1308:51:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "1326:19:0", "nodeType": "YulAssignment", "src": "60:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "1342:2:0", @@ -603,8 +536,7 @@ IR AST: "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "1336:5:0", "nodeType": "YulIdentifier", @@ -614,8 +546,7 @@ IR AST: "nodeType": "YulFunctionCall", "src": "60:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "1326:6:0", @@ -629,8 +560,7 @@ IR AST: "name": "allocate_unbounded", "nativeSrc": "1268:91:0", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "1301:6:0", @@ -642,18 +572,14 @@ IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "1462:44:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1487:1:0", @@ -671,8 +597,7 @@ IR AST: "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "1480:6:0", "nodeType": "YulIdentifier", @@ -699,8 +624,7 @@ IR AST: }, "name": "C_2_deployed", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { "nodeType": "YulData", "value": "" @@ -711,29 +635,23 @@ IR AST: } Optimized IR AST: { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "59:790:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { "nativeSrc": "59:790:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { "nativeSrc": "122:16:0", "nodeType": "YulVariableDeclaration", "src": "60:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "134:3:0", @@ -743,8 +661,7 @@ Optimized IR AST: "value": "0x80" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "122:11:0", "nodeType": "YulIdentifier", @@ -754,8 +671,7 @@ Optimized IR AST: "nodeType": "YulFunctionCall", "src": "60:13:0" }, - "variables": - [ + "variables": [ { "name": "_1", "nativeSrc": "122:16:0", @@ -766,10 +682,8 @@ Optimized IR AST: ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "118:2:0", @@ -785,8 +699,7 @@ Optimized IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "111:6:0", "nodeType": "YulIdentifier", @@ -801,18 +714,14 @@ Optimized IR AST: "src": "60:13:0" }, { - "body": - { + "body": { "nativeSrc": "163:83:0", "nodeType": "YulBlock", "src": "60:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "650:1:0", @@ -830,8 +739,7 @@ Optimized IR AST: "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "640:6:0", "nodeType": "YulIdentifier", @@ -847,11 +755,9 @@ Optimized IR AST: } ] }, - "condition": - { + "condition": { "arguments": [], - "functionName": - { + "functionName": { "name": "callvalue", "nativeSrc": "151:9:0", "nodeType": "YulIdentifier", @@ -869,10 +775,8 @@ Optimized IR AST: "nativeSrc": "363:24:0", "nodeType": "YulVariableDeclaration", "src": "60:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -883,8 +787,7 @@ Optimized IR AST: "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "363:8:0", "nodeType": "YulIdentifier", @@ -894,8 +797,7 @@ Optimized IR AST: "nodeType": "YulFunctionCall", "src": "60:13:0" }, - "variables": - [ + "variables": [ { "name": "_2", "nativeSrc": "363:24:0", @@ -906,10 +808,8 @@ Optimized IR AST: ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "331:2:0", @@ -917,8 +817,7 @@ Optimized IR AST: "src": "60:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -929,8 +828,7 @@ Optimized IR AST: "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "dataoffset", "nativeSrc": "335:10:0", "nodeType": "YulIdentifier", @@ -947,8 +845,7 @@ Optimized IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "codecopy", "nativeSrc": "322:8:0", "nodeType": "YulIdentifier", @@ -963,10 +860,8 @@ Optimized IR AST: "src": "60:13:0" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "405:2:0", @@ -980,8 +875,7 @@ Optimized IR AST: "src": "60:13:0" } ], - "functionName": - { + "functionName": { "name": "return", "nativeSrc": "398:6:0", "nodeType": "YulIdentifier", @@ -1003,29 +897,22 @@ Optimized IR AST: }, "name": "C_2", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "929:588:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { "nativeSrc": "929:588:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1490:1:0", @@ -1043,8 +930,7 @@ Optimized IR AST: "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "1480:6:0", "nodeType": "YulIdentifier", @@ -1066,8 +952,7 @@ Optimized IR AST: }, "name": "C_2_deployed", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { "nodeType": "YulData", "value": "" diff --git a/test/cmdlineTests/combined_json_abi/output b/test/cmdlineTests/combined_json_abi/output index c775c6d72ca1..79b539db78d0 100644 --- a/test/cmdlineTests/combined_json_abi/output +++ b/test/cmdlineTests/combined_json_abi/output @@ -1,8 +1,6 @@ { - "contracts": - { - "combined_json_abi/input.sol:C": - { + "contracts": { + "combined_json_abi/input.sol:C": { "abi": [] } }, diff --git a/test/cmdlineTests/combined_json_generated_sources/output b/test/cmdlineTests/combined_json_generated_sources/output index 5ef9078d6e80..db7c86ce13d7 100644 --- a/test/cmdlineTests/combined_json_generated_sources/output +++ b/test/cmdlineTests/combined_json_generated_sources/output @@ -1,35 +1,26 @@ { - "contracts": - { - "combined_json_generated_sources/input.sol:C": - { + "contracts": { + "combined_json_generated_sources/input.sol:C": { "generated-sources": [], - "generated-sources-runtime": - [ + "generated-sources-runtime": [ { - "ast": - { + "ast": { "nativeSrc": "0:1856:1", "nodeType": "YulBlock", "src": "0:1856:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "47:35:1", "nodeType": "YulBlock", "src": "47:35:1", - "statements": - [ + "statements": [ { "nativeSrc": "57:19:1", "nodeType": "YulAssignment", "src": "57:19:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "73:2:1", @@ -39,8 +30,7 @@ "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "67:5:1", "nodeType": "YulIdentifier", @@ -50,8 +40,7 @@ "nodeType": "YulFunctionCall", "src": "67:9:1" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "57:6:1", @@ -65,8 +54,7 @@ "name": "allocate_unbounded", "nativeSrc": "7:75:1", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "40:6:1", @@ -78,18 +66,14 @@ "src": "7:75:1" }, { - "body": - { + "body": { "nativeSrc": "177:28:1", "nodeType": "YulBlock", "src": "177:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "194:1:1", @@ -107,8 +91,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "187:6:1", "nodeType": "YulIdentifier", @@ -130,18 +113,14 @@ "src": "88:117:1" }, { - "body": - { + "body": { "nativeSrc": "300:28:1", "nodeType": "YulBlock", "src": "300:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "317:1:1", @@ -159,8 +138,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "310:6:1", "nodeType": "YulIdentifier", @@ -182,18 +160,14 @@ "src": "211:117:1" }, { - "body": - { + "body": { "nativeSrc": "423:28:1", "nodeType": "YulBlock", "src": "423:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "440:1:1", @@ -211,8 +185,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "433:6:1", "nodeType": "YulIdentifier", @@ -234,18 +207,14 @@ "src": "334:117:1" }, { - "body": - { + "body": { "nativeSrc": "546:28:1", "nodeType": "YulBlock", "src": "546:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "563:1:1", @@ -263,8 +232,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "556:6:1", "nodeType": "YulIdentifier", @@ -286,18 +254,14 @@ "src": "457:117:1" }, { - "body": - { + "body": { "nativeSrc": "669:28:1", "nodeType": "YulBlock", "src": "669:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "686:1:1", @@ -315,8 +279,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "679:6:1", "nodeType": "YulIdentifier", @@ -338,27 +301,21 @@ "src": "580:117:1" }, { - "body": - { + "body": { "nativeSrc": "810:478:1", "nodeType": "YulBlock", "src": "810:478:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "859:83:1", "nodeType": "YulBlock", "src": "859:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_1b9f4a0a5773e33b91aa01db23bf8c55fce1411167c872835e7fa00a4f17d46d", "nativeSrc": "861:77:1", "nodeType": "YulIdentifier", @@ -374,16 +331,12 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "offset", "nativeSrc": "838:6:1", @@ -399,8 +352,7 @@ "value": "0x1f" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "834:3:1", "nodeType": "YulIdentifier", @@ -417,8 +369,7 @@ "src": "853:3:1" } ], - "functionName": - { + "functionName": { "name": "slt", "nativeSrc": "830:3:1", "nodeType": "YulIdentifier", @@ -429,8 +380,7 @@ "src": "830:27:1" } ], - "functionName": - { + "functionName": { "name": "iszero", "nativeSrc": "823:6:1", "nodeType": "YulIdentifier", @@ -448,10 +398,8 @@ "nativeSrc": "951:30:1", "nodeType": "YulAssignment", "src": "951:30:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "offset", "nativeSrc": "974:6:1", @@ -459,8 +407,7 @@ "src": "974:6:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", "nativeSrc": "961:12:1", "nodeType": "YulIdentifier", @@ -470,8 +417,7 @@ "nodeType": "YulFunctionCall", "src": "961:20:1" }, - "variableNames": - [ + "variableNames": [ { "name": "length", "nativeSrc": "951:6:1", @@ -481,19 +427,15 @@ ] }, { - "body": - { + "body": { "nativeSrc": "1024:83:1", "nodeType": "YulBlock", "src": "1024:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_15abf5612cd996bc235ba1e55a4a30ac60e6bb601ff7ba4ad3f179b6be8d0490", "nativeSrc": "1026:77:1", "nodeType": "YulIdentifier", @@ -509,10 +451,8 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "length", "nativeSrc": "996:6:1", @@ -528,8 +468,7 @@ "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "993:2:1", "nodeType": "YulIdentifier", @@ -547,10 +486,8 @@ "nativeSrc": "1116:29:1", "nodeType": "YulAssignment", "src": "1116:29:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "offset", "nativeSrc": "1132:6:1", @@ -566,8 +503,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "1128:3:1", "nodeType": "YulIdentifier", @@ -577,8 +513,7 @@ "nodeType": "YulFunctionCall", "src": "1128:17:1" }, - "variableNames": - [ + "variableNames": [ { "name": "arrayPos", "nativeSrc": "1116:8:1", @@ -588,19 +523,15 @@ ] }, { - "body": - { + "body": { "nativeSrc": "1199:83:1", "nodeType": "YulBlock", "src": "1199:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_81385d8c0b31fffe14be1da910c8bd3a80be4cfa248e04f42ec0faea3132a8ef", "nativeSrc": "1201:77:1", "nodeType": "YulIdentifier", @@ -616,13 +547,10 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "arrayPos", "nativeSrc": "1164:8:1", @@ -630,8 +558,7 @@ "src": "1164:8:1" }, { - "arguments": - [ + "arguments": [ { "name": "length", "nativeSrc": "1178:6:1", @@ -647,8 +574,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "mul", "nativeSrc": "1174:3:1", "nodeType": "YulIdentifier", @@ -659,8 +585,7 @@ "src": "1174:17:1" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "1160:3:1", "nodeType": "YulIdentifier", @@ -677,8 +602,7 @@ "src": "1194:3:1" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "1157:2:1", "nodeType": "YulIdentifier", @@ -697,8 +621,7 @@ "name": "abi_decode_t_array$_t_uint256_$dyn_calldata_ptr", "nativeSrc": "720:568:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "offset", "nativeSrc": "777:6:1", @@ -714,8 +637,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "arrayPos", "nativeSrc": "793:8:1", @@ -734,27 +656,21 @@ "src": "720:568:1" }, { - "body": - { + "body": { "nativeSrc": "1395:458:1", "nodeType": "YulBlock", "src": "1395:458:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "1441:83:1", "nodeType": "YulBlock", "src": "1441:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b", "nativeSrc": "1443:77:1", "nodeType": "YulIdentifier", @@ -770,13 +686,10 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "dataEnd", "nativeSrc": "1416:7:1", @@ -790,8 +703,7 @@ "src": "1425:9:1" } ], - "functionName": - { + "functionName": { "name": "sub", "nativeSrc": "1412:3:1", "nodeType": "YulIdentifier", @@ -810,8 +722,7 @@ "value": "32" } ], - "functionName": - { + "functionName": { "name": "slt", "nativeSrc": "1408:3:1", "nodeType": "YulIdentifier", @@ -829,19 +740,15 @@ "nativeSrc": "1534:312:1", "nodeType": "YulBlock", "src": "1534:312:1", - "statements": - [ + "statements": [ { "nativeSrc": "1549:45:1", "nodeType": "YulVariableDeclaration", "src": "1549:45:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "headStart", "nativeSrc": "1580:9:1", @@ -857,8 +764,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "1576:3:1", "nodeType": "YulIdentifier", @@ -869,8 +775,7 @@ "src": "1576:17:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", "nativeSrc": "1563:12:1", "nodeType": "YulIdentifier", @@ -880,8 +785,7 @@ "nodeType": "YulFunctionCall", "src": "1563:31:1" }, - "variables": - [ + "variables": [ { "name": "offset", "nativeSrc": "1553:6:1", @@ -892,19 +796,15 @@ ] }, { - "body": - { + "body": { "nativeSrc": "1641:83:1", "nodeType": "YulBlock", "src": "1641:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db", "nativeSrc": "1643:77:1", "nodeType": "YulIdentifier", @@ -920,10 +820,8 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "offset", "nativeSrc": "1613:6:1", @@ -939,8 +837,7 @@ "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "1610:2:1", "nodeType": "YulIdentifier", @@ -958,13 +855,10 @@ "nativeSrc": "1738:98:1", "nodeType": "YulAssignment", "src": "1738:98:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "headStart", "nativeSrc": "1808:9:1", @@ -978,8 +872,7 @@ "src": "1819:6:1" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "1804:3:1", "nodeType": "YulIdentifier", @@ -996,8 +889,7 @@ "src": "1828:7:1" } ], - "functionName": - { + "functionName": { "name": "abi_decode_t_array$_t_uint256_$dyn_calldata_ptr", "nativeSrc": "1756:47:1", "nodeType": "YulIdentifier", @@ -1007,8 +899,7 @@ "nodeType": "YulFunctionCall", "src": "1756:80:1" }, - "variableNames": - [ + "variableNames": [ { "name": "value0", "nativeSrc": "1738:6:1", @@ -1030,8 +921,7 @@ "name": "abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr", "nativeSrc": "1294:559:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "headStart", "nativeSrc": "1357:9:1", @@ -1047,8 +937,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "value0", "nativeSrc": "1380:6:1", diff --git a/test/cmdlineTests/combined_json_stop_after_parsing/output b/test/cmdlineTests/combined_json_stop_after_parsing/output index 32cdd019b859..64e66e3f1227 100644 --- a/test/cmdlineTests/combined_json_stop_after_parsing/output +++ b/test/cmdlineTests/combined_json_stop_after_parsing/output @@ -1,28 +1,21 @@ { - "contracts": - { + "contracts": { "combined_json_stop_after_parsing/input.sol:C": {} }, - "sourceList": - [ + "sourceList": [ "combined_json_stop_after_parsing/input.sol" ], - "sources": - { - "combined_json_stop_after_parsing/input.sol": - { - "AST": - { + "sources": { + "combined_json_stop_after_parsing/input.sol": { + "AST": { "absolutePath": "combined_json_stop_after_parsing/input.sol", "id": 3, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", "*" ], diff --git a/test/cmdlineTests/combined_json_with_base_path/output b/test/cmdlineTests/combined_json_with_base_path/output index ec9bbcbcb22e..0a3add37e3b4 100644 --- a/test/cmdlineTests/combined_json_with_base_path/output +++ b/test/cmdlineTests/combined_json_with_base_path/output @@ -1,36 +1,27 @@ { - "contracts": - { + "contracts": { "combined_json_with_base_path/c.sol:C": {} }, - "sourceList": - [ + "sourceList": [ "combined_json_with_base_path/c.sol", "combined_json_with_base_path/input.sol" ], - "sources": - { - "combined_json_with_base_path/c.sol": - { - "AST": - { + "sources": { + "combined_json_with_base_path/c.sol": { + "AST": { "absolutePath": "combined_json_with_base_path/c.sol", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 4, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" @@ -46,8 +37,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", @@ -64,27 +54,21 @@ }, "id": 0 }, - "combined_json_with_base_path/input.sol": - { - "AST": - { + "combined_json_with_base_path/input.sol": { + "AST": { "absolutePath": "combined_json_with_base_path/input.sol", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 3, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" diff --git a/test/cmdlineTests/combined_json_with_devdoc/output b/test/cmdlineTests/combined_json_with_devdoc/output index d3df44a90d17..817018ea6c58 100644 --- a/test/cmdlineTests/combined_json_with_devdoc/output +++ b/test/cmdlineTests/combined_json_with_devdoc/output @@ -1,20 +1,15 @@ { - "contracts": - { - "combined_json_with_devdoc/input.sol:C": - { - "devdoc": - { + "contracts": { + "combined_json_with_devdoc/input.sol:C": { + "devdoc": { "details": "This is devdoc.", "kind": "dev", "methods": {}, "version": 1 } }, - "combined_json_with_devdoc/input.sol:D": - { - "devdoc": - { + "combined_json_with_devdoc/input.sol:D": { + "devdoc": { "kind": "dev", "methods": {}, "version": 1 diff --git a/test/cmdlineTests/combined_json_with_userdoc/output b/test/cmdlineTests/combined_json_with_userdoc/output index 650981d67c4f..4eb56fe24dd2 100644 --- a/test/cmdlineTests/combined_json_with_userdoc/output +++ b/test/cmdlineTests/combined_json_with_userdoc/output @@ -1,20 +1,15 @@ { - "contracts": - { - "combined_json_with_userdoc/input.sol:C": - { - "userdoc": - { + "contracts": { + "combined_json_with_userdoc/input.sol:C": { + "userdoc": { "kind": "user", "methods": {}, "notice": "Description for users.", "version": 1 } }, - "combined_json_with_userdoc/input.sol:D": - { - "userdoc": - { + "combined_json_with_userdoc/input.sol:D": { + "userdoc": { "kind": "user", "methods": {}, "version": 1 diff --git a/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output b/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output index 0bd6285b785e..d5c02fc82151 100644 --- a/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output +++ b/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output @@ -428,8 +428,7 @@ object "D_27" { { /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." let _1 := memoryguard(0x80) - let _2 := 64 - mstore(_2, _1) + mstore(64, _1) if iszero(lt(calldatasize(), 4)) { if eq(0x26121ff0, shr(224, calldataload(0))) @@ -437,10 +436,9 @@ object "D_27" { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } /// @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." - let _3 := datasize("C_2") - let _4 := add(_1, _3) - let _5 := 0xffffffffffffffff - if or(gt(_4, _5), lt(_4, _1)) + let _2 := datasize("C_2") + let _3 := add(_1, _2) + if or(gt(_3, 0xffffffffffffffff), lt(_3, _1)) { /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." mstore(0, shl(224, 0x4e487b71)) @@ -448,45 +446,53 @@ object "D_27" { revert(0, 0x24) } /// @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." - datacopy(_1, dataoffset("C_2"), _3) - if iszero(create(/** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ 0, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _1, sub(_4, _1))) + datacopy(_1, dataoffset("C_2"), _2) + if iszero(create(/** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ 0, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _1, sub(_3, _1))) { /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." - let pos := mload(_2) + let pos := mload(64) returndatacopy(pos, 0, returndatasize()) revert(pos, returndatasize()) } - let memPtr := mload(_2) - let newFreePtr := add(memPtr, _2) - if or(gt(newFreePtr, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _5), /** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ lt(newFreePtr, memPtr)) + let memPtr := 0 + let size := 0 + size := 0 + let memPtr_1 := mload(64) + let newFreePtr := add(memPtr_1, 64) + if or(gt(newFreePtr, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ 0xffffffffffffffff), /** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ lt(newFreePtr, memPtr_1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - mstore(_2, newFreePtr) - mstore(memPtr, 2) - mstore(add(memPtr, 32), "/*") - let memPtr_1 := mload(_2) - let newFreePtr_1 := add(memPtr_1, 96) - if or(gt(newFreePtr_1, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _5), /** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ lt(newFreePtr_1, memPtr_1)) + mstore(64, newFreePtr) + memPtr := memPtr_1 + mstore(memPtr_1, 2) + mstore(add(memPtr_1, 32), "/*") + let memPtr_2 := 0 + let size_1 := 0 + size_1 := 0 + let memPtr_3 := mload(64) + let newFreePtr_1 := add(memPtr_3, 96) + if or(gt(newFreePtr_1, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ 0xffffffffffffffff), /** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ lt(newFreePtr_1, memPtr_3)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - mstore(_2, newFreePtr_1) - mstore(memPtr_1, 39) - let _6 := add(memPtr_1, 32) - mstore(_6, 0x2f2a2a204073726320303a39363a313635202022636f6e74726163742044207b) - mstore(add(memPtr_1, _2), shl(200, 0x2e2e2e22202a2f)) - let memPos := mload(_2) + mstore(64, newFreePtr_1) + memPtr_2 := memPtr_3 + mstore(memPtr_3, 39) + let _4 := add(memPtr_3, 32) + mstore(_4, 0x2f2a2a204073726320303a39363a313635202022636f6e74726163742044207b) + mstore(add(memPtr_3, 64), shl(200, 0x2e2e2e22202a2f)) + let memPos := mload(64) mstore(memPos, 32) - let length := mload(memPtr_1) + let length := mload(memPtr_3) mstore(add(memPos, 32), length) - mcopy(add(memPos, _2), _6, length) - mstore(add(add(memPos, length), _2), 0) - return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), _2)) + mcopy(add(memPos, 64), _4, length) + mstore(add(add(memPos, length), 64), 0) + return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), 64)) } } revert(0, 0) diff --git a/test/cmdlineTests/events_in_abi/output b/test/cmdlineTests/events_in_abi/output index 6c18a17521f0..ab246ef24a15 100644 --- a/test/cmdlineTests/events_in_abi/output +++ b/test/cmdlineTests/events_in_abi/output @@ -4,8 +4,7 @@ Contract JSON ABI [ { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", @@ -18,8 +17,7 @@ Contract JSON ABI }, { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": true, "internalType": "uint256", @@ -44,8 +42,7 @@ Contract JSON ABI [ { "anonymous": false, - "inputs": - [ + "inputs": [ { "indexed": false, "internalType": "uint256", diff --git a/test/cmdlineTests/function_debug_info/output b/test/cmdlineTests/function_debug_info/output index c359d4e1c155..c1346e33ab0c 100644 --- a/test/cmdlineTests/function_debug_info/output +++ b/test/cmdlineTests/function_debug_info/output @@ -1,58 +1,46 @@ { - "contracts": - { - "function_debug_info/input.sol:C": - { - "function-debug": - { - "@_34": - { + "contracts": { + "function_debug_info/input.sol:C": { + "function-debug": { + "@_34": { "id": 34, "parameterSlots": 1, "returnSlots": 0 }, - "abi_decode_tuple_t_uint256_fromMemory": - { + "abi_decode_tuple_t_uint256_fromMemory": { "entryPoint": 88, "parameterSlots": 2, "returnSlots": 1 } }, - "function-debug-runtime": - { - "@f_14": - { + "function-debug-runtime": { + "@f_14": { "entryPoint": 124, "id": 14, "parameterSlots": 2, "returnSlots": 1 }, - "@t_22": - { + "@t_22": { "id": 22, "parameterSlots": 0, "returnSlots": 0 }, - "abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr": - { + "abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr": { "entryPoint": 158, "parameterSlots": 2, "returnSlots": 2 }, - "abi_decode_tuple_t_uint256": - { - "entryPoint": 269, + "abi_decode_tuple_t_uint256": { + "entryPoint": 271, "parameterSlots": 2, "returnSlots": 1 }, - "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed": - { + "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed": { "parameterSlots": 2, "returnSlots": 1 }, - "panic_error_0x32": - { - "entryPoint": 292, + "panic_error_0x32": { + "entryPoint": 294, "parameterSlots": 0, "returnSlots": 0 } diff --git a/test/cmdlineTests/function_debug_info_via_yul/output b/test/cmdlineTests/function_debug_info_via_yul/output index 5af245ce4afa..05c2da48c607 100644 --- a/test/cmdlineTests/function_debug_info_via_yul/output +++ b/test/cmdlineTests/function_debug_info_via_yul/output @@ -1,8 +1,6 @@ { - "contracts": - { - "function_debug_info_via_yul/input.sol:C": - { + "contracts": { + "function_debug_info_via_yul/input.sol:C": { "function-debug": {}, "function-debug-runtime": {} } diff --git a/test/cmdlineTests/asm_json_import_all_valid_flags/args b/test/cmdlineTests/import_asm_json_all_valid_flags/args similarity index 100% rename from test/cmdlineTests/asm_json_import_all_valid_flags/args rename to test/cmdlineTests/import_asm_json_all_valid_flags/args diff --git a/test/cmdlineTests/asm_json_import_all_valid_flags/output b/test/cmdlineTests/import_asm_json_all_valid_flags/output similarity index 76% rename from test/cmdlineTests/asm_json_import_all_valid_flags/output rename to test/cmdlineTests/import_asm_json_all_valid_flags/output index 837187d195ae..c96001047a3c 100644 --- a/test/cmdlineTests/asm_json_import_all_valid_flags/output +++ b/test/cmdlineTests/import_asm_json_all_valid_flags/output @@ -1,12 +1,8 @@ { - "contracts": - { - "": - { - "asm": - { - ".code": - [ + "contracts": { + "": { + "asm": { + ".code": [ { "begin": -1, "end": -1, @@ -15,12 +11,9 @@ "value": "0" } ], - ".data": - { - "0": - { - ".code": - [ + ".data": { + "0": { + ".code": [ { "begin": -1, "end": -1, @@ -31,8 +24,7 @@ ] } }, - "sourceList": - [ + "sourceList": [ "contract.sol", "#utility.yul" ] @@ -44,8 +36,7 @@ "srcmap-runtime": ":::-:0" } }, - "sourceList": - [ + "sourceList": [ "contract.sol", "#utility.yul" ], @@ -57,8 +48,7 @@ Binary of the runtime part: 6001 EVM assembly: { - ".code": - [ + ".code": [ { "begin": -1, "end": -1, @@ -67,12 +57,9 @@ EVM assembly: "value": "0" } ], - ".data": - { - "0": - { - ".code": - [ + ".data": { + "0": { + ".code": [ { "begin": -1, "end": -1, @@ -83,8 +70,7 @@ EVM assembly: ] } }, - "sourceList": - [ + "sourceList": [ "contract.sol", "#utility.yul" ] diff --git a/test/cmdlineTests/asm_json_import_all_valid_flags/stdin b/test/cmdlineTests/import_asm_json_all_valid_flags/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_all_valid_flags/stdin rename to test/cmdlineTests/import_asm_json_all_valid_flags/stdin diff --git a/test/cmdlineTests/asm_json_import_difficulty_prevrandao/args b/test/cmdlineTests/import_asm_json_difficulty_prevrandao/args similarity index 100% rename from test/cmdlineTests/asm_json_import_difficulty_prevrandao/args rename to test/cmdlineTests/import_asm_json_difficulty_prevrandao/args diff --git a/test/cmdlineTests/asm_json_import_difficulty_prevrandao/output b/test/cmdlineTests/import_asm_json_difficulty_prevrandao/output similarity index 100% rename from test/cmdlineTests/asm_json_import_difficulty_prevrandao/output rename to test/cmdlineTests/import_asm_json_difficulty_prevrandao/output diff --git a/test/cmdlineTests/asm_json_import_difficulty_prevrandao/stdin b/test/cmdlineTests/import_asm_json_difficulty_prevrandao/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_difficulty_prevrandao/stdin rename to test/cmdlineTests/import_asm_json_difficulty_prevrandao/stdin diff --git a/test/cmdlineTests/asm_json_import_hex_subassembly_indices/args b/test/cmdlineTests/import_asm_json_hex_subassembly_indices/args similarity index 100% rename from test/cmdlineTests/asm_json_import_hex_subassembly_indices/args rename to test/cmdlineTests/import_asm_json_hex_subassembly_indices/args diff --git a/test/cmdlineTests/asm_json_import_hex_subassembly_indices/output b/test/cmdlineTests/import_asm_json_hex_subassembly_indices/output similarity index 100% rename from test/cmdlineTests/asm_json_import_hex_subassembly_indices/output rename to test/cmdlineTests/import_asm_json_hex_subassembly_indices/output diff --git a/test/cmdlineTests/asm_json_import_hex_subassembly_indices/stdin b/test/cmdlineTests/import_asm_json_hex_subassembly_indices/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_hex_subassembly_indices/stdin rename to test/cmdlineTests/import_asm_json_hex_subassembly_indices/stdin diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_hex/args b/test/cmdlineTests/import_asm_json_invalid_data_not_hex/args similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_hex/args rename to test/cmdlineTests/import_asm_json_invalid_data_not_hex/args diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_hex/err b/test/cmdlineTests/import_asm_json_invalid_data_not_hex/err similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_hex/err rename to test/cmdlineTests/import_asm_json_invalid_data_not_hex/err diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_hex/exit b/test/cmdlineTests/import_asm_json_invalid_data_not_hex/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_hex/exit rename to test/cmdlineTests/import_asm_json_invalid_data_not_hex/exit diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_hex/stdin b/test/cmdlineTests/import_asm_json_invalid_data_not_hex/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_hex/stdin rename to test/cmdlineTests/import_asm_json_invalid_data_not_hex/stdin diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_object/args b/test/cmdlineTests/import_asm_json_invalid_data_not_object/args similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_object/args rename to test/cmdlineTests/import_asm_json_invalid_data_not_object/args diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_object/err b/test/cmdlineTests/import_asm_json_invalid_data_not_object/err similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_object/err rename to test/cmdlineTests/import_asm_json_invalid_data_not_object/err diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_object/exit b/test/cmdlineTests/import_asm_json_invalid_data_not_object/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_object/exit rename to test/cmdlineTests/import_asm_json_invalid_data_not_object/exit diff --git a/test/cmdlineTests/asm_json_import_invalid_data_not_object/stdin b/test/cmdlineTests/import_asm_json_invalid_data_not_object/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_data_not_object/stdin rename to test/cmdlineTests/import_asm_json_invalid_data_not_object/stdin diff --git a/test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/args b/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/args similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/args rename to test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/args diff --git a/test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/err b/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/err similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/err rename to test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/err diff --git a/test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/exit b/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/exit rename to test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/exit diff --git a/test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/stdin b/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_jumptype_instruction/stdin rename to test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/stdin diff --git a/test/cmdlineTests/asm_json_import_invalid_value/args b/test/cmdlineTests/import_asm_json_invalid_value/args similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_value/args rename to test/cmdlineTests/import_asm_json_invalid_value/args diff --git a/test/cmdlineTests/asm_json_import_invalid_value/err b/test/cmdlineTests/import_asm_json_invalid_value/err similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_value/err rename to test/cmdlineTests/import_asm_json_invalid_value/err diff --git a/test/cmdlineTests/asm_json_import_invalid_value/exit b/test/cmdlineTests/import_asm_json_invalid_value/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_value/exit rename to test/cmdlineTests/import_asm_json_invalid_value/exit diff --git a/test/cmdlineTests/asm_json_import_invalid_value/stdin b/test/cmdlineTests/import_asm_json_invalid_value/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_invalid_value/stdin rename to test/cmdlineTests/import_asm_json_invalid_value/stdin diff --git a/test/cmdlineTests/asm_json_import_missing_subobject_indices/args b/test/cmdlineTests/import_asm_json_missing_subobject_indices/args similarity index 100% rename from test/cmdlineTests/asm_json_import_missing_subobject_indices/args rename to test/cmdlineTests/import_asm_json_missing_subobject_indices/args diff --git a/test/cmdlineTests/asm_json_import_missing_subobject_indices/err b/test/cmdlineTests/import_asm_json_missing_subobject_indices/err similarity index 100% rename from test/cmdlineTests/asm_json_import_missing_subobject_indices/err rename to test/cmdlineTests/import_asm_json_missing_subobject_indices/err diff --git a/test/cmdlineTests/asm_json_import_missing_subobject_indices/exit b/test/cmdlineTests/import_asm_json_missing_subobject_indices/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_missing_subobject_indices/exit rename to test/cmdlineTests/import_asm_json_missing_subobject_indices/exit diff --git a/test/cmdlineTests/asm_json_import_missing_subobject_indices/stdin b/test/cmdlineTests/import_asm_json_missing_subobject_indices/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_missing_subobject_indices/stdin rename to test/cmdlineTests/import_asm_json_missing_subobject_indices/stdin diff --git a/test/cmdlineTests/asm_json_import_no_value/args b/test/cmdlineTests/import_asm_json_no_value/args similarity index 100% rename from test/cmdlineTests/asm_json_import_no_value/args rename to test/cmdlineTests/import_asm_json_no_value/args diff --git a/test/cmdlineTests/asm_json_import_no_value/err b/test/cmdlineTests/import_asm_json_no_value/err similarity index 100% rename from test/cmdlineTests/asm_json_import_no_value/err rename to test/cmdlineTests/import_asm_json_no_value/err diff --git a/test/cmdlineTests/asm_json_import_no_value/exit b/test/cmdlineTests/import_asm_json_no_value/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_no_value/exit rename to test/cmdlineTests/import_asm_json_no_value/exit diff --git a/test/cmdlineTests/asm_json_import_no_value/stdin b/test/cmdlineTests/import_asm_json_no_value/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_no_value/stdin rename to test/cmdlineTests/import_asm_json_no_value/stdin diff --git a/test/cmdlineTests/asm_json_import_non_unique_sources/args b/test/cmdlineTests/import_asm_json_non_unique_sources/args similarity index 100% rename from test/cmdlineTests/asm_json_import_non_unique_sources/args rename to test/cmdlineTests/import_asm_json_non_unique_sources/args diff --git a/test/cmdlineTests/asm_json_import_non_unique_sources/err b/test/cmdlineTests/import_asm_json_non_unique_sources/err similarity index 100% rename from test/cmdlineTests/asm_json_import_non_unique_sources/err rename to test/cmdlineTests/import_asm_json_non_unique_sources/err diff --git a/test/cmdlineTests/asm_json_import_non_unique_sources/exit b/test/cmdlineTests/import_asm_json_non_unique_sources/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_non_unique_sources/exit rename to test/cmdlineTests/import_asm_json_non_unique_sources/exit diff --git a/test/cmdlineTests/asm_json_import_non_unique_sources/stdin b/test/cmdlineTests/import_asm_json_non_unique_sources/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_non_unique_sources/stdin rename to test/cmdlineTests/import_asm_json_non_unique_sources/stdin diff --git a/test/cmdlineTests/asm_json_import_optimize_not_supported/args b/test/cmdlineTests/import_asm_json_optimize_not_supported/args similarity index 100% rename from test/cmdlineTests/asm_json_import_optimize_not_supported/args rename to test/cmdlineTests/import_asm_json_optimize_not_supported/args diff --git a/test/cmdlineTests/asm_json_import_optimize_not_supported/err b/test/cmdlineTests/import_asm_json_optimize_not_supported/err similarity index 100% rename from test/cmdlineTests/asm_json_import_optimize_not_supported/err rename to test/cmdlineTests/import_asm_json_optimize_not_supported/err diff --git a/test/cmdlineTests/asm_json_import_optimize_not_supported/exit b/test/cmdlineTests/import_asm_json_optimize_not_supported/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_optimize_not_supported/exit rename to test/cmdlineTests/import_asm_json_optimize_not_supported/exit diff --git a/test/cmdlineTests/asm_json_import_optimize_not_supported/stdin b/test/cmdlineTests/import_asm_json_optimize_not_supported/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_optimize_not_supported/stdin rename to test/cmdlineTests/import_asm_json_optimize_not_supported/stdin diff --git a/test/cmdlineTests/asm_json_import_out_of_range_data_index/args b/test/cmdlineTests/import_asm_json_out_of_range_data_index/args similarity index 100% rename from test/cmdlineTests/asm_json_import_out_of_range_data_index/args rename to test/cmdlineTests/import_asm_json_out_of_range_data_index/args diff --git a/test/cmdlineTests/asm_json_import_out_of_range_data_index/err b/test/cmdlineTests/import_asm_json_out_of_range_data_index/err similarity index 100% rename from test/cmdlineTests/asm_json_import_out_of_range_data_index/err rename to test/cmdlineTests/import_asm_json_out_of_range_data_index/err diff --git a/test/cmdlineTests/asm_json_import_out_of_range_data_index/exit b/test/cmdlineTests/import_asm_json_out_of_range_data_index/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_out_of_range_data_index/exit rename to test/cmdlineTests/import_asm_json_out_of_range_data_index/exit diff --git a/test/cmdlineTests/asm_json_import_out_of_range_data_index/stdin b/test/cmdlineTests/import_asm_json_out_of_range_data_index/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_out_of_range_data_index/stdin rename to test/cmdlineTests/import_asm_json_out_of_range_data_index/stdin diff --git a/test/cmdlineTests/asm_json_import_random_order_data_index/args b/test/cmdlineTests/import_asm_json_random_order_data_index/args similarity index 100% rename from test/cmdlineTests/asm_json_import_random_order_data_index/args rename to test/cmdlineTests/import_asm_json_random_order_data_index/args diff --git a/test/cmdlineTests/asm_json_import_random_order_data_index/output b/test/cmdlineTests/import_asm_json_random_order_data_index/output similarity index 100% rename from test/cmdlineTests/asm_json_import_random_order_data_index/output rename to test/cmdlineTests/import_asm_json_random_order_data_index/output diff --git a/test/cmdlineTests/asm_json_import_random_order_data_index/stdin b/test/cmdlineTests/import_asm_json_random_order_data_index/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_random_order_data_index/stdin rename to test/cmdlineTests/import_asm_json_random_order_data_index/stdin diff --git a/test/cmdlineTests/asm_json_import_unrecognized_field/args b/test/cmdlineTests/import_asm_json_unrecognized_field/args similarity index 100% rename from test/cmdlineTests/asm_json_import_unrecognized_field/args rename to test/cmdlineTests/import_asm_json_unrecognized_field/args diff --git a/test/cmdlineTests/asm_json_import_unrecognized_field/err b/test/cmdlineTests/import_asm_json_unrecognized_field/err similarity index 100% rename from test/cmdlineTests/asm_json_import_unrecognized_field/err rename to test/cmdlineTests/import_asm_json_unrecognized_field/err diff --git a/test/cmdlineTests/asm_json_import_unrecognized_field/exit b/test/cmdlineTests/import_asm_json_unrecognized_field/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_unrecognized_field/exit rename to test/cmdlineTests/import_asm_json_unrecognized_field/exit diff --git a/test/cmdlineTests/asm_json_import_unrecognized_field/stdin b/test/cmdlineTests/import_asm_json_unrecognized_field/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_unrecognized_field/stdin rename to test/cmdlineTests/import_asm_json_unrecognized_field/stdin diff --git a/test/cmdlineTests/asm_json_import_untagged_jumpdest/args b/test/cmdlineTests/import_asm_json_untagged_jumpdest/args similarity index 100% rename from test/cmdlineTests/asm_json_import_untagged_jumpdest/args rename to test/cmdlineTests/import_asm_json_untagged_jumpdest/args diff --git a/test/cmdlineTests/asm_json_import_untagged_jumpdest/err b/test/cmdlineTests/import_asm_json_untagged_jumpdest/err similarity index 100% rename from test/cmdlineTests/asm_json_import_untagged_jumpdest/err rename to test/cmdlineTests/import_asm_json_untagged_jumpdest/err diff --git a/test/cmdlineTests/asm_json_import_untagged_jumpdest/exit b/test/cmdlineTests/import_asm_json_untagged_jumpdest/exit similarity index 100% rename from test/cmdlineTests/asm_json_import_untagged_jumpdest/exit rename to test/cmdlineTests/import_asm_json_untagged_jumpdest/exit diff --git a/test/cmdlineTests/asm_json_import_untagged_jumpdest/stdin b/test/cmdlineTests/import_asm_json_untagged_jumpdest/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_untagged_jumpdest/stdin rename to test/cmdlineTests/import_asm_json_untagged_jumpdest/stdin diff --git a/test/cmdlineTests/asm_json_import_verbatim/args b/test/cmdlineTests/import_asm_json_verbatim/args similarity index 100% rename from test/cmdlineTests/asm_json_import_verbatim/args rename to test/cmdlineTests/import_asm_json_verbatim/args diff --git a/test/cmdlineTests/asm_json_import_verbatim/output b/test/cmdlineTests/import_asm_json_verbatim/output similarity index 100% rename from test/cmdlineTests/asm_json_import_verbatim/output rename to test/cmdlineTests/import_asm_json_verbatim/output diff --git a/test/cmdlineTests/asm_json_import_verbatim/stdin b/test/cmdlineTests/import_asm_json_verbatim/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_verbatim/stdin rename to test/cmdlineTests/import_asm_json_verbatim/stdin diff --git a/test/cmdlineTests/asm_json_import_yul_more_subobjects/args b/test/cmdlineTests/import_asm_json_yul_more_subobjects/args similarity index 100% rename from test/cmdlineTests/asm_json_import_yul_more_subobjects/args rename to test/cmdlineTests/import_asm_json_yul_more_subobjects/args diff --git a/test/cmdlineTests/asm_json_import_yul_more_subobjects/output b/test/cmdlineTests/import_asm_json_yul_more_subobjects/output similarity index 100% rename from test/cmdlineTests/asm_json_import_yul_more_subobjects/output rename to test/cmdlineTests/import_asm_json_yul_more_subobjects/output diff --git a/test/cmdlineTests/asm_json_import_yul_more_subobjects/stdin b/test/cmdlineTests/import_asm_json_yul_more_subobjects/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_yul_more_subobjects/stdin rename to test/cmdlineTests/import_asm_json_yul_more_subobjects/stdin diff --git a/test/cmdlineTests/asm_json_import_yul_subobjects/args b/test/cmdlineTests/import_asm_json_yul_subobjects/args similarity index 100% rename from test/cmdlineTests/asm_json_import_yul_subobjects/args rename to test/cmdlineTests/import_asm_json_yul_subobjects/args diff --git a/test/cmdlineTests/asm_json_import_yul_subobjects/output b/test/cmdlineTests/import_asm_json_yul_subobjects/output similarity index 100% rename from test/cmdlineTests/asm_json_import_yul_subobjects/output rename to test/cmdlineTests/import_asm_json_yul_subobjects/output diff --git a/test/cmdlineTests/asm_json_import_yul_subobjects/stdin b/test/cmdlineTests/import_asm_json_yul_subobjects/stdin similarity index 100% rename from test/cmdlineTests/asm_json_import_yul_subobjects/stdin rename to test/cmdlineTests/import_asm_json_yul_subobjects/stdin diff --git a/test/cmdlineTests/inline_assembly_function_name_clash/output b/test/cmdlineTests/inline_assembly_function_name_clash/output index 8becb87ae06f..d7c7bf9e09d9 100644 --- a/test/cmdlineTests/inline_assembly_function_name_clash/output +++ b/test/cmdlineTests/inline_assembly_function_name_clash/output @@ -1,204 +1,169 @@ { - "contracts": - { - "inline_assembly_function_name_clash/input.sol:C": - { - "function-debug-runtime": - { - "abi_decode": - { + "contracts": { + "inline_assembly_function_name_clash/input.sol:C": { + "function-debug-runtime": { + "abi_decode": { "entryPoint": 80, "parameterSlots": 2, "returnSlots": 0 }, - "abi_encode_uint256": - { + "abi_encode_uint256": { "entryPoint": 111, "parameterSlots": 2, "returnSlots": 1 }, - "abi_encode_uint256_to_uint256": - { + "abi_encode_uint256_to_uint256": { "entryPoint": 98, "parameterSlots": 2, "returnSlots": 0 }, - "allocate_unbounded": - { + "allocate_unbounded": { "entryPoint": 66, "parameterSlots": 0, "returnSlots": 1 }, - "cleanup_uint256": - { + "cleanup_uint256": { "entryPoint": 95, "parameterSlots": 1, "returnSlots": 1 }, - "convert_uint256_to_uint256": - { + "convert_uint256_to_uint256": { "entryPoint": 276, "parameterSlots": 1, "returnSlots": 1 }, - "external_fun_f": - { + "external_fun_f": { "entryPoint": 132, "parameterSlots": 0, "returnSlots": 0 }, - "external_fun_g": - { + "external_fun_g": { "entryPoint": 185, "parameterSlots": 0, "returnSlots": 0 }, - "fun_f": - { + "fun_f": { "entryPoint": 442, "id": 25, "parameterSlots": 0, "returnSlots": 1 }, - "fun_f_inner": - { + "fun_f_inner": { "entryPoint": 430, "parameterSlots": 1, "returnSlots": 1 }, - "fun_g": - { + "fun_g": { "entryPoint": 564, "id": 36, "parameterSlots": 0, "returnSlots": 1 }, - "fun_g_inner": - { + "fun_g_inner": { "entryPoint": 552, "parameterSlots": 1, "returnSlots": 1 }, - "identity": - { + "identity": { "entryPoint": 273, "parameterSlots": 1, "returnSlots": 1 }, - "modifier_m": - { + "modifier_m": { "entryPoint": 509, "id": 14, "parameterSlots": 1, "returnSlots": 1 }, - "modifier_m_17": - { + "modifier_m_17": { "entryPoint": 344, "id": 14, "parameterSlots": 1, "returnSlots": 1 }, - "modifier_m_19": - { + "modifier_m_19": { "entryPoint": 387, "id": 14, "parameterSlots": 1, "returnSlots": 1 }, - "modifier_m_28": - { + "modifier_m_28": { "entryPoint": 466, "id": 14, "parameterSlots": 1, "returnSlots": 1 }, - "prepare_store_uint256": - { + "prepare_store_uint256": { "entryPoint": 304, "parameterSlots": 1, "returnSlots": 1 }, - "revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74": - { + "revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74": { "entryPoint": 238, "parameterSlots": 0, "returnSlots": 0 }, - "revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb": - { + "revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb": { "entryPoint": 72, "parameterSlots": 0, "returnSlots": 0 }, - "revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b": - { + "revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b": { "entryPoint": 76, "parameterSlots": 0, "returnSlots": 0 }, - "shift_left": - { + "shift_left": { "entryPoint": 246, "parameterSlots": 1, "returnSlots": 1 }, - "shift_right_unsigned": - { + "shift_right_unsigned": { "entryPoint": 60, "parameterSlots": 1, "returnSlots": 1 }, - "update_byte_slice_shift": - { + "update_byte_slice_shift": { "entryPoint": 251, "parameterSlots": 2, "returnSlots": 1 }, - "update_storage_value_offsett_uint256_to_uint256": - { + "update_storage_value_offsett_uint256_to_uint256": { "entryPoint": 307, "parameterSlots": 2, "returnSlots": 0 }, - "usr$f": - { + "usr$f": { "entryPoint": 339, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_17": - { + "usr$f_17": { "entryPoint": 382, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_22": - { + "usr$f_22": { "entryPoint": 425, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_26": - { + "usr$f_26": { "entryPoint": 461, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_32": - { + "usr$f_32": { "entryPoint": 504, "parameterSlots": 0, "returnSlots": 1 }, - "usr$f_37": - { + "usr$f_37": { "entryPoint": 547, "parameterSlots": 0, "returnSlots": 1 }, - "zero_value_for_split_uint256": - { + "zero_value_for_split_uint256": { "entryPoint": 242, "parameterSlots": 0, "returnSlots": 1 diff --git a/test/cmdlineTests/linking_standard_solidity/output.json b/test/cmdlineTests/linking_standard_solidity/output.json index 83813d806b01..1e49af2ca0fa 100644 --- a/test/cmdlineTests/linking_standard_solidity/output.json +++ b/test/cmdlineTests/linking_standard_solidity/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A": - { - "C": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "C": { + "evm": { + "bytecode": { "linkReferences": {}, "object": "" } @@ -16,10 +11,8 @@ } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/linking_standard_solidity_quote_in_file_name/output.json b/test/cmdlineTests/linking_standard_solidity_quote_in_file_name/output.json index 38e0a1b5aa18..87e80b8d19a8 100644 --- a/test/cmdlineTests/linking_standard_solidity_quote_in_file_name/output.json +++ b/test/cmdlineTests/linking_standard_solidity_quote_in_file_name/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A\"B": - { - "C": - { - "evm": - { - "bytecode": - { + "contracts": { + "A\"B": { + "C": { + "evm": { + "bytecode": { "linkReferences": {}, "object": "" } @@ -16,10 +11,8 @@ } } }, - "sources": - { - "A\"B": - { + "sources": { + "A\"B": { "id": 0 } } diff --git a/test/cmdlineTests/linking_standard_solidity_unresolved_references/output.json b/test/cmdlineTests/linking_standard_solidity_unresolved_references/output.json index 3a69e3e2d782..71c17347a754 100644 --- a/test/cmdlineTests/linking_standard_solidity_unresolved_references/output.json +++ b/test/cmdlineTests/linking_standard_solidity_unresolved_references/output.json @@ -1,20 +1,12 @@ { - "contracts": - { - "A": - { - "C": - { - "evm": - { - "bytecode": - { - "linkReferences": - { - "A": - { - "L2": - [ + "contracts": { + "A": { + "C": { + "evm": { + "bytecode": { + "linkReferences": { + "A": { + "L2": [ { "length": 20, "start": 173 @@ -32,10 +24,8 @@ } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/linking_standard_yul/output.json b/test/cmdlineTests/linking_standard_yul/output.json index b9059bdfd622..90445cfe0831 100644 --- a/test/cmdlineTests/linking_standard_yul/output.json +++ b/test/cmdlineTests/linking_standard_yul/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A": - { - "a": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "a": { + "evm": { + "bytecode": { "linkReferences": {}, "object": "" } diff --git a/test/cmdlineTests/linking_standard_yul_quote_in_file_name/output.json b/test/cmdlineTests/linking_standard_yul_quote_in_file_name/output.json index b9059bdfd622..90445cfe0831 100644 --- a/test/cmdlineTests/linking_standard_yul_quote_in_file_name/output.json +++ b/test/cmdlineTests/linking_standard_yul_quote_in_file_name/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A": - { - "a": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "a": { + "evm": { + "bytecode": { "linkReferences": {}, "object": "" } diff --git a/test/cmdlineTests/linking_standard_yul_unresolved_references/output.json b/test/cmdlineTests/linking_standard_yul_unresolved_references/output.json index ac1250cd4c74..041e8206b830 100644 --- a/test/cmdlineTests/linking_standard_yul_unresolved_references/output.json +++ b/test/cmdlineTests/linking_standard_yul_unresolved_references/output.json @@ -1,20 +1,12 @@ { - "contracts": - { - "A": - { - "a": - { - "evm": - { - "bytecode": - { - "linkReferences": - { - "contract/test.sol": - { - "L2": - [ + "contracts": { + "A": { + "a": { + "evm": { + "bytecode": { + "linkReferences": { + "contract/test.sol": { + "L2": [ { "length": 20, "start": 22 diff --git a/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output b/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output index 2441357d97fb..170cdf1a7a3a 100644 --- a/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output +++ b/test/cmdlineTests/mcopy_bytes_array_returned_from_function/output @@ -22,25 +22,24 @@ object "C_14" { { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _2 := 64 - let newFreePtr := add(_1, _2) + let newFreePtr := add(_1, 64) if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 36) } - mstore(_2, newFreePtr) + mstore(64, newFreePtr) mstore(_1, 5) - let _3 := add(_1, 0x20) - mstore(_3, "aaaaa") - let memPos := mload(_2) - mstore(memPos, 0x20) + let _2 := add(_1, 32) + mstore(_2, "aaaaa") + let memPos := mload(64) + mstore(memPos, 32) let length := mload(_1) - mstore(add(memPos, 0x20), length) - mcopy(add(memPos, _2), _3, length) - mstore(add(add(memPos, length), _2), 0) - return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), _2)) + mstore(add(memPos, 32), length) + mcopy(add(memPos, 64), _2, length) + mstore(add(add(memPos, length), 64), 0) + return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), 64)) } } revert(0, 0) diff --git a/test/cmdlineTests/mcopy_string_literal_returned_from_function/output b/test/cmdlineTests/mcopy_string_literal_returned_from_function/output index 02740ec0d6cb..548c34de8628 100644 --- a/test/cmdlineTests/mcopy_string_literal_returned_from_function/output +++ b/test/cmdlineTests/mcopy_string_literal_returned_from_function/output @@ -22,25 +22,24 @@ object "C_10" { { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _2 := 64 - let newFreePtr := add(_1, _2) + let newFreePtr := add(_1, 64) if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - mstore(_2, newFreePtr) + mstore(64, newFreePtr) mstore(_1, 25) - let _3 := add(_1, 0x20) - mstore(_3, "MCOPY on Cancun vacation.") - let memPos := mload(_2) - mstore(memPos, 0x20) + let _2 := add(_1, 32) + mstore(_2, "MCOPY on Cancun vacation.") + let memPos := mload(64) + mstore(memPos, 32) let length := mload(_1) - mstore(add(memPos, 0x20), length) - mcopy(add(memPos, _2), _3, length) - mstore(add(add(memPos, length), _2), 0) - return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), _2)) + mstore(add(memPos, 32), length) + mcopy(add(memPos, 64), _2, length) + mstore(add(add(memPos, length), 64), 0) + return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), 64)) } } revert(0, 0) diff --git a/test/cmdlineTests/model_checker_contracts_all/err b/test/cmdlineTests/model_checker_contracts_all/err index 57b620b49b68..9135483d5f79 100644 --- a/test/cmdlineTests/model_checker_contracts_all/err +++ b/test/cmdlineTests/model_checker_contracts_all/err @@ -6,10 +6,10 @@ x = 0 Transaction trace: B.constructor() B.f(0) - --> model_checker_contracts_all/input.sol:5:3: + --> model_checker_contracts_all/input.sol:5:9: | -5 | assert(x > 0); - | ^^^^^^^^^^^^^ +5 | assert(x > 0); + | ^^^^^^^^^^^^^ Warning: CHC: Assertion violation happens here. Counterexample: @@ -19,7 +19,7 @@ y = 0 Transaction trace: A.constructor() A.g(0) - --> model_checker_contracts_all/input.sol:10:3: + --> model_checker_contracts_all/input.sol:10:9: | -10 | assert(y > 0); - | ^^^^^^^^^^^^^ +10 | assert(y > 0); + | ^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/model_checker_contracts_all/input.sol b/test/cmdlineTests/model_checker_contracts_all/input.sol index 52b71f2e5d68..f47f2f31d63c 100644 --- a/test/cmdlineTests/model_checker_contracts_all/input.sol +++ b/test/cmdlineTests/model_checker_contracts_all/input.sol @@ -2,11 +2,11 @@ pragma solidity >=0.0; contract B { function f(uint x) public pure { - assert(x > 0); + assert(x > 0); } } contract A is B { function g(uint y) public pure { - assert(y > 0); + assert(y > 0); } -} \ No newline at end of file +} diff --git a/test/cmdlineTests/model_checker_invariants_all/err b/test/cmdlineTests/model_checker_invariants_all/err index 347f40325d14..7ec97678e990 100644 --- a/test/cmdlineTests/model_checker_invariants_all/err +++ b/test/cmdlineTests/model_checker_invariants_all/err @@ -9,6 +9,6 @@ Info: CHC: 1 verification condition(s) proved safe! Enable the model checker opt Info: Contract invariant(s) for model_checker_invariants_all/input.sol:test: (!(x >= 1) || true) Reentrancy property(ies) for model_checker_invariants_all/input.sol:test: -(((!(x <= 0) || !(x' >= 1)) && (!(x <= 0) || !( >= 1))) || true) +(((!(x <= 0) || !( >= 1)) && (!(x <= 0) || !(x' >= 1))) || true) = 0 -> no errors = 1 -> Assertion failed at assert(x == 0) diff --git a/test/cmdlineTests/model_checker_invariants_contract_eld/args b/test/cmdlineTests/model_checker_invariants_contract_eld/args new file mode 100644 index 000000000000..7f2a13bfd8c1 --- /dev/null +++ b/test/cmdlineTests/model_checker_invariants_contract_eld/args @@ -0,0 +1 @@ +--model-checker-engine chc --model-checker-invariants contract --model-checker-solvers eld diff --git a/test/cmdlineTests/model_checker_invariants_contract_eld/err b/test/cmdlineTests/model_checker_invariants_contract_eld/err new file mode 100644 index 000000000000..29c5a5bc8eae --- /dev/null +++ b/test/cmdlineTests/model_checker_invariants_contract_eld/err @@ -0,0 +1,4 @@ +Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. + +Info: Contract invariant(s) for model_checker_invariants_contract_eld/input.sol:test: +(x = 0) diff --git a/test/cmdlineTests/model_checker_invariants_contract_eld/input.sol b/test/cmdlineTests/model_checker_invariants_contract_eld/input.sol new file mode 100644 index 000000000000..4bee228bd65f --- /dev/null +++ b/test/cmdlineTests/model_checker_invariants_contract_eld/input.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; +contract test { + uint x; + function f() public view { + assert(x < 10); + } +} diff --git a/test/cmdlineTests/model_checker_invariants_contract_reentrancy/err b/test/cmdlineTests/model_checker_invariants_contract_reentrancy/err index c6d149f15a40..11ee3a702f8c 100644 --- a/test/cmdlineTests/model_checker_invariants_contract_reentrancy/err +++ b/test/cmdlineTests/model_checker_invariants_contract_reentrancy/err @@ -9,6 +9,6 @@ Info: CHC: 1 verification condition(s) proved safe! Enable the model checker opt Info: Contract invariant(s) for model_checker_invariants_contract_reentrancy/input.sol:test: (!(x >= 1) || true) Reentrancy property(ies) for model_checker_invariants_contract_reentrancy/input.sol:test: -(((!(x <= 0) || !(x' >= 1)) && (!(x <= 0) || !( >= 1))) || true) +(((!(x <= 0) || !( >= 1)) && (!(x <= 0) || !(x' >= 1))) || true) = 0 -> no errors = 1 -> Assertion failed at assert(x == 0) diff --git a/test/cmdlineTests/model_checker_solvers_eld/args b/test/cmdlineTests/model_checker_solvers_eld/args new file mode 100644 index 000000000000..e4acd0b46b71 --- /dev/null +++ b/test/cmdlineTests/model_checker_solvers_eld/args @@ -0,0 +1 @@ +--model-checker-engine chc --model-checker-solvers eld diff --git a/test/cmdlineTests/model_checker_solvers_eld/err b/test/cmdlineTests/model_checker_solvers_eld/err new file mode 100644 index 000000000000..ff7ad37b313e --- /dev/null +++ b/test/cmdlineTests/model_checker_solvers_eld/err @@ -0,0 +1,5 @@ +Warning: CHC: Assertion violation happens here. + --> model_checker_solvers_eld/input.sol:5:3: + | +5 | assert(x > 0); + | ^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/model_checker_solvers_eld/input.sol b/test/cmdlineTests/model_checker_solvers_eld/input.sol new file mode 100644 index 000000000000..7d05ef6e5f3e --- /dev/null +++ b/test/cmdlineTests/model_checker_solvers_eld/input.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; +contract test { + function f(uint x) public pure { + assert(x > 0); + } +} \ No newline at end of file diff --git a/test/cmdlineTests/model_checker_targets_all_all_engines/err b/test/cmdlineTests/model_checker_targets_all_all_engines/err index cc8a8ea33d1c..c67d97b61216 100644 --- a/test/cmdlineTests/model_checker_targets_all_all_engines/err +++ b/test/cmdlineTests/model_checker_targets_all_all_engines/err @@ -88,21 +88,11 @@ test.f(0x0, 1) 13 | arr[x]; | ^^^^^^ +Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. + Warning: BMC: Condition is always true. --> model_checker_targets_all_all_engines/input.sol:6:11: | 6 | require(x >= 0); | ^^^^^^ Note: Callstack: - -Warning: BMC: Insufficient funds happens here. - --> model_checker_targets_all_all_engines/input.sol:10:3: - | -10 | a.transfer(x); - | ^^^^^^^^^^^^^ -Note: Counterexample: - a = 0 - x = 0 - -Note: Callstack: -Note: diff --git a/test/cmdlineTests/model_checker_targets_all_chc/err b/test/cmdlineTests/model_checker_targets_all_chc/err index d0404ecfb6b9..9c257cefe9eb 100644 --- a/test/cmdlineTests/model_checker_targets_all_chc/err +++ b/test/cmdlineTests/model_checker_targets_all_chc/err @@ -87,3 +87,5 @@ test.f(0x0, 1) | 13 | arr[x]; | ^^^^^^ + +Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/cmdlineTests/model_checker_targets_balance_chc/err b/test/cmdlineTests/model_checker_targets_balance_chc/err new file mode 100644 index 000000000000..57bfe42678e4 --- /dev/null +++ b/test/cmdlineTests/model_checker_targets_balance_chc/err @@ -0,0 +1 @@ +Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/cmdlineTests/model_checker_targets_default_all_engines/err b/test/cmdlineTests/model_checker_targets_default_all_engines/err index c1fe2f5b3e59..62d3b203cb9c 100644 --- a/test/cmdlineTests/model_checker_targets_default_all_engines/err +++ b/test/cmdlineTests/model_checker_targets_default_all_engines/err @@ -58,21 +58,11 @@ test.f(0x0, 1) 13 | arr[x]; | ^^^^^^ +Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. + Warning: BMC: Condition is always true. --> model_checker_targets_default_all_engines/input.sol:6:11: | 6 | require(x >= 0); | ^^^^^^ Note: Callstack: - -Warning: BMC: Insufficient funds happens here. - --> model_checker_targets_default_all_engines/input.sol:10:3: - | -10 | a.transfer(x); - | ^^^^^^^^^^^^^ -Note: Counterexample: - a = 0 - x = 0 - -Note: Callstack: -Note: diff --git a/test/cmdlineTests/model_checker_targets_default_chc/err b/test/cmdlineTests/model_checker_targets_default_chc/err index bd2aa0b4de1d..70f3c5bc6072 100644 --- a/test/cmdlineTests/model_checker_targets_default_chc/err +++ b/test/cmdlineTests/model_checker_targets_default_chc/err @@ -57,3 +57,5 @@ test.f(0x0, 1) | 13 | arr[x]; | ^^^^^^ + +Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index 0a461e3e4af4..04abaf600103 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -17,100 +17,104 @@ object "C_59" { code { { /// @src 0:346:625 "contract C {..." - let _1 := memoryguard(0x80) - let _2 := 4 - if iszero(lt(calldatasize(), _2)) + mstore(64, memoryguard(0x80)) + if iszero(lt(calldatasize(), 4)) { if eq(0xf8eddcc6, shr(224, calldataload(0))) { if callvalue() { revert(0, 0) } - let _3 := 32 - if slt(add(calldatasize(), not(3)), _3) { revert(0, 0) } - let offset := calldataload(_2) - let _4 := 0xffffffffffffffff - if gt(offset, _4) { revert(0, 0) } + if slt(add(calldatasize(), not(3)), 32) { revert(0, 0) } + let offset := calldataload(4) + if gt(offset, 0xffffffffffffffff) { revert(0, 0) } if iszero(slt(add(offset, 35), calldatasize())) { revert(0, 0) } - let _5 := calldataload(add(_2, offset)) - let _6 := 36 - if gt(_5, _4) + let length := calldataload(add(4, offset)) + if gt(length, 0xffffffffffffffff) { mstore(0, shl(224, 0x4e487b71)) - mstore(_2, 0x41) - revert(0, _6) + mstore(4, 0x41) + revert(0, 36) } - let _7 := shl(5, _5) - let _8 := not(31) - let newFreePtr := add(_1, and(add(_7, 63), _8)) - if or(gt(newFreePtr, _4), lt(newFreePtr, _1)) + let _1 := shl(5, length) + let memPtr := 0 + memPtr := mload(64) + let newFreePtr := add(memPtr, and(add(_1, 63), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { mstore(0, shl(224, 0x4e487b71)) - mstore(_2, 0x41) - revert(0, _6) + mstore(4, 0x41) + revert(0, 36) } - let _9 := 64 - mstore(_9, newFreePtr) - let dst := _1 - mstore(_1, _5) - dst := add(_1, _3) + mstore(64, newFreePtr) + let dst := memPtr + mstore(memPtr, length) + dst := add(memPtr, 32) let dst_1 := dst - let srcEnd := add(add(offset, _7), _6) + let srcEnd := add(add(offset, _1), 36) if gt(srcEnd, calldatasize()) { revert(0, 0) } - let src := add(offset, _6) - for { } lt(src, srcEnd) { src := add(src, _3) } + let src := add(offset, 36) + for { } lt(src, srcEnd) { src := add(src, 32) } { - if slt(sub(calldatasize(), src), _3) { revert(0, 0) } - let memPtr := mload(_9) - let newFreePtr_1 := add(memPtr, _3) - if or(gt(newFreePtr_1, _4), lt(newFreePtr_1, memPtr)) + if slt(sub(calldatasize(), src), 32) { revert(0, 0) } + let memPtr_1 := 0 + memPtr_1 := mload(64) + let newFreePtr_1 := add(memPtr_1, 32) + if or(gt(newFreePtr_1, 0xffffffffffffffff), lt(newFreePtr_1, memPtr_1)) { mstore(0, shl(224, 0x4e487b71)) - mstore(_2, 0x41) - revert(0, _6) + mstore(4, 0x41) + revert(0, 36) } - mstore(_9, newFreePtr_1) - mstore(memPtr, calldataload(src)) - mstore(dst, memPtr) - dst := add(dst, _3) + mstore(64, newFreePtr_1) + mstore(memPtr_1, calldataload(src)) + mstore(dst, memPtr_1) + dst := add(dst, 32) } - if iszero(mload(_1)) + /// @src 0:469:474 "_s[0]" + let addr := /** @src 0:346:625 "contract C {..." */ 0 + if iszero(mload(memPtr)) { mstore(0, shl(224, 0x4e487b71)) - mstore(_2, 0x32) - revert(0, _6) + mstore(4, 0x32) + revert(0, 36) } + addr := dst_1 sstore(0, mload(/** @src 0:469:474 "_s[0]" */ mload(dst_1))) - /// @src 0:346:625 "contract C {..." - if iszero(lt(/** @src 0:492:493 "1" */ 0x01, /** @src 0:346:625 "contract C {..." */ mload(_1))) + /// @src 0:489:494 "_s[1]" + let addr_1 := /** @src 0:346:625 "contract C {..." */ 0 + if iszero(lt(/** @src 0:492:493 "1" */ 0x01, /** @src 0:346:625 "contract C {..." */ mload(memPtr))) { mstore(0, shl(224, 0x4e487b71)) - mstore(_2, 0x32) - revert(0, _6) + mstore(4, 0x32) + revert(0, 36) } - let _10 := mload(/** @src 0:489:494 "_s[1]" */ mload(/** @src 0:346:625 "contract C {..." */ add(_1, _9))) - sstore(0x02, _10) - let memPtr_1 := mload(_9) - let newFreePtr_2 := add(memPtr_1, 160) - if or(gt(newFreePtr_2, _4), lt(newFreePtr_2, memPtr_1)) + addr_1 := add(memPtr, 64) + let _2 := mload(/** @src 0:489:494 "_s[1]" */ mload(addr_1)) + /// @src 0:346:625 "contract C {..." + sstore(0x02, _2) + let memPtr_2 := 0 + memPtr_2 := mload(64) + let newFreePtr_2 := add(memPtr_2, 160) + if or(gt(newFreePtr_2, 0xffffffffffffffff), lt(newFreePtr_2, memPtr_2)) { mstore(0, shl(224, 0x4e487b71)) - mstore(_2, 0x41) - revert(0, _6) + mstore(4, 0x41) + revert(0, 36) } - mstore(_9, newFreePtr_2) - mstore(memPtr_1, 100) - let _11 := add(memPtr_1, _3) - mstore(_11, "longstringlongstringlongstringlo") - mstore(add(memPtr_1, _9), "ngstringlongstringlongstringlong") - mstore(add(memPtr_1, 96), "stringlongstringlongstringlongst") - mstore(add(memPtr_1, 128), "ring") - let memPos := mload(_9) - mstore(memPos, _10) - mstore(add(memPos, _3), _9) - let length := mload(memPtr_1) - mstore(add(memPos, _9), length) - mcopy(add(memPos, 96), _11, length) - mstore(add(add(memPos, length), 96), 0) - return(memPos, add(sub(add(memPos, and(add(length, 31), _8)), memPos), 96)) + mstore(64, newFreePtr_2) + mstore(memPtr_2, 100) + let _3 := add(memPtr_2, 32) + mstore(_3, "longstringlongstringlongstringlo") + mstore(add(memPtr_2, 64), "ngstringlongstringlongstringlong") + mstore(add(memPtr_2, 96), "stringlongstringlongstringlongst") + mstore(add(memPtr_2, 128), "ring") + let memPos := mload(64) + mstore(memPos, _2) + mstore(add(memPos, 32), 64) + let length_1 := mload(memPtr_2) + mstore(add(memPos, 64), length_1) + mcopy(add(memPos, 96), _3, length_1) + mstore(add(add(memPos, length_1), 96), 0) + return(memPos, add(sub(add(memPos, and(add(length_1, 0x1f), not(31))), memPos), 96)) } } revert(0, 0) diff --git a/test/cmdlineTests/no_contract_combined_json/output b/test/cmdlineTests/no_contract_combined_json/output index e0caa6fa1acc..8c454e341442 100644 --- a/test/cmdlineTests/no_contract_combined_json/output +++ b/test/cmdlineTests/no_contract_combined_json/output @@ -1,25 +1,19 @@ { - "sourceList": - [ + "sourceList": [ "no_contract_combined_json/input.sol" ], - "sources": - { - "no_contract_combined_json/input.sol": - { - "AST": - { + "sources": { + "no_contract_combined_json/input.sol": { + "AST": { "absolutePath": "no_contract_combined_json/input.sol", "exportedSymbols": {}, "id": 2, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" diff --git a/test/cmdlineTests/optimizer_array_sload/output b/test/cmdlineTests/optimizer_array_sload/output index b32d421d0717..c1e0796f56fa 100644 --- a/test/cmdlineTests/optimizer_array_sload/output +++ b/test/cmdlineTests/optimizer_array_sload/output @@ -18,7 +18,6 @@ object "Arraysum_34" { { /// @src 0:80:429 "contract Arraysum {..." mstore(64, memoryguard(0x80)) - let _1 := 4 if iszero(lt(calldatasize(), 4)) { if eq(0x81d73423, shr(224, calldataload(0))) @@ -26,12 +25,14 @@ object "Arraysum_34" { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } let var_sum := 0 + /// @src 0:175:182 "sum = 0" + var_sum := /** @src 0:80:429 "contract Arraysum {..." */ 0 /// @src 0:368:378 "uint i = 0" let var_i := /** @src 0:80:429 "contract Arraysum {..." */ 0 - let _2 := sload(0) + let _1 := sload(0) /// @src 0:364:423 "for(uint i = 0; i < values.length; i++)..." for { } - /** @src 0:380:397 "i < values.length" */ lt(var_i, _2) + /** @src 0:80:429 "contract Arraysum {..." */ 1 /// @src 0:368:378 "uint i = 0" { /// @src 0:399:402 "i++" @@ -39,13 +40,17 @@ object "Arraysum_34" { } /// @src 0:399:402 "i++" { + /// @src 0:380:397 "i < values.length" + let _2 := iszero(lt(var_i, _1)) + if _2 { break } /// @src 0:80:429 "contract Arraysum {..." + _2 := 0 mstore(0, 0) let sum := add(var_sum, sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i))) if gt(var_sum, sum) { mstore(0, shl(224, 0x4e487b71)) - mstore(_1, 0x11) + mstore(4, 0x11) revert(0, 0x24) } /// @src 0:407:423 "sum += values[i]" @@ -54,7 +59,7 @@ object "Arraysum_34" { /// @src 0:80:429 "contract Arraysum {..." let memPos := mload(64) mstore(memPos, var_sum) - return(memPos, 32) + return(memPos, 0x20) } } revert(0, 0) diff --git a/test/cmdlineTests/output_selection_all_A1/output.json b/test/cmdlineTests/output_selection_all_A1/output.json index b21b632bdc88..e28a8af254e5 100644 --- a/test/cmdlineTests/output_selection_all_A1/output.json +++ b/test/cmdlineTests/output_selection_all_A1/output.json @@ -1,41 +1,29 @@ { - "contracts": - { - "a.sol": - { - "A1": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A1": { + "evm": { + "bytecode": { "object": "" } } } }, - "b.sol": - { - "A1": - { - "evm": - { - "bytecode": - { + "b.sol": { + "A1": { + "evm": { + "bytecode": { "object": "" } } } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/output_selection_all_A2/output.json b/test/cmdlineTests/output_selection_all_A2/output.json index c33941c2f9e5..9e6ea3b0e715 100644 --- a/test/cmdlineTests/output_selection_all_A2/output.json +++ b/test/cmdlineTests/output_selection_all_A2/output.json @@ -1,28 +1,20 @@ { - "contracts": - { - "a.sol": - { - "A2": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A2": { + "evm": { + "bytecode": { "object": "" } } } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/output_selection_all_blank/output.json b/test/cmdlineTests/output_selection_all_blank/output.json index b4c60911cb64..d05ed608c34c 100644 --- a/test/cmdlineTests/output_selection_all_blank/output.json +++ b/test/cmdlineTests/output_selection_all_blank/output.json @@ -1,12 +1,9 @@ { - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/output_selection_all_star/output.json b/test/cmdlineTests/output_selection_all_star/output.json index f709636212b6..668c4b4235c9 100644 --- a/test/cmdlineTests/output_selection_all_star/output.json +++ b/test/cmdlineTests/output_selection_all_star/output.json @@ -1,61 +1,43 @@ { - "contracts": - { - "a.sol": - { - "A1": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A1": { + "evm": { + "bytecode": { "object": "" } } }, - "A2": - { - "evm": - { - "bytecode": - { + "A2": { + "evm": { + "bytecode": { "object": "" } } } }, - "b.sol": - { - "A1": - { - "evm": - { - "bytecode": - { + "b.sol": { + "A1": { + "evm": { + "bytecode": { "object": "" } } }, - "B2": - { - "evm": - { - "bytecode": - { + "B2": { + "evm": { + "bytecode": { "object": "" } } } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/output_selection_single_A1/output.json b/test/cmdlineTests/output_selection_single_A1/output.json index ab44a2d540a4..137b19cc0dd8 100644 --- a/test/cmdlineTests/output_selection_single_A1/output.json +++ b/test/cmdlineTests/output_selection_single_A1/output.json @@ -1,28 +1,20 @@ { - "contracts": - { - "a.sol": - { - "A1": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A1": { + "evm": { + "bytecode": { "object": "" } } } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/output_selection_single_B1/output.json b/test/cmdlineTests/output_selection_single_B1/output.json index ffaf266b4d06..87dd70b3aa28 100644 --- a/test/cmdlineTests/output_selection_single_B1/output.json +++ b/test/cmdlineTests/output_selection_single_B1/output.json @@ -1,28 +1,20 @@ { - "contracts": - { - "b.sol": - { - "B2": - { - "evm": - { - "bytecode": - { + "contracts": { + "b.sol": { + "B2": { + "evm": { + "bytecode": { "object": "" } } } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/output_selection_single_all/output.json b/test/cmdlineTests/output_selection_single_all/output.json index 52d04cb18ddf..123f437137f3 100644 --- a/test/cmdlineTests/output_selection_single_all/output.json +++ b/test/cmdlineTests/output_selection_single_all/output.json @@ -1,38 +1,27 @@ { - "contracts": - { - "a.sol": - { - "A1": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A1": { + "evm": { + "bytecode": { "object": "" } } }, - "A2": - { - "evm": - { - "bytecode": - { + "A2": { + "evm": { + "bytecode": { "object": "" } } } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 }, - "b.sol": - { + "b.sol": { "id": 1 } } diff --git a/test/cmdlineTests/pretty_json_indent_only/output.json b/test/cmdlineTests/pretty_json_indent_only/output.json index 80d51c4f1f2f..eeefefbd74da 100644 --- a/test/cmdlineTests/pretty_json_indent_only/output.json +++ b/test/cmdlineTests/pretty_json_indent_only/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/pretty_json_standard/output.json b/test/cmdlineTests/pretty_json_standard/output.json index 29185e758349..96281af4e0a9 100644 --- a/test/cmdlineTests/pretty_json_standard/output.json +++ b/test/cmdlineTests/pretty_json_standard/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/pretty_json_standard_indent/output.json b/test/cmdlineTests/pretty_json_standard_indent/output.json index 80d51c4f1f2f..eeefefbd74da 100644 --- a/test/cmdlineTests/pretty_json_standard_indent/output.json +++ b/test/cmdlineTests/pretty_json_standard_indent/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/require_overload/err b/test/cmdlineTests/require_overload/err index 4c33672d4a27..184c8c22bdd0 100644 --- a/test/cmdlineTests/require_overload/err +++ b/test/cmdlineTests/require_overload/err @@ -5,3 +5,4 @@ Error: No matching declaration found after argument-dependent lookup. | ^^^^^^^ Note: Candidate: function require(bool) Note: Candidate: function require(bool, string memory) +Note: Candidate: function require(bool, error) diff --git a/test/cmdlineTests/require_with_error_ir/args b/test/cmdlineTests/require_with_error_ir/args new file mode 100644 index 000000000000..be08aefb416b --- /dev/null +++ b/test/cmdlineTests/require_with_error_ir/args @@ -0,0 +1 @@ +--ir --debug-info none diff --git a/test/cmdlineTests/require_with_error_ir/input.sol b/test/cmdlineTests/require_with_error_ir/input.sol new file mode 100644 index 000000000000..eb0787fcc16d --- /dev/null +++ b/test/cmdlineTests/require_with_error_ir/input.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; + +error CustomError(uint256, string); + +contract C { + function f(bool condition) external pure { + require(condition, CustomError(1, "two")); + } + + function g(bool condition) external pure { + require(condition, CustomError(2, "three")); + } +} diff --git a/test/cmdlineTests/require_with_error_ir/output b/test/cmdlineTests/require_with_error_ir/output new file mode 100644 index 000000000000..09515f3cd82e --- /dev/null +++ b/test/cmdlineTests/require_with_error_ir/output @@ -0,0 +1,271 @@ +IR: + +/// @use-src 0:"require_with_error_ir/input.sol" +object "C_36" { + code { + + mstore(64, memoryguard(128)) + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + + constructor_C_36() + + let _1 := allocate_unbounded() + codecopy(_1, dataoffset("C_36_deployed"), datasize("C_36_deployed")) + + return(_1, datasize("C_36_deployed")) + + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + + function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { + revert(0, 0) + } + + function constructor_C_36() { + + } + + } + /// @use-src 0:"require_with_error_ir/input.sol" + object "C_36_deployed" { + code { + + mstore(64, memoryguard(128)) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x98c3a6c1 + { + // f(bool) + + external_fun_f_21() + } + + case 0xd48092f7 + { + // g(bool) + + external_fun_g_35() + } + + default {} + } + + revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() + + function shift_right_224_unsigned(value) -> newValue { + newValue := + + shr(224, value) + + } + + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + + function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { + revert(0, 0) + } + + function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { + revert(0, 0) + } + + function revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db() { + revert(0, 0) + } + + function cleanup_t_bool(value) -> cleaned { + cleaned := iszero(iszero(value)) + } + + function validator_revert_t_bool(value) { + if iszero(eq(value, cleanup_t_bool(value))) { revert(0, 0) } + } + + function abi_decode_t_bool(offset, end) -> value { + value := calldataload(offset) + validator_revert_t_bool(value) + } + + function abi_decode_tuple_t_bool(headStart, dataEnd) -> value0 { + if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } + + { + + let offset := 0 + + value0 := abi_decode_t_bool(add(headStart, offset), dataEnd) + } + + } + + function abi_encode_tuple__to__fromStack(headStart ) -> tail { + tail := add(headStart, 0) + + } + + function external_fun_f_21() { + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + let param_0 := abi_decode_tuple_t_bool(4, calldatasize()) + fun_f_21(param_0) + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple__to__fromStack(memPos ) + return(memPos, sub(memEnd, memPos)) + + } + + function external_fun_g_35() { + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + let param_0 := abi_decode_tuple_t_bool(4, calldatasize()) + fun_g_35(param_0) + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple__to__fromStack(memPos ) + return(memPos, sub(memEnd, memPos)) + + } + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function cleanup_t_rational_1_by_1(value) -> cleaned { + cleaned := value + } + + function cleanup_t_uint256(value) -> cleaned { + cleaned := value + } + + function identity(value) -> ret { + ret := value + } + + function convert_t_rational_1_by_1_to_t_uint256(value) -> converted { + converted := cleanup_t_uint256(identity(cleanup_t_rational_1_by_1(value))) + } + + function abi_encode_t_rational_1_by_1_to_t_uint256_fromStack(value, pos) { + mstore(pos, convert_t_rational_1_by_1_to_t_uint256(value)) + } + + function array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length) -> updated_pos { + mstore(pos, length) + updated_pos := add(pos, 0x20) + } + + function store_literal_in_memory_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720(memPtr) { + + mstore(add(memPtr, 0), "two") + + } + + function abi_encode_t_stringliteral_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720_to_t_string_memory_ptr_fromStack(pos) -> end { + pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, 3) + store_literal_in_memory_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720(pos) + end := add(pos, 32) + } + + function abi_encode_tuple_t_rational_1_by_1_t_stringliteral_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720__to_t_uint256_t_string_memory_ptr__fromStack(headStart , value0) -> tail { + tail := add(headStart, 64) + + abi_encode_t_rational_1_by_1_to_t_uint256_fromStack(value0, add(headStart, 0)) + + mstore(add(headStart, 32), sub(tail, headStart)) + tail := abi_encode_t_stringliteral_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720_to_t_string_memory_ptr_fromStack( tail) + + } + + function require_helper_t_error_7_CustomError_t_rational_1_by_1_t_stringliteral_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720(condition , expr_15) { + if iszero(condition) + { + + let memPtr := allocate_unbounded() + + mstore(memPtr, 0x97ea5a2f00000000000000000000000000000000000000000000000000000000) + let end := abi_encode_tuple_t_rational_1_by_1_t_stringliteral_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720__to_t_uint256_t_string_memory_ptr__fromStack(add(memPtr, 4) , expr_15) + revert(memPtr, sub(end, memPtr)) + } + } + + function fun_f_21(var_condition_9) { + + let _1 := var_condition_9 + let expr_13 := _1 + + let expr_15 := 0x01 + + require_helper_t_error_7_CustomError_t_rational_1_by_1_t_stringliteral_332c39dcd398ea34a48b871898d589f55fc4c7bce00562fb670c972e7e1b0720(expr_13, expr_15) + + } + + function cleanup_t_rational_2_by_1(value) -> cleaned { + cleaned := value + } + + function convert_t_rational_2_by_1_to_t_uint256(value) -> converted { + converted := cleanup_t_uint256(identity(cleanup_t_rational_2_by_1(value))) + } + + function abi_encode_t_rational_2_by_1_to_t_uint256_fromStack(value, pos) { + mstore(pos, convert_t_rational_2_by_1_to_t_uint256(value)) + } + + function store_literal_in_memory_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5(memPtr) { + + mstore(add(memPtr, 0), "three") + + } + + function abi_encode_t_stringliteral_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5_to_t_string_memory_ptr_fromStack(pos) -> end { + pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, 5) + store_literal_in_memory_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5(pos) + end := add(pos, 32) + } + + function abi_encode_tuple_t_rational_2_by_1_t_stringliteral_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5__to_t_uint256_t_string_memory_ptr__fromStack(headStart , value0) -> tail { + tail := add(headStart, 64) + + abi_encode_t_rational_2_by_1_to_t_uint256_fromStack(value0, add(headStart, 0)) + + mstore(add(headStart, 32), sub(tail, headStart)) + tail := abi_encode_t_stringliteral_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5_to_t_string_memory_ptr_fromStack( tail) + + } + + function require_helper_t_error_7_CustomError_t_rational_2_by_1_t_stringliteral_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5(condition , expr_29) { + if iszero(condition) + { + + let memPtr := allocate_unbounded() + + mstore(memPtr, 0x97ea5a2f00000000000000000000000000000000000000000000000000000000) + let end := abi_encode_tuple_t_rational_2_by_1_t_stringliteral_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5__to_t_uint256_t_string_memory_ptr__fromStack(add(memPtr, 4) , expr_29) + revert(memPtr, sub(end, memPtr)) + } + } + + function fun_g_35(var_condition_23) { + + let _2 := var_condition_23 + let expr_27 := _2 + + let expr_29 := 0x02 + + require_helper_t_error_7_CustomError_t_rational_2_by_1_t_stringliteral_89027a4db8d1d3a0787296eb1553fba0dc506f981f9697f1a66994c458d392b5(expr_27, expr_29) + + } + + } + + data ".metadata" hex"" + } + +} diff --git a/test/cmdlineTests/require_with_string_ir/args b/test/cmdlineTests/require_with_string_ir/args new file mode 100644 index 000000000000..be08aefb416b --- /dev/null +++ b/test/cmdlineTests/require_with_string_ir/args @@ -0,0 +1 @@ +--ir --debug-info none diff --git a/test/cmdlineTests/require_with_string_ir/input.sol b/test/cmdlineTests/require_with_string_ir/input.sol new file mode 100644 index 000000000000..c47045171405 --- /dev/null +++ b/test/cmdlineTests/require_with_string_ir/input.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; + +contract C { + function f(bool condition) external pure { + string memory message = "Condition must be satisfied"; + require(condition, message); + } + + function g(bool condition) external pure { + require(condition, "Condition must be satisfied"); + } +} diff --git a/test/cmdlineTests/require_with_string_ir/output b/test/cmdlineTests/require_with_string_ir/output new file mode 100644 index 000000000000..3a19db372796 --- /dev/null +++ b/test/cmdlineTests/require_with_string_ir/output @@ -0,0 +1,294 @@ +IR: + +/// @use-src 0:"require_with_string_ir/input.sol" +object "C_28" { + code { + + mstore(64, memoryguard(128)) + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + + constructor_C_28() + + let _1 := allocate_unbounded() + codecopy(_1, dataoffset("C_28_deployed"), datasize("C_28_deployed")) + + return(_1, datasize("C_28_deployed")) + + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + + function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { + revert(0, 0) + } + + function constructor_C_28() { + + } + + } + /// @use-src 0:"require_with_string_ir/input.sol" + object "C_28_deployed" { + code { + + mstore(64, memoryguard(128)) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x98c3a6c1 + { + // f(bool) + + external_fun_f_16() + } + + case 0xd48092f7 + { + // g(bool) + + external_fun_g_27() + } + + default {} + } + + revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() + + function shift_right_224_unsigned(value) -> newValue { + newValue := + + shr(224, value) + + } + + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + + function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { + revert(0, 0) + } + + function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { + revert(0, 0) + } + + function revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db() { + revert(0, 0) + } + + function cleanup_t_bool(value) -> cleaned { + cleaned := iszero(iszero(value)) + } + + function validator_revert_t_bool(value) { + if iszero(eq(value, cleanup_t_bool(value))) { revert(0, 0) } + } + + function abi_decode_t_bool(offset, end) -> value { + value := calldataload(offset) + validator_revert_t_bool(value) + } + + function abi_decode_tuple_t_bool(headStart, dataEnd) -> value0 { + if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } + + { + + let offset := 0 + + value0 := abi_decode_t_bool(add(headStart, offset), dataEnd) + } + + } + + function abi_encode_tuple__to__fromStack(headStart ) -> tail { + tail := add(headStart, 0) + + } + + function external_fun_f_16() { + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + let param_0 := abi_decode_tuple_t_bool(4, calldatasize()) + fun_f_16(param_0) + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple__to__fromStack(memPos ) + return(memPos, sub(memEnd, memPos)) + + } + + function external_fun_g_27() { + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + let param_0 := abi_decode_tuple_t_bool(4, calldatasize()) + fun_g_27(param_0) + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple__to__fromStack(memPos ) + return(memPos, sub(memEnd, memPos)) + + } + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function round_up_to_mul_of_32(value) -> result { + result := and(add(value, 31), not(31)) + } + + function panic_error_0x41() { + mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) + mstore(4, 0x41) + revert(0, 0x24) + } + + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function array_allocation_size_t_string_memory_ptr(length) -> size { + // Make sure we can allocate memory without overflow + if gt(length, 0xffffffffffffffff) { panic_error_0x41() } + + size := round_up_to_mul_of_32(length) + + // add length slot + size := add(size, 0x20) + + } + + function allocate_memory_array_t_string_memory_ptr(length) -> memPtr { + let allocSize := array_allocation_size_t_string_memory_ptr(length) + memPtr := allocate_memory(allocSize) + + mstore(memPtr, length) + + } + + function store_literal_in_memory_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46(memPtr) { + + mstore(add(memPtr, 0), "Condition must be satisfied") + + } + + function copy_literal_to_memory_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46() -> memPtr { + memPtr := allocate_memory_array_t_string_memory_ptr(27) + store_literal_in_memory_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46(add(memPtr, 32)) + } + + function convert_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46_to_t_string_memory_ptr() -> converted { + converted := copy_literal_to_memory_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46() + } + + function array_length_t_string_memory_ptr(value) -> length { + + length := mload(value) + + } + + function array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length) -> updated_pos { + mstore(pos, length) + updated_pos := add(pos, 0x20) + } + + function copy_memory_to_memory_with_cleanup(src, dst, length) { + + mcopy(dst, src, length) + mstore(add(dst, length), 0) + + } + + function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end { + let length := array_length_t_string_memory_ptr(value) + pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length) + copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length) + end := add(pos, round_up_to_mul_of_32(length)) + } + + function abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack(headStart , value0) -> tail { + tail := add(headStart, 32) + + mstore(add(headStart, 0), sub(tail, headStart)) + tail := abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value0, tail) + + } + + function require_helper_t_string_memory_ptr(condition , expr_12_mpos) { + if iszero(condition) + { + + let memPtr := allocate_unbounded() + + mstore(memPtr, 0x08c379a000000000000000000000000000000000000000000000000000000000) + let end := abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack(add(memPtr, 4) , expr_12_mpos) + revert(memPtr, sub(end, memPtr)) + } + } + + function fun_f_16(var_condition_3) { + + let var_message_7_mpos := convert_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46_to_t_string_memory_ptr() + + let _1 := var_condition_3 + let expr_11 := _1 + + let _2_mpos := var_message_7_mpos + let expr_12_mpos := _2_mpos + + require_helper_t_string_memory_ptr(expr_11, expr_12_mpos) + + } + + function abi_encode_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46_to_t_string_memory_ptr_fromStack(pos) -> end { + pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, 27) + store_literal_in_memory_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46(pos) + end := add(pos, 32) + } + + function abi_encode_tuple_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46__to_t_string_memory_ptr__fromStack(headStart ) -> tail { + tail := add(headStart, 32) + + mstore(add(headStart, 0), sub(tail, headStart)) + tail := abi_encode_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46_to_t_string_memory_ptr_fromStack( tail) + + } + + function require_helper_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46(condition ) { + if iszero(condition) + { + + let memPtr := allocate_unbounded() + + mstore(memPtr, 0x08c379a000000000000000000000000000000000000000000000000000000000) + let end := abi_encode_tuple_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46__to_t_string_memory_ptr__fromStack(add(memPtr, 4) ) + revert(memPtr, sub(end, memPtr)) + } + } + + function fun_g_27(var_condition_18) { + + let _3 := var_condition_18 + let expr_22 := _3 + + require_helper_t_stringliteral_b25d43cff48de8365ad132c5f45b74f4593f9e69e5b749d86685f77282c88e46(expr_22) + + } + + } + + data ".metadata" hex"" + } + +} diff --git a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/input.json b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/input.json index c1a7209b3e3e..6ff7662901e4 100644 --- a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/input.json +++ b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/input.json @@ -4,11 +4,11 @@ { "C": { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" }, "D": { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n" + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n" } }, "settings": diff --git a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json index 143ad92c304a..4ef3c6df1873 100644 --- a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json @@ -1,13 +1,9 @@ { - "contracts": - { - "C": - { - "C": - { - "evm": - { - "assembly": " /* \"C\":79:428 contract C... */ + "contracts": { + "C": { + "C": { + "evm": { + "assembly": " /* \"C\":79:503 contract C... */ 0xa0 jumpi(tag_5, callvalue) 0x1f @@ -49,10 +45,10 @@ tag_5 jumpi mload - /* \"C\":147:149 42 */ + /* \"C\":153:155 42 */ mstore(0x80, 0x2a) 0x00 - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ sstore mload(0x40) dataSize(sub_0) @@ -61,9 +57,9 @@ dataOffset(sub_0) dup3 codecopy - /* \"C\":147:149 42 */ + /* \"C\":153:155 42 */ 0x80 - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ mload dup2 assignImmutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") @@ -79,26 +75,19 @@ tag_3: stop sub_0: assembly { - /* \"C\":79:428 contract C... */ - 0x80 - 0x40 - swap1 - dup1 - dup3 - mstore + /* \"C\":79:503 contract C... */ + mstore(0x40, 0x80) jumpi(tag_2, iszero(lt(calldatasize, 0x04))) 0x00 dup1 revert tag_2: shr(0xe0, calldataload(0x00)) - swap1 - dup2 + dup1 0x26121ff0 eq tag_4 jumpi - pop dup1 0x793816ec eq @@ -126,136 +115,129 @@ sub_0: assembly { dup2 swap1 sstore - dup2 - mload + mload(0x40) shl(0xe4, 0x026121ff) - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ dup2 mstore - /* \"C\":79:428 contract C... */ - swap2 + /* \"C\":79:503 contract C... */ swap1 - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ 0x20 - /* \"C\":79:428 contract C... */ - dup4 + /* \"C\":79:503 contract C... */ + dup3 0x04 dup2 - /* \"C\":403:407 this */ + /* \"C\":475:479 this */ address - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ gas staticcall - swap3 - dup4 + swap2 + dup3 iszero tag_16 jumpi - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x00 - /* \"C\":403:411 this.f() */ - swap4 + /* \"C\":475:483 this.f() */ + swap3 tag_18 jumpi - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ tag_19: - /* \"C\":392:411 stateVar + this.f() */ - pop - tag_20 - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ 0x20 - /* \"C\":392:411 stateVar + this.f() */ - swap4 - /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":464:494 stateVar + this.f() + immutVar */ + tag_20 + /* \"C\":464:483 stateVar + this.f() */ tag_21 - /* \"C\":392:411 stateVar + this.f() */ - swap3 + dup6 + dup6 tag_1 jump\t// in - tag_20: - /* \"C\":414:422 immutVar */ + tag_21: + /* \"C\":486:494 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":464:494 stateVar + this.f() + immutVar */ swap1 tag_1 jump\t// in - tag_21: - /* \"C\":79:428 contract C... */ - swap1 - mload + tag_20: + /* \"C\":79:503 contract C... */ + mload(0x40) swap1 dup2 mstore return - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ tag_18: - swap3 + swap2 pop 0x20 jumpi(tag_22, gt(0x20, returndatasize)) tag_23: - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x1f dup2 add not(0x1f) and - dup5 + dup4 add 0xffffffffffffffff dup2 gt - dup6 + dup5 dup3 lt or tag_24 jumpi - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ 0x20 - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ swap2 - dup6 + dup5 swap2 - dup6 + 0x40 mstore - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ dup2 add - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ sub slt tag_26 jumpi - swap2 + swap1 mload - swap2 - /* \"C\":392:411 stateVar + this.f() */ - tag_20 - /* \"C\":403:411 this.f() */ + swap1 + /* \"C\":464:483 stateVar + this.f() */ + tag_21 + /* \"C\":475:483 this.f() */ jump(tag_19) - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ tag_26: 0x00 dup1 revert tag_24: - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ shl(0xe0, 0x4e487b71) - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x00 mstore mstore(0x04, 0x41) revert(0x00, 0x24) - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ tag_22: pop returndatasize jump(tag_23) tag_16: - /* \"C\":79:428 contract C... */ - dup3 - mload + /* \"C\":79:503 contract C... */ + mload(0x40) returndatasize 0x00 dup3 @@ -264,32 +246,29 @@ sub_0: assembly { swap1 revert tag_14: - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ shl(0xe0, 0x4e487b71) - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x00 - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ mstore 0x11 - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x04 - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ mstore 0x24 - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x00 - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ revert - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ tag_6: - pop jumpi(tag_26, callvalue) jumpi(tag_26, slt(add(not(0x03), calldatasize), 0x00)) 0x20 - swap1 sload(0x00) - swap1 - mload + mload(0x40) swap1 dup2 mstore @@ -297,27 +276,28 @@ sub_0: assembly { tag_4: jumpi(tag_26, callvalue) jumpi(tag_26, slt(add(not(0x03), calldatasize), 0x00)) - /* \"C\":290:298 immutVar */ + /* \"C\":326:334 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":117:119 41 */ - swap1 - dup2 + /* \"C\":120:122 41 */ + dup1 0x29 add - swap2 - dup3 + swap1 + dup2 slt 0x01 and tag_14 jumpi - /* \"C\":79:428 contract C... */ + /* \"C\":79:503 contract C... */ 0x20 - swap2 + swap1 + mload(0x40) + swap1 dup2 mstore return - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ tag_1: swap2 swap1 @@ -350,13 +330,10 @@ sub_0: assembly { } } }, - "D": - { - "D": - { - "evm": - { - "assembly": " /* \"D\":91:166 contract D is C(3)... */ + "D": { + "D": { + "evm": { + "assembly": " /* \"D\":91:181 contract D is C(3)... */ 0xa0 jumpi(tag_5, callvalue) 0x1f @@ -398,13 +375,13 @@ sub_0: assembly { tag_5 jumpi mload - /* \"C\":147:149 42 */ + /* \"C\":153:155 42 */ mstore(0x80, 0x2a) - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ dup1 /* \"D\":107:108 3 */ 0x03 - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ add swap1 dup2 @@ -422,9 +399,9 @@ sub_0: assembly { dataOffset(sub_0) dup3 codecopy - /* \"C\":147:149 42 */ + /* \"C\":153:155 42 */ 0x80 - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ mload dup2 assignImmutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") @@ -444,26 +421,19 @@ tag_3: stop sub_0: assembly { - /* \"D\":91:166 contract D is C(3)... */ - 0x80 - 0x40 - swap1 - dup1 - dup3 - mstore + /* \"D\":91:181 contract D is C(3)... */ + mstore(0x40, 0x80) jumpi(tag_2, iszero(lt(calldatasize, 0x04))) 0x00 dup1 revert tag_2: shr(0xe0, calldataload(0x00)) - swap1 - dup2 + dup1 0x26121ff0 eq tag_4 jumpi - pop dup1 0x793816ec eq @@ -491,136 +461,129 @@ sub_0: assembly { dup2 swap1 sstore - dup2 - mload + mload(0x40) shl(0xe4, 0x026121ff) - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ dup2 mstore - /* \"D\":91:166 contract D is C(3)... */ - swap2 + /* \"D\":91:181 contract D is C(3)... */ swap1 - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ 0x20 - /* \"D\":91:166 contract D is C(3)... */ - dup4 + /* \"D\":91:181 contract D is C(3)... */ + dup3 0x04 dup2 - /* \"C\":403:407 this */ + /* \"C\":475:479 this */ address - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ gas staticcall - swap3 - dup4 + swap2 + dup3 iszero tag_16 jumpi - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x00 - /* \"C\":403:411 this.f() */ - swap4 + /* \"C\":475:483 this.f() */ + swap3 tag_18 jumpi - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ tag_19: - /* \"C\":392:411 stateVar + this.f() */ - pop - tag_20 - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ 0x20 - /* \"C\":392:411 stateVar + this.f() */ - swap4 - /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":464:494 stateVar + this.f() + immutVar */ + tag_20 + /* \"C\":464:483 stateVar + this.f() */ tag_21 - /* \"C\":392:411 stateVar + this.f() */ - swap3 + dup6 + dup6 tag_1 jump\t// in - tag_20: - /* \"C\":414:422 immutVar */ + tag_21: + /* \"C\":486:494 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":464:494 stateVar + this.f() + immutVar */ swap1 tag_1 jump\t// in - tag_21: - /* \"D\":91:166 contract D is C(3)... */ - swap1 - mload + tag_20: + /* \"D\":91:181 contract D is C(3)... */ + mload(0x40) swap1 dup2 mstore return - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ tag_18: - swap3 + swap2 pop 0x20 jumpi(tag_22, gt(0x20, returndatasize)) tag_23: - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x1f dup2 add not(0x1f) and - dup5 + dup4 add 0xffffffffffffffff dup2 gt - dup6 + dup5 dup3 lt or tag_24 jumpi - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ 0x20 - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ swap2 - dup6 + dup5 swap2 - dup6 + 0x40 mstore - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ dup2 add - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ sub slt tag_26 jumpi - swap2 + swap1 mload - swap2 - /* \"C\":392:411 stateVar + this.f() */ - tag_20 - /* \"C\":403:411 this.f() */ + swap1 + /* \"C\":464:483 stateVar + this.f() */ + tag_21 + /* \"C\":475:483 this.f() */ jump(tag_19) - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ tag_26: 0x00 dup1 revert tag_24: - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ shl(0xe0, 0x4e487b71) - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x00 mstore mstore(0x04, 0x41) revert(0x00, 0x24) - /* \"C\":403:411 this.f() */ + /* \"C\":475:483 this.f() */ tag_22: pop returndatasize jump(tag_23) tag_16: - /* \"D\":91:166 contract D is C(3)... */ - dup3 - mload + /* \"D\":91:181 contract D is C(3)... */ + mload(0x40) returndatasize 0x00 dup3 @@ -629,32 +592,29 @@ sub_0: assembly { swap1 revert tag_14: - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ shl(0xe0, 0x4e487b71) - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x00 - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ mstore 0x11 - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x04 - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ mstore 0x24 - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x00 - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ revert - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ tag_6: - pop jumpi(tag_26, callvalue) jumpi(tag_26, slt(add(not(0x03), calldatasize), 0x00)) 0x20 - swap1 sload(0x00) - swap1 - mload + mload(0x40) swap1 dup2 mstore @@ -662,27 +622,28 @@ sub_0: assembly { tag_4: jumpi(tag_26, callvalue) jumpi(tag_26, slt(add(not(0x03), calldatasize), 0x00)) - /* \"C\":290:298 immutVar */ + /* \"C\":326:334 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - /* \"C\":117:119 41 */ - swap1 - dup2 + /* \"C\":120:122 41 */ + dup1 0x29 add - swap2 - dup3 + swap1 + dup2 slt 0x01 and tag_14 jumpi - /* \"D\":91:166 contract D is C(3)... */ + /* \"D\":91:181 contract D is C(3)... */ 0x20 - swap2 + swap1 + mload(0x40) + swap1 dup2 mstore return - /* \"C\":117:119 41 */ + /* \"C\":120:122 41 */ tag_1: swap2 swap1 @@ -716,14 +677,11 @@ sub_0: assembly { } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 }, - "D": - { + "D": { "id": 1 } } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json index ee958b55b029..9489a75bf3df 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C": - { - "evm": - { + "contracts": { + "C": { + "C": { + "evm": { "assembly": " /* \"C\":60:101 contract C {... */ mstore(0x40, 0x80) callvalue @@ -211,10 +207,8 @@ object \"C_6\" { } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json index 007b7fc62bad..f8f2958b0384 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C": - { - "evm": - { + "contracts": { + "C": { + "C": { + "evm": { "assembly": " /* \"C\":60:101 */ mstore(0x40, 0x80) callvalue @@ -210,10 +206,8 @@ object \"C_6\" { } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json index 884da9eb9715..2a5a2bc2ae15 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C": - { - "evm": - { + "contracts": { + "C": { + "C": { + "evm": { "assembly": " mstore(0x40, 0x80) callvalue dup1 @@ -199,10 +195,8 @@ object \"C_6\" { } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json index fb7f199a75cf..7f48fd4e93bc 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "To use 'snippet' with settings.debug.debugInfo you must select also 'location'.", diff --git a/test/cmdlineTests/standard_debug_info_in_yul_location/input.json b/test/cmdlineTests/standard_debug_info_in_yul_location/input.json index 8ba84239afd9..47dd4d234ccc 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_location/input.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_location/input.json @@ -4,11 +4,11 @@ { "C": { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int public constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int public constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" }, "D": { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n" + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n" } }, "settings": diff --git a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json index 2671162722e0..8f0d5b5b5d6d 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json @@ -1,15 +1,12 @@ { - "contracts": - { - "C": - { - "C": - { + "contracts": { + "C": { + "C": { "ir": " /// @use-src 0:\"C\" object \"C_54\" { code { - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" mstore(64, memoryguard(160)) if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } @@ -136,31 +133,31 @@ object \"C_54\" { } /// @ast-id 20 - /// @src 0:182:230 \"constructor(int _init)...\" + /// @src 0:194:254 \"constructor(int _init)...\" function constructor_C_54(var__init_12) { - /// @src 0:182:230 \"constructor(int _init)...\" + /// @src 0:194:254 \"constructor(int _init)...\" - /// @src 0:154:156 \"42\" + /// @src 0:160:162 \"42\" let expr_7 := 0x2a let _3 := convert_t_rational_42_by_1_to_t_int256(expr_7) mstore(128, _3) - /// @src 0:221:226 \"_init\" + /// @src 0:242:247 \"_init\" let _4 := var__init_12 let expr_16 := _4 - /// @src 0:210:226 \"stateVar = _init\" + /// @src 0:231:247 \"stateVar = _init\" update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_16) let expr_17 := expr_16 } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" } /// @use-src 0:\"C\" object \"C_54_deployed\" { code { - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" mstore(64, memoryguard(128)) if iszero(lt(calldatasize(), 4)) @@ -272,7 +269,7 @@ object \"C_54\" { } /// @ast-id 10 - /// @src 0:159:178 \"int public stateVar\" + /// @src 0:168:187 \"int public stateVar\" function getter_fun_stateVar_10() -> ret { let slot := 0 @@ -281,7 +278,7 @@ object \"C_54\" { ret := read_from_storage_split_dynamic_t_int256(slot, offset) } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" function external_fun_stateVar_10() { @@ -317,9 +314,9 @@ object \"C_54\" { converted := cleanup_t_int256(identity(cleanup_t_rational_41_by_1(value))) } - /// @src 0:93:126 \"int public constant constVar = 41\" + /// @src 0:96:129 \"int public constant constVar = 41\" function constant_constVar_5() -> ret { - /// @src 0:124:126 \"41\" + /// @src 0:127:129 \"41\" let expr_4 := 0x29 let _1 := convert_t_rational_41_by_1_to_t_int256(expr_4) @@ -327,11 +324,11 @@ object \"C_54\" { } /// @ast-id 5 - /// @src 0:93:126 \"int public constant constVar = 41\" + /// @src 0:96:129 \"int public constant constVar = 41\" function getter_fun_constVar_5() -> ret_0 { ret_0 := constant_constVar_5() } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" function external_fun_constVar_5() { @@ -373,26 +370,26 @@ object \"C_54\" { } /// @ast-id 30 - /// @src 0:233:309 \"function f() external pure returns (int)...\" + /// @src 0:260:348 \"function f() external pure returns (int)...\" function fun_f_30() -> var__23 { - /// @src 0:269:272 \"int\" + /// @src 0:296:299 \"int\" let zero_t_int256_2 := zero_value_for_split_t_int256() var__23 := zero_t_int256_2 - /// @src 0:286:294 \"constVar\" + /// @src 0:322:330 \"constVar\" let expr_25 := constant_constVar_5() - /// @src 0:297:305 \"immutVar\" + /// @src 0:333:341 \"immutVar\" let _3 := loadimmutable(\"8\") let expr_26 := _3 - /// @src 0:286:305 \"constVar + immutVar\" + /// @src 0:322:341 \"constVar + immutVar\" let expr_27 := checked_add_t_int256(expr_25, expr_26) - /// @src 0:279:305 \"return constVar + immutVar\" + /// @src 0:315:341 \"return constVar + immutVar\" var__23 := expr_27 leave } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" function shift_right_0_unsigned(value) -> newValue { newValue := @@ -444,20 +441,20 @@ object \"C_54\" { } /// @ast-id 37 - /// @src 0:311:348 \"modifier m()...\" + /// @src 0:353:408 \"modifier m()...\" function modifier_m_40(var__42) -> _5 { _5 := var__42 - /// @src 0:329:339 \"stateVar++\" + /// @src 0:380:390 \"stateVar++\" let _7 := read_from_storage_split_offset_0_t_int256(0x00) let _6 := increment_t_int256(_7) update_storage_value_offset_0t_int256_to_t_int256(0x00, _6) let expr_33 := _7 - /// @src 0:343:344 \"_\" + /// @src 0:400:401 \"_\" _5 := fun_f2_53_inner(var__42) } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" function cleanup_t_uint160(value) -> cleaned { cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffff) @@ -539,19 +536,19 @@ object \"C_54\" { revert(pos, returndatasize()) } - /// @src 0:350:433 \"function f2() m public returns (int)...\" + /// @src 0:413:508 \"function f2() m public returns (int)...\" function fun_f2_53_inner(_8) -> var__42 { var__42 := _8 - /// @src 0:399:407 \"stateVar\" + /// @src 0:471:479 \"stateVar\" let _9 := read_from_storage_split_offset_0_t_int256(0x00) let expr_44 := _9 - /// @src 0:410:414 \"this\" + /// @src 0:482:486 \"this\" let expr_45_address := address() - /// @src 0:410:416 \"this.f\" + /// @src 0:482:488 \"this.f\" let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 - /// @src 0:410:418 \"this.f()\" + /// @src 0:482:490 \"this.f()\" // storage for arguments and returned data let _10 := allocate_unbounded() @@ -577,32 +574,32 @@ object \"C_54\" { // decode return parameters from external try-call into retVars expr_47 := abi_decode_tuple_t_int256_fromMemory(_10, add(_10, _13)) } - /// @src 0:399:418 \"stateVar + this.f()\" + /// @src 0:471:490 \"stateVar + this.f()\" let expr_48 := checked_add_t_int256(expr_44, expr_47) - /// @src 0:421:429 \"immutVar\" + /// @src 0:493:501 \"immutVar\" let _14 := loadimmutable(\"8\") let expr_49 := _14 - /// @src 0:399:429 \"stateVar + this.f() + immutVar\" + /// @src 0:471:501 \"stateVar + this.f() + immutVar\" let expr_50 := checked_add_t_int256(expr_48, expr_49) - /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" + /// @src 0:464:501 \"return stateVar + this.f() + immutVar\" var__42 := expr_50 leave } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" /// @ast-id 53 - /// @src 0:350:433 \"function f2() m public returns (int)...\" + /// @src 0:413:508 \"function f2() m public returns (int)...\" function fun_f2_53() -> var__42 { - /// @src 0:382:385 \"int\" + /// @src 0:445:448 \"int\" let zero_t_int256_4 := zero_value_for_split_t_int256() var__42 := zero_t_int256_4 var__42 := modifier_m_40(var__42) } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" } @@ -616,7 +613,7 @@ object \"C_54\" { object \"C_54\" { code { { - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" let _1 := memoryguard(0xa0) if callvalue() { revert(0, 0) } let programSize := datasize(\"C_54\") @@ -624,9 +621,9 @@ object \"C_54\" { let newFreePtr := add(_1, and(add(argSize, 31), not(31))) if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, _1)) { - mstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ shl(224, 0x4e487b71)) + mstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:510 \"contract C...\" */ shl(224, 0x4e487b71)) mstore(4, 0x41) - revert(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ 0x24) + revert(/** @src -1:-1:-1 */ 0, /** @src 0:79:510 \"contract C...\" */ 0x24) } mstore(64, newFreePtr) codecopy(_1, programSize, argSize) @@ -634,17 +631,17 @@ object \"C_54\" { { revert(/** @src -1:-1:-1 */ 0, 0) } - /// @src 0:79:435 \"contract C...\" + /// @src 0:79:510 \"contract C...\" let value := mload(_1) - /// @src 0:154:156 \"42\" + /// @src 0:160:162 \"42\" mstore(128, 0x2a) - /// @src 0:79:435 \"contract C...\" - sstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ value) + /// @src 0:79:510 \"contract C...\" + sstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:510 \"contract C...\" */ value) let _2 := mload(64) let _3 := datasize(\"C_54_deployed\") codecopy(_2, dataoffset(\"C_54_deployed\"), _3) - setimmutable(_2, \"8\", mload(/** @src 0:154:156 \"42\" */ 128)) - /// @src 0:79:435 \"contract C...\" + setimmutable(_2, \"8\", mload(/** @src 0:160:162 \"42\" */ 128)) + /// @src 0:79:510 \"contract C...\" return(_2, _3) } } @@ -652,100 +649,100 @@ object \"C_54\" { object \"C_54_deployed\" { code { { - /// @src 0:79:435 \"contract C...\" - let _1 := memoryguard(0x80) - let _2 := 64 - mstore(_2, _1) + /// @src 0:79:510 \"contract C...\" + mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { switch shr(224, calldataload(0)) case 0x26121ff0 { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - /// @src 0:297:305 \"immutVar\" - let _3 := loadimmutable(\"8\") - /// @src 0:79:435 \"contract C...\" - let sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ _3) - if and(1, slt(sum, _3)) + /// @src 0:333:341 \"immutVar\" + let _1 := loadimmutable(\"8\") + /// @src 0:322:341 \"constVar + immutVar\" + let sum := /** @src 0:79:510 \"contract C...\" */ 0 + sum := add(/** @src 0:127:129 \"41\" */ 0x29, /** @src 0:79:510 \"contract C...\" */ _1) + if and(1, slt(sum, _1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } - mstore(_1, sum) - return(_1, 32) + let memPos := mload(64) + mstore(memPos, sum) + return(memPos, 32) } case 0x793816ec { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _4 := sload(0) - let memPos := mload(_2) - mstore(memPos, _4) - return(memPos, 32) + let _2 := sload(0) + let memPos_1 := mload(64) + mstore(memPos_1, _2) + return(memPos_1, 32) } case 0x9942ec6f { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _5 := sload(0) - if eq(_5, sub(shl(255, 1), 1)) + let _3 := sload(0) + if eq(_3, sub(shl(255, 1), 1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } - let ret := add(_5, 1) + let ret := add(_3, 1) sstore(0, ret) - /// @src 0:410:418 \"this.f()\" - let _6 := /** @src 0:79:435 \"contract C...\" */ mload(_2) - /// @src 0:410:418 \"this.f()\" - mstore(_6, /** @src 0:79:435 \"contract C...\" */ shl(228, 0x026121ff)) - /// @src 0:410:418 \"this.f()\" - let _7 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _6, /** @src 0:79:435 \"contract C...\" */ 4, /** @src 0:410:418 \"this.f()\" */ _6, 32) - if iszero(_7) + /// @src 0:482:490 \"this.f()\" + let _4 := /** @src 0:79:510 \"contract C...\" */ mload(64) + /// @src 0:482:490 \"this.f()\" + mstore(_4, /** @src 0:79:510 \"contract C...\" */ shl(228, 0x026121ff)) + /// @src 0:482:490 \"this.f()\" + let _5 := staticcall(gas(), /** @src 0:482:486 \"this\" */ address(), /** @src 0:482:490 \"this.f()\" */ _4, /** @src 0:79:510 \"contract C...\" */ 4, /** @src 0:482:490 \"this.f()\" */ _4, 32) + if iszero(_5) { - /// @src 0:79:435 \"contract C...\" - let pos := mload(_2) + /// @src 0:79:510 \"contract C...\" + let pos := mload(64) returndatacopy(pos, 0, returndatasize()) revert(pos, returndatasize()) } - /// @src 0:410:418 \"this.f()\" - let expr := /** @src 0:79:435 \"contract C...\" */ 0 - /// @src 0:410:418 \"this.f()\" - if _7 + /// @src 0:482:490 \"this.f()\" + let expr := /** @src 0:79:510 \"contract C...\" */ 0 + /// @src 0:482:490 \"this.f()\" + if _5 { - let _8 := 32 - if gt(32, returndatasize()) { _8 := returndatasize() } - /// @src 0:79:435 \"contract C...\" - let newFreePtr := add(_6, and(add(_8, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _6)) + let _6 := 32 + if gt(32, returndatasize()) { _6 := returndatasize() } + /// @src 0:79:510 \"contract C...\" + let newFreePtr := add(_4, and(add(_6, 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - mstore(_2, newFreePtr) - if slt(sub(/** @src 0:410:418 \"this.f()\" */ add(_6, _8), /** @src 0:79:435 \"contract C...\" */ _6), /** @src 0:410:418 \"this.f()\" */ 32) - /// @src 0:79:435 \"contract C...\" + mstore(64, newFreePtr) + if slt(sub(/** @src 0:482:490 \"this.f()\" */ add(_4, _6), /** @src 0:79:510 \"contract C...\" */ _4), /** @src 0:482:490 \"this.f()\" */ 32) + /// @src 0:79:510 \"contract C...\" { revert(0, 0) } - /// @src 0:410:418 \"this.f()\" - expr := /** @src 0:79:435 \"contract C...\" */ mload(_6) + /// @src 0:482:490 \"this.f()\" + expr := /** @src 0:79:510 \"contract C...\" */ mload(_4) } - /// @src 0:399:418 \"stateVar + this.f()\" + /// @src 0:471:490 \"stateVar + this.f()\" let expr_1 := checked_add_int256(ret, expr) - /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" - let var := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) - /// @src 0:79:435 \"contract C...\" - let memPos_1 := mload(_2) - mstore(memPos_1, var) - return(memPos_1, /** @src 0:410:418 \"this.f()\" */ 32) + /// @src 0:464:501 \"return stateVar + this.f() + immutVar\" + let var := /** @src 0:471:501 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:493:501 \"immutVar\" */ loadimmutable(\"8\")) + /// @src 0:79:510 \"contract C...\" + let memPos_2 := mload(64) + mstore(memPos_2, var) + return(memPos_2, /** @src 0:482:490 \"this.f()\" */ 32) } - case /** @src 0:79:435 \"contract C...\" */ 0xa00b982b { + case /** @src 0:79:510 \"contract C...\" */ 0xa00b982b { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let memPos_2 := mload(_2) - mstore(memPos_2, /** @src 0:124:126 \"41\" */ 0x29) - /// @src 0:79:435 \"contract C...\" - return(memPos_2, 32) + let memPos_3 := mload(64) + mstore(memPos_3, /** @src 0:127:129 \"41\" */ 0x29) + /// @src 0:79:510 \"contract C...\" + return(memPos_3, 32) } } revert(0, 0) @@ -769,15 +766,13 @@ object \"C_54\" { " } }, - "D": - { - "D": - { + "D": { + "D": { "ir": " /// @use-src 0:\"C\", 1:\"D\" object \"D_72\" { code { - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" mstore(64, memoryguard(160)) if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } @@ -944,26 +939,26 @@ object \"D_72\" { } /// @ast-id 71 - /// @src 1:113:164 \"constructor(int _init2)...\" + /// @src 1:116:179 \"constructor(int _init2)...\" function constructor_D_72(var__init2_63) { /// @src 1:107:108 \"3\" let expr_60 := 0x03 let _3 := convert_t_rational_3_by_1_to_t_int256(expr_60) - /// @src 1:113:164 \"constructor(int _init2)...\" + /// @src 1:116:179 \"constructor(int _init2)...\" constructor_C_54(_3) - /// @src 1:154:160 \"_init2\" + /// @src 1:166:172 \"_init2\" let _4 := var__init2_63 let expr_67 := _4 - /// @src 1:142:160 \"stateVar += _init2\" + /// @src 1:154:172 \"stateVar += _init2\" let _5 := read_from_storage_split_offset_0_t_int256(0x00) let expr_68 := checked_add_t_int256(_5, expr_67) update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_68) } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" function cleanup_t_rational_42_by_1(value) -> cleaned { cleaned := value @@ -974,31 +969,31 @@ object \"D_72\" { } /// @ast-id 20 - /// @src 0:182:230 \"constructor(int _init)...\" + /// @src 0:194:254 \"constructor(int _init)...\" function constructor_C_54(var__init_12) { - /// @src 0:182:230 \"constructor(int _init)...\" + /// @src 0:194:254 \"constructor(int _init)...\" - /// @src 0:154:156 \"42\" + /// @src 0:160:162 \"42\" let expr_7 := 0x2a let _6 := convert_t_rational_42_by_1_to_t_int256(expr_7) mstore(128, _6) - /// @src 0:221:226 \"_init\" + /// @src 0:242:247 \"_init\" let _7 := var__init_12 let expr_16 := _7 - /// @src 0:210:226 \"stateVar = _init\" + /// @src 0:231:247 \"stateVar = _init\" update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_16) let expr_17 := expr_16 } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" } /// @use-src 0:\"C\", 1:\"D\" object \"D_72_deployed\" { code { - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" mstore(64, memoryguard(128)) if iszero(lt(calldatasize(), 4)) @@ -1110,7 +1105,7 @@ object \"D_72\" { } /// @ast-id 10 - /// @src 0:159:178 \"int public stateVar\" + /// @src 0:168:187 \"int public stateVar\" function getter_fun_stateVar_10() -> ret { let slot := 0 @@ -1119,7 +1114,7 @@ object \"D_72\" { ret := read_from_storage_split_dynamic_t_int256(slot, offset) } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" function external_fun_stateVar_10() { @@ -1155,9 +1150,9 @@ object \"D_72\" { converted := cleanup_t_int256(identity(cleanup_t_rational_41_by_1(value))) } - /// @src 0:93:126 \"int public constant constVar = 41\" + /// @src 0:96:129 \"int public constant constVar = 41\" function constant_constVar_5() -> ret { - /// @src 0:124:126 \"41\" + /// @src 0:127:129 \"41\" let expr_4 := 0x29 let _1 := convert_t_rational_41_by_1_to_t_int256(expr_4) @@ -1165,11 +1160,11 @@ object \"D_72\" { } /// @ast-id 5 - /// @src 0:93:126 \"int public constant constVar = 41\" + /// @src 0:96:129 \"int public constant constVar = 41\" function getter_fun_constVar_5() -> ret_0 { ret_0 := constant_constVar_5() } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" function external_fun_constVar_5() { @@ -1211,26 +1206,26 @@ object \"D_72\" { } /// @ast-id 30 - /// @src 0:233:309 \"function f() external pure returns (int)...\" + /// @src 0:260:348 \"function f() external pure returns (int)...\" function fun_f_30() -> var__23 { - /// @src 0:269:272 \"int\" + /// @src 0:296:299 \"int\" let zero_t_int256_2 := zero_value_for_split_t_int256() var__23 := zero_t_int256_2 - /// @src 0:286:294 \"constVar\" + /// @src 0:322:330 \"constVar\" let expr_25 := constant_constVar_5() - /// @src 0:297:305 \"immutVar\" + /// @src 0:333:341 \"immutVar\" let _3 := loadimmutable(\"8\") let expr_26 := _3 - /// @src 0:286:305 \"constVar + immutVar\" + /// @src 0:322:341 \"constVar + immutVar\" let expr_27 := checked_add_t_int256(expr_25, expr_26) - /// @src 0:279:305 \"return constVar + immutVar\" + /// @src 0:315:341 \"return constVar + immutVar\" var__23 := expr_27 leave } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" function shift_right_0_unsigned(value) -> newValue { newValue := @@ -1282,20 +1277,20 @@ object \"D_72\" { } /// @ast-id 37 - /// @src 0:311:348 \"modifier m()...\" + /// @src 0:353:408 \"modifier m()...\" function modifier_m_40(var__42) -> _5 { _5 := var__42 - /// @src 0:329:339 \"stateVar++\" + /// @src 0:380:390 \"stateVar++\" let _7 := read_from_storage_split_offset_0_t_int256(0x00) let _6 := increment_t_int256(_7) update_storage_value_offset_0t_int256_to_t_int256(0x00, _6) let expr_33 := _7 - /// @src 0:343:344 \"_\" + /// @src 0:400:401 \"_\" _5 := fun_f2_53_inner(var__42) } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" function cleanup_t_uint160(value) -> cleaned { cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffff) @@ -1377,19 +1372,19 @@ object \"D_72\" { revert(pos, returndatasize()) } - /// @src 0:350:433 \"function f2() m public returns (int)...\" + /// @src 0:413:508 \"function f2() m public returns (int)...\" function fun_f2_53_inner(_8) -> var__42 { var__42 := _8 - /// @src 0:399:407 \"stateVar\" + /// @src 0:471:479 \"stateVar\" let _9 := read_from_storage_split_offset_0_t_int256(0x00) let expr_44 := _9 - /// @src 0:410:414 \"this\" + /// @src 0:482:486 \"this\" let expr_45_address := address() - /// @src 0:410:416 \"this.f\" + /// @src 0:482:488 \"this.f\" let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 - /// @src 0:410:418 \"this.f()\" + /// @src 0:482:490 \"this.f()\" // storage for arguments and returned data let _10 := allocate_unbounded() @@ -1415,32 +1410,32 @@ object \"D_72\" { // decode return parameters from external try-call into retVars expr_47 := abi_decode_tuple_t_int256_fromMemory(_10, add(_10, _13)) } - /// @src 0:399:418 \"stateVar + this.f()\" + /// @src 0:471:490 \"stateVar + this.f()\" let expr_48 := checked_add_t_int256(expr_44, expr_47) - /// @src 0:421:429 \"immutVar\" + /// @src 0:493:501 \"immutVar\" let _14 := loadimmutable(\"8\") let expr_49 := _14 - /// @src 0:399:429 \"stateVar + this.f() + immutVar\" + /// @src 0:471:501 \"stateVar + this.f() + immutVar\" let expr_50 := checked_add_t_int256(expr_48, expr_49) - /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" + /// @src 0:464:501 \"return stateVar + this.f() + immutVar\" var__42 := expr_50 leave } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" /// @ast-id 53 - /// @src 0:350:433 \"function f2() m public returns (int)...\" + /// @src 0:413:508 \"function f2() m public returns (int)...\" function fun_f2_53() -> var__42 { - /// @src 0:382:385 \"int\" + /// @src 0:445:448 \"int\" let zero_t_int256_4 := zero_value_for_split_t_int256() var__42 := zero_t_int256_4 var__42 := modifier_m_40(var__42) } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" } @@ -1454,7 +1449,7 @@ object \"D_72\" { object \"D_72\" { code { { - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" let _1 := memoryguard(0xa0) if callvalue() { revert(0, 0) } let programSize := datasize(\"D_72\") @@ -1462,9 +1457,9 @@ object \"D_72\" { let newFreePtr := add(_1, and(add(argSize, 31), not(31))) if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, _1)) { - mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) + mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) mstore(4, 0x41) - revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) + revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ 0x24) } mstore(64, newFreePtr) codecopy(_1, programSize, argSize) @@ -1472,24 +1467,24 @@ object \"D_72\" { { revert(/** @src -1:-1:-1 */ 0, 0) } - /// @src 1:91:166 \"contract D is C(3)...\" + /// @src 1:91:181 \"contract D is C(3)...\" let value := mload(_1) - /// @src 0:154:156 \"42\" + /// @src 0:160:162 \"42\" mstore(128, 0x2a) - /// @src 1:91:166 \"contract D is C(3)...\" - let sum := add(/** @src 1:107:108 \"3\" */ 0x03, /** @src 1:91:166 \"contract D is C(3)...\" */ value) + /// @src 1:91:181 \"contract D is C(3)...\" + let sum := add(/** @src 1:107:108 \"3\" */ 0x03, /** @src 1:91:181 \"contract D is C(3)...\" */ value) if and(1, slt(sum, value)) { - mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) + mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) mstore(4, 0x11) - revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) + revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ 0x24) } - sstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ sum) + sstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:181 \"contract D is C(3)...\" */ sum) let _2 := mload(64) let _3 := datasize(\"D_72_deployed\") codecopy(_2, dataoffset(\"D_72_deployed\"), _3) - setimmutable(_2, \"8\", mload(/** @src 0:154:156 \"42\" */ 128)) - /// @src 1:91:166 \"contract D is C(3)...\" + setimmutable(_2, \"8\", mload(/** @src 0:160:162 \"42\" */ 128)) + /// @src 1:91:181 \"contract D is C(3)...\" return(_2, _3) } } @@ -1497,100 +1492,100 @@ object \"D_72\" { object \"D_72_deployed\" { code { { - /// @src 1:91:166 \"contract D is C(3)...\" - let _1 := memoryguard(0x80) - let _2 := 64 - mstore(_2, _1) + /// @src 1:91:181 \"contract D is C(3)...\" + mstore(64, memoryguard(0x80)) if iszero(lt(calldatasize(), 4)) { switch shr(224, calldataload(0)) case 0x26121ff0 { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - /// @src 0:297:305 \"immutVar\" - let _3 := loadimmutable(\"8\") - /// @src 1:91:166 \"contract D is C(3)...\" - let sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ _3) - if and(1, slt(sum, _3)) + /// @src 0:333:341 \"immutVar\" + let _1 := loadimmutable(\"8\") + /// @src 0:322:341 \"constVar + immutVar\" + let sum := /** @src 1:91:181 \"contract D is C(3)...\" */ 0 + sum := add(/** @src 0:127:129 \"41\" */ 0x29, /** @src 1:91:181 \"contract D is C(3)...\" */ _1) + if and(1, slt(sum, _1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } - mstore(_1, sum) - return(_1, 32) + let memPos := mload(64) + mstore(memPos, sum) + return(memPos, 32) } case 0x793816ec { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _4 := sload(0) - let memPos := mload(_2) - mstore(memPos, _4) - return(memPos, 32) + let _2 := sload(0) + let memPos_1 := mload(64) + mstore(memPos_1, _2) + return(memPos_1, 32) } case 0x9942ec6f { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _5 := sload(0) - if eq(_5, sub(shl(255, 1), 1)) + let _3 := sload(0) + if eq(_3, sub(shl(255, 1), 1)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x11) revert(0, 0x24) } - let ret := add(_5, 1) + let ret := add(_3, 1) sstore(0, ret) - /// @src 0:410:418 \"this.f()\" - let _6 := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(_2) - /// @src 0:410:418 \"this.f()\" - mstore(_6, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) - /// @src 0:410:418 \"this.f()\" - let _7 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _6, /** @src 1:91:166 \"contract D is C(3)...\" */ 4, /** @src 0:410:418 \"this.f()\" */ _6, 32) - if iszero(_7) + /// @src 0:482:490 \"this.f()\" + let _4 := /** @src 1:91:181 \"contract D is C(3)...\" */ mload(64) + /// @src 0:482:490 \"this.f()\" + mstore(_4, /** @src 1:91:181 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) + /// @src 0:482:490 \"this.f()\" + let _5 := staticcall(gas(), /** @src 0:482:486 \"this\" */ address(), /** @src 0:482:490 \"this.f()\" */ _4, /** @src 1:91:181 \"contract D is C(3)...\" */ 4, /** @src 0:482:490 \"this.f()\" */ _4, 32) + if iszero(_5) { - /// @src 1:91:166 \"contract D is C(3)...\" - let pos := mload(_2) + /// @src 1:91:181 \"contract D is C(3)...\" + let pos := mload(64) returndatacopy(pos, 0, returndatasize()) revert(pos, returndatasize()) } - /// @src 0:410:418 \"this.f()\" - let expr := /** @src 1:91:166 \"contract D is C(3)...\" */ 0 - /// @src 0:410:418 \"this.f()\" - if _7 + /// @src 0:482:490 \"this.f()\" + let expr := /** @src 1:91:181 \"contract D is C(3)...\" */ 0 + /// @src 0:482:490 \"this.f()\" + if _5 { - let _8 := 32 - if gt(32, returndatasize()) { _8 := returndatasize() } - /// @src 1:91:166 \"contract D is C(3)...\" - let newFreePtr := add(_6, and(add(_8, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _6)) + let _6 := 32 + if gt(32, returndatasize()) { _6 := returndatasize() } + /// @src 1:91:181 \"contract D is C(3)...\" + let newFreePtr := add(_4, and(add(_6, 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - mstore(_2, newFreePtr) - if slt(sub(/** @src 0:410:418 \"this.f()\" */ add(_6, _8), /** @src 1:91:166 \"contract D is C(3)...\" */ _6), /** @src 0:410:418 \"this.f()\" */ 32) - /// @src 1:91:166 \"contract D is C(3)...\" + mstore(64, newFreePtr) + if slt(sub(/** @src 0:482:490 \"this.f()\" */ add(_4, _6), /** @src 1:91:181 \"contract D is C(3)...\" */ _4), /** @src 0:482:490 \"this.f()\" */ 32) + /// @src 1:91:181 \"contract D is C(3)...\" { revert(0, 0) } - /// @src 0:410:418 \"this.f()\" - expr := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(_6) + /// @src 0:482:490 \"this.f()\" + expr := /** @src 1:91:181 \"contract D is C(3)...\" */ mload(_4) } - /// @src 0:399:418 \"stateVar + this.f()\" + /// @src 0:471:490 \"stateVar + this.f()\" let expr_1 := checked_add_int256(ret, expr) - /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" - let var := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) - /// @src 1:91:166 \"contract D is C(3)...\" - let memPos_1 := mload(_2) - mstore(memPos_1, var) - return(memPos_1, /** @src 0:410:418 \"this.f()\" */ 32) + /// @src 0:464:501 \"return stateVar + this.f() + immutVar\" + let var := /** @src 0:471:501 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:493:501 \"immutVar\" */ loadimmutable(\"8\")) + /// @src 1:91:181 \"contract D is C(3)...\" + let memPos_2 := mload(64) + mstore(memPos_2, var) + return(memPos_2, /** @src 0:482:490 \"this.f()\" */ 32) } - case /** @src 1:91:166 \"contract D is C(3)...\" */ 0xa00b982b { + case /** @src 1:91:181 \"contract D is C(3)...\" */ 0xa00b982b { if callvalue() { revert(0, 0) } if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let memPos_2 := mload(_2) - mstore(memPos_2, /** @src 0:124:126 \"41\" */ 0x29) - /// @src 1:91:166 \"contract D is C(3)...\" - return(memPos_2, 32) + let memPos_3 := mload(64) + mstore(memPos_3, /** @src 0:127:129 \"41\" */ 0x29) + /// @src 1:91:181 \"contract D is C(3)...\" + return(memPos_3, 32) } } revert(0, 0) @@ -1615,14 +1610,11 @@ object \"D_72\" { } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 }, - "D": - { + "D": { "id": 1 } } diff --git a/test/cmdlineTests/standard_default_success/output.json b/test/cmdlineTests/standard_default_success/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_default_success/output.json +++ b/test/cmdlineTests/standard_default_success/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_empty_file_name/output.json b/test/cmdlineTests/standard_empty_file_name/output.json index 4e4d84c41c75..1fd016e54e81 100644 --- a/test/cmdlineTests/standard_empty_file_name/output.json +++ b/test/cmdlineTests/standard_empty_file_name/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2904", @@ -9,8 +8,7 @@ ", "message": "Declaration \"A\" not found in \"\" (referenced as \".\").", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 79, "file": "", "start": 59 diff --git a/test/cmdlineTests/standard_evm_version_byzantium/output.json b/test/cmdlineTests/standard_evm_version_byzantium/output.json index b2428b105060..36570f9c2a9a 100644 --- a/test/cmdlineTests/standard_evm_version_byzantium/output.json +++ b/test/cmdlineTests/standard_evm_version_byzantium/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Support for EVM versions older than constantinople is deprecated and will be removed in the future.", @@ -9,10 +8,8 @@ "type": "Warning" } ], - "sources": - { - "input.sol": - { + "sources": { + "input.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_evm_version_constantinople/output.json b/test/cmdlineTests/standard_evm_version_constantinople/output.json index 1ce414a4cc79..81fa23ff623f 100644 --- a/test/cmdlineTests/standard_evm_version_constantinople/output.json +++ b/test/cmdlineTests/standard_evm_version_constantinople/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "input.sol": - { + "sources": { + "input.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_function_debug_info/output.json b/test/cmdlineTests/standard_function_debug_info/output.json index bbbb6b96faf3..645e1646a698 100644 --- a/test/cmdlineTests/standard_function_debug_info/output.json +++ b/test/cmdlineTests/standard_function_debug_info/output.json @@ -1,169 +1,140 @@ { - "contracts": - { - "a.sol": - { - "A": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A": { + "evm": { + "bytecode": { "functionDebugData": {} }, - "deployedBytecode": - { - "functionDebugData": - { - "@f_19": - { + "deployedBytecode": { + "functionDebugData": { + "@f_19": { "entryPoint": 93, "id": 19, "parameterSlots": 1, "returnSlots": 1 }, - "abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr": - { + "abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr": { "entryPoint": 421, "id": null, "parameterSlots": 3, "returnSlots": 1 }, - "abi_decode_t_array$_t_uint256_$dyn_memory_ptr": - { + "abi_decode_t_array$_t_uint256_$dyn_memory_ptr": { "entryPoint": 525, "id": null, "parameterSlots": 2, "returnSlots": 1 }, - "abi_decode_t_uint256": - { + "abi_decode_t_uint256": { "entryPoint": 401, "id": null, "parameterSlots": 2, "returnSlots": 1 }, - "abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr": - { + "abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr": { "entryPoint": 570, "id": null, "parameterSlots": 2, "returnSlots": 1 }, - "abi_encode_t_uint256_to_t_uint256_fromStack": - { + "abi_encode_t_uint256_to_t_uint256_fromStack": { "entryPoint": 641, "id": null, "parameterSlots": 2, "returnSlots": 0 }, - "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed": - { + "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed": { "entryPoint": 656, "id": null, "parameterSlots": 2, "returnSlots": 1 }, - "allocate_memory": - { + "allocate_memory": { "entryPoint": 297, "id": null, "parameterSlots": 1, "returnSlots": 1 }, - "allocate_unbounded": - { + "allocate_unbounded": { "entryPoint": 166, "id": null, "parameterSlots": 0, "returnSlots": 1 }, - "array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr": - { + "array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr": { "entryPoint": 323, "id": null, "parameterSlots": 1, "returnSlots": 1 }, - "checked_add_t_uint256": - { + "checked_add_t_uint256": { "entryPoint": 771, "id": null, "parameterSlots": 2, "returnSlots": 1 }, - "cleanup_t_uint256": - { + "cleanup_t_uint256": { "entryPoint": 370, "id": null, "parameterSlots": 1, "returnSlots": 1 }, - "finalize_allocation": - { + "finalize_allocation": { "entryPoint": 248, "id": null, "parameterSlots": 2, "returnSlots": 0 }, - "panic_error_0x11": - { + "panic_error_0x11": { "entryPoint": 726, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "panic_error_0x32": - { + "panic_error_0x32": { "entryPoint": 681, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "panic_error_0x41": - { + "panic_error_0x41": { "entryPoint": 203, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "revert_error_1b9f4a0a5773e33b91aa01db23bf8c55fce1411167c872835e7fa00a4f17d46d": - { + "revert_error_1b9f4a0a5773e33b91aa01db23bf8c55fce1411167c872835e7fa00a4f17d46d": { "entryPoint": 183, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "revert_error_81385d8c0b31fffe14be1da910c8bd3a80be4cfa248e04f42ec0faea3132a8ef": - { + "revert_error_81385d8c0b31fffe14be1da910c8bd3a80be4cfa248e04f42ec0faea3132a8ef": { "entryPoint": 366, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db": - { + "revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db": { "entryPoint": 179, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b": - { + "revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b": { "entryPoint": 175, "id": null, "parameterSlots": 0, "returnSlots": 0 }, - "round_up_to_mul_of_32": - { + "round_up_to_mul_of_32": { "entryPoint": 187, "id": null, "parameterSlots": 1, "returnSlots": 1 }, - "validator_revert_t_uint256": - { + "validator_revert_t_uint256": { "entryPoint": 379, "id": null, "parameterSlots": 1, @@ -175,10 +146,8 @@ } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_generatedSources/output.json b/test/cmdlineTests/standard_generatedSources/output.json index 350d108991bd..4fb0b3dcc336 100644 --- a/test/cmdlineTests/standard_generatedSources/output.json +++ b/test/cmdlineTests/standard_generatedSources/output.json @@ -1,45 +1,32 @@ { - "contracts": - { - "a.sol": - { - "A": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A": { + "evm": { + "bytecode": { "generatedSources": [], "object": "" }, - "deployedBytecode": - { - "generatedSources": - [ + "deployedBytecode": { + "generatedSources": [ { - "ast": - { + "ast": { "nativeSrc": "0:3989:1", "nodeType": "YulBlock", "src": "0:3989:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "47:35:1", "nodeType": "YulBlock", "src": "47:35:1", - "statements": - [ + "statements": [ { "nativeSrc": "57:19:1", "nodeType": "YulAssignment", "src": "57:19:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "73:2:1", @@ -49,8 +36,7 @@ "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "67:5:1", "nodeType": "YulIdentifier", @@ -60,8 +46,7 @@ "nodeType": "YulFunctionCall", "src": "67:9:1" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "57:6:1", @@ -75,8 +60,7 @@ "name": "allocate_unbounded", "nativeSrc": "7:75:1", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "40:6:1", @@ -88,18 +72,14 @@ "src": "7:75:1" }, { - "body": - { + "body": { "nativeSrc": "177:28:1", "nodeType": "YulBlock", "src": "177:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "194:1:1", @@ -117,8 +97,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "187:6:1", "nodeType": "YulIdentifier", @@ -140,18 +119,14 @@ "src": "88:117:1" }, { - "body": - { + "body": { "nativeSrc": "300:28:1", "nodeType": "YulBlock", "src": "300:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "317:1:1", @@ -169,8 +144,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "310:6:1", "nodeType": "YulIdentifier", @@ -192,18 +166,14 @@ "src": "211:117:1" }, { - "body": - { + "body": { "nativeSrc": "423:28:1", "nodeType": "YulBlock", "src": "423:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "440:1:1", @@ -221,8 +191,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "433:6:1", "nodeType": "YulIdentifier", @@ -244,24 +213,19 @@ "src": "334:117:1" }, { - "body": - { + "body": { "nativeSrc": "505:54:1", "nodeType": "YulBlock", "src": "505:54:1", - "statements": - [ + "statements": [ { "nativeSrc": "515:38:1", "nodeType": "YulAssignment", "src": "515:38:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "value", "nativeSrc": "533:5:1", @@ -277,8 +241,7 @@ "value": "31" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "529:3:1", "nodeType": "YulIdentifier", @@ -289,8 +252,7 @@ "src": "529:14:1" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "549:2:1", @@ -300,8 +262,7 @@ "value": "31" } ], - "functionName": - { + "functionName": { "name": "not", "nativeSrc": "545:3:1", "nodeType": "YulIdentifier", @@ -312,8 +273,7 @@ "src": "545:7:1" } ], - "functionName": - { + "functionName": { "name": "and", "nativeSrc": "525:3:1", "nodeType": "YulIdentifier", @@ -323,8 +283,7 @@ "nodeType": "YulFunctionCall", "src": "525:28:1" }, - "variableNames": - [ + "variableNames": [ { "name": "result", "nativeSrc": "515:6:1", @@ -338,8 +297,7 @@ "name": "round_up_to_mul_of_32", "nativeSrc": "457:102:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "value", "nativeSrc": "488:5:1", @@ -348,8 +306,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "result", "nativeSrc": "498:6:1", @@ -361,18 +318,14 @@ "src": "457:102:1" }, { - "body": - { + "body": { "nativeSrc": "593:152:1", "nodeType": "YulBlock", "src": "593:152:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "610:1:1", @@ -390,8 +343,7 @@ "value": "35408467139433450592217433187231851964531694900788300625387963629091585785856" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "603:6:1", "nodeType": "YulIdentifier", @@ -406,10 +358,8 @@ "src": "603:88:1" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "707:1:1", @@ -427,8 +377,7 @@ "value": "0x41" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "700:6:1", "nodeType": "YulIdentifier", @@ -443,10 +392,8 @@ "src": "700:15:1" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "731:1:1", @@ -464,8 +411,7 @@ "value": "0x24" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "724:6:1", "nodeType": "YulIdentifier", @@ -487,21 +433,17 @@ "src": "565:180:1" }, { - "body": - { + "body": { "nativeSrc": "794:238:1", "nodeType": "YulBlock", "src": "794:238:1", - "statements": - [ + "statements": [ { "nativeSrc": "804:58:1", "nodeType": "YulVariableDeclaration", "src": "804:58:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "memPtr", "nativeSrc": "826:6:1", @@ -509,8 +451,7 @@ "src": "826:6:1" }, { - "arguments": - [ + "arguments": [ { "name": "size", "nativeSrc": "856:4:1", @@ -518,8 +459,7 @@ "src": "856:4:1" } ], - "functionName": - { + "functionName": { "name": "round_up_to_mul_of_32", "nativeSrc": "834:21:1", "nodeType": "YulIdentifier", @@ -530,8 +470,7 @@ "src": "834:27:1" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "822:3:1", "nodeType": "YulIdentifier", @@ -541,8 +480,7 @@ "nodeType": "YulFunctionCall", "src": "822:40:1" }, - "variables": - [ + "variables": [ { "name": "newFreePtr", "nativeSrc": "808:10:1", @@ -553,19 +491,15 @@ ] }, { - "body": - { + "body": { "nativeSrc": "973:22:1", "nodeType": "YulBlock", "src": "973:22:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "panic_error_0x41", "nativeSrc": "975:16:1", "nodeType": "YulIdentifier", @@ -581,13 +515,10 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "newFreePtr", "nativeSrc": "916:10:1", @@ -603,8 +534,7 @@ "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "913:2:1", "nodeType": "YulIdentifier", @@ -615,8 +545,7 @@ "src": "913:34:1" }, { - "arguments": - [ + "arguments": [ { "name": "newFreePtr", "nativeSrc": "952:10:1", @@ -630,8 +559,7 @@ "src": "964:6:1" } ], - "functionName": - { + "functionName": { "name": "lt", "nativeSrc": "949:2:1", "nodeType": "YulIdentifier", @@ -642,8 +570,7 @@ "src": "949:22:1" } ], - "functionName": - { + "functionName": { "name": "or", "nativeSrc": "910:2:1", "nodeType": "YulIdentifier", @@ -658,10 +585,8 @@ "src": "907:88:1" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1011:2:1", @@ -677,8 +602,7 @@ "src": "1015:10:1" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "1004:6:1", "nodeType": "YulIdentifier", @@ -697,8 +621,7 @@ "name": "finalize_allocation", "nativeSrc": "751:281:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "memPtr", "nativeSrc": "780:6:1", @@ -717,22 +640,18 @@ "src": "751:281:1" }, { - "body": - { + "body": { "nativeSrc": "1079:88:1", "nodeType": "YulBlock", "src": "1079:88:1", - "statements": - [ + "statements": [ { "nativeSrc": "1089:30:1", "nodeType": "YulAssignment", "src": "1089:30:1", - "value": - { + "value": { "arguments": [], - "functionName": - { + "functionName": { "name": "allocate_unbounded", "nativeSrc": "1099:18:1", "nodeType": "YulIdentifier", @@ -742,8 +661,7 @@ "nodeType": "YulFunctionCall", "src": "1099:20:1" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "1089:6:1", @@ -753,10 +671,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "memPtr", "nativeSrc": "1148:6:1", @@ -770,8 +686,7 @@ "src": "1156:4:1" } ], - "functionName": - { + "functionName": { "name": "finalize_allocation", "nativeSrc": "1128:19:1", "nodeType": "YulIdentifier", @@ -790,8 +705,7 @@ "name": "allocate_memory", "nativeSrc": "1038:129:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "size", "nativeSrc": "1063:4:1", @@ -800,8 +714,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "1072:6:1", @@ -813,27 +726,21 @@ "src": "1038:129:1" }, { - "body": - { + "body": { "nativeSrc": "1255:229:1", "nodeType": "YulBlock", "src": "1255:229:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "1360:22:1", "nodeType": "YulBlock", "src": "1360:22:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "panic_error_0x41", "nativeSrc": "1362:16:1", "nodeType": "YulIdentifier", @@ -849,10 +756,8 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "length", "nativeSrc": "1332:6:1", @@ -868,8 +773,7 @@ "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "1329:2:1", "nodeType": "YulIdentifier", @@ -887,10 +791,8 @@ "nativeSrc": "1392:25:1", "nodeType": "YulAssignment", "src": "1392:25:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "length", "nativeSrc": "1404:6:1", @@ -906,8 +808,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "mul", "nativeSrc": "1400:3:1", "nodeType": "YulIdentifier", @@ -917,8 +818,7 @@ "nodeType": "YulFunctionCall", "src": "1400:17:1" }, - "variableNames": - [ + "variableNames": [ { "name": "size", "nativeSrc": "1392:4:1", @@ -931,10 +831,8 @@ "nativeSrc": "1454:23:1", "nodeType": "YulAssignment", "src": "1454:23:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "size", "nativeSrc": "1466:4:1", @@ -950,8 +848,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "1462:3:1", "nodeType": "YulIdentifier", @@ -961,8 +858,7 @@ "nodeType": "YulFunctionCall", "src": "1462:15:1" }, - "variableNames": - [ + "variableNames": [ { "name": "size", "nativeSrc": "1454:4:1", @@ -976,8 +872,7 @@ "name": "array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "1173:311:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "length", "nativeSrc": "1239:6:1", @@ -986,8 +881,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "size", "nativeSrc": "1250:4:1", @@ -999,18 +893,14 @@ "src": "1173:311:1" }, { - "body": - { + "body": { "nativeSrc": "1579:28:1", "nodeType": "YulBlock", "src": "1579:28:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1596:1:1", @@ -1028,8 +918,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "1589:6:1", "nodeType": "YulIdentifier", @@ -1051,26 +940,22 @@ "src": "1490:117:1" }, { - "body": - { + "body": { "nativeSrc": "1658:32:1", "nodeType": "YulBlock", "src": "1658:32:1", - "statements": - [ + "statements": [ { "nativeSrc": "1668:16:1", "nodeType": "YulAssignment", "src": "1668:16:1", - "value": - { + "value": { "name": "value", "nativeSrc": "1679:5:1", "nodeType": "YulIdentifier", "src": "1679:5:1" }, - "variableNames": - [ + "variableNames": [ { "name": "cleaned", "nativeSrc": "1668:7:1", @@ -1084,8 +969,7 @@ "name": "cleanup_t_uint256", "nativeSrc": "1613:77:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "value", "nativeSrc": "1640:5:1", @@ -1094,8 +978,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "cleaned", "nativeSrc": "1650:7:1", @@ -1107,26 +990,20 @@ "src": "1613:77:1" }, { - "body": - { + "body": { "nativeSrc": "1739:79:1", "nodeType": "YulBlock", "src": "1739:79:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "1796:16:1", "nodeType": "YulBlock", "src": "1796:16:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1805:1:1", @@ -1144,8 +1021,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "1798:6:1", "nodeType": "YulIdentifier", @@ -1161,13 +1037,10 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "value", "nativeSrc": "1762:5:1", @@ -1175,8 +1048,7 @@ "src": "1762:5:1" }, { - "arguments": - [ + "arguments": [ { "name": "value", "nativeSrc": "1787:5:1", @@ -1184,8 +1056,7 @@ "src": "1787:5:1" } ], - "functionName": - { + "functionName": { "name": "cleanup_t_uint256", "nativeSrc": "1769:17:1", "nodeType": "YulIdentifier", @@ -1196,8 +1067,7 @@ "src": "1769:24:1" } ], - "functionName": - { + "functionName": { "name": "eq", "nativeSrc": "1759:2:1", "nodeType": "YulIdentifier", @@ -1208,8 +1078,7 @@ "src": "1759:35:1" } ], - "functionName": - { + "functionName": { "name": "iszero", "nativeSrc": "1752:6:1", "nodeType": "YulIdentifier", @@ -1228,8 +1097,7 @@ "name": "validator_revert_t_uint256", "nativeSrc": "1696:122:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "value", "nativeSrc": "1732:5:1", @@ -1241,21 +1109,17 @@ "src": "1696:122:1" }, { - "body": - { + "body": { "nativeSrc": "1876:87:1", "nodeType": "YulBlock", "src": "1876:87:1", - "statements": - [ + "statements": [ { "nativeSrc": "1886:29:1", "nodeType": "YulAssignment", "src": "1886:29:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "offset", "nativeSrc": "1908:6:1", @@ -1263,8 +1127,7 @@ "src": "1908:6:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", "nativeSrc": "1895:12:1", "nodeType": "YulIdentifier", @@ -1274,8 +1137,7 @@ "nodeType": "YulFunctionCall", "src": "1895:20:1" }, - "variableNames": - [ + "variableNames": [ { "name": "value", "nativeSrc": "1886:5:1", @@ -1285,10 +1147,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "value", "nativeSrc": "1951:5:1", @@ -1296,8 +1156,7 @@ "src": "1951:5:1" } ], - "functionName": - { + "functionName": { "name": "validator_revert_t_uint256", "nativeSrc": "1924:26:1", "nodeType": "YulIdentifier", @@ -1316,8 +1175,7 @@ "name": "abi_decode_t_uint256", "nativeSrc": "1824:139:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "offset", "nativeSrc": "1854:6:1", @@ -1333,8 +1191,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "value", "nativeSrc": "1870:5:1", @@ -1346,24 +1203,19 @@ "src": "1824:139:1" }, { - "body": - { + "body": { "nativeSrc": "2088:608:1", "nodeType": "YulBlock", "src": "2088:608:1", - "statements": - [ + "statements": [ { "nativeSrc": "2098:90:1", "nodeType": "YulAssignment", "src": "2098:90:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "length", "nativeSrc": "2180:6:1", @@ -1371,8 +1223,7 @@ "src": "2180:6:1" } ], - "functionName": - { + "functionName": { "name": "array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "2123:56:1", "nodeType": "YulIdentifier", @@ -1383,8 +1234,7 @@ "src": "2123:64:1" } ], - "functionName": - { + "functionName": { "name": "allocate_memory", "nativeSrc": "2107:15:1", "nodeType": "YulIdentifier", @@ -1394,8 +1244,7 @@ "nodeType": "YulFunctionCall", "src": "2107:81:1" }, - "variableNames": - [ + "variableNames": [ { "name": "array", "nativeSrc": "2098:5:1", @@ -1408,15 +1257,13 @@ "nativeSrc": "2197:16:1", "nodeType": "YulVariableDeclaration", "src": "2197:16:1", - "value": - { + "value": { "name": "array", "nativeSrc": "2208:5:1", "nodeType": "YulIdentifier", "src": "2208:5:1" }, - "variables": - [ + "variables": [ { "name": "dst", "nativeSrc": "2201:3:1", @@ -1427,10 +1274,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "array", "nativeSrc": "2230:5:1", @@ -1444,8 +1289,7 @@ "src": "2237:6:1" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "2223:6:1", "nodeType": "YulIdentifier", @@ -1463,10 +1307,8 @@ "nativeSrc": "2253:23:1", "nodeType": "YulAssignment", "src": "2253:23:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "array", "nativeSrc": "2264:5:1", @@ -1482,8 +1324,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "2260:3:1", "nodeType": "YulIdentifier", @@ -1493,8 +1334,7 @@ "nodeType": "YulFunctionCall", "src": "2260:16:1" }, - "variableNames": - [ + "variableNames": [ { "name": "dst", "nativeSrc": "2253:3:1", @@ -1507,10 +1347,8 @@ "nativeSrc": "2286:44:1", "nodeType": "YulVariableDeclaration", "src": "2286:44:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "offset", "nativeSrc": "2304:6:1", @@ -1518,8 +1356,7 @@ "src": "2304:6:1" }, { - "arguments": - [ + "arguments": [ { "name": "length", "nativeSrc": "2316:6:1", @@ -1535,8 +1372,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "mul", "nativeSrc": "2312:3:1", "nodeType": "YulIdentifier", @@ -1547,8 +1383,7 @@ "src": "2312:17:1" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "2300:3:1", "nodeType": "YulIdentifier", @@ -1558,8 +1393,7 @@ "nodeType": "YulFunctionCall", "src": "2300:30:1" }, - "variables": - [ + "variables": [ { "name": "srcEnd", "nativeSrc": "2290:6:1", @@ -1570,19 +1404,15 @@ ] }, { - "body": - { + "body": { "nativeSrc": "2358:103:1", "nodeType": "YulBlock", "src": "2358:103:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_81385d8c0b31fffe14be1da910c8bd3a80be4cfa248e04f42ec0faea3132a8ef", "nativeSrc": "2372:77:1", "nodeType": "YulIdentifier", @@ -1598,10 +1428,8 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "srcEnd", "nativeSrc": "2345:6:1", @@ -1615,8 +1443,7 @@ "src": "2353:3:1" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "2342:2:1", "nodeType": "YulIdentifier", @@ -1631,26 +1458,22 @@ "src": "2339:122:1" }, { - "body": - { + "body": { "nativeSrc": "2546:144:1", "nodeType": "YulBlock", "src": "2546:144:1", - "statements": - [ + "statements": [ { "nativeSrc": "2561:21:1", "nodeType": "YulVariableDeclaration", "src": "2561:21:1", - "value": - { + "value": { "name": "src", "nativeSrc": "2579:3:1", "nodeType": "YulIdentifier", "src": "2579:3:1" }, - "variables": - [ + "variables": [ { "name": "elementPos", "nativeSrc": "2565:10:1", @@ -1661,10 +1484,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "dst", "nativeSrc": "2603:3:1", @@ -1672,8 +1493,7 @@ "src": "2603:3:1" }, { - "arguments": - [ + "arguments": [ { "name": "elementPos", "nativeSrc": "2629:10:1", @@ -1687,8 +1507,7 @@ "src": "2641:3:1" } ], - "functionName": - { + "functionName": { "name": "abi_decode_t_uint256", "nativeSrc": "2608:20:1", "nodeType": "YulIdentifier", @@ -1699,8 +1518,7 @@ "src": "2608:37:1" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "2596:6:1", "nodeType": "YulIdentifier", @@ -1718,10 +1536,8 @@ "nativeSrc": "2659:21:1", "nodeType": "YulAssignment", "src": "2659:21:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "dst", "nativeSrc": "2670:3:1", @@ -1737,8 +1553,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "2666:3:1", "nodeType": "YulIdentifier", @@ -1748,8 +1563,7 @@ "nodeType": "YulFunctionCall", "src": "2666:14:1" }, - "variableNames": - [ + "variableNames": [ { "name": "dst", "nativeSrc": "2659:3:1", @@ -1760,10 +1574,8 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "src", "nativeSrc": "2499:3:1", @@ -1777,8 +1589,7 @@ "src": "2504:6:1" } ], - "functionName": - { + "functionName": { "name": "lt", "nativeSrc": "2496:2:1", "nodeType": "YulIdentifier", @@ -1790,21 +1601,17 @@ }, "nativeSrc": "2470:220:1", "nodeType": "YulForLoop", - "post": - { + "post": { "nativeSrc": "2512:25:1", "nodeType": "YulBlock", "src": "2512:25:1", - "statements": - [ + "statements": [ { "nativeSrc": "2514:21:1", "nodeType": "YulAssignment", "src": "2514:21:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "src", "nativeSrc": "2525:3:1", @@ -1820,8 +1627,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "2521:3:1", "nodeType": "YulIdentifier", @@ -1831,8 +1637,7 @@ "nodeType": "YulFunctionCall", "src": "2521:14:1" }, - "variableNames": - [ + "variableNames": [ { "name": "src", "nativeSrc": "2514:3:1", @@ -1843,26 +1648,22 @@ } ] }, - "pre": - { + "pre": { "nativeSrc": "2474:21:1", "nodeType": "YulBlock", "src": "2474:21:1", - "statements": - [ + "statements": [ { "nativeSrc": "2476:17:1", "nodeType": "YulVariableDeclaration", "src": "2476:17:1", - "value": - { + "value": { "name": "offset", "nativeSrc": "2487:6:1", "nodeType": "YulIdentifier", "src": "2487:6:1" }, - "variables": - [ + "variables": [ { "name": "src", "nativeSrc": "2480:3:1", @@ -1881,8 +1682,7 @@ "name": "abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "1986:710:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "offset", "nativeSrc": "2058:6:1", @@ -1905,8 +1705,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "array", "nativeSrc": "2082:5:1", @@ -1918,27 +1717,21 @@ "src": "1986:710:1" }, { - "body": - { + "body": { "nativeSrc": "2796:293:1", "nodeType": "YulBlock", "src": "2796:293:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "2845:83:1", "nodeType": "YulBlock", "src": "2845:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_1b9f4a0a5773e33b91aa01db23bf8c55fce1411167c872835e7fa00a4f17d46d", "nativeSrc": "2847:77:1", "nodeType": "YulIdentifier", @@ -1954,16 +1747,12 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "offset", "nativeSrc": "2824:6:1", @@ -1979,8 +1768,7 @@ "value": "0x1f" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "2820:3:1", "nodeType": "YulIdentifier", @@ -1997,8 +1785,7 @@ "src": "2839:3:1" } ], - "functionName": - { + "functionName": { "name": "slt", "nativeSrc": "2816:3:1", "nodeType": "YulIdentifier", @@ -2009,8 +1796,7 @@ "src": "2816:27:1" } ], - "functionName": - { + "functionName": { "name": "iszero", "nativeSrc": "2809:6:1", "nodeType": "YulIdentifier", @@ -2028,10 +1814,8 @@ "nativeSrc": "2937:34:1", "nodeType": "YulVariableDeclaration", "src": "2937:34:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "offset", "nativeSrc": "2964:6:1", @@ -2039,8 +1823,7 @@ "src": "2964:6:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", "nativeSrc": "2951:12:1", "nodeType": "YulIdentifier", @@ -2050,8 +1833,7 @@ "nodeType": "YulFunctionCall", "src": "2951:20:1" }, - "variables": - [ + "variables": [ { "name": "length", "nativeSrc": "2941:6:1", @@ -2065,13 +1847,10 @@ "nativeSrc": "2980:103:1", "nodeType": "YulAssignment", "src": "2980:103:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "offset", "nativeSrc": "3056:6:1", @@ -2087,8 +1866,7 @@ "value": "0x20" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "3052:3:1", "nodeType": "YulIdentifier", @@ -2111,8 +1889,7 @@ "src": "3079:3:1" } ], - "functionName": - { + "functionName": { "name": "abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "2989:62:1", "nodeType": "YulIdentifier", @@ -2122,8 +1899,7 @@ "nodeType": "YulFunctionCall", "src": "2989:94:1" }, - "variableNames": - [ + "variableNames": [ { "name": "array", "nativeSrc": "2980:5:1", @@ -2137,8 +1913,7 @@ "name": "abi_decode_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "2719:370:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "offset", "nativeSrc": "2774:6:1", @@ -2154,8 +1929,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "array", "nativeSrc": "2790:5:1", @@ -2167,27 +1941,21 @@ "src": "2719:370:1" }, { - "body": - { + "body": { "nativeSrc": "3186:448:1", "nodeType": "YulBlock", "src": "3186:448:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "3232:83:1", "nodeType": "YulBlock", "src": "3232:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b", "nativeSrc": "3234:77:1", "nodeType": "YulIdentifier", @@ -2203,13 +1971,10 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "dataEnd", "nativeSrc": "3207:7:1", @@ -2223,8 +1988,7 @@ "src": "3216:9:1" } ], - "functionName": - { + "functionName": { "name": "sub", "nativeSrc": "3203:3:1", "nodeType": "YulIdentifier", @@ -2243,8 +2007,7 @@ "value": "32" } ], - "functionName": - { + "functionName": { "name": "slt", "nativeSrc": "3199:3:1", "nodeType": "YulIdentifier", @@ -2262,19 +2025,15 @@ "nativeSrc": "3325:302:1", "nodeType": "YulBlock", "src": "3325:302:1", - "statements": - [ + "statements": [ { "nativeSrc": "3340:45:1", "nodeType": "YulVariableDeclaration", "src": "3340:45:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "headStart", "nativeSrc": "3371:9:1", @@ -2290,8 +2049,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "3367:3:1", "nodeType": "YulIdentifier", @@ -2302,8 +2060,7 @@ "src": "3367:17:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", "nativeSrc": "3354:12:1", "nodeType": "YulIdentifier", @@ -2313,8 +2070,7 @@ "nodeType": "YulFunctionCall", "src": "3354:31:1" }, - "variables": - [ + "variables": [ { "name": "offset", "nativeSrc": "3344:6:1", @@ -2325,19 +2081,15 @@ ] }, { - "body": - { + "body": { "nativeSrc": "3432:83:1", "nodeType": "YulBlock", "src": "3432:83:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db", "nativeSrc": "3434:77:1", "nodeType": "YulIdentifier", @@ -2353,10 +2105,8 @@ } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "offset", "nativeSrc": "3404:6:1", @@ -2372,8 +2122,7 @@ "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", "nativeSrc": "3401:2:1", "nodeType": "YulIdentifier", @@ -2391,13 +2140,10 @@ "nativeSrc": "3529:88:1", "nodeType": "YulAssignment", "src": "3529:88:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "headStart", "nativeSrc": "3589:9:1", @@ -2411,8 +2157,7 @@ "src": "3600:6:1" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "3585:3:1", "nodeType": "YulIdentifier", @@ -2429,8 +2174,7 @@ "src": "3609:7:1" } ], - "functionName": - { + "functionName": { "name": "abi_decode_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "3539:45:1", "nodeType": "YulIdentifier", @@ -2440,8 +2184,7 @@ "nodeType": "YulFunctionCall", "src": "3539:78:1" }, - "variableNames": - [ + "variableNames": [ { "name": "value0", "nativeSrc": "3529:6:1", @@ -2457,8 +2200,7 @@ "name": "abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr", "nativeSrc": "3095:539:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "headStart", "nativeSrc": "3156:9:1", @@ -2474,8 +2216,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "value0", "nativeSrc": "3179:6:1", @@ -2487,18 +2228,14 @@ "src": "3095:539:1" }, { - "body": - { + "body": { "nativeSrc": "3705:53:1", "nodeType": "YulBlock", "src": "3705:53:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "pos", "nativeSrc": "3722:3:1", @@ -2506,8 +2243,7 @@ "src": "3722:3:1" }, { - "arguments": - [ + "arguments": [ { "name": "value", "nativeSrc": "3745:5:1", @@ -2515,8 +2251,7 @@ "src": "3745:5:1" } ], - "functionName": - { + "functionName": { "name": "cleanup_t_uint256", "nativeSrc": "3727:17:1", "nodeType": "YulIdentifier", @@ -2527,8 +2262,7 @@ "src": "3727:24:1" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "3715:6:1", "nodeType": "YulIdentifier", @@ -2547,8 +2281,7 @@ "name": "abi_encode_t_uint256_to_t_uint256_fromStack", "nativeSrc": "3640:118:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "value", "nativeSrc": "3693:5:1", @@ -2567,21 +2300,17 @@ "src": "3640:118:1" }, { - "body": - { + "body": { "nativeSrc": "3862:124:1", "nodeType": "YulBlock", "src": "3862:124:1", - "statements": - [ + "statements": [ { "nativeSrc": "3872:26:1", "nodeType": "YulAssignment", "src": "3872:26:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "headStart", "nativeSrc": "3884:9:1", @@ -2597,8 +2326,7 @@ "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "3880:3:1", "nodeType": "YulIdentifier", @@ -2608,8 +2336,7 @@ "nodeType": "YulFunctionCall", "src": "3880:18:1" }, - "variableNames": - [ + "variableNames": [ { "name": "tail", "nativeSrc": "3872:4:1", @@ -2619,10 +2346,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "value0", "nativeSrc": "3952:6:1", @@ -2630,8 +2355,7 @@ "src": "3952:6:1" }, { - "arguments": - [ + "arguments": [ { "name": "headStart", "nativeSrc": "3965:9:1", @@ -2647,8 +2371,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "3961:3:1", "nodeType": "YulIdentifier", @@ -2659,8 +2382,7 @@ "src": "3961:17:1" } ], - "functionName": - { + "functionName": { "name": "abi_encode_t_uint256_to_t_uint256_fromStack", "nativeSrc": "3908:43:1", "nodeType": "YulIdentifier", @@ -2679,8 +2401,7 @@ "name": "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed", "nativeSrc": "3764:222:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "headStart", "nativeSrc": "3834:9:1", @@ -2696,8 +2417,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "tail", "nativeSrc": "3857:4:1", @@ -2843,8 +2563,7 @@ } } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3420", @@ -2854,8 +2573,7 @@ ", "message": "Source file does not specify required compiler version!", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": -1, "file": "a.sol", "start": -1 @@ -2863,10 +2581,8 @@ "type": "Warning" } ], - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_immutable_references/output.json b/test/cmdlineTests/standard_immutable_references/output.json index e25a911fff6e..cfa087bce500 100644 --- a/test/cmdlineTests/standard_immutable_references/output.json +++ b/test/cmdlineTests/standard_immutable_references/output.json @@ -1,18 +1,11 @@ { - "contracts": - { - "a.sol": - { - "A": - { - "evm": - { - "deployedBytecode": - { - "immutableReferences": - { - "6": - [ + "contracts": { + "a.sol": { + "A": { + "evm": { + "deployedBytecode": { + "immutableReferences": { + "6": [ { "length": 32, "start": 75 @@ -24,10 +17,8 @@ } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_import_evmasm/input.json b/test/cmdlineTests/standard_import_asm_json/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm/input.json rename to test/cmdlineTests/standard_import_asm_json/input.json diff --git a/test/cmdlineTests/standard_import_evmasm/output.json b/test/cmdlineTests/standard_import_asm_json/output.json similarity index 72% rename from test/cmdlineTests/standard_import_evmasm/output.json rename to test/cmdlineTests/standard_import_asm_json/output.json index 5b7cdf3bb9d4..1db28796071a 100644 --- a/test/cmdlineTests/standard_import_evmasm/output.json +++ b/test/cmdlineTests/standard_import_asm_json/output.json @@ -1,25 +1,19 @@ { - "contracts": - { - "A": - { - "": - { - "evm": - { + "contracts": { + "A": { + "": { + "evm": { "assembly": " /* \"\":36:51 */ 0x00 ", - "bytecode": - { + "bytecode": { "functionDebugData": {}, "linkReferences": {}, "object": "", "opcodes":"", "sourceMap":"" }, - "deployedBytecode": - { + "deployedBytecode": { "functionDebugData": {}, "immutableReferences": {}, "linkReferences": {}, @@ -27,10 +21,8 @@ "opcodes": "", "sourceMap": "" }, - "legacyAssembly": - { - ".code": - [ + "legacyAssembly": { + ".code": [ { "begin": 36, "end": 51, @@ -39,8 +31,7 @@ "value": "0" } ], - "sourceList": - [ + "sourceList": [ "" ] } diff --git a/test/cmdlineTests/standard_import_evmasm_immutable_references/input.json b/test/cmdlineTests/standard_import_asm_json_immutable_references/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_immutable_references/input.json rename to test/cmdlineTests/standard_import_asm_json_immutable_references/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_immutable_references/output.json b/test/cmdlineTests/standard_import_asm_json_immutable_references/output.json similarity index 69% rename from test/cmdlineTests/standard_import_evmasm_immutable_references/output.json rename to test/cmdlineTests/standard_import_asm_json_immutable_references/output.json index 05a6ff7d5eca..f0554d8c602b 100644 --- a/test/cmdlineTests/standard_import_evmasm_immutable_references/output.json +++ b/test/cmdlineTests/standard_import_asm_json_immutable_references/output.json @@ -1,27 +1,19 @@ { - "contracts": - { - "A": - { - "": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "": { + "evm": { + "bytecode": { "functionDebugData": {}, "linkReferences": {}, "object": "", "opcodes":"", "sourceMap":"" }, - "deployedBytecode": - { + "deployedBytecode": { "functionDebugData": {}, - "immutableReferences": - { - "6": - [ + "immutableReferences": { + "6": [ { "length": 32, "start": 1 diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_input_array/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_input_array/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_invalid_input_array/input.json rename to test/cmdlineTests/standard_import_asm_json_invalid_input_array/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_key_other_source/output.json b/test/cmdlineTests/standard_import_asm_json_invalid_input_array/output.json similarity index 95% rename from test/cmdlineTests/standard_import_evmasm_invalid_key_other_source/output.json rename to test/cmdlineTests/standard_import_asm_json_invalid_input_array/output.json index 2a075efd02ae..489a41933198 100644 --- a/test/cmdlineTests/standard_import_evmasm_invalid_key_other_source/output.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_input_array/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid input source specified. Expected exactly one object, named 'assemblyJson', inside $.sources.A", diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_key_inside_source/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_key_inside_source/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_invalid_key_inside_source/input.json rename to test/cmdlineTests/standard_import_asm_json_invalid_key_inside_source/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_input_array/output.json b/test/cmdlineTests/standard_import_asm_json_invalid_key_inside_source/output.json similarity index 95% rename from test/cmdlineTests/standard_import_evmasm_invalid_input_array/output.json rename to test/cmdlineTests/standard_import_asm_json_invalid_key_inside_source/output.json index 2a075efd02ae..489a41933198 100644 --- a/test/cmdlineTests/standard_import_evmasm_invalid_input_array/output.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_key_inside_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid input source specified. Expected exactly one object, named 'assemblyJson', inside $.sources.A", diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_key_other_source/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_key_other_source/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_invalid_key_other_source/input.json rename to test/cmdlineTests/standard_import_asm_json_invalid_key_other_source/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_key_inside_source/output.json b/test/cmdlineTests/standard_import_asm_json_invalid_key_other_source/output.json similarity index 95% rename from test/cmdlineTests/standard_import_evmasm_invalid_key_inside_source/output.json rename to test/cmdlineTests/standard_import_asm_json_invalid_key_other_source/output.json index 2a075efd02ae..489a41933198 100644 --- a/test/cmdlineTests/standard_import_evmasm_invalid_key_inside_source/output.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_key_other_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid input source specified. Expected exactly one object, named 'assemblyJson', inside $.sources.A", diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_no_source/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_no_source/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_invalid_no_source/input.json rename to test/cmdlineTests/standard_import_asm_json_invalid_no_source/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_no_source/output.json b/test/cmdlineTests/standard_import_asm_json_invalid_no_source/output.json similarity index 92% rename from test/cmdlineTests/standard_import_evmasm_invalid_no_source/output.json rename to test/cmdlineTests/standard_import_asm_json_invalid_no_source/output.json index 3495a7411d9e..135ec60dea2d 100644 --- a/test/cmdlineTests/standard_import_evmasm_invalid_no_source/output.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_no_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "No input sources specified.", diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_opcode/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_opcode/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_invalid_opcode/input.json rename to test/cmdlineTests/standard_import_asm_json_invalid_opcode/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_opcode/output.json b/test/cmdlineTests/standard_import_asm_json_invalid_opcode/output.json similarity index 93% rename from test/cmdlineTests/standard_import_evmasm_invalid_opcode/output.json rename to test/cmdlineTests/standard_import_asm_json_invalid_opcode/output.json index 6314f8b05693..cccd241d9416 100644 --- a/test/cmdlineTests/standard_import_evmasm_invalid_opcode/output.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_opcode/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Assembly import error: InvalidOpcode", diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_two_sources/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_two_sources/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_invalid_two_sources/input.json rename to test/cmdlineTests/standard_import_asm_json_invalid_two_sources/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_invalid_two_sources/output.json b/test/cmdlineTests/standard_import_asm_json_invalid_two_sources/output.json similarity index 93% rename from test/cmdlineTests/standard_import_evmasm_invalid_two_sources/output.json rename to test/cmdlineTests/standard_import_asm_json_invalid_two_sources/output.json index affe4c34e651..9e85128bbdc4 100644 --- a/test/cmdlineTests/standard_import_evmasm_invalid_two_sources/output.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_two_sources/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "EVMAssembly import only supports exactly one input file.", diff --git a/test/cmdlineTests/standard_import_evmasm_link_references/input.json b/test/cmdlineTests/standard_import_asm_json_link_references/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_link_references/input.json rename to test/cmdlineTests/standard_import_asm_json_link_references/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_link_references/output.json b/test/cmdlineTests/standard_import_asm_json_link_references/output.json similarity index 68% rename from test/cmdlineTests/standard_import_evmasm_link_references/output.json rename to test/cmdlineTests/standard_import_asm_json_link_references/output.json index 864f65a53f70..fed476e620c5 100644 --- a/test/cmdlineTests/standard_import_evmasm_link_references/output.json +++ b/test/cmdlineTests/standard_import_asm_json_link_references/output.json @@ -1,30 +1,21 @@ { - "contracts": - { - "A": - { - "": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "": { + "evm": { + "bytecode": { "functionDebugData": {}, "linkReferences": {}, "object": "", "opcodes":"", "sourceMap": "" }, - "deployedBytecode": - { + "deployedBytecode": { "functionDebugData": {}, "immutableReferences": {}, - "linkReferences": - { - "test.sol": - { - "L": - [ + "linkReferences": { + "test.sol": { + "L": [ { "length": 20, "start": 1 diff --git a/test/cmdlineTests/standard_import_evmasm_multiple_keys_inside_source/input.json b/test/cmdlineTests/standard_import_asm_json_multiple_keys_inside_source/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_multiple_keys_inside_source/input.json rename to test/cmdlineTests/standard_import_asm_json_multiple_keys_inside_source/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_multiple_keys_inside_source/output.json b/test/cmdlineTests/standard_import_asm_json_multiple_keys_inside_source/output.json similarity index 95% rename from test/cmdlineTests/standard_import_evmasm_multiple_keys_inside_source/output.json rename to test/cmdlineTests/standard_import_asm_json_multiple_keys_inside_source/output.json index 2a075efd02ae..489a41933198 100644 --- a/test/cmdlineTests/standard_import_evmasm_multiple_keys_inside_source/output.json +++ b/test/cmdlineTests/standard_import_asm_json_multiple_keys_inside_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid input source specified. Expected exactly one object, named 'assemblyJson', inside $.sources.A", diff --git a/test/cmdlineTests/standard_import_evmasm_no_output_selection/input.json b/test/cmdlineTests/standard_import_asm_json_no_output_selection/input.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_no_output_selection/input.json rename to test/cmdlineTests/standard_import_asm_json_no_output_selection/input.json diff --git a/test/cmdlineTests/standard_import_evmasm_no_output_selection/output.json b/test/cmdlineTests/standard_import_asm_json_no_output_selection/output.json similarity index 100% rename from test/cmdlineTests/standard_import_evmasm_no_output_selection/output.json rename to test/cmdlineTests/standard_import_asm_json_no_output_selection/output.json diff --git a/test/cmdlineTests/standard_import_ast/output.json b/test/cmdlineTests/standard_import_ast/output.json index 6ecac5ca364d..d54da1750bc8 100644 --- a/test/cmdlineTests/standard_import_ast/output.json +++ b/test/cmdlineTests/standard_import_ast/output.json @@ -1,27 +1,20 @@ { - "sources": - { - "A": - { - "ast": - { + "sources": { + "A": { + "ast": { "absolutePath": "A", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" @@ -37,18 +30,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "68:1:0", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "97:2:0", @@ -62,15 +52,13 @@ "name": "f", "nameLocation": "81:1:0", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], "src": "82:2:0" }, - "returnParameters": - { + "returnParameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], diff --git a/test/cmdlineTests/standard_import_ast_select_bytecode/output.json b/test/cmdlineTests/standard_import_ast_select_bytecode/output.json index 0fca3f2715a3..c060efd971a7 100644 --- a/test/cmdlineTests/standard_import_ast_select_bytecode/output.json +++ b/test/cmdlineTests/standard_import_ast_select_bytecode/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A": - { - "test": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "test": { + "evm": { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -20,10 +15,8 @@ } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_import_with_comments/input.json b/test/cmdlineTests/standard_import_with_comments/input.json new file mode 100644 index 000000000000..4ed88177cf1f --- /dev/null +++ b/test/cmdlineTests/standard_import_with_comments/input.json @@ -0,0 +1,95 @@ +{ + "language": "SolidityAST", + "sources": { // this is a comment + "A": { + "ast": { + "absolutePath": "A", + "exportedSymbols": { + "C": [ + 6 /* and this another comment */ + ] + }, + "id": 7, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": /* and this is a comment too */[ + // this is a comment + { + /*this is a comment*/"id"/* and this is another comment too*/: 1, + "literals": [ + "solidity", + ">=", + "0.0" + ], + "nodeType": "PragmaDirective", + "src": "36:22:0" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 6, + "linearizedBaseContracts": [ + 6 + ], + "name": "C", + "nameLocation": "68:1:0", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 4, + "nodeType": "Block", + "src": "97:2:0", + "statements": [] + }, + "functionSelector": "26121ff0", + "id": 5, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "81:1:0", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 2, + "nodeType": "ParameterList", + "parameters": [], + "src": "82:2:0" + }, + "returnParameters": { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "97:0:0" + }, + "scope": 6, + "src": "72:27:0", + "stateMutability": "pure", + "virtual": false, + "visibility": "public" + } + ], + "scope": 7, + "src": "59:42:0", + "usedErrors": [] + } + ], + "src": "36:65:0" + }, + "id": 0 + } + }, + "settings": { + "outputSelection": { + "*": { + "": [ + "ast" + ] + } + } + } +} diff --git a/test/cmdlineTests/standard_import_with_comments/output.json b/test/cmdlineTests/standard_import_with_comments/output.json new file mode 100644 index 000000000000..d54da1750bc8 --- /dev/null +++ b/test/cmdlineTests/standard_import_with_comments/output.json @@ -0,0 +1,85 @@ +{ + "sources": { + "A": { + "ast": { + "absolutePath": "A", + "exportedSymbols": { + "C": [ + 6 + ] + }, + "id": 7, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + ">=", + "0.0" + ], + "nodeType": "PragmaDirective", + "src": "36:22:0" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 6, + "linearizedBaseContracts": [ + 6 + ], + "name": "C", + "nameLocation": "68:1:0", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 4, + "nodeType": "Block", + "src": "97:2:0", + "statements": [] + }, + "functionSelector": "26121ff0", + "id": 5, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "81:1:0", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 2, + "nodeType": "ParameterList", + "parameters": [], + "src": "82:2:0" + }, + "returnParameters": { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "97:0:0" + }, + "scope": 6, + "src": "72:27:0", + "stateMutability": "pure", + "virtual": false, + "visibility": "public" + } + ], + "scope": 7, + "src": "59:42:0", + "usedErrors": [], + "usedEvents": [] + } + ], + "src": "36:65:0" + }, + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_import_with_comments_simple/input.json b/test/cmdlineTests/standard_import_with_comments_simple/input.json new file mode 100644 index 000000000000..21faca8c624e --- /dev/null +++ b/test/cmdlineTests/standard_import_with_comments_simple/input.json @@ -0,0 +1,85 @@ +{ + "language": "SolidityAST", + "sources": { + // this is a comment + "A": { + "ast": { + "absolutePath": "A", + "exportedSymbols": { + "C": [6 /* and this another comment */] + }, + "id": 7, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": ["solidity", ">=", "0.0"], + "nodeType": "PragmaDirective", + "src": "36:22:0" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 6, + "linearizedBaseContracts": [6], + "name": "C", + "nameLocation": "68:1:0", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 4, + "nodeType": "Block", + "src": "97:2:0", + "statements": [] + }, + "functionSelector": "26121ff0", + "id": 5, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "81:1:0", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 2, + "nodeType": "ParameterList", + "parameters": [], + "src": "82:2:0" + }, + "returnParameters": { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "97:0:0" + }, + "scope": 6, + "src": "72:27:0", + "stateMutability": "pure", + "virtual": false, + "visibility": "public" + } + ], + "scope": 7, + "src": "59:42:0", + "usedErrors": [] + } + ], + "src": "36:65:0" + }, + "id": 0 + } + }, + "settings": { + "outputSelection": { + "*": { + "": ["ast"] + } + } + } +} diff --git a/test/cmdlineTests/standard_import_with_comments_simple/output.json b/test/cmdlineTests/standard_import_with_comments_simple/output.json new file mode 100644 index 000000000000..d54da1750bc8 --- /dev/null +++ b/test/cmdlineTests/standard_import_with_comments_simple/output.json @@ -0,0 +1,85 @@ +{ + "sources": { + "A": { + "ast": { + "absolutePath": "A", + "exportedSymbols": { + "C": [ + 6 + ] + }, + "id": 7, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + ">=", + "0.0" + ], + "nodeType": "PragmaDirective", + "src": "36:22:0" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 6, + "linearizedBaseContracts": [ + 6 + ], + "name": "C", + "nameLocation": "68:1:0", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 4, + "nodeType": "Block", + "src": "97:2:0", + "statements": [] + }, + "functionSelector": "26121ff0", + "id": 5, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "81:1:0", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 2, + "nodeType": "ParameterList", + "parameters": [], + "src": "82:2:0" + }, + "returnParameters": { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "97:0:0" + }, + "scope": 6, + "src": "72:27:0", + "stateMutability": "pure", + "virtual": false, + "visibility": "public" + } + ], + "scope": 7, + "src": "59:42:0", + "usedErrors": [], + "usedEvents": [] + } + ], + "src": "36:65:0" + }, + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_import_with_invalid_utf8/input.json b/test/cmdlineTests/standard_import_with_invalid_utf8/input.json new file mode 100644 index 000000000000..7b54aebfbb66 --- /dev/null +++ b/test/cmdlineTests/standard_import_with_invalid_utf8/input.json @@ -0,0 +1,29 @@ +{ + "language": "EVMAssembly", + "sources": { + "A": { + "assemblyJson": { + ".code": [ + { + "begin": 36, + "end": 51, + "name": "PUSH", + "source": 0, + "value": "\ud800" + } + ], + "sourceList": [ + "" + ] + } + } + }, + "settings": { + "outputSelection": { + "*": { + "": [ + ] + } + } + } +} diff --git a/test/cmdlineTests/standard_import_with_invalid_utf8/output.json b/test/cmdlineTests/standard_import_with_invalid_utf8/output.json new file mode 100644 index 000000000000..e168f8797b06 --- /dev/null +++ b/test/cmdlineTests/standard_import_with_invalid_utf8/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "parse error at line 12, column 23: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\ud800\"'", + "message": "parse error at line 12, column 23: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\ud800\"'", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_irOptimized_ast_requested/output.json b/test/cmdlineTests/standard_irOptimized_ast_requested/output.json index 200b653ff443..91d0e87f3619 100644 --- a/test/cmdlineTests/standard_irOptimized_ast_requested/output.json +++ b/test/cmdlineTests/standard_irOptimized_ast_requested/output.json @@ -1,32 +1,22 @@ { - "contracts": - { - "C": - { - "C": - { - "irOptimizedAst": - { - "code": - { - "block": - { + "contracts": { + "C": { + "C": { + "irOptimizedAst": { + "code": { + "block": { "nativeSrc": "44:790:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { "nativeSrc": "44:790:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "103:2:0", @@ -36,8 +26,7 @@ "value": "64" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "119:3:0", @@ -47,8 +36,7 @@ "value": "0x80" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "107:11:0", "nodeType": "YulIdentifier", @@ -59,8 +47,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "96:6:0", "nodeType": "YulIdentifier", @@ -75,19 +62,15 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "148:83:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb", "nativeSrc": "150:77:0", "nodeType": "YulIdentifier", @@ -103,11 +86,9 @@ } ] }, - "condition": - { + "condition": { "arguments": [], - "functionName": - { + "functionName": { "name": "callvalue", "nativeSrc": "136:9:0", "nodeType": "YulIdentifier", @@ -125,11 +106,9 @@ "nativeSrc": "268:30:0", "nodeType": "YulVariableDeclaration", "src": "56:13:0", - "value": - { + "value": { "arguments": [], - "functionName": - { + "functionName": { "name": "allocate_unbounded", "nativeSrc": "278:18:0", "nodeType": "YulIdentifier", @@ -139,8 +118,7 @@ "nodeType": "YulFunctionCall", "src": "56:13:0" }, - "variables": - [ + "variables": [ { "name": "_1", "nativeSrc": "272:2:0", @@ -151,10 +129,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "316:2:0", @@ -162,8 +138,7 @@ "src": "56:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -174,8 +149,7 @@ "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "dataoffset", "nativeSrc": "320:10:0", "nodeType": "YulIdentifier", @@ -186,8 +160,7 @@ "src": "56:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -198,8 +171,7 @@ "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "348:8:0", "nodeType": "YulIdentifier", @@ -210,8 +182,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "codecopy", "nativeSrc": "307:8:0", "nodeType": "YulIdentifier", @@ -226,10 +197,8 @@ "src": "56:13:0" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "390:2:0", @@ -237,8 +206,7 @@ "src": "56:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -249,8 +217,7 @@ "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "394:8:0", "nodeType": "YulIdentifier", @@ -261,8 +228,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "return", "nativeSrc": "383:6:0", "nodeType": "YulIdentifier", @@ -279,21 +245,17 @@ ] }, { - "body": - { + "body": { "nativeSrc": "469:43:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "483:19:0", "nodeType": "YulAssignment", "src": "56:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "499:2:0", @@ -303,8 +265,7 @@ "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "493:5:0", "nodeType": "YulIdentifier", @@ -314,8 +275,7 @@ "nodeType": "YulFunctionCall", "src": "56:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "483:6:0", @@ -329,8 +289,7 @@ "name": "allocate_unbounded", "nativeSrc": "429:83:0", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "462:6:0", @@ -342,18 +301,14 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "611:36:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "632:1:0", @@ -371,8 +326,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "625:6:0", "nodeType": "YulIdentifier", @@ -399,29 +353,22 @@ }, "name": "C_2", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "899:588:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { "nativeSrc": "899:588:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "966:2:0", @@ -431,8 +378,7 @@ "value": "64" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "982:3:0", @@ -442,8 +388,7 @@ "value": "0x80" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "970:11:0", "nodeType": "YulIdentifier", @@ -454,8 +399,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "959:6:0", "nodeType": "YulIdentifier", @@ -470,11 +414,9 @@ "src": "56:13:0" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74", "nativeSrc": "1001:77:0", "nodeType": "YulIdentifier", @@ -491,18 +433,14 @@ ] }, { - "body": - { + "body": { "nativeSrc": "1432:44:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1457:1:0", @@ -520,8 +458,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "1450:6:0", "nodeType": "YulIdentifier", @@ -548,8 +485,7 @@ }, "name": "C_2_deployed", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { "nodeType": "YulData", "value": "" @@ -561,10 +497,8 @@ } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_irOptimized_requested/output.json b/test/cmdlineTests/standard_irOptimized_requested/output.json index 88ce6489578e..849b436b24a5 100644 --- a/test/cmdlineTests/standard_irOptimized_requested/output.json +++ b/test/cmdlineTests/standard_irOptimized_requested/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "irOptimized": "/// @use-src 0:\"A\" object \"C_7\" { code { @@ -77,10 +74,8 @@ object \"C_7\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_ir_ast_requested/output.json b/test/cmdlineTests/standard_ir_ast_requested/output.json index f949d7b30cb2..b2e1c0c7dd39 100644 --- a/test/cmdlineTests/standard_ir_ast_requested/output.json +++ b/test/cmdlineTests/standard_ir_ast_requested/output.json @@ -1,26 +1,17 @@ { - "contracts": - { - "C": - { - "C": - { - "irAst": - { - "code": - { - "block": - { + "contracts": { + "C": { + "C": { + "irAst": { + "code": { + "block": { "nativeSrc": "44:790:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "103:2:0", @@ -30,8 +21,7 @@ "value": "64" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "119:3:0", @@ -41,8 +31,7 @@ "value": "128" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "107:11:0", "nodeType": "YulIdentifier", @@ -53,8 +42,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "96:6:0", "nodeType": "YulIdentifier", @@ -69,19 +57,15 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "148:83:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb", "nativeSrc": "150:77:0", "nodeType": "YulIdentifier", @@ -97,11 +81,9 @@ } ] }, - "condition": - { + "condition": { "arguments": [], - "functionName": - { + "functionName": { "name": "callvalue", "nativeSrc": "136:9:0", "nodeType": "YulIdentifier", @@ -116,11 +98,9 @@ "src": "56:13:0" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "constructor_C_2", "nativeSrc": "241:15:0", "nodeType": "YulIdentifier", @@ -138,11 +118,9 @@ "nativeSrc": "268:30:0", "nodeType": "YulVariableDeclaration", "src": "56:13:0", - "value": - { + "value": { "arguments": [], - "functionName": - { + "functionName": { "name": "allocate_unbounded", "nativeSrc": "278:18:0", "nodeType": "YulIdentifier", @@ -152,8 +130,7 @@ "nodeType": "YulFunctionCall", "src": "56:13:0" }, - "variables": - [ + "variables": [ { "name": "_1", "nativeSrc": "272:2:0", @@ -164,10 +141,8 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "316:2:0", @@ -175,8 +150,7 @@ "src": "56:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -187,8 +161,7 @@ "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "dataoffset", "nativeSrc": "320:10:0", "nodeType": "YulIdentifier", @@ -199,8 +172,7 @@ "src": "56:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -211,8 +183,7 @@ "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "348:8:0", "nodeType": "YulIdentifier", @@ -223,8 +194,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "codecopy", "nativeSrc": "307:8:0", "nodeType": "YulIdentifier", @@ -239,10 +209,8 @@ "src": "56:13:0" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "_1", "nativeSrc": "390:2:0", @@ -250,8 +218,7 @@ "src": "56:13:0" }, { - "arguments": - [ + "arguments": [ { "hexValue": "435f325f6465706c6f796564", "kind": "string", @@ -262,8 +229,7 @@ "value": "C_2_deployed" } ], - "functionName": - { + "functionName": { "name": "datasize", "nativeSrc": "394:8:0", "nodeType": "YulIdentifier", @@ -274,8 +240,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "return", "nativeSrc": "383:6:0", "nodeType": "YulIdentifier", @@ -290,21 +255,17 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "469:43:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "483:19:0", "nodeType": "YulAssignment", "src": "56:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "499:2:0", @@ -314,8 +275,7 @@ "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "493:5:0", "nodeType": "YulIdentifier", @@ -325,8 +285,7 @@ "nodeType": "YulFunctionCall", "src": "56:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "483:6:0", @@ -340,8 +299,7 @@ "name": "allocate_unbounded", "nativeSrc": "429:83:0", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "462:6:0", @@ -353,18 +311,14 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "611:36:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "632:1:0", @@ -382,8 +336,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "625:6:0", "nodeType": "YulIdentifier", @@ -405,8 +358,7 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "726:59:0", "nodeType": "YulBlock", "src": "56:13:0", @@ -423,23 +375,17 @@ }, "name": "C_2", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "899:588:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "966:2:0", @@ -449,8 +395,7 @@ "value": "64" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "982:3:0", @@ -460,8 +405,7 @@ "value": "128" } ], - "functionName": - { + "functionName": { "name": "memoryguard", "nativeSrc": "970:11:0", "nodeType": "YulIdentifier", @@ -472,8 +416,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "959:6:0", "nodeType": "YulIdentifier", @@ -488,11 +431,9 @@ "src": "56:13:0" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74", "nativeSrc": "1001:77:0", "nodeType": "YulIdentifier", @@ -507,21 +448,17 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "1147:77:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "1165:44:0", "nodeType": "YulAssignment", "src": "56:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "1198:3:0", @@ -537,8 +474,7 @@ "src": "56:13:0" } ], - "functionName": - { + "functionName": { "name": "shr", "nativeSrc": "1194:3:0", "nodeType": "YulIdentifier", @@ -548,8 +484,7 @@ "nodeType": "YulFunctionCall", "src": "56:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "newValue", "nativeSrc": "1165:8:0", @@ -563,8 +498,7 @@ "name": "shift_right_224_unsigned", "nativeSrc": "1094:130:0", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "value", "nativeSrc": "1128:5:0", @@ -573,8 +507,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "newValue", "nativeSrc": "1138:8:0", @@ -586,21 +519,17 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "1278:51:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { "nativeSrc": "1296:19:0", "nodeType": "YulAssignment", "src": "56:13:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "1312:2:0", @@ -610,8 +539,7 @@ "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "1306:5:0", "nodeType": "YulIdentifier", @@ -621,8 +549,7 @@ "nodeType": "YulFunctionCall", "src": "56:13:0" }, - "variableNames": - [ + "variableNames": [ { "name": "memPtr", "nativeSrc": "1296:6:0", @@ -636,8 +563,7 @@ "name": "allocate_unbounded", "nativeSrc": "1238:91:0", "nodeType": "YulFunctionDefinition", - "returnVariables": - [ + "returnVariables": [ { "name": "memPtr", "nativeSrc": "1271:6:0", @@ -649,18 +575,14 @@ "src": "56:13:0" }, { - "body": - { + "body": { "nativeSrc": "1432:44:0", "nodeType": "YulBlock", "src": "56:13:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "1457:1:0", @@ -678,8 +600,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "1450:6:0", "nodeType": "YulIdentifier", @@ -706,8 +627,7 @@ }, "name": "C_2_deployed", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { "nodeType": "YulData", "value": "" @@ -719,10 +639,8 @@ } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_ir_requested/output.json b/test/cmdlineTests/standard_ir_requested/output.json index ab38f0a58921..e359d5ca550f 100644 --- a/test/cmdlineTests/standard_ir_requested/output.json +++ b/test/cmdlineTests/standard_ir_requested/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "ir": " /// @use-src 0:\"A\" object \"C_7\" { @@ -122,10 +119,8 @@ object \"C_7\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_metadata/output.json b/test/cmdlineTests/standard_metadata/output.json index 955d30c34475..5b9c8504f386 100644 --- a/test/cmdlineTests/standard_metadata/output.json +++ b/test/cmdlineTests/standard_metadata/output.json @@ -1,18 +1,13 @@ { - "contracts": - { - "C": - { - "C": - { + "contracts": { + "C": { + "C": { "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"C\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"C\":{\"keccak256\":\"0x5cf617b1707a484e3c4bd59643013dec76ab7d75900b46855214729ae3e0ceb0\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://ac418a02dfadf87234150d3568f33269e3f49460345cb39300e017a6d755eff2\",\"dweb:/ipfs/QmQq3owBu25x2WV46HB1WyKzJpxiAPecU7eMKqtXCF7eeS\"]}},\"version\":1}" } } }, - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_method_identifiers_requested/output.json b/test/cmdlineTests/standard_method_identifiers_requested/output.json index 35d4f5002508..df1e81f732cf 100644 --- a/test/cmdlineTests/standard_method_identifiers_requested/output.json +++ b/test/cmdlineTests/standard_method_identifiers_requested/output.json @@ -1,24 +1,17 @@ { - "contracts": - { - "A": - { - "C": - { - "evm": - { - "methodIdentifiers": - { + "contracts": { + "A": { + "C": { + "evm": { + "methodIdentifiers": { "f()": "26121ff0" } } } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_method_identifiers_requested_empty/output.json b/test/cmdlineTests/standard_method_identifiers_requested_empty/output.json index f90a33351b35..1d3245c20487 100644 --- a/test/cmdlineTests/standard_method_identifiers_requested_empty/output.json +++ b/test/cmdlineTests/standard_method_identifiers_requested_empty/output.json @@ -1,21 +1,15 @@ { - "contracts": - { - "A": - { - "C": - { - "evm": - { + "contracts": { + "A": { + "C": { + "evm": { "methodIdentifiers": {} } } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json b/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json index f3a09c9e7bfb..d18ad81fa715 100644 --- a/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json +++ b/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Support for EVM versions older than constantinople is deprecated and will be removed in the future.", @@ -9,10 +8,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_bmc_loop_iterations/output.json b/test/cmdlineTests/standard_model_checker_bmc_loop_iterations/output.json index 139b0825bc47..ffaa2823bfe4 100644 --- a/test/cmdlineTests/standard_model_checker_bmc_loop_iterations/output.json +++ b/test/cmdlineTests/standard_model_checker_bmc_loop_iterations/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6002", @@ -12,10 +11,8 @@ "type": "Info" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_bmc_loop_iterations_invalid_arg/output.json b/test/cmdlineTests/standard_model_checker_bmc_loop_iterations_invalid_arg/output.json index 971973d85c0c..05b835e56922 100644 --- a/test/cmdlineTests/standard_model_checker_bmc_loop_iterations_invalid_arg/output.json +++ b/test/cmdlineTests/standard_model_checker_bmc_loop_iterations_invalid_arg/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.bmcLoopIterations must be an unsigned integer.", diff --git a/test/cmdlineTests/standard_model_checker_contracts_all/output.json b/test/cmdlineTests/standard_model_checker_contracts_all/output.json index b4bfd66b8489..e9fc1b4cf6b5 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_all/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_all/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: B.constructor() B.g(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 137, "file": "Source", "start": 124 @@ -61,8 +59,7 @@ Transaction trace: A.constructor() A.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 231, "file": "Source", "start": 218 @@ -70,10 +67,8 @@ A.f(0)", "type": "Warning" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_contracts_all_explicit/output.json b/test/cmdlineTests/standard_model_checker_contracts_all_explicit/output.json index b4bfd66b8489..e9fc1b4cf6b5 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_all_explicit/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_all_explicit/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: B.constructor() B.g(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 137, "file": "Source", "start": 124 @@ -61,8 +59,7 @@ Transaction trace: A.constructor() A.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 231, "file": "Source", "start": 218 @@ -70,10 +67,8 @@ A.f(0)", "type": "Warning" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_contracts_empty_array/output.json b/test/cmdlineTests/standard_model_checker_contracts_empty_array/output.json index ada440ad3880..fe1bdb97dda3 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_empty_array/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_empty_array/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Source contracts must be a non-empty array.", diff --git a/test/cmdlineTests/standard_model_checker_contracts_empty_contract/output.json b/test/cmdlineTests/standard_model_checker_contracts_empty_contract/output.json index c3b171e99e4f..e31326ff861e 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_empty_contract/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_empty_contract/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Contract name cannot be empty.", diff --git a/test/cmdlineTests/standard_model_checker_contracts_empty_source/output.json b/test/cmdlineTests/standard_model_checker_contracts_empty_source/output.json index 98dcc1afadfb..b4495bb2223c 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_empty_source/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_empty_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Source name cannot be empty.", diff --git a/test/cmdlineTests/standard_model_checker_contracts_inexistent_contract/output.json b/test/cmdlineTests/standard_model_checker_contracts_inexistent_contract/output.json index 7ff30950c1ba..22d5f32de32b 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_inexistent_contract/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_inexistent_contract/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7400", @@ -37,8 +36,7 @@ Transaction trace: B.constructor() B.g(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 137, "file": "Source", "start": 124 @@ -71,8 +69,7 @@ Transaction trace: A.constructor() A.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 231, "file": "Source", "start": 218 @@ -80,10 +77,8 @@ A.f(0)", "type": "Warning" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_contracts_multi_source/output.json b/test/cmdlineTests/standard_model_checker_contracts_multi_source/output.json index cb18875e1bf4..fe287f833637 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_multi_source/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_multi_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: B.constructor() B.g(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 137, "file": "Source", "start": 124 @@ -61,8 +59,7 @@ Transaction trace: A.constructor() A.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 231, "file": "Source", "start": 218 @@ -95,8 +92,7 @@ Transaction trace: C.constructor() C.h(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 165, "file": "Source2", "start": 150 @@ -104,14 +100,11 @@ C.h(0)", "type": "Warning" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 }, - "Source2": - { + "Source2": { "id": 1 } } diff --git a/test/cmdlineTests/standard_model_checker_contracts_only_one/output.json b/test/cmdlineTests/standard_model_checker_contracts_only_one/output.json index b4bfd66b8489..e9fc1b4cf6b5 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_only_one/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_only_one/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: B.constructor() B.g(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 137, "file": "Source", "start": 124 @@ -61,8 +59,7 @@ Transaction trace: A.constructor() A.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 231, "file": "Source", "start": 218 @@ -70,10 +67,8 @@ A.f(0)", "type": "Warning" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources/output.json b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources/output.json index d38ad1b599ef..b792b6d93bea 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "9134", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "Source": - { + "sources": { + "Source": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_2/output.json b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_2/output.json index 98365d1bf8a6..05bab373313b 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_2/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_2/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.contracts is not a JSON object.", diff --git a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_3/output.json b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_3/output.json index 567db80afe4e..d07d645f4ae2 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_3/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_3/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Source contracts must be an array.", diff --git a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_4/output.json b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_4/output.json index 30d4c2dcf098..90790a859e8d 100644 --- a/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_4/output.json +++ b/test/cmdlineTests/standard_model_checker_contracts_wrong_key_sources_4/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Every contract in settings.modelChecker.contracts must be a string.", diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_default_all/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_default_all/output.json index b8637143b07c..82ee5a107717 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_default_all/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_default_all/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1391", @@ -12,10 +11,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_default_bmc/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_default_bmc/output.json index a6ce9b3c96f9..dfba5336499a 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_default_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_default_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6002", @@ -12,10 +11,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_default_chc/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_default_chc/output.json index b8637143b07c..82ee5a107717 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_default_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_default_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1391", @@ -12,10 +11,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_false_all/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_false_all/output.json index f7ecf690d82a..eefa60785bb2 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_false_all/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_false_all/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1218", @@ -13,8 +12,7 @@ ", "message": "CHC: Error trying to invoke SMT solver.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 182, "file": "A", "start": 177 @@ -33,8 +31,7 @@ ", "message": "CHC: Error trying to invoke SMT solver.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 189, "file": "A", "start": 184 @@ -62,10 +59,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_false_bmc/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_false_bmc/output.json index a6ce9b3c96f9..dfba5336499a 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_false_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_false_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6002", @@ -12,10 +11,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_false_chc/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_false_chc/output.json index fccd15838fc8..16fb77513081 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_false_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_false_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1218", @@ -13,8 +12,7 @@ ", "message": "CHC: Error trying to invoke SMT solver.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 182, "file": "A", "start": 177 @@ -33,8 +31,7 @@ ", "message": "CHC: Error trying to invoke SMT solver.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 189, "file": "A", "start": 184 @@ -52,10 +49,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_divModSlacks_wrong/output.json b/test/cmdlineTests/standard_model_checker_divModSlacks_wrong/output.json index 457fb1ba0cc8..dae639c6410a 100644 --- a/test/cmdlineTests/standard_model_checker_divModSlacks_wrong/output.json +++ b/test/cmdlineTests/standard_model_checker_divModSlacks_wrong/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.divModNoSlacks must be a Boolean.", diff --git a/test/cmdlineTests/standard_model_checker_engine_all/output.json b/test/cmdlineTests/standard_model_checker_engine_all/output.json index 2a2c394fdd72..be51d6b2e518 100644 --- a/test/cmdlineTests/standard_model_checker_engine_all/output.json +++ b/test/cmdlineTests/standard_model_checker_engine_all/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: C.constructor() C.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 119, "file": "A", "start": 106 @@ -36,10 +34,8 @@ C.f(0)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_engine_bmc/output.json b/test/cmdlineTests/standard_model_checker_engine_bmc/output.json index 75e679ef473d..4727ea083585 100644 --- a/test/cmdlineTests/standard_model_checker_engine_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_engine_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4661", @@ -17,8 +16,7 @@ Note: ", "message": "BMC: Assertion violation happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: x = 0 @@ -32,8 +30,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 119, "file": "A", "start": 106 @@ -41,10 +38,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_engine_chc/output.json b/test/cmdlineTests/standard_model_checker_engine_chc/output.json index 2a2c394fdd72..be51d6b2e518 100644 --- a/test/cmdlineTests/standard_model_checker_engine_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_engine_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: C.constructor() C.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 119, "file": "A", "start": 106 @@ -36,10 +34,8 @@ C.f(0)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_engine_none/output.json b/test/cmdlineTests/standard_model_checker_engine_none/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_model_checker_engine_none/output.json +++ b/test/cmdlineTests/standard_model_checker_engine_none/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_ext_calls_empty_arg/output.json b/test/cmdlineTests/standard_model_checker_ext_calls_empty_arg/output.json index 4e214a37b2db..34d69504d5bd 100644 --- a/test/cmdlineTests/standard_model_checker_ext_calls_empty_arg/output.json +++ b/test/cmdlineTests/standard_model_checker_ext_calls_empty_arg/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid model checker extCalls requested.", diff --git a/test/cmdlineTests/standard_model_checker_ext_calls_trusted_chc/output.json b/test/cmdlineTests/standard_model_checker_ext_calls_trusted_chc/output.json index 7f3993410144..16bfff9b7736 100644 --- a/test/cmdlineTests/standard_model_checker_ext_calls_trusted_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_ext_calls_trusted_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 152, "file": "A", "start": 85 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_ext_calls_untrusted_chc/output.json b/test/cmdlineTests/standard_model_checker_ext_calls_untrusted_chc/output.json index c6b072a85863..858d225e67f9 100644 --- a/test/cmdlineTests/standard_model_checker_ext_calls_untrusted_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_ext_calls_untrusted_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -31,8 +30,7 @@ test.constructor() test.g(0) e.f() -- untrusted external call", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 254, "file": "A", "start": 240 @@ -40,10 +38,8 @@ test.g(0) "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_1/output.json b/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_1/output.json index 4e214a37b2db..34d69504d5bd 100644 --- a/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_1/output.json +++ b/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_1/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid model checker extCalls requested.", diff --git a/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_2/output.json b/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_2/output.json index e869637ed125..5daa6a447ad7 100644 --- a/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_2/output.json +++ b/test/cmdlineTests/standard_model_checker_ext_calls_wrong_arg_2/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.extCalls must be a string.", diff --git a/test/cmdlineTests/standard_model_checker_invariants_contract/output.json b/test/cmdlineTests/standard_model_checker_invariants_contract/output.json index 314b66aae4ae..f3cd0758c0ea 100644 --- a/test/cmdlineTests/standard_model_checker_invariants_contract/output.json +++ b/test/cmdlineTests/standard_model_checker_invariants_contract/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1391", @@ -26,10 +25,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_invariants_contract_reentrancy/output.json b/test/cmdlineTests/standard_model_checker_invariants_contract_reentrancy/output.json index 5a83ba7ac752..d46fdda8a917 100644 --- a/test/cmdlineTests/standard_model_checker_invariants_contract_reentrancy/output.json +++ b/test/cmdlineTests/standard_model_checker_invariants_contract_reentrancy/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "9302", @@ -13,8 +12,7 @@ ", "message": "Return value of low-level calls not used.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 143, "file": "A", "start": 132 @@ -51,8 +49,7 @@ State: x = 0 test.f(0x0) _a.call(\"\") -- untrusted external call", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 166, "file": "A", "start": 151 @@ -60,10 +57,8 @@ test.f(0x0) "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_invariants_reentrancy/output.json b/test/cmdlineTests/standard_model_checker_invariants_reentrancy/output.json index feb586a3e32b..bf6b296cdfa3 100644 --- a/test/cmdlineTests/standard_model_checker_invariants_reentrancy/output.json +++ b/test/cmdlineTests/standard_model_checker_invariants_reentrancy/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "9302", @@ -13,8 +12,7 @@ ", "message": "Return value of low-level calls not used.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 143, "file": "A", "start": 132 @@ -50,10 +48,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_invariants_wrong_key/output.json b/test/cmdlineTests/standard_model_checker_invariants_wrong_key/output.json index 45fcfbe984ce..06b42cb6f418 100644 --- a/test/cmdlineTests/standard_model_checker_invariants_wrong_key/output.json +++ b/test/cmdlineTests/standard_model_checker_invariants_wrong_key/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid model checker invariants requested.", diff --git a/test/cmdlineTests/standard_model_checker_invariants_wrong_type/output.json b/test/cmdlineTests/standard_model_checker_invariants_wrong_type/output.json index d1992e464d6e..c59605d2cd3a 100644 --- a/test/cmdlineTests/standard_model_checker_invariants_wrong_type/output.json +++ b/test/cmdlineTests/standard_model_checker_invariants_wrong_type/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Every invariant type in settings.modelChecker.invariants must be a string.", diff --git a/test/cmdlineTests/standard_model_checker_invariants_wrong_type_2/output.json b/test/cmdlineTests/standard_model_checker_invariants_wrong_type_2/output.json index 078edfc1d8e3..eaa736025cab 100644 --- a/test/cmdlineTests/standard_model_checker_invariants_wrong_type_2/output.json +++ b/test/cmdlineTests/standard_model_checker_invariants_wrong_type_2/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.invariants must be an array.", diff --git a/test/cmdlineTests/standard_model_checker_print_query_all/output.json b/test/cmdlineTests/standard_model_checker_print_query_all/output.json index b8e11ced7301..16ff42e0c306 100644 --- a/test/cmdlineTests/standard_model_checker_print_query_all/output.json +++ b/test/cmdlineTests/standard_model_checker_print_query_all/output.json @@ -1,8 +1,6 @@ { - "auxiliaryInputRequested": - { - "smtlib2queries": - { + "auxiliaryInputRequested": { + "smtlib2queries": { "0x1880095c52d8681601c6821e4a5c29740649509af99947bce54102546dd3376a": "(set-option :timeout 1000) (set-logic HORN) (declare-datatypes ((|bytes_tuple| 0)) (((|bytes_tuple| (|bytes_tuple_accessor_array| (Array Int Int)) (|bytes_tuple_accessor_length| Int))))) @@ -159,8 +157,7 @@ " } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2339", @@ -530,10 +527,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_print_query_bmc/output.json b/test/cmdlineTests/standard_model_checker_print_query_bmc/output.json index f7b4dc7e2871..1c9826ad22e0 100644 --- a/test/cmdlineTests/standard_model_checker_print_query_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_print_query_bmc/output.json @@ -1,8 +1,6 @@ { - "auxiliaryInputRequested": - { - "smtlib2queries": - { + "auxiliaryInputRequested": { + "smtlib2queries": { "0x8704a7b848b706ef33cbfc06e4f185636f568a29621126b7244355dd0de956bb": "(set-option :produce-models true) (set-logic ALL) (declare-fun |error_0| () Int) @@ -32,8 +30,7 @@ " } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6240", @@ -119,10 +116,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_print_query_chc/output.json b/test/cmdlineTests/standard_model_checker_print_query_chc/output.json index 9ef925b205a2..a9b0df0fb687 100644 --- a/test/cmdlineTests/standard_model_checker_print_query_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_print_query_chc/output.json @@ -1,8 +1,6 @@ { - "auxiliaryInputRequested": - { - "smtlib2queries": - { + "auxiliaryInputRequested": { + "smtlib2queries": { "0x1880095c52d8681601c6821e4a5c29740649509af99947bce54102546dd3376a": "(set-option :timeout 1000) (set-logic HORN) (declare-datatypes ((|bytes_tuple| 0)) (((|bytes_tuple| (|bytes_tuple_accessor_array| (Array Int Int)) (|bytes_tuple_accessor_length| Int))))) @@ -129,8 +127,7 @@ " } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2339", @@ -410,10 +407,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_print_query_invalid_arg/output.json b/test/cmdlineTests/standard_model_checker_print_query_invalid_arg/output.json index 00c389f7a433..a9f44c912fa5 100644 --- a/test/cmdlineTests/standard_model_checker_print_query_invalid_arg/output.json +++ b/test/cmdlineTests/standard_model_checker_print_query_invalid_arg/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.printQuery must be a Boolean value.", diff --git a/test/cmdlineTests/standard_model_checker_print_query_no_smtlib2_solver/output.json b/test/cmdlineTests/standard_model_checker_print_query_no_smtlib2_solver/output.json index 42d4b5b2db8a..d675499f91db 100644 --- a/test/cmdlineTests/standard_model_checker_print_query_no_smtlib2_solver/output.json +++ b/test/cmdlineTests/standard_model_checker_print_query_no_smtlib2_solver/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Only SMTLib2 solver can be enabled to print queries", diff --git a/test/cmdlineTests/standard_model_checker_print_query_superflous_solver/output.json b/test/cmdlineTests/standard_model_checker_print_query_superflous_solver/output.json index 42d4b5b2db8a..d675499f91db 100644 --- a/test/cmdlineTests/standard_model_checker_print_query_superflous_solver/output.json +++ b/test/cmdlineTests/standard_model_checker_print_query_superflous_solver/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Only SMTLib2 solver can be enabled to print queries", diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_default_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_default_all_engines/output.json index b8118ba16a5d..4c57da4607c0 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_default_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_default_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_default_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_default_bmc/output.json index eb6ed6e27705..6d9dbb4092b2 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_default_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_default_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_default_chc/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_default_chc/output.json index b8118ba16a5d..4c57da4607c0 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_default_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_default_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_false_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_false_all_engines/output.json index b8118ba16a5d..4c57da4607c0 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_false_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_false_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_false_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_false_bmc/output.json index eb6ed6e27705..6d9dbb4092b2 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_false_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_false_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_false_chc/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_false_chc/output.json index b8118ba16a5d..4c57da4607c0 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_false_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_false_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -32,10 +30,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_true_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_true_all_engines/output.json index 8482298559ec..22f863b12c64 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_true_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_true_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -33,8 +31,7 @@ ", "message": "CHC: Assertion violation check is safe!", "severity": "info", - "sourceLocation": - { + "sourceLocation": { "end": 130, "file": "A", "start": 116 @@ -53,8 +50,7 @@ ", "message": "CHC: Assertion violation check is safe!", "severity": "info", - "sourceLocation": - { + "sourceLocation": { "end": 154, "file": "A", "start": 138 @@ -62,10 +58,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_true_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_true_bmc/output.json index 20ddce1fd542..2788a64a8ac9 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_true_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_true_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -33,8 +31,7 @@ ", "message": "BMC: Assertion violation check is safe!", "severity": "info", - "sourceLocation": - { + "sourceLocation": { "end": 130, "file": "A", "start": 116 @@ -53,8 +50,7 @@ ", "message": "BMC: Assertion violation check is safe!", "severity": "info", - "sourceLocation": - { + "sourceLocation": { "end": 154, "file": "A", "start": 138 @@ -62,10 +58,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_true_chc/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_true_chc/output.json index 8482298559ec..22f863b12c64 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_true_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_true_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2018", @@ -13,8 +12,7 @@ ", "message": "Function state mutability can be restricted to pure", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 162, "file": "A", "start": 81 @@ -33,8 +31,7 @@ ", "message": "CHC: Assertion violation check is safe!", "severity": "info", - "sourceLocation": - { + "sourceLocation": { "end": 130, "file": "A", "start": 116 @@ -53,8 +50,7 @@ ", "message": "CHC: Assertion violation check is safe!", "severity": "info", - "sourceLocation": - { + "sourceLocation": { "end": 154, "file": "A", "start": 138 @@ -62,10 +58,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_proved_safe_wrong/output.json b/test/cmdlineTests/standard_model_checker_show_proved_safe_wrong/output.json index 7c8ccff6e2e5..b5811ff03505 100644 --- a/test/cmdlineTests/standard_model_checker_show_proved_safe_wrong/output.json +++ b/test/cmdlineTests/standard_model_checker_show_proved_safe_wrong/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.showProvedSafe must be a Boolean value.", diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_default_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_default_all_engines/output.json index fb599d21d2e4..da3b3dcad888 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_default_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_default_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5840", @@ -22,10 +21,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_false_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_false_all_engines/output.json index fb599d21d2e4..da3b3dcad888 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_false_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_false_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5840", @@ -22,10 +21,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_false_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_false_bmc/output.json index 4554ec69e93a..67f8df731994 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_false_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_false_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2788", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_false_chc/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_false_chc/output.json index 7f0e676cb818..66cdf505c609 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_false_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_false_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5840", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_true_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_true_all_engines/output.json index ecb157f88fbc..b6153de5ebe5 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_true_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_true_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -13,8 +12,7 @@ ", "message": "CHC: Assertion violation might happen here.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 201, "file": "A", "start": 186 @@ -33,15 +31,13 @@ Note: ", "message": "BMC: Assertion violation might happen here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "" } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 201, "file": "A", "start": 186 @@ -49,10 +45,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_true_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_true_bmc/output.json index 116af8dce28c..6c3b57c79553 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_true_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_true_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7812", @@ -13,15 +12,13 @@ Note: ", "message": "BMC: Assertion violation might happen here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "" } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 201, "file": "A", "start": 186 @@ -29,10 +26,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_true_chc/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_true_chc/output.json index 58956287fd52..78efcad94963 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_true_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_true_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -13,8 +12,7 @@ ", "message": "CHC: Assertion violation might happen here.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 201, "file": "A", "start": 186 @@ -22,10 +20,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unproved_wrong/output.json b/test/cmdlineTests/standard_model_checker_show_unproved_wrong/output.json index a9342cddfbb7..49b97bab572c 100644 --- a/test/cmdlineTests/standard_model_checker_show_unproved_wrong/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unproved_wrong/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.showUnproved must be a Boolean value.", diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_default_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_default_all_engines/output.json index 23cf80defb86..b8f8515b8b4a 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_default_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_default_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5724", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_default_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_default_bmc/output.json index 23cf80defb86..b8f8515b8b4a 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_default_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_default_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5724", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_default_chc/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_default_chc/output.json index 23cf80defb86..b8f8515b8b4a 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_default_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_default_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5724", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_false_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_false_all_engines/output.json index 23cf80defb86..b8f8515b8b4a 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_false_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_false_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5724", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_false_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_false_bmc/output.json index 23cf80defb86..b8f8515b8b4a 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_false_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_false_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5724", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_false_chc/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_false_chc/output.json index 23cf80defb86..b8f8515b8b4a 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_false_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_false_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5724", @@ -12,10 +11,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_true_all_engines/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_true_all_engines/output.json index 13d327d40547..e9eb877ea055 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_true_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_true_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7737", @@ -13,8 +12,7 @@ ", "message": "Inline assembly may cause SMTChecker to produce spurious warnings (false positives).", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 127, "file": "A", "start": 116 @@ -22,10 +20,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_true_bmc/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_true_bmc/output.json index 13d327d40547..e9eb877ea055 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_true_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_true_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7737", @@ -13,8 +12,7 @@ ", "message": "Inline assembly may cause SMTChecker to produce spurious warnings (false positives).", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 127, "file": "A", "start": 116 @@ -22,10 +20,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_true_chc/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_true_chc/output.json index 13d327d40547..e9eb877ea055 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_true_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_true_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7737", @@ -13,8 +12,7 @@ ", "message": "Inline assembly may cause SMTChecker to produce spurious warnings (false positives).", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 127, "file": "A", "start": 116 @@ -22,10 +20,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_show_unsupported_wrong/output.json b/test/cmdlineTests/standard_model_checker_show_unsupported_wrong/output.json index 997b005ef7ee..068c3a872b7e 100644 --- a/test/cmdlineTests/standard_model_checker_show_unsupported_wrong/output.json +++ b/test/cmdlineTests/standard_model_checker_show_unsupported_wrong/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.showUnsupported must be a Boolean value.", diff --git a/test/cmdlineTests/standard_model_checker_solvers_none/output.json b/test/cmdlineTests/standard_model_checker_solvers_none/output.json index e5d356ce5a9d..e8de49d1ede3 100644 --- a/test/cmdlineTests/standard_model_checker_solvers_none/output.json +++ b/test/cmdlineTests/standard_model_checker_solvers_none/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7649", @@ -22,10 +21,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_solvers_smtlib2/output.json b/test/cmdlineTests/standard_model_checker_solvers_smtlib2/output.json index ebeca53f5ba3..d3bdc6b7eb28 100644 --- a/test/cmdlineTests/standard_model_checker_solvers_smtlib2/output.json +++ b/test/cmdlineTests/standard_model_checker_solvers_smtlib2/output.json @@ -1,8 +1,6 @@ { - "auxiliaryInputRequested": - { - "smtlib2queries": - { + "auxiliaryInputRequested": { + "smtlib2queries": { "0x75b95497d56c30e254a59358d72ddd4e78f9e90db621cfe677e85d05b2252411": "(set-option :produce-models true) (set-logic ALL) (declare-fun |x_3_3| () Int) @@ -155,8 +153,7 @@ " } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5840", @@ -198,10 +195,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_solvers_z3/output.json b/test/cmdlineTests/standard_model_checker_solvers_z3/output.json index 2a2c394fdd72..be51d6b2e518 100644 --- a/test/cmdlineTests/standard_model_checker_solvers_z3/output.json +++ b/test/cmdlineTests/standard_model_checker_solvers_z3/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: C.constructor() C.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 119, "file": "A", "start": 106 @@ -36,10 +34,8 @@ C.f(0)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_solvers_z3_smtlib2/output.json b/test/cmdlineTests/standard_model_checker_solvers_z3_smtlib2/output.json index 2a2c394fdd72..be51d6b2e518 100644 --- a/test/cmdlineTests/standard_model_checker_solvers_z3_smtlib2/output.json +++ b/test/cmdlineTests/standard_model_checker_solvers_z3_smtlib2/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -27,8 +26,7 @@ Transaction trace: C.constructor() C.f(0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 119, "file": "A", "start": 106 @@ -36,10 +34,8 @@ C.f(0)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_assert_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_assert_bmc/output.json index 18452ccbc985..9e90ec538d35 100644 --- a/test/cmdlineTests/standard_model_checker_targets_assert_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_assert_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4661", @@ -18,8 +17,7 @@ Note: ", "message": "BMC: Assertion violation happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: a = 0 @@ -34,8 +32,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -43,10 +40,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_assert_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_assert_chc/output.json index 5c43fe6b54d8..bf4fa6626933 100644 --- a/test/cmdlineTests/standard_model_checker_targets_assert_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_assert_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6328", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -40,10 +38,8 @@ test.f(0x0, 1)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_balance_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_balance_bmc/output.json index 9ee51daba1fb..6c2c90c9888b 100644 --- a/test/cmdlineTests/standard_model_checker_targets_balance_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_balance_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1236", @@ -18,8 +17,7 @@ Note: ", "message": "BMC: Insufficient funds happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: a = 0 @@ -34,8 +32,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 237, "file": "A", "start": 224 @@ -43,10 +40,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_balance_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_balance_chc/output.json index acf3b74ef1de..9d3e40b708f1 100644 --- a/test/cmdlineTests/standard_model_checker_targets_balance_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_balance_chc/output.json @@ -1,8 +1,18 @@ { - "sources": - { - "A": + "errors": [ { + "component": "general", + "errorCode": "1391", + "formattedMessage": "Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them. + +", + "message": "CHC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them.", + "severity": "info", + "type": "Info" + } + ], + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_constantCondition_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_constantCondition_bmc/output.json index 94ba81c2bea4..9bfdf0b02111 100644 --- a/test/cmdlineTests/standard_model_checker_targets_constantCondition_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_constantCondition_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6838", @@ -13,15 +12,13 @@ Note: Callstack: ", "message": "BMC: Condition is always true.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Callstack:" } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 165, "file": "A", "start": 159 @@ -29,10 +26,8 @@ Note: Callstack: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_constantCondition_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_constantCondition_chc/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_model_checker_targets_constantCondition_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_constantCondition_chc/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_default_all_engines/output.json b/test/cmdlineTests/standard_model_checker_targets_default_all_engines/output.json index 4c967fa5d0ae..8f20d854bfb5 100644 --- a/test/cmdlineTests/standard_model_checker_targets_default_all_engines/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_default_all_engines/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4281", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 216, "file": "A", "start": 211 @@ -69,8 +67,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -107,8 +104,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 275, "file": "A", "start": 266 @@ -145,14 +141,23 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 289, "file": "A", "start": 283 }, "type": "Warning" }, + { + "component": "general", + "errorCode": "1391", + "formattedMessage": "Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them. + +", + "message": "CHC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them.", + "severity": "info", + "type": "Info" + }, { "component": "general", "errorCode": "6838", @@ -165,67 +170,22 @@ Note: Callstack: ", "message": "BMC: Condition is always true.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Callstack:" } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 165, "file": "A", "start": 159 }, "type": "Warning" - }, - { - "component": "general", - "errorCode": "1236", - "formattedMessage": "Warning: BMC: Insufficient funds happens here. - --> A:11:7: - | -11 | \t\t\t\t\t\ta.transfer(x); - | \t\t\t\t\t\t^^^^^^^^^^^^^ -Note: Counterexample: - a = 0 - x = 0 - -Note: Callstack: -Note: - -", - "message": "BMC: Insufficient funds happens here.", - "secondarySourceLocations": - [ - { - "message": "Counterexample: - a = 0 - x = 0 -" - }, - { - "message": "Callstack:" - }, - { - "message": "" - } - ], - "severity": "warning", - "sourceLocation": - { - "end": 237, - "file": "A", - "start": 224 - }, - "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_default_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_default_bmc/output.json index 1be99ca4556c..e055d38d2e53 100644 --- a/test/cmdlineTests/standard_model_checker_targets_default_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_default_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6838", @@ -13,15 +12,13 @@ Note: Callstack: ", "message": "BMC: Condition is always true.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Callstack:" } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 165, "file": "A", "start": 159 @@ -46,8 +43,7 @@ Note: ", "message": "BMC: Division by zero happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = 0 @@ -63,8 +59,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 216, "file": "A", "start": 211 @@ -88,8 +83,7 @@ Note: ", "message": "BMC: Insufficient funds happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: a = 0 @@ -104,8 +98,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 237, "file": "A", "start": 224 @@ -129,8 +122,7 @@ Note: ", "message": "BMC: Assertion violation happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: a = 0 @@ -145,8 +137,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -154,10 +145,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_default_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_default_chc/output.json index c3df366c990d..e045a8bff49a 100644 --- a/test/cmdlineTests/standard_model_checker_targets_default_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_default_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4281", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 216, "file": "A", "start": 211 @@ -69,8 +67,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -107,8 +104,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 275, "file": "A", "start": 266 @@ -145,19 +141,26 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 289, "file": "A", "start": 283 }, "type": "Warning" + }, + { + "component": "general", + "errorCode": "1391", + "formattedMessage": "Info: CHC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them. + +", + "message": "CHC: 1 verification condition(s) proved safe! Enable the model checker option \"show proved safe\" to see all of them.", + "severity": "info", + "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_div_by_zero_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_div_by_zero_bmc/output.json index 05ce12ca2c2b..6ba0e6f82057 100644 --- a/test/cmdlineTests/standard_model_checker_targets_div_by_zero_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_div_by_zero_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3046", @@ -19,8 +18,7 @@ Note: ", "message": "BMC: Division by zero happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = 0 @@ -36,8 +34,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 216, "file": "A", "start": 211 @@ -45,10 +42,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_div_by_zero_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_div_by_zero_chc/output.json index 5c09175e7297..0789c79996fe 100644 --- a/test/cmdlineTests/standard_model_checker_targets_div_by_zero_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_div_by_zero_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4281", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 216, "file": "A", "start": 211 @@ -40,10 +38,8 @@ test.f(0x0, 1)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_empty_array/output.json b/test/cmdlineTests/standard_model_checker_targets_empty_array/output.json index 312af9741c32..6b5c6e0689da 100644 --- a/test/cmdlineTests/standard_model_checker_targets_empty_array/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_empty_array/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.targets must be a non-empty array.", diff --git a/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_bmc/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_bmc/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_chc/output.json index b87480e74b4c..f5f49fb508e7 100644 --- a/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_out_of_bounds_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6368", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 289, "file": "A", "start": 283 @@ -40,10 +38,8 @@ test.f(0x0, 1)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_overflow_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_overflow_bmc/output.json index 09c1cdb5f10a..8d34765cdb14 100644 --- a/test/cmdlineTests/standard_model_checker_targets_overflow_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_overflow_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2661", @@ -19,8 +18,7 @@ Note: ", "message": "BMC: Overflow (resulting value larger than 2**256 - 1) happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = 2**256 @@ -36,8 +34,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 203, "file": "A", "start": 185 @@ -45,10 +42,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_overflow_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_overflow_chc/output.json index b700a938ed14..9beb30a35b7c 100644 --- a/test/cmdlineTests/standard_model_checker_targets_overflow_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_overflow_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4984", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 2)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 203, "file": "A", "start": 185 @@ -40,10 +38,8 @@ test.f(0x0, 2)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_pop_empty_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_pop_empty_bmc/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_model_checker_targets_pop_empty_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_pop_empty_bmc/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_pop_empty_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_pop_empty_chc/output.json index c670bb4f6088..4cccf8456df4 100644 --- a/test/cmdlineTests/standard_model_checker_targets_pop_empty_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_pop_empty_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2529", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 275, "file": "A", "start": 266 @@ -40,10 +38,8 @@ test.f(0x0, 1)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_underflow_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_underflow_bmc/output.json index c656eda21a9c..df17886b2fea 100644 --- a/test/cmdlineTests/standard_model_checker_targets_underflow_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_underflow_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4144", @@ -19,8 +18,7 @@ Note: ", "message": "BMC: Underflow (resulting value less than 0) happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = (- 1) @@ -36,8 +34,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 177, "file": "A", "start": 174 @@ -45,10 +42,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_underflow_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_underflow_chc/output.json index 600d7fe6b842..442f2f47a981 100644 --- a/test/cmdlineTests/standard_model_checker_targets_underflow_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_underflow_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3944", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 177, "file": "A", "start": 174 @@ -40,10 +38,8 @@ test.f(0x0, 0)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_bmc/output.json index 004b98128e2c..c80d3e22a8e2 100644 --- a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4144", @@ -19,8 +18,7 @@ Note: ", "message": "BMC: Underflow (resulting value less than 0) happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = (- 1) @@ -36,8 +34,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 177, "file": "A", "start": 174 @@ -62,8 +59,7 @@ Note: ", "message": "BMC: Overflow (resulting value larger than 2**256 - 1) happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = 2**256 @@ -79,8 +75,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 203, "file": "A", "start": 185 @@ -104,8 +99,7 @@ Note: ", "message": "BMC: Assertion violation happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: a = 0 @@ -120,8 +114,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -129,10 +122,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_chc/output.json index 5afeeaa9407e..e5719640aad3 100644 --- a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_assert_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3944", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 177, "file": "A", "start": 174 @@ -69,8 +67,7 @@ test.constructor() State: arr = [] test.f(0x0, 2)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 203, "file": "A", "start": 185 @@ -107,8 +104,7 @@ test.constructor() State: arr = [] test.f(0x0, 1)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "A", "start": 245 @@ -116,10 +112,8 @@ test.f(0x0, 1)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_bmc/output.json b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_bmc/output.json index 8a9452a7b83d..de02d57c90ab 100644 --- a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "4144", @@ -19,8 +18,7 @@ Note: ", "message": "BMC: Underflow (resulting value less than 0) happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = (- 1) @@ -36,8 +34,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 177, "file": "A", "start": 174 @@ -62,8 +59,7 @@ Note: ", "message": "BMC: Overflow (resulting value larger than 2**256 - 1) happens here.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "message": "Counterexample: = 2**256 @@ -79,8 +75,7 @@ Note: } ], "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 203, "file": "A", "start": 185 @@ -88,10 +83,8 @@ Note: "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_chc/output.json b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_chc/output.json index 9a07b669ad3b..6fb8762e4312 100644 --- a/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_underflow_overflow_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3944", @@ -31,8 +30,7 @@ test.constructor() State: arr = [] test.f(0x0, 0)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 177, "file": "A", "start": 174 @@ -69,8 +67,7 @@ test.constructor() State: arr = [] test.f(0x0, 2)", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 203, "file": "A", "start": 185 @@ -78,10 +75,8 @@ test.f(0x0, 2)", "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_targets_wrong_target_types/output.json b/test/cmdlineTests/standard_model_checker_targets_wrong_target_types/output.json index 6e2af863ec69..fee6f21958a1 100644 --- a/test/cmdlineTests/standard_model_checker_targets_wrong_target_types/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_wrong_target_types/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Every target in settings.modelChecker.targets must be a string.", diff --git a/test/cmdlineTests/standard_model_checker_targets_wrong_target_types_2/output.json b/test/cmdlineTests/standard_model_checker_targets_wrong_target_types_2/output.json index c1e7759b5c10..996d75e70916 100644 --- a/test/cmdlineTests/standard_model_checker_targets_wrong_target_types_2/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_wrong_target_types_2/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.targets must be an array.", diff --git a/test/cmdlineTests/standard_model_checker_targets_wrong_targets/output.json b/test/cmdlineTests/standard_model_checker_targets_wrong_targets/output.json index d0bf7f56daba..e51a85258117 100644 --- a/test/cmdlineTests/standard_model_checker_targets_wrong_targets/output.json +++ b/test/cmdlineTests/standard_model_checker_targets_wrong_targets/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid model checker targets requested.", diff --git a/test/cmdlineTests/standard_model_checker_timeout_all/output.json b/test/cmdlineTests/standard_model_checker_timeout_all/output.json index 73b117145445..2da324f33ae6 100644 --- a/test/cmdlineTests/standard_model_checker_timeout_all/output.json +++ b/test/cmdlineTests/standard_model_checker_timeout_all/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5840", @@ -32,10 +31,8 @@ "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_timeout_bmc/output.json b/test/cmdlineTests/standard_model_checker_timeout_bmc/output.json index a709ec062c79..f813782d74d1 100644 --- a/test/cmdlineTests/standard_model_checker_timeout_bmc/output.json +++ b/test/cmdlineTests/standard_model_checker_timeout_bmc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2788", @@ -22,10 +21,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_timeout_chc/output.json b/test/cmdlineTests/standard_model_checker_timeout_chc/output.json index 553a1b93b62b..1ff515e25ee4 100644 --- a/test/cmdlineTests/standard_model_checker_timeout_chc/output.json +++ b/test/cmdlineTests/standard_model_checker_timeout_chc/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "5840", @@ -22,10 +21,8 @@ "type": "Info" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_model_checker_timeout_wrong_key/output.json b/test/cmdlineTests/standard_model_checker_timeout_wrong_key/output.json index 137562f4196b..afa05c3a8d58 100644 --- a/test/cmdlineTests/standard_model_checker_timeout_wrong_key/output.json +++ b/test/cmdlineTests/standard_model_checker_timeout_wrong_key/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"atimeout\"", diff --git a/test/cmdlineTests/standard_model_checker_timeout_wrong_value/output.json b/test/cmdlineTests/standard_model_checker_timeout_wrong_value/output.json index ce630905c6c8..7fbdfbbe82a3 100644 --- a/test/cmdlineTests/standard_model_checker_timeout_wrong_value/output.json +++ b/test/cmdlineTests/standard_model_checker_timeout_wrong_value/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "settings.modelChecker.timeout must be an unsigned integer.", diff --git a/test/cmdlineTests/standard_no_append_cbor/output.json b/test/cmdlineTests/standard_no_append_cbor/output.json index 0fca3f2715a3..c060efd971a7 100644 --- a/test/cmdlineTests/standard_no_append_cbor/output.json +++ b/test/cmdlineTests/standard_no_append_cbor/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A": - { - "test": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "test": { + "evm": { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -20,10 +15,8 @@ } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_no_append_cbor_with_metadata_hash/output.json b/test/cmdlineTests/standard_no_append_cbor_with_metadata_hash/output.json index 0c264f898a87..a31841944eda 100644 --- a/test/cmdlineTests/standard_no_append_cbor_with_metadata_hash/output.json +++ b/test/cmdlineTests/standard_no_append_cbor_with_metadata_hash/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"ipfs\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\".", diff --git a/test/cmdlineTests/standard_no_import_callback/output.json b/test/cmdlineTests/standard_no_import_callback/output.json index a4e2d8d3a2bf..3c16f1caa7cf 100644 --- a/test/cmdlineTests/standard_no_import_callback/output.json +++ b/test/cmdlineTests/standard_no_import_callback/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "6275", @@ -13,8 +12,7 @@ ", "message": "Source \"standard_no_import_callback/B.sol\" not found: No import callback.", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 102, "file": "A", "start": 59 diff --git a/test/cmdlineTests/standard_non_utf8_filename/input.json b/test/cmdlineTests/standard_non_utf8_filename/input.json new file mode 100644 index 000000000000..b0f7d595768a --- /dev/null +++ b/test/cmdlineTests/standard_non_utf8_filename/input.json @@ -0,0 +1,17 @@ +{ + "language": "Solidity", + "sources": + { + "": + { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; pragma abicoder v2; contract C { function f() public pure {} }" + } + }, + "settings": + { + "outputSelection": + { + "*": { "*": ["ir"] } + } + } +} diff --git a/test/cmdlineTests/standard_non_utf8_filename/output.json b/test/cmdlineTests/standard_non_utf8_filename/output.json new file mode 100644 index 000000000000..5dc1b6f1b678 --- /dev/null +++ b/test/cmdlineTests/standard_non_utf8_filename/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "parse error at line 5, column 4: syntax error while parsing object key - invalid string: ill-formed UTF-8 byte; last read: '\"\\xff'; expected string literal", + "message": "parse error at line 5, column 4: syntax error while parsing object key - invalid string: ill-formed UTF-8 byte; last read: '\"\\xff'; expected string literal", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_non_utf8_filename2/input.json b/test/cmdlineTests/standard_non_utf8_filename2/input.json new file mode 100644 index 000000000000..7310c1472397 --- /dev/null +++ b/test/cmdlineTests/standard_non_utf8_filename2/input.json @@ -0,0 +1,17 @@ +{ + "language": "Solidity", + "sources": + { + "": + { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; pragma abicoder v2; contract C { function f() public pure {} }" + } + }, + "settings": + { + "outputSelection": + { + "*": { "*": ["ir"] } + } + } +} diff --git a/test/cmdlineTests/standard_non_utf8_filename2/output.json b/test/cmdlineTests/standard_non_utf8_filename2/output.json new file mode 100644 index 000000000000..5dc1b6f1b678 --- /dev/null +++ b/test/cmdlineTests/standard_non_utf8_filename2/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "parse error at line 5, column 4: syntax error while parsing object key - invalid string: ill-formed UTF-8 byte; last read: '\"\\xff'; expected string literal", + "message": "parse error at line 5, column 4: syntax error while parsing object key - invalid string: ill-formed UTF-8 byte; last read: '\"\\xff'; expected string literal", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_only_ast_requested/output.json b/test/cmdlineTests/standard_only_ast_requested/output.json index 6ecac5ca364d..d54da1750bc8 100644 --- a/test/cmdlineTests/standard_only_ast_requested/output.json +++ b/test/cmdlineTests/standard_only_ast_requested/output.json @@ -1,27 +1,20 @@ { - "sources": - { - "A": - { - "ast": - { + "sources": { + "A": { + "ast": { "absolutePath": "A", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" @@ -37,18 +30,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "68:1:0", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "97:2:0", @@ -62,15 +52,13 @@ "name": "f", "nameLocation": "81:1:0", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], "src": "82:2:0" }, - "returnParameters": - { + "returnParameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], diff --git a/test/cmdlineTests/standard_optimizer_generatedSources/output.json b/test/cmdlineTests/standard_optimizer_generatedSources/output.json index da2c31cbee25..e5b276b1b9b6 100644 --- a/test/cmdlineTests/standard_optimizer_generatedSources/output.json +++ b/test/cmdlineTests/standard_optimizer_generatedSources/output.json @@ -1,29 +1,20 @@ { - "contracts": - { - "a.sol": - { - "A": - { - "evm": - { - "bytecode": - { + "contracts": { + "a.sol": { + "A": { + "evm": { + "bytecode": { "generatedSources": [], "object": "" }, - "deployedBytecode": - { - "generatedSources": - [ + "deployedBytecode": { + "generatedSources": [ { - "ast": - { - "nativeSrc": "0:1445:1", + "ast": { + "nativeSrc": "0:1505:1", "nodeType": "YulBlock", - "src": "0:1445:1", - "statements": - [ + "src": "0:1505:1", + "statements": [ { "nativeSrc": "6:3:1", "nodeType": "YulBlock", @@ -31,18 +22,14 @@ "statements": [] }, { - "body": - { + "body": { "nativeSrc": "46:95:1", "nodeType": "YulBlock", "src": "46:95:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "63:1:1", @@ -52,8 +39,7 @@ "value": "0" }, { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "70:3:1", @@ -71,8 +57,7 @@ "value": "0x4e487b71" } ], - "functionName": - { + "functionName": { "name": "shl", "nativeSrc": "66:3:1", "nodeType": "YulIdentifier", @@ -83,8 +68,7 @@ "src": "66:20:1" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "56:6:1", "nodeType": "YulIdentifier", @@ -99,10 +83,8 @@ "src": "56:31:1" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "103:1:1", @@ -120,8 +102,7 @@ "value": "0x41" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "96:6:1", "nodeType": "YulIdentifier", @@ -136,10 +117,8 @@ "src": "96:15:1" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "127:1:1", @@ -157,8 +136,7 @@ "value": "0x24" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "120:6:1", "nodeType": "YulIdentifier", @@ -180,1362 +158,1239 @@ "src": "14:127:1" }, { - "body": - { - "nativeSrc": "241:1020:1", + "body": { + "nativeSrc": "241:1080:1", "nodeType": "YulBlock", - "src": "241:1020:1", - "statements": - [ + "src": "241:1080:1", + "statements": [ { - "nativeSrc": "251:12:1", - "nodeType": "YulVariableDeclaration", - "src": "251:12:1", - "value": - { - "kind": "number", - "nativeSrc": "261:2:1", - "nodeType": "YulLiteral", - "src": "261:2:1", - "type": "", - "value": "32" - }, - "variables": - [ - { - "name": "_1", - "nativeSrc": "255:2:1", - "nodeType": "YulTypedName", - "src": "255:2:1", - "type": "" - } - ] - }, - { - "body": - { - "nativeSrc": "308:16:1", + "body": { + "nativeSrc": "287:16:1", "nodeType": "YulBlock", - "src": "308:16:1", - "statements": - [ + "src": "287:16:1", + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", - "nativeSrc": "317:1:1", + "nativeSrc": "296:1:1", "nodeType": "YulLiteral", - "src": "317:1:1", + "src": "296:1:1", "type": "", "value": "0" }, { "kind": "number", - "nativeSrc": "320:1:1", + "nativeSrc": "299:1:1", "nodeType": "YulLiteral", - "src": "320:1:1", + "src": "299:1:1", "type": "", "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", - "nativeSrc": "310:6:1", + "nativeSrc": "289:6:1", "nodeType": "YulIdentifier", - "src": "310:6:1" + "src": "289:6:1" }, - "nativeSrc": "310:12:1", + "nativeSrc": "289:12:1", "nodeType": "YulFunctionCall", - "src": "310:12:1" + "src": "289:12:1" }, - "nativeSrc": "310:12:1", + "nativeSrc": "289:12:1", "nodeType": "YulExpressionStatement", - "src": "310:12:1" + "src": "289:12:1" } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "dataEnd", - "nativeSrc": "283:7:1", + "nativeSrc": "262:7:1", "nodeType": "YulIdentifier", - "src": "283:7:1" + "src": "262:7:1" }, { "name": "headStart", - "nativeSrc": "292:9:1", + "nativeSrc": "271:9:1", "nodeType": "YulIdentifier", - "src": "292:9:1" + "src": "271:9:1" } ], - "functionName": - { + "functionName": { "name": "sub", - "nativeSrc": "279:3:1", + "nativeSrc": "258:3:1", "nodeType": "YulIdentifier", - "src": "279:3:1" + "src": "258:3:1" }, - "nativeSrc": "279:23:1", + "nativeSrc": "258:23:1", "nodeType": "YulFunctionCall", - "src": "279:23:1" + "src": "258:23:1" }, { - "name": "_1", - "nativeSrc": "304:2:1", - "nodeType": "YulIdentifier", - "src": "304:2:1" + "kind": "number", + "nativeSrc": "283:2:1", + "nodeType": "YulLiteral", + "src": "283:2:1", + "type": "", + "value": "32" } ], - "functionName": - { + "functionName": { "name": "slt", - "nativeSrc": "275:3:1", + "nativeSrc": "254:3:1", "nodeType": "YulIdentifier", - "src": "275:3:1" + "src": "254:3:1" }, - "nativeSrc": "275:32:1", + "nativeSrc": "254:32:1", "nodeType": "YulFunctionCall", - "src": "275:32:1" + "src": "254:32:1" }, - "nativeSrc": "272:52:1", + "nativeSrc": "251:52:1", "nodeType": "YulIf", - "src": "272:52:1" + "src": "251:52:1" }, { - "nativeSrc": "333:37:1", + "nativeSrc": "312:37:1", "nodeType": "YulVariableDeclaration", - "src": "333:37:1", - "value": - { - "arguments": - [ + "src": "312:37:1", + "value": { + "arguments": [ { "name": "headStart", - "nativeSrc": "360:9:1", + "nativeSrc": "339:9:1", "nodeType": "YulIdentifier", - "src": "360:9:1" + "src": "339:9:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", - "nativeSrc": "347:12:1", + "nativeSrc": "326:12:1", "nodeType": "YulIdentifier", - "src": "347:12:1" + "src": "326:12:1" }, - "nativeSrc": "347:23:1", + "nativeSrc": "326:23:1", "nodeType": "YulFunctionCall", - "src": "347:23:1" + "src": "326:23:1" }, - "variables": - [ + "variables": [ { "name": "offset", - "nativeSrc": "337:6:1", - "nodeType": "YulTypedName", - "src": "337:6:1", - "type": "" - } - ] - }, - { - "nativeSrc": "379:28:1", - "nodeType": "YulVariableDeclaration", - "src": "379:28:1", - "value": - { - "kind": "number", - "nativeSrc": "389:18:1", - "nodeType": "YulLiteral", - "src": "389:18:1", - "type": "", - "value": "0xffffffffffffffff" - }, - "variables": - [ - { - "name": "_2", - "nativeSrc": "383:2:1", + "nativeSrc": "316:6:1", "nodeType": "YulTypedName", - "src": "383:2:1", + "src": "316:6:1", "type": "" } ] }, { - "body": - { - "nativeSrc": "434:16:1", + "body": { + "nativeSrc": "392:16:1", "nodeType": "YulBlock", - "src": "434:16:1", - "statements": - [ + "src": "392:16:1", + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", - "nativeSrc": "443:1:1", + "nativeSrc": "401:1:1", "nodeType": "YulLiteral", - "src": "443:1:1", + "src": "401:1:1", "type": "", "value": "0" }, { "kind": "number", - "nativeSrc": "446:1:1", + "nativeSrc": "404:1:1", "nodeType": "YulLiteral", - "src": "446:1:1", + "src": "404:1:1", "type": "", "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", - "nativeSrc": "436:6:1", + "nativeSrc": "394:6:1", "nodeType": "YulIdentifier", - "src": "436:6:1" + "src": "394:6:1" }, - "nativeSrc": "436:12:1", + "nativeSrc": "394:12:1", "nodeType": "YulFunctionCall", - "src": "436:12:1" + "src": "394:12:1" }, - "nativeSrc": "436:12:1", + "nativeSrc": "394:12:1", "nodeType": "YulExpressionStatement", - "src": "436:12:1" + "src": "394:12:1" } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "offset", - "nativeSrc": "422:6:1", + "nativeSrc": "364:6:1", "nodeType": "YulIdentifier", - "src": "422:6:1" + "src": "364:6:1" }, { - "name": "_2", - "nativeSrc": "430:2:1", - "nodeType": "YulIdentifier", - "src": "430:2:1" + "kind": "number", + "nativeSrc": "372:18:1", + "nodeType": "YulLiteral", + "src": "372:18:1", + "type": "", + "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", - "nativeSrc": "419:2:1", + "nativeSrc": "361:2:1", "nodeType": "YulIdentifier", - "src": "419:2:1" + "src": "361:2:1" }, - "nativeSrc": "419:14:1", + "nativeSrc": "361:30:1", "nodeType": "YulFunctionCall", - "src": "419:14:1" + "src": "361:30:1" }, - "nativeSrc": "416:34:1", + "nativeSrc": "358:50:1", "nodeType": "YulIf", - "src": "416:34:1" + "src": "358:50:1" }, { - "nativeSrc": "459:32:1", + "nativeSrc": "417:32:1", "nodeType": "YulVariableDeclaration", - "src": "459:32:1", - "value": - { - "arguments": - [ + "src": "417:32:1", + "value": { + "arguments": [ { "name": "headStart", - "nativeSrc": "473:9:1", + "nativeSrc": "431:9:1", "nodeType": "YulIdentifier", - "src": "473:9:1" + "src": "431:9:1" }, { "name": "offset", - "nativeSrc": "484:6:1", + "nativeSrc": "442:6:1", "nodeType": "YulIdentifier", - "src": "484:6:1" + "src": "442:6:1" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "469:3:1", + "nativeSrc": "427:3:1", "nodeType": "YulIdentifier", - "src": "469:3:1" + "src": "427:3:1" }, - "nativeSrc": "469:22:1", + "nativeSrc": "427:22:1", "nodeType": "YulFunctionCall", - "src": "469:22:1" + "src": "427:22:1" }, - "variables": - [ + "variables": [ { - "name": "_3", - "nativeSrc": "463:2:1", + "name": "_1", + "nativeSrc": "421:2:1", "nodeType": "YulTypedName", - "src": "463:2:1", + "src": "421:2:1", "type": "" } ] }, { - "body": - { - "nativeSrc": "539:16:1", + "body": { + "nativeSrc": "497:16:1", "nodeType": "YulBlock", - "src": "539:16:1", - "statements": - [ + "src": "497:16:1", + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", - "nativeSrc": "548:1:1", + "nativeSrc": "506:1:1", "nodeType": "YulLiteral", - "src": "548:1:1", + "src": "506:1:1", "type": "", "value": "0" }, { "kind": "number", - "nativeSrc": "551:1:1", + "nativeSrc": "509:1:1", "nodeType": "YulLiteral", - "src": "551:1:1", + "src": "509:1:1", "type": "", "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", - "nativeSrc": "541:6:1", + "nativeSrc": "499:6:1", "nodeType": "YulIdentifier", - "src": "541:6:1" + "src": "499:6:1" }, - "nativeSrc": "541:12:1", + "nativeSrc": "499:12:1", "nodeType": "YulFunctionCall", - "src": "541:12:1" + "src": "499:12:1" }, - "nativeSrc": "541:12:1", + "nativeSrc": "499:12:1", "nodeType": "YulExpressionStatement", - "src": "541:12:1" + "src": "499:12:1" } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { - "arguments": - [ + "arguments": [ { - "name": "_3", - "nativeSrc": "518:2:1", + "name": "_1", + "nativeSrc": "476:2:1", "nodeType": "YulIdentifier", - "src": "518:2:1" + "src": "476:2:1" }, { "kind": "number", - "nativeSrc": "522:4:1", + "nativeSrc": "480:4:1", "nodeType": "YulLiteral", - "src": "522:4:1", + "src": "480:4:1", "type": "", "value": "0x1f" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "514:3:1", + "nativeSrc": "472:3:1", "nodeType": "YulIdentifier", - "src": "514:3:1" + "src": "472:3:1" }, - "nativeSrc": "514:13:1", + "nativeSrc": "472:13:1", "nodeType": "YulFunctionCall", - "src": "514:13:1" + "src": "472:13:1" }, { "name": "dataEnd", - "nativeSrc": "529:7:1", + "nativeSrc": "487:7:1", "nodeType": "YulIdentifier", - "src": "529:7:1" + "src": "487:7:1" } ], - "functionName": - { + "functionName": { "name": "slt", - "nativeSrc": "510:3:1", + "nativeSrc": "468:3:1", "nodeType": "YulIdentifier", - "src": "510:3:1" + "src": "468:3:1" }, - "nativeSrc": "510:27:1", + "nativeSrc": "468:27:1", "nodeType": "YulFunctionCall", - "src": "510:27:1" + "src": "468:27:1" } ], - "functionName": - { + "functionName": { "name": "iszero", - "nativeSrc": "503:6:1", + "nativeSrc": "461:6:1", "nodeType": "YulIdentifier", - "src": "503:6:1" + "src": "461:6:1" }, - "nativeSrc": "503:35:1", + "nativeSrc": "461:35:1", "nodeType": "YulFunctionCall", - "src": "503:35:1" + "src": "461:35:1" }, - "nativeSrc": "500:55:1", + "nativeSrc": "458:55:1", "nodeType": "YulIf", - "src": "500:55:1" + "src": "458:55:1" }, { - "nativeSrc": "564:26:1", + "nativeSrc": "522:30:1", "nodeType": "YulVariableDeclaration", - "src": "564:26:1", - "value": - { - "arguments": - [ + "src": "522:30:1", + "value": { + "arguments": [ { - "name": "_3", - "nativeSrc": "587:2:1", + "name": "_1", + "nativeSrc": "549:2:1", "nodeType": "YulIdentifier", - "src": "587:2:1" + "src": "549:2:1" } ], - "functionName": - { + "functionName": { "name": "calldataload", - "nativeSrc": "574:12:1", + "nativeSrc": "536:12:1", "nodeType": "YulIdentifier", - "src": "574:12:1" + "src": "536:12:1" }, - "nativeSrc": "574:16:1", + "nativeSrc": "536:16:1", "nodeType": "YulFunctionCall", - "src": "574:16:1" + "src": "536:16:1" }, - "variables": - [ + "variables": [ { - "name": "_4", - "nativeSrc": "568:2:1", + "name": "length", + "nativeSrc": "526:6:1", "nodeType": "YulTypedName", - "src": "568:2:1", + "src": "526:6:1", "type": "" } ] }, { - "body": - { - "nativeSrc": "613:22:1", + "body": { + "nativeSrc": "595:22:1", "nodeType": "YulBlock", - "src": "613:22:1", - "statements": - [ + "src": "595:22:1", + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "panic_error_0x41", - "nativeSrc": "615:16:1", + "nativeSrc": "597:16:1", "nodeType": "YulIdentifier", - "src": "615:16:1" + "src": "597:16:1" }, - "nativeSrc": "615:18:1", + "nativeSrc": "597:18:1", "nodeType": "YulFunctionCall", - "src": "615:18:1" + "src": "597:18:1" }, - "nativeSrc": "615:18:1", + "nativeSrc": "597:18:1", "nodeType": "YulExpressionStatement", - "src": "615:18:1" + "src": "597:18:1" } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "name": "_4", - "nativeSrc": "605:2:1", + "name": "length", + "nativeSrc": "567:6:1", "nodeType": "YulIdentifier", - "src": "605:2:1" + "src": "567:6:1" }, { - "name": "_2", - "nativeSrc": "609:2:1", - "nodeType": "YulIdentifier", - "src": "609:2:1" + "kind": "number", + "nativeSrc": "575:18:1", + "nodeType": "YulLiteral", + "src": "575:18:1", + "type": "", + "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", - "nativeSrc": "602:2:1", + "nativeSrc": "564:2:1", "nodeType": "YulIdentifier", - "src": "602:2:1" + "src": "564:2:1" }, - "nativeSrc": "602:10:1", + "nativeSrc": "564:30:1", "nodeType": "YulFunctionCall", - "src": "602:10:1" + "src": "564:30:1" }, - "nativeSrc": "599:36:1", + "nativeSrc": "561:56:1", "nodeType": "YulIf", - "src": "599:36:1" + "src": "561:56:1" }, { - "nativeSrc": "644:20:1", + "nativeSrc": "626:24:1", "nodeType": "YulVariableDeclaration", - "src": "644:20:1", - "value": - { - "arguments": - [ + "src": "626:24:1", + "value": { + "arguments": [ { "kind": "number", - "nativeSrc": "658:1:1", + "nativeSrc": "640:1:1", "nodeType": "YulLiteral", - "src": "658:1:1", + "src": "640:1:1", "type": "", "value": "5" }, { - "name": "_4", - "nativeSrc": "661:2:1", + "name": "length", + "nativeSrc": "643:6:1", "nodeType": "YulIdentifier", - "src": "661:2:1" + "src": "643:6:1" } ], - "functionName": - { + "functionName": { "name": "shl", - "nativeSrc": "654:3:1", + "nativeSrc": "636:3:1", "nodeType": "YulIdentifier", - "src": "654:3:1" + "src": "636:3:1" }, - "nativeSrc": "654:10:1", + "nativeSrc": "636:14:1", "nodeType": "YulFunctionCall", - "src": "654:10:1" + "src": "636:14:1" }, - "variables": - [ + "variables": [ { - "name": "_5", - "nativeSrc": "648:2:1", + "name": "_2", + "nativeSrc": "630:2:1", "nodeType": "YulTypedName", - "src": "648:2:1", + "src": "630:2:1", "type": "" } ] }, { - "nativeSrc": "673:23:1", + "nativeSrc": "659:23:1", "nodeType": "YulVariableDeclaration", - "src": "673:23:1", - "value": - { - "arguments": - [ + "src": "659:23:1", + "value": { + "arguments": [ { "kind": "number", - "nativeSrc": "693:2:1", + "nativeSrc": "679:2:1", "nodeType": "YulLiteral", - "src": "693:2:1", + "src": "679:2:1", "type": "", "value": "64" } ], - "functionName": - { + "functionName": { "name": "mload", - "nativeSrc": "687:5:1", + "nativeSrc": "673:5:1", "nodeType": "YulIdentifier", - "src": "687:5:1" + "src": "673:5:1" }, - "nativeSrc": "687:9:1", + "nativeSrc": "673:9:1", "nodeType": "YulFunctionCall", - "src": "687:9:1" + "src": "673:9:1" }, - "variables": - [ + "variables": [ { "name": "memPtr", - "nativeSrc": "677:6:1", + "nativeSrc": "663:6:1", "nodeType": "YulTypedName", - "src": "677:6:1", + "src": "663:6:1", "type": "" } ] }, { - "nativeSrc": "705:56:1", + "nativeSrc": "691:56:1", "nodeType": "YulVariableDeclaration", - "src": "705:56:1", - "value": - { - "arguments": - [ + "src": "691:56:1", + "value": { + "arguments": [ { "name": "memPtr", - "nativeSrc": "727:6:1", + "nativeSrc": "713:6:1", "nodeType": "YulIdentifier", - "src": "727:6:1" + "src": "713:6:1" }, { - "arguments": - [ + "arguments": [ { - "arguments": - [ + "arguments": [ { - "name": "_5", - "nativeSrc": "743:2:1", + "name": "_2", + "nativeSrc": "729:2:1", "nodeType": "YulIdentifier", - "src": "743:2:1" + "src": "729:2:1" }, { "kind": "number", - "nativeSrc": "747:2:1", + "nativeSrc": "733:2:1", "nodeType": "YulLiteral", - "src": "747:2:1", + "src": "733:2:1", "type": "", "value": "63" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "739:3:1", + "nativeSrc": "725:3:1", "nodeType": "YulIdentifier", - "src": "739:3:1" + "src": "725:3:1" }, - "nativeSrc": "739:11:1", + "nativeSrc": "725:11:1", "nodeType": "YulFunctionCall", - "src": "739:11:1" + "src": "725:11:1" }, { - "arguments": - [ + "arguments": [ { "kind": "number", - "nativeSrc": "756:2:1", + "nativeSrc": "742:2:1", "nodeType": "YulLiteral", - "src": "756:2:1", + "src": "742:2:1", "type": "", "value": "31" } ], - "functionName": - { + "functionName": { "name": "not", - "nativeSrc": "752:3:1", + "nativeSrc": "738:3:1", "nodeType": "YulIdentifier", - "src": "752:3:1" + "src": "738:3:1" }, - "nativeSrc": "752:7:1", + "nativeSrc": "738:7:1", "nodeType": "YulFunctionCall", - "src": "752:7:1" + "src": "738:7:1" } ], - "functionName": - { + "functionName": { "name": "and", - "nativeSrc": "735:3:1", + "nativeSrc": "721:3:1", "nodeType": "YulIdentifier", - "src": "735:3:1" + "src": "721:3:1" }, - "nativeSrc": "735:25:1", + "nativeSrc": "721:25:1", "nodeType": "YulFunctionCall", - "src": "735:25:1" + "src": "721:25:1" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "723:3:1", + "nativeSrc": "709:3:1", "nodeType": "YulIdentifier", - "src": "723:3:1" + "src": "709:3:1" }, - "nativeSrc": "723:38:1", + "nativeSrc": "709:38:1", "nodeType": "YulFunctionCall", - "src": "723:38:1" + "src": "709:38:1" }, - "variables": - [ + "variables": [ { "name": "newFreePtr", - "nativeSrc": "709:10:1", + "nativeSrc": "695:10:1", "nodeType": "YulTypedName", - "src": "709:10:1", + "src": "695:10:1", "type": "" } ] }, { - "body": - { - "nativeSrc": "820:22:1", + "body": { + "nativeSrc": "822:22:1", "nodeType": "YulBlock", - "src": "820:22:1", - "statements": - [ + "src": "822:22:1", + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "panic_error_0x41", - "nativeSrc": "822:16:1", + "nativeSrc": "824:16:1", "nodeType": "YulIdentifier", - "src": "822:16:1" + "src": "824:16:1" }, - "nativeSrc": "822:18:1", + "nativeSrc": "824:18:1", "nodeType": "YulFunctionCall", - "src": "822:18:1" + "src": "824:18:1" }, - "nativeSrc": "822:18:1", + "nativeSrc": "824:18:1", "nodeType": "YulExpressionStatement", - "src": "822:18:1" + "src": "824:18:1" } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "newFreePtr", - "nativeSrc": "779:10:1", + "nativeSrc": "765:10:1", "nodeType": "YulIdentifier", - "src": "779:10:1" + "src": "765:10:1" }, { - "name": "_2", - "nativeSrc": "791:2:1", - "nodeType": "YulIdentifier", - "src": "791:2:1" + "kind": "number", + "nativeSrc": "777:18:1", + "nodeType": "YulLiteral", + "src": "777:18:1", + "type": "", + "value": "0xffffffffffffffff" } ], - "functionName": - { + "functionName": { "name": "gt", - "nativeSrc": "776:2:1", + "nativeSrc": "762:2:1", "nodeType": "YulIdentifier", - "src": "776:2:1" + "src": "762:2:1" }, - "nativeSrc": "776:18:1", + "nativeSrc": "762:34:1", "nodeType": "YulFunctionCall", - "src": "776:18:1" + "src": "762:34:1" }, { - "arguments": - [ + "arguments": [ { "name": "newFreePtr", - "nativeSrc": "799:10:1", + "nativeSrc": "801:10:1", "nodeType": "YulIdentifier", - "src": "799:10:1" + "src": "801:10:1" }, { "name": "memPtr", - "nativeSrc": "811:6:1", + "nativeSrc": "813:6:1", "nodeType": "YulIdentifier", - "src": "811:6:1" + "src": "813:6:1" } ], - "functionName": - { + "functionName": { "name": "lt", - "nativeSrc": "796:2:1", + "nativeSrc": "798:2:1", "nodeType": "YulIdentifier", - "src": "796:2:1" + "src": "798:2:1" }, - "nativeSrc": "796:22:1", + "nativeSrc": "798:22:1", "nodeType": "YulFunctionCall", - "src": "796:22:1" + "src": "798:22:1" } ], - "functionName": - { + "functionName": { "name": "or", - "nativeSrc": "773:2:1", + "nativeSrc": "759:2:1", "nodeType": "YulIdentifier", - "src": "773:2:1" + "src": "759:2:1" }, - "nativeSrc": "773:46:1", + "nativeSrc": "759:62:1", "nodeType": "YulFunctionCall", - "src": "773:46:1" + "src": "759:62:1" }, - "nativeSrc": "770:72:1", + "nativeSrc": "756:88:1", "nodeType": "YulIf", - "src": "770:72:1" + "src": "756:88:1" }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", - "nativeSrc": "858:2:1", + "nativeSrc": "860:2:1", "nodeType": "YulLiteral", - "src": "858:2:1", + "src": "860:2:1", "type": "", "value": "64" }, { "name": "newFreePtr", - "nativeSrc": "862:10:1", + "nativeSrc": "864:10:1", "nodeType": "YulIdentifier", - "src": "862:10:1" + "src": "864:10:1" } ], - "functionName": - { + "functionName": { "name": "mstore", - "nativeSrc": "851:6:1", + "nativeSrc": "853:6:1", "nodeType": "YulIdentifier", - "src": "851:6:1" + "src": "853:6:1" }, - "nativeSrc": "851:22:1", + "nativeSrc": "853:22:1", "nodeType": "YulFunctionCall", - "src": "851:22:1" + "src": "853:22:1" }, - "nativeSrc": "851:22:1", + "nativeSrc": "853:22:1", "nodeType": "YulExpressionStatement", - "src": "851:22:1" + "src": "853:22:1" }, { - "nativeSrc": "882:17:1", + "nativeSrc": "884:17:1", "nodeType": "YulVariableDeclaration", - "src": "882:17:1", - "value": - { + "src": "884:17:1", + "value": { "name": "memPtr", - "nativeSrc": "893:6:1", + "nativeSrc": "895:6:1", "nodeType": "YulIdentifier", - "src": "893:6:1" + "src": "895:6:1" }, - "variables": - [ + "variables": [ { "name": "dst", - "nativeSrc": "886:3:1", + "nativeSrc": "888:3:1", "nodeType": "YulTypedName", - "src": "886:3:1", + "src": "888:3:1", "type": "" } ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "memPtr", - "nativeSrc": "915:6:1", + "nativeSrc": "917:6:1", "nodeType": "YulIdentifier", - "src": "915:6:1" + "src": "917:6:1" }, { - "name": "_4", - "nativeSrc": "923:2:1", + "name": "length", + "nativeSrc": "925:6:1", "nodeType": "YulIdentifier", - "src": "923:2:1" + "src": "925:6:1" } ], - "functionName": - { + "functionName": { "name": "mstore", - "nativeSrc": "908:6:1", + "nativeSrc": "910:6:1", "nodeType": "YulIdentifier", - "src": "908:6:1" + "src": "910:6:1" }, - "nativeSrc": "908:18:1", + "nativeSrc": "910:22:1", "nodeType": "YulFunctionCall", - "src": "908:18:1" + "src": "910:22:1" }, - "nativeSrc": "908:18:1", + "nativeSrc": "910:22:1", "nodeType": "YulExpressionStatement", - "src": "908:18:1" + "src": "910:22:1" }, { - "nativeSrc": "935:22:1", + "nativeSrc": "941:22:1", "nodeType": "YulAssignment", - "src": "935:22:1", - "value": - { - "arguments": - [ + "src": "941:22:1", + "value": { + "arguments": [ { "name": "memPtr", - "nativeSrc": "946:6:1", + "nativeSrc": "952:6:1", "nodeType": "YulIdentifier", - "src": "946:6:1" + "src": "952:6:1" }, { - "name": "_1", - "nativeSrc": "954:2:1", - "nodeType": "YulIdentifier", - "src": "954:2:1" + "kind": "number", + "nativeSrc": "960:2:1", + "nodeType": "YulLiteral", + "src": "960:2:1", + "type": "", + "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "942:3:1", + "nativeSrc": "948:3:1", "nodeType": "YulIdentifier", - "src": "942:3:1" + "src": "948:3:1" }, - "nativeSrc": "942:15:1", + "nativeSrc": "948:15:1", "nodeType": "YulFunctionCall", - "src": "942:15:1" + "src": "948:15:1" }, - "variableNames": - [ + "variableNames": [ { "name": "dst", - "nativeSrc": "935:3:1", + "nativeSrc": "941:3:1", "nodeType": "YulIdentifier", - "src": "935:3:1" + "src": "941:3:1" } ] }, { - "nativeSrc": "966:34:1", + "nativeSrc": "972:34:1", "nodeType": "YulVariableDeclaration", - "src": "966:34:1", - "value": - { - "arguments": - [ + "src": "972:34:1", + "value": { + "arguments": [ { - "arguments": - [ + "arguments": [ { - "name": "_3", - "nativeSrc": "988:2:1", + "name": "_1", + "nativeSrc": "994:2:1", "nodeType": "YulIdentifier", - "src": "988:2:1" + "src": "994:2:1" }, { - "name": "_5", - "nativeSrc": "992:2:1", + "name": "_2", + "nativeSrc": "998:2:1", "nodeType": "YulIdentifier", - "src": "992:2:1" + "src": "998:2:1" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "984:3:1", + "nativeSrc": "990:3:1", "nodeType": "YulIdentifier", - "src": "984:3:1" + "src": "990:3:1" }, - "nativeSrc": "984:11:1", + "nativeSrc": "990:11:1", "nodeType": "YulFunctionCall", - "src": "984:11:1" + "src": "990:11:1" }, { - "name": "_1", - "nativeSrc": "997:2:1", - "nodeType": "YulIdentifier", - "src": "997:2:1" + "kind": "number", + "nativeSrc": "1003:2:1", + "nodeType": "YulLiteral", + "src": "1003:2:1", + "type": "", + "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "980:3:1", + "nativeSrc": "986:3:1", "nodeType": "YulIdentifier", - "src": "980:3:1" + "src": "986:3:1" }, - "nativeSrc": "980:20:1", + "nativeSrc": "986:20:1", "nodeType": "YulFunctionCall", - "src": "980:20:1" + "src": "986:20:1" }, - "variables": - [ + "variables": [ { "name": "srcEnd", - "nativeSrc": "970:6:1", + "nativeSrc": "976:6:1", "nodeType": "YulTypedName", - "src": "970:6:1", + "src": "976:6:1", "type": "" } ] }, { - "body": - { - "nativeSrc": "1032:16:1", + "body": { + "nativeSrc": "1038:16:1", "nodeType": "YulBlock", - "src": "1032:16:1", - "statements": - [ + "src": "1038:16:1", + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", - "nativeSrc": "1041:1:1", + "nativeSrc": "1047:1:1", "nodeType": "YulLiteral", - "src": "1041:1:1", + "src": "1047:1:1", "type": "", "value": "0" }, { "kind": "number", - "nativeSrc": "1044:1:1", + "nativeSrc": "1050:1:1", "nodeType": "YulLiteral", - "src": "1044:1:1", + "src": "1050:1:1", "type": "", "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", - "nativeSrc": "1034:6:1", + "nativeSrc": "1040:6:1", "nodeType": "YulIdentifier", - "src": "1034:6:1" + "src": "1040:6:1" }, - "nativeSrc": "1034:12:1", + "nativeSrc": "1040:12:1", "nodeType": "YulFunctionCall", - "src": "1034:12:1" + "src": "1040:12:1" }, - "nativeSrc": "1034:12:1", + "nativeSrc": "1040:12:1", "nodeType": "YulExpressionStatement", - "src": "1034:12:1" + "src": "1040:12:1" } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "srcEnd", - "nativeSrc": "1015:6:1", + "nativeSrc": "1021:6:1", "nodeType": "YulIdentifier", - "src": "1015:6:1" + "src": "1021:6:1" }, { "name": "dataEnd", - "nativeSrc": "1023:7:1", + "nativeSrc": "1029:7:1", "nodeType": "YulIdentifier", - "src": "1023:7:1" + "src": "1029:7:1" } ], - "functionName": - { + "functionName": { "name": "gt", - "nativeSrc": "1012:2:1", + "nativeSrc": "1018:2:1", "nodeType": "YulIdentifier", - "src": "1012:2:1" + "src": "1018:2:1" }, - "nativeSrc": "1012:19:1", + "nativeSrc": "1018:19:1", "nodeType": "YulFunctionCall", - "src": "1012:19:1" + "src": "1018:19:1" }, - "nativeSrc": "1009:39:1", + "nativeSrc": "1015:39:1", "nodeType": "YulIf", - "src": "1009:39:1" + "src": "1015:39:1" }, { - "nativeSrc": "1057:22:1", + "nativeSrc": "1063:22:1", "nodeType": "YulVariableDeclaration", - "src": "1057:22:1", - "value": - { - "arguments": - [ + "src": "1063:22:1", + "value": { + "arguments": [ { - "name": "_3", - "nativeSrc": "1072:2:1", + "name": "_1", + "nativeSrc": "1078:2:1", "nodeType": "YulIdentifier", - "src": "1072:2:1" + "src": "1078:2:1" }, { - "name": "_1", - "nativeSrc": "1076:2:1", - "nodeType": "YulIdentifier", - "src": "1076:2:1" + "kind": "number", + "nativeSrc": "1082:2:1", + "nodeType": "YulLiteral", + "src": "1082:2:1", + "type": "", + "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "1068:3:1", + "nativeSrc": "1074:3:1", "nodeType": "YulIdentifier", - "src": "1068:3:1" + "src": "1074:3:1" }, - "nativeSrc": "1068:11:1", + "nativeSrc": "1074:11:1", "nodeType": "YulFunctionCall", - "src": "1068:11:1" + "src": "1074:11:1" }, - "variables": - [ + "variables": [ { "name": "src", - "nativeSrc": "1061:3:1", + "nativeSrc": "1067:3:1", "nodeType": "YulTypedName", - "src": "1061:3:1", + "src": "1067:3:1", "type": "" } ] }, { - "body": - { - "nativeSrc": "1144:86:1", + "body": { + "nativeSrc": "1150:140:1", "nodeType": "YulBlock", - "src": "1144:86:1", - "statements": - [ + "src": "1150:140:1", + "statements": [ { - "expression": - { - "arguments": - [ + "nativeSrc": "1164:14:1", + "nodeType": "YulVariableDeclaration", + "src": "1164:14:1", + "value": { + "kind": "number", + "nativeSrc": "1177:1:1", + "nodeType": "YulLiteral", + "src": "1177:1:1", + "type": "", + "value": "0" + }, + "variables": [ + { + "name": "value", + "nativeSrc": "1168:5:1", + "nodeType": "YulTypedName", + "src": "1168:5:1", + "type": "" + } + ] + }, + { + "nativeSrc": "1191:26:1", + "nodeType": "YulAssignment", + "src": "1191:26:1", + "value": { + "arguments": [ + { + "name": "src", + "nativeSrc": "1213:3:1", + "nodeType": "YulIdentifier", + "src": "1213:3:1" + } + ], + "functionName": { + "name": "calldataload", + "nativeSrc": "1200:12:1", + "nodeType": "YulIdentifier", + "src": "1200:12:1" + }, + "nativeSrc": "1200:17:1", + "nodeType": "YulFunctionCall", + "src": "1200:17:1" + }, + "variableNames": [ + { + "name": "value", + "nativeSrc": "1191:5:1", + "nodeType": "YulIdentifier", + "src": "1191:5:1" + } + ] + }, + { + "expression": { + "arguments": [ { "name": "dst", - "nativeSrc": "1165:3:1", + "nativeSrc": "1237:3:1", "nodeType": "YulIdentifier", - "src": "1165:3:1" + "src": "1237:3:1" }, { - "arguments": - [ - { - "name": "src", - "nativeSrc": "1183:3:1", - "nodeType": "YulIdentifier", - "src": "1183:3:1" - } - ], - "functionName": - { - "name": "calldataload", - "nativeSrc": "1170:12:1", - "nodeType": "YulIdentifier", - "src": "1170:12:1" - }, - "nativeSrc": "1170:17:1", - "nodeType": "YulFunctionCall", - "src": "1170:17:1" + "name": "value", + "nativeSrc": "1242:5:1", + "nodeType": "YulIdentifier", + "src": "1242:5:1" } ], - "functionName": - { + "functionName": { "name": "mstore", - "nativeSrc": "1158:6:1", + "nativeSrc": "1230:6:1", "nodeType": "YulIdentifier", - "src": "1158:6:1" + "src": "1230:6:1" }, - "nativeSrc": "1158:30:1", + "nativeSrc": "1230:18:1", "nodeType": "YulFunctionCall", - "src": "1158:30:1" + "src": "1230:18:1" }, - "nativeSrc": "1158:30:1", + "nativeSrc": "1230:18:1", "nodeType": "YulExpressionStatement", - "src": "1158:30:1" + "src": "1230:18:1" }, { - "nativeSrc": "1201:19:1", + "nativeSrc": "1261:19:1", "nodeType": "YulAssignment", - "src": "1201:19:1", - "value": - { - "arguments": - [ + "src": "1261:19:1", + "value": { + "arguments": [ { "name": "dst", - "nativeSrc": "1212:3:1", + "nativeSrc": "1272:3:1", "nodeType": "YulIdentifier", - "src": "1212:3:1" + "src": "1272:3:1" }, { - "name": "_1", - "nativeSrc": "1217:2:1", - "nodeType": "YulIdentifier", - "src": "1217:2:1" + "kind": "number", + "nativeSrc": "1277:2:1", + "nodeType": "YulLiteral", + "src": "1277:2:1", + "type": "", + "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "1208:3:1", + "nativeSrc": "1268:3:1", "nodeType": "YulIdentifier", - "src": "1208:3:1" + "src": "1268:3:1" }, - "nativeSrc": "1208:12:1", + "nativeSrc": "1268:12:1", "nodeType": "YulFunctionCall", - "src": "1208:12:1" + "src": "1268:12:1" }, - "variableNames": - [ + "variableNames": [ { "name": "dst", - "nativeSrc": "1201:3:1", + "nativeSrc": "1261:3:1", "nodeType": "YulIdentifier", - "src": "1201:3:1" + "src": "1261:3:1" } ] } ] }, - "condition": - { - "arguments": - [ + "condition": { + "arguments": [ { "name": "src", - "nativeSrc": "1099:3:1", + "nativeSrc": "1105:3:1", "nodeType": "YulIdentifier", - "src": "1099:3:1" + "src": "1105:3:1" }, { "name": "srcEnd", - "nativeSrc": "1104:6:1", + "nativeSrc": "1110:6:1", "nodeType": "YulIdentifier", - "src": "1104:6:1" + "src": "1110:6:1" } ], - "functionName": - { + "functionName": { "name": "lt", - "nativeSrc": "1096:2:1", + "nativeSrc": "1102:2:1", "nodeType": "YulIdentifier", - "src": "1096:2:1" + "src": "1102:2:1" }, - "nativeSrc": "1096:15:1", + "nativeSrc": "1102:15:1", "nodeType": "YulFunctionCall", - "src": "1096:15:1" + "src": "1102:15:1" }, - "nativeSrc": "1088:142:1", + "nativeSrc": "1094:196:1", "nodeType": "YulForLoop", - "post": - { - "nativeSrc": "1112:23:1", + "post": { + "nativeSrc": "1118:23:1", "nodeType": "YulBlock", - "src": "1112:23:1", - "statements": - [ + "src": "1118:23:1", + "statements": [ { - "nativeSrc": "1114:19:1", + "nativeSrc": "1120:19:1", "nodeType": "YulAssignment", - "src": "1114:19:1", - "value": - { - "arguments": - [ + "src": "1120:19:1", + "value": { + "arguments": [ { "name": "src", - "nativeSrc": "1125:3:1", + "nativeSrc": "1131:3:1", "nodeType": "YulIdentifier", - "src": "1125:3:1" + "src": "1131:3:1" }, { - "name": "_1", - "nativeSrc": "1130:2:1", - "nodeType": "YulIdentifier", - "src": "1130:2:1" + "kind": "number", + "nativeSrc": "1136:2:1", + "nodeType": "YulLiteral", + "src": "1136:2:1", + "type": "", + "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "1121:3:1", + "nativeSrc": "1127:3:1", "nodeType": "YulIdentifier", - "src": "1121:3:1" + "src": "1127:3:1" }, - "nativeSrc": "1121:12:1", + "nativeSrc": "1127:12:1", "nodeType": "YulFunctionCall", - "src": "1121:12:1" + "src": "1127:12:1" }, - "variableNames": - [ + "variableNames": [ { "name": "src", - "nativeSrc": "1114:3:1", + "nativeSrc": "1120:3:1", "nodeType": "YulIdentifier", - "src": "1114:3:1" + "src": "1120:3:1" } ] } ] }, - "pre": - { - "nativeSrc": "1092:3:1", + "pre": { + "nativeSrc": "1098:3:1", "nodeType": "YulBlock", - "src": "1092:3:1", + "src": "1098:3:1", "statements": [] }, - "src": "1088:142:1" + "src": "1094:196:1" }, { - "nativeSrc": "1239:16:1", + "nativeSrc": "1299:16:1", "nodeType": "YulAssignment", - "src": "1239:16:1", - "value": - { + "src": "1299:16:1", + "value": { "name": "memPtr", - "nativeSrc": "1249:6:1", + "nativeSrc": "1309:6:1", "nodeType": "YulIdentifier", - "src": "1249:6:1" + "src": "1309:6:1" }, - "variableNames": - [ + "variableNames": [ { "name": "value0", - "nativeSrc": "1239:6:1", + "nativeSrc": "1299:6:1", "nodeType": "YulIdentifier", - "src": "1239:6:1" + "src": "1299:6:1" } ] } ] }, "name": "abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr", - "nativeSrc": "146:1115:1", + "nativeSrc": "146:1175:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "headStart", "nativeSrc": "207:9:1", @@ -1551,8 +1406,7 @@ "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "value0", "nativeSrc": "230:6:1", @@ -1561,126 +1415,115 @@ "type": "" } ], - "src": "146:1115:1" + "src": "146:1175:1" }, { - "body": - { - "nativeSrc": "1367:76:1", + "body": { + "nativeSrc": "1427:76:1", "nodeType": "YulBlock", - "src": "1367:76:1", - "statements": - [ + "src": "1427:76:1", + "statements": [ { - "nativeSrc": "1377:26:1", + "nativeSrc": "1437:26:1", "nodeType": "YulAssignment", - "src": "1377:26:1", - "value": - { - "arguments": - [ + "src": "1437:26:1", + "value": { + "arguments": [ { "name": "headStart", - "nativeSrc": "1389:9:1", + "nativeSrc": "1449:9:1", "nodeType": "YulIdentifier", - "src": "1389:9:1" + "src": "1449:9:1" }, { "kind": "number", - "nativeSrc": "1400:2:1", + "nativeSrc": "1460:2:1", "nodeType": "YulLiteral", - "src": "1400:2:1", + "src": "1460:2:1", "type": "", "value": "32" } ], - "functionName": - { + "functionName": { "name": "add", - "nativeSrc": "1385:3:1", + "nativeSrc": "1445:3:1", "nodeType": "YulIdentifier", - "src": "1385:3:1" + "src": "1445:3:1" }, - "nativeSrc": "1385:18:1", + "nativeSrc": "1445:18:1", "nodeType": "YulFunctionCall", - "src": "1385:18:1" + "src": "1445:18:1" }, - "variableNames": - [ + "variableNames": [ { "name": "tail", - "nativeSrc": "1377:4:1", + "nativeSrc": "1437:4:1", "nodeType": "YulIdentifier", - "src": "1377:4:1" + "src": "1437:4:1" } ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "name": "headStart", - "nativeSrc": "1419:9:1", + "nativeSrc": "1479:9:1", "nodeType": "YulIdentifier", - "src": "1419:9:1" + "src": "1479:9:1" }, { "name": "value0", - "nativeSrc": "1430:6:1", + "nativeSrc": "1490:6:1", "nodeType": "YulIdentifier", - "src": "1430:6:1" + "src": "1490:6:1" } ], - "functionName": - { + "functionName": { "name": "mstore", - "nativeSrc": "1412:6:1", + "nativeSrc": "1472:6:1", "nodeType": "YulIdentifier", - "src": "1412:6:1" + "src": "1472:6:1" }, - "nativeSrc": "1412:25:1", + "nativeSrc": "1472:25:1", "nodeType": "YulFunctionCall", - "src": "1412:25:1" + "src": "1472:25:1" }, - "nativeSrc": "1412:25:1", + "nativeSrc": "1472:25:1", "nodeType": "YulExpressionStatement", - "src": "1412:25:1" + "src": "1472:25:1" } ] }, "name": "abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed", - "nativeSrc": "1266:177:1", + "nativeSrc": "1326:177:1", "nodeType": "YulFunctionDefinition", - "parameters": - [ + "parameters": [ { "name": "headStart", - "nativeSrc": "1336:9:1", + "nativeSrc": "1396:9:1", "nodeType": "YulTypedName", - "src": "1336:9:1", + "src": "1396:9:1", "type": "" }, { "name": "value0", - "nativeSrc": "1347:6:1", + "nativeSrc": "1407:6:1", "nodeType": "YulTypedName", - "src": "1347:6:1", + "src": "1407:6:1", "type": "" } ], - "returnVariables": - [ + "returnVariables": [ { "name": "tail", - "nativeSrc": "1358:4:1", + "nativeSrc": "1418:4:1", "nodeType": "YulTypedName", - "src": "1358:4:1", + "src": "1418:4:1", "type": "" } ], - "src": "1266:177:1" + "src": "1326:177:1" } ] }, @@ -1694,30 +1537,30 @@ } function abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr(headStart, dataEnd) -> value0 { - let _1 := 32 - if slt(sub(dataEnd, headStart), _1) { revert(0, 0) } + if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } let offset := calldataload(headStart) - let _2 := 0xffffffffffffffff - if gt(offset, _2) { revert(0, 0) } - let _3 := add(headStart, offset) - if iszero(slt(add(_3, 0x1f), dataEnd)) { revert(0, 0) } - let _4 := calldataload(_3) - if gt(_4, _2) { panic_error_0x41() } - let _5 := shl(5, _4) + if gt(offset, 0xffffffffffffffff) { revert(0, 0) } + let _1 := add(headStart, offset) + if iszero(slt(add(_1, 0x1f), dataEnd)) { revert(0, 0) } + let length := calldataload(_1) + if gt(length, 0xffffffffffffffff) { panic_error_0x41() } + let _2 := shl(5, length) let memPtr := mload(64) - let newFreePtr := add(memPtr, and(add(_5, 63), not(31))) - if or(gt(newFreePtr, _2), lt(newFreePtr, memPtr)) { panic_error_0x41() } + let newFreePtr := add(memPtr, and(add(_2, 63), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } mstore(64, newFreePtr) let dst := memPtr - mstore(memPtr, _4) - dst := add(memPtr, _1) - let srcEnd := add(add(_3, _5), _1) + mstore(memPtr, length) + dst := add(memPtr, 32) + let srcEnd := add(add(_1, _2), 32) if gt(srcEnd, dataEnd) { revert(0, 0) } - let src := add(_3, _1) - for { } lt(src, srcEnd) { src := add(src, _1) } + let src := add(_1, 32) + for { } lt(src, srcEnd) { src := add(src, 32) } { - mstore(dst, calldataload(src)) - dst := add(dst, _1) + let value := 0 + value := calldataload(src) + mstore(dst, value) + dst := add(dst, 32) } value0 := memPtr } @@ -1737,10 +1580,8 @@ } } }, - "sources": - { - "a.sol": - { + "sources": { + "a.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_invalid_detail_type/output.json b/test/cmdlineTests/standard_optimizer_invalid_detail_type/output.json index 2601dea6c3d1..10ba5e396196 100644 --- a/test/cmdlineTests/standard_optimizer_invalid_detail_type/output.json +++ b/test/cmdlineTests/standard_optimizer_invalid_detail_type/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.optimizer.details.peephole\" must be Boolean", diff --git a/test/cmdlineTests/standard_optimizer_invalid_details/output.json b/test/cmdlineTests/standard_optimizer_invalid_details/output.json index c7dfaf3142f9..79b0de4e8004 100644 --- a/test/cmdlineTests/standard_optimizer_invalid_details/output.json +++ b/test/cmdlineTests/standard_optimizer_invalid_details/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"notThere\"", diff --git a/test/cmdlineTests/standard_optimizer_no_yul/output.json b/test/cmdlineTests/standard_optimizer_no_yul/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_no_yul/output.json +++ b/test/cmdlineTests/standard_optimizer_no_yul/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yul/output.json b/test/cmdlineTests/standard_optimizer_yul/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yul/output.json +++ b/test/cmdlineTests/standard_optimizer_yul/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails/output.json b/test/cmdlineTests/standard_optimizer_yulDetails/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_no_object/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_no_object/output.json index 86a0c86986fc..c658301e9aff 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_no_object/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_no_object/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.optimizer.details.yulDetails\" must be an object", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_metadata/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_metadata/input.json new file mode 100644 index 000000000000..e229656ea2ea --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_metadata/input.json @@ -0,0 +1,25 @@ +{ + "language": "Solidity", + "sources": { + "A": {"content": " + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.0; + contract C { } + "} + }, + "settings": { + "optimizer": { + "details": { + "yul": false, + "yulDetails": { + "optimizerSteps": ":" + } + } + }, + "outputSelection": { + "*": { + "*": ["metadata"] + } + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_metadata/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_metadata/output.json new file mode 100644 index 000000000000..c461a1485bda --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_metadata/output.json @@ -0,0 +1,14 @@ +{ + "contracts": { + "A": { + "C": { + "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"A\":\"C\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"details\":{\"constantOptimizer\":false,\"cse\":false,\"deduplicate\":false,\"inliner\":false,\"jumpdestRemover\":true,\"orderLiterals\":false,\"peephole\":true,\"simpleCounterForLoopUncheckedIncrement\":true,\"yul\":false,\"yulDetails\":{\"optimizerSteps\":\":\"}},\"runs\":200},\"remappings\":[]},\"sources\":{\"A\":{\"keccak256\":\"0xb284c39999cb85b80be315a6e9e322adf67a783c66e91ba4439168694580a66d\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://098cee915fad095b8a996813768bd7d5e8c9e40c405e8c43d0572bb7bbc17334\",\"dweb:/ipfs/QmZmUzvSryrrD7pJ9S32iQnEWn4QBL4J1NdbQqL2Xc3yTr\"]}},\"version\":1}" + } + } + }, + "sources": { + "A": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_whitespaces_metadata/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_whitespaces_metadata/input.json new file mode 100644 index 000000000000..ddf2d963ff94 --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_whitespaces_metadata/input.json @@ -0,0 +1,25 @@ +{ + "language": "Solidity", + "sources": { + "A": {"content": " + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.0; + contract C { } + "} + }, + "settings": { + "optimizer": { + "details": { + "yul": false, + "yulDetails": { + "optimizerSteps": " : " + } + } + }, + "outputSelection": { + "*": { + "*": ["metadata"] + } + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_whitespaces_metadata/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_whitespaces_metadata/output.json new file mode 100644 index 000000000000..c461a1485bda --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_empty_sequence_whitespaces_metadata/output.json @@ -0,0 +1,14 @@ +{ + "contracts": { + "A": { + "C": { + "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"A\":\"C\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"details\":{\"constantOptimizer\":false,\"cse\":false,\"deduplicate\":false,\"inliner\":false,\"jumpdestRemover\":true,\"orderLiterals\":false,\"peephole\":true,\"simpleCounterForLoopUncheckedIncrement\":true,\"yul\":false,\"yulDetails\":{\"optimizerSteps\":\":\"}},\"runs\":200},\"remappings\":[]},\"sources\":{\"A\":{\"keccak256\":\"0xb284c39999cb85b80be315a6e9e322adf67a783c66e91ba4439168694580a66d\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://098cee915fad095b8a996813768bd7d5e8c9e40c405e8c43d0572bb7bbc17334\",\"dweb:/ipfs/QmZmUzvSryrrD7pJ9S32iQnEWn4QBL4J1NdbQqL2Xc3yTr\"]}},\"version\":1}" + } + } + }, + "sources": { + "A": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/output.json index d4f6ef3a7e55..267a8c3609ae 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": 'b' is not a valid step abbreviation", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nested_delimiter/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nested_delimiter/output.json index f44ca7e2e589..ea101d2e18e4 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nested_delimiter/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nested_delimiter/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Cleanup sequence delimiter cannot be placed inside the brackets", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_mutliple_delimiters/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_mutliple_delimiters/output.json index 16cba14d70c6..595049f41c52 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_mutliple_delimiters/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_mutliple_delimiters/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Too many cleanup sequence delimiters", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nested_brackets/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nested_brackets/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nested_brackets/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nested_brackets/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nesting_too_deep/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nesting_too_deep/output.json index e06e14205db0..25fc97e47ee1 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nesting_too_deep/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_nesting_too_deep/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Brackets nested too deep", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul/output.json index fa3c9d93edc5..322a7e25b9bc 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul/output.json @@ -1,10 +1,9 @@ { - "errors": - [ + "errors": [ { "component": "general", - "formattedMessage": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted.", - "message": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted.", + "formattedMessage": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted. Note that the empty optimizer sequence is properly denoted by \":\".", + "message": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted. Note that the empty optimizer sequence is properly denoted by \":\".", "severity": "error", "type": "JSONError" } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_empty_string/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_empty_string/input.json new file mode 100644 index 000000000000..ad7d7ff14b51 --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_empty_string/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": { + "A": {"content": " + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.0; + "} + }, + "settings": { + "optimizer": { + "details": { + "yul": false, + "yulDetails": { + "optimizerSteps": "" + } + } + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_empty_string/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_empty_string/output.json new file mode 100644 index 000000000000..322a7e25b9bc --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_empty_string/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted. Note that the empty optimizer sequence is properly denoted by \":\".", + "message": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted. Note that the empty optimizer sequence is properly denoted by \":\".", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_whitespaces/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_whitespaces/input.json new file mode 100644 index 000000000000..85a53fce7713 --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_whitespaces/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": { + "A": {"content": " + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.0; + "} + }, + "settings": { + "optimizer": { + "details": { + "yul": false, + "yulDetails": { + "optimizerSteps": " " + } + } + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_whitespaces/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_whitespaces/output.json new file mode 100644 index 000000000000..322a7e25b9bc --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_whitespaces/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted. Note that the empty optimizer sequence is properly denoted by \":\".", + "message": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted. Note that the empty optimizer sequence is properly denoted by \":\".", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/output.json index d6f9a9df8560..a1e5151c1d3f 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.optimizer.details.optimizerSteps\" must be a string", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_closing_bracket/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_closing_bracket/output.json index 316529b0d9c8..3f93509f2726 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_closing_bracket/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_closing_bracket/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Unbalanced brackets", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_opening_bracket/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_opening_bracket/output.json index 316529b0d9c8..3f93509f2726 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_opening_bracket/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_opening_bracket/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Unbalanced brackets", diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_cleanup_sequence/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_cleanup_sequence/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_cleanup_sequence/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_cleanup_sequence/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_optimisation_sequence/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_optimisation_sequence/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_optimisation_sequence/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_optimisation_sequence/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/input.json index 9de7beea915a..8e6add377cac 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/input.json @@ -1,16 +1,16 @@ { - "language": "Solidity", - "sources": { - "A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/in.sol"]} - }, - "settings": { - "optimizer": { - "details": { - "yul": false, - "yulDetails": { - "optimizerSteps": ":" - } - } - } - } + "language": "Solidity", + "sources": { + "A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/in.sol"]} + }, + "settings": { + "optimizer": { + "details": { + "yul": false, + "yulDetails": { + "optimizerSteps": ":" + } + } + } + } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_whitespace_newline_sequence_no_yul/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_whitespace_newline_sequence_no_yul/output.json index acf3b74ef1de..f047ff70a9eb 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_whitespace_newline_sequence_no_yul/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_with_whitespace_newline_sequence_no_yul/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/output.json b/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/output.json index 2470015e1fb0..1da39084e74b 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/output.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Only optimizerSteps can be set in yulDetails when Yul optimizer is disabled.", diff --git a/test/cmdlineTests/standard_outputs_on_analysis_error_fatal/output.json b/test/cmdlineTests/standard_outputs_on_analysis_error_fatal/output.json index 51d12668fb13..e0c83975351b 100644 --- a/test/cmdlineTests/standard_outputs_on_analysis_error_fatal/output.json +++ b/test/cmdlineTests/standard_outputs_on_analysis_error_fatal/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3644", @@ -13,8 +12,7 @@ ", "message": "This parameter has a type that can only be used internally. You can make the contract abstract to avoid this problem.", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 258, "file": "C", "start": 244 diff --git a/test/cmdlineTests/standard_outputs_on_analysis_error_fatal_after_current_step/output.json b/test/cmdlineTests/standard_outputs_on_analysis_error_fatal_after_current_step/output.json index d47ded5d4018..d6357a5b16d7 100644 --- a/test/cmdlineTests/standard_outputs_on_analysis_error_fatal_after_current_step/output.json +++ b/test/cmdlineTests/standard_outputs_on_analysis_error_fatal_after_current_step/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "8297", @@ -13,8 +12,7 @@ ", "message": "The \"immutable\" keyword can only be used for state variables.", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 259, "file": "C", "start": 243 diff --git a/test/cmdlineTests/standard_outputs_on_analysis_error_non_fatal/output.json b/test/cmdlineTests/standard_outputs_on_analysis_error_non_fatal/output.json index 2f3aaae4420c..2dcecead01ff 100644 --- a/test/cmdlineTests/standard_outputs_on_analysis_error_non_fatal/output.json +++ b/test/cmdlineTests/standard_outputs_on_analysis_error_non_fatal/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7407", @@ -13,8 +12,7 @@ ", "message": "Type uint256 is not implicitly convertible to expected type string storage ref.", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 235, "file": "C", "start": 234 diff --git a/test/cmdlineTests/standard_outputs_on_compilation_error/output.json b/test/cmdlineTests/standard_outputs_on_compilation_error/output.json index aae6d02f6b41..09f4afc4ef2d 100644 --- a/test/cmdlineTests/standard_outputs_on_compilation_error/output.json +++ b/test/cmdlineTests/standard_outputs_on_compilation_error/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C": - { - "abi": - [ + "contracts": { + "C": { + "C": { + "abi": [ { "inputs": [], "stateMutability": "nonpayable", @@ -15,8 +11,7 @@ { "inputs": [], "name": "x", - "outputs": - [ + "outputs": [ { "internalType": "uint256", "name": "", @@ -27,27 +22,22 @@ "type": "function" } ], - "devdoc": - { + "devdoc": { "kind": "dev", "methods": {}, "version": 1 }, - "evm": - { - "methodIdentifiers": - { + "evm": { + "methodIdentifiers": { "x()": "0c55699c" } }, "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"x\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"C\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"C\":{\"keccak256\":\"0x67a13ebd685e4c6f792e71eb747dac57edb99e94d04d841ee6c979ae517934ce\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://665b000da768823654f680d02686c1e59d682a0b3882e43a77fed9f80ce64ae8\",\"dweb:/ipfs/QmVnKvuidH6KiCdNQpoAQUtDbB8hXkafVLXWMNitUcxnqC\"]}},\"version\":1}", - "storageLayout": - { + "storageLayout": { "storage": [], "types": null }, - "userdoc": - { + "userdoc": { "kind": "user", "methods": {}, "version": 1 @@ -55,8 +45,7 @@ } } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "1284", @@ -68,29 +57,22 @@ "type": "CodeGenerationError" } ], - "sources": - { - "C": - { - "ast": - { + "sources": { + "C": { + "ast": { "absolutePath": "C", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 15 ] }, "id": 16, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", "*" ], @@ -105,15 +87,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 15, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 15 ], "name": "C", "nameLocation": "65:1:0", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "functionSelector": "0c55699c", @@ -126,19 +106,16 @@ "src": "228:23:0", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "228:4:0", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -146,39 +123,33 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 13, "nodeType": "Block", "src": "272:46:0", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "id": 8, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "leftHandSide": - { + "leftHandSide": { "id": 6, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, "src": "282:1:0", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", - "rightHandSide": - { + "rightHandSide": { "hexValue": "30", "id": 7, "isConstant": false, @@ -188,16 +159,14 @@ "lValueRequested": false, "nodeType": "Literal", "src": "286:1:0", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "282:5:0", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -207,15 +176,13 @@ "src": "282:5:0" }, { - "body": - { + "body": { "id": 11, "nodeType": "Block", "src": "310:2:0", "statements": [] }, - "condition": - { + "condition": { "hexValue": "74727565", "id": 10, "isConstant": false, @@ -225,8 +192,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "304:4:0", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, @@ -245,15 +211,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "269:2:0" }, - "returnParameters": - { + "returnParameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], diff --git a/test/cmdlineTests/standard_outputs_on_parsing_error/output.json b/test/cmdlineTests/standard_outputs_on_parsing_error/output.json index 8c1f6c0dbe28..6730d772ee02 100644 --- a/test/cmdlineTests/standard_outputs_on_parsing_error/output.json +++ b/test/cmdlineTests/standard_outputs_on_parsing_error/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "7858", @@ -13,8 +12,7 @@ ", "message": "Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition.", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 121, "file": "C", "start": 120 diff --git a/test/cmdlineTests/standard_parsing_import_absolute_paths/output.json b/test/cmdlineTests/standard_parsing_import_absolute_paths/output.json index 1982561ef2a2..1be9f4b0d095 100644 --- a/test/cmdlineTests/standard_parsing_import_absolute_paths/output.json +++ b/test/cmdlineTests/standard_parsing_import_absolute_paths/output.json @@ -1,20 +1,15 @@ { - "sources": - { - "/lib/L.sol": - { - "ast": - { + "sources": { + "/lib/L.sol": { + "ast": { "absolutePath": "/lib/L.sol", "id": 2, "license": "GPL-2.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" @@ -27,20 +22,16 @@ }, "id": 0 }, - "/project/../C.sol": - { - "ast": - { + "/project/../C.sol": { + "ast": { "absolutePath": "/project/../C.sol", "id": 5, "license": "GPL-2.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 3, - "literals": - [ + "literals": [ "solidity", ">=", "0.0" diff --git a/test/cmdlineTests/standard_raw_utf16_filename/input.json b/test/cmdlineTests/standard_raw_utf16_filename/input.json new file mode 100644 index 000000000000..1c4a1b3232cf Binary files /dev/null and b/test/cmdlineTests/standard_raw_utf16_filename/input.json differ diff --git a/test/cmdlineTests/standard_raw_utf16_filename/output.json b/test/cmdlineTests/standard_raw_utf16_filename/output.json new file mode 100644 index 000000000000..cebd87943a63 --- /dev/null +++ b/test/cmdlineTests/standard_raw_utf16_filename/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "parse error at line 5, column 4: syntax error while parsing object key - invalid string: control character U+0000 (NUL) must be escaped to \\u0000; last read: '\"'; expected string literal", + "message": "parse error at line 5, column 4: syntax error while parsing object key - invalid string: control character U+0000 (NUL) must be escaped to \\u0000; last read: '\"'; expected string literal", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_secondary_source_location/output.json b/test/cmdlineTests/standard_secondary_source_location/output.json index 6423769aab15..ea47eeaade30 100644 --- a/test/cmdlineTests/standard_secondary_source_location/output.json +++ b/test/cmdlineTests/standard_secondary_source_location/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "errorCode": "3364", @@ -22,8 +21,7 @@ Note: Second constructor call is here: ", "message": "Base constructor arguments given twice.", - "secondarySourceLocations": - [ + "secondarySourceLocations": [ { "end": 112, "file": "A", @@ -38,8 +36,7 @@ Note: Second constructor call is here: } ], "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 160, "file": "A", "start": 139 diff --git a/test/cmdlineTests/standard_stop_after_parsing_ast_requested/output.json b/test/cmdlineTests/standard_stop_after_parsing_ast_requested/output.json index 6907d4780f58..3bddad829272 100644 --- a/test/cmdlineTests/standard_stop_after_parsing_ast_requested/output.json +++ b/test/cmdlineTests/standard_stop_after_parsing_ast_requested/output.json @@ -1,20 +1,15 @@ { - "sources": - { - "C": - { - "ast": - { + "sources": { + "C": { + "ast": { "absolutePath": "C", "id": 4, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", "*" ], diff --git a/test/cmdlineTests/standard_stop_after_parsing_bytecode_requested/output.json b/test/cmdlineTests/standard_stop_after_parsing_bytecode_requested/output.json index 37195309631d..1699ed88086c 100644 --- a/test/cmdlineTests/standard_stop_after_parsing_bytecode_requested/output.json +++ b/test/cmdlineTests/standard_stop_after_parsing_bytecode_requested/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Requested output selection conflicts with \"settings.stopAfter\".", diff --git a/test/cmdlineTests/standard_stop_after_parsing_non_binary_output_requested/output.json b/test/cmdlineTests/standard_stop_after_parsing_non_binary_output_requested/output.json index 5b64763be82f..264cd37be95e 100644 --- a/test/cmdlineTests/standard_stop_after_parsing_non_binary_output_requested/output.json +++ b/test/cmdlineTests/standard_stop_after_parsing_non_binary_output_requested/output.json @@ -1,8 +1,6 @@ { - "sources": - { - "C": - { + "sources": { + "C": { "id": 0 } } diff --git a/test/cmdlineTests/standard_urls_existing_and_missing/output.json b/test/cmdlineTests/standard_urls_existing_and_missing/output.json index 87db5f4db78e..e9db1135d764 100644 --- a/test/cmdlineTests/standard_urls_existing_and_missing/output.json +++ b/test/cmdlineTests/standard_urls_existing_and_missing/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Cannot import url (\"standard_urls_existing_and_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".", @@ -9,10 +8,8 @@ "type": "Warning" } ], - "sources": - { - "url_not_found.sol": - { + "sources": { + "url_not_found.sol": { "id": 0 } } diff --git a/test/cmdlineTests/standard_urls_missing/output.json b/test/cmdlineTests/standard_urls_missing/output.json index 267618ee9330..7e2bb3dd59c2 100644 --- a/test/cmdlineTests/standard_urls_missing/output.json +++ b/test/cmdlineTests/standard_urls_missing/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Cannot import url (\"standard_urls_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".", diff --git a/test/cmdlineTests/standard_viair_requested/output.json b/test/cmdlineTests/standard_viair_requested/output.json index 3e459c56f959..0105ea97298a 100644 --- a/test/cmdlineTests/standard_viair_requested/output.json +++ b/test/cmdlineTests/standard_viair_requested/output.json @@ -1,19 +1,13 @@ { - "contracts": - { - "A": - { - "C": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "C": { + "evm": { + "bytecode": { "generatedSources": [], "object": "" }, - "deployedBytecode": - { + "deployedBytecode": { "object": "" } }, @@ -81,17 +75,13 @@ object \"C_3\" { " }, - "D": - { - "evm": - { - "bytecode": - { + "D": { + "evm": { + "bytecode": { "generatedSources": [], "object": "" }, - "deployedBytecode": - { + "deployedBytecode": { "object": "" } }, @@ -299,8 +289,7 @@ object \"D_16\" { } } }, - "errors": - [ + "errors": [ { "component": "general", "errorCode": "2072", @@ -313,8 +302,7 @@ object \"D_16\" { ", "message": "Unused local variable.", "severity": "warning", - "sourceLocation": - { + "sourceLocation": { "end": 131, "file": "A", "start": 128 @@ -322,10 +310,8 @@ object \"D_16\" { "type": "Warning" } ], - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/standard_wrong_key_auxiliary_input/output.json b/test/cmdlineTests/standard_wrong_key_auxiliary_input/output.json index 1e846d19c708..e1ac73e8fd5a 100644 --- a/test/cmdlineTests/standard_wrong_key_auxiliary_input/output.json +++ b/test/cmdlineTests/standard_wrong_key_auxiliary_input/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"key1\"", diff --git a/test/cmdlineTests/standard_wrong_key_metadata/input.json b/test/cmdlineTests/standard_wrong_key_metadata/input.json index a52d45004b57..e0906d312e40 100644 --- a/test/cmdlineTests/standard_wrong_key_metadata/input.json +++ b/test/cmdlineTests/standard_wrong_key_metadata/input.json @@ -10,13 +10,13 @@ "settings": { "optimizer": { - "enabled": true, - "runs": 200 - }, - "evmVersion": "byzantium", - "metadata": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "byzantium", + "metadata": { "key1": "test", - "useLiteralContent": true - } + "useLiteralContent": true + } } } diff --git a/test/cmdlineTests/standard_wrong_key_metadata/output.json b/test/cmdlineTests/standard_wrong_key_metadata/output.json index 1e846d19c708..e1ac73e8fd5a 100644 --- a/test/cmdlineTests/standard_wrong_key_metadata/output.json +++ b/test/cmdlineTests/standard_wrong_key_metadata/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"key1\"", diff --git a/test/cmdlineTests/standard_wrong_key_optimizer/input.json b/test/cmdlineTests/standard_wrong_key_optimizer/input.json index 945c1e3460ee..2d54f09ebfff 100644 --- a/test/cmdlineTests/standard_wrong_key_optimizer/input.json +++ b/test/cmdlineTests/standard_wrong_key_optimizer/input.json @@ -11,12 +11,12 @@ { "optimizer": { "key1": "test", - "enabled": true, - "runs": 200 - }, - "evmVersion": "byzantium", - "metadata": { - "useLiteralContent": true - } + "enabled": true, + "runs": 200 + }, + "evmVersion": "byzantium", + "metadata": { + "useLiteralContent": true + } } } diff --git a/test/cmdlineTests/standard_wrong_key_optimizer/output.json b/test/cmdlineTests/standard_wrong_key_optimizer/output.json index 1e846d19c708..e1ac73e8fd5a 100644 --- a/test/cmdlineTests/standard_wrong_key_optimizer/output.json +++ b/test/cmdlineTests/standard_wrong_key_optimizer/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"key1\"", diff --git a/test/cmdlineTests/standard_wrong_key_root/output.json b/test/cmdlineTests/standard_wrong_key_root/output.json index 1e846d19c708..e1ac73e8fd5a 100644 --- a/test/cmdlineTests/standard_wrong_key_root/output.json +++ b/test/cmdlineTests/standard_wrong_key_root/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"key1\"", diff --git a/test/cmdlineTests/standard_wrong_key_settings/input.json b/test/cmdlineTests/standard_wrong_key_settings/input.json index 8f0e1d06b96e..2ce8871f9e1b 100644 --- a/test/cmdlineTests/standard_wrong_key_settings/input.json +++ b/test/cmdlineTests/standard_wrong_key_settings/input.json @@ -1,22 +1,22 @@ { - "language": "Solidity", - "sources": - { - "A": - { - "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" - } - }, - "settings": - { - "optimizer": { - "enabled": true, - "runs": 200 - }, - "evmVersion": "byzantium", - "metadata": { - "useLiteralContent": true - }, - "key1": "test" - } + "language": "Solidity", + "sources": + { + "A": + { + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" + } + }, + "settings": + { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "byzantium", + "metadata": { + "useLiteralContent": true + }, + "key1": "test" + } } diff --git a/test/cmdlineTests/standard_wrong_key_settings/output.json b/test/cmdlineTests/standard_wrong_key_settings/output.json index 1e846d19c708..e1ac73e8fd5a 100644 --- a/test/cmdlineTests/standard_wrong_key_settings/output.json +++ b/test/cmdlineTests/standard_wrong_key_settings/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"key1\"", diff --git a/test/cmdlineTests/standard_wrong_key_source/output.json b/test/cmdlineTests/standard_wrong_key_source/output.json index 1e846d19c708..e1ac73e8fd5a 100644 --- a/test/cmdlineTests/standard_wrong_key_source/output.json +++ b/test/cmdlineTests/standard_wrong_key_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Unknown key \"key1\"", diff --git a/test/cmdlineTests/standard_wrong_type_auxiliary_input/output.json b/test/cmdlineTests/standard_wrong_type_auxiliary_input/output.json index 877ecad4dce6..efe3d722e629 100644 --- a/test/cmdlineTests/standard_wrong_type_auxiliary_input/output.json +++ b/test/cmdlineTests/standard_wrong_type_auxiliary_input/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"auxiliaryInput\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/output.json b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/output.json index c28238145e4c..ec3c7a804477 100644 --- a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/output.json +++ b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"auxiliaryInput.smtlib2responses\" must be an object.", diff --git a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/output.json b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/output.json index 6676998c6cca..0cbceafdad98 100644 --- a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/output.json +++ b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"smtlib2Responses.abc\" must be a string.", diff --git a/test/cmdlineTests/standard_wrong_type_metadata/output.json b/test/cmdlineTests/standard_wrong_type_metadata/output.json index df9f8cae37ad..38b2ffca6a96 100644 --- a/test/cmdlineTests/standard_wrong_type_metadata/output.json +++ b/test/cmdlineTests/standard_wrong_type_metadata/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.metadata\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_optimizer/output.json b/test/cmdlineTests/standard_wrong_type_optimizer/output.json index d7ce30326b92..c6bc5cc3fafa 100644 --- a/test/cmdlineTests/standard_wrong_type_optimizer/output.json +++ b/test/cmdlineTests/standard_wrong_type_optimizer/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.optimizer\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_output_selection/output.json b/test/cmdlineTests/standard_wrong_type_output_selection/output.json index d7d8f563fde5..346590a7cd89 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection/output.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.outputSelection\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_output_selection_contract/output.json b/test/cmdlineTests/standard_wrong_type_output_selection_contract/output.json index 5a35419ef94d..dbb4af997110 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection_contract/output.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection_contract/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.outputSelection.fileA.A\" must be a string array", diff --git a/test/cmdlineTests/standard_wrong_type_output_selection_file/output.json b/test/cmdlineTests/standard_wrong_type_output_selection_file/output.json index 888efc75b01c..4a7385834231 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection_file/output.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection_file/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.outputSelection.fileA\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_output_selection_output/output.json b/test/cmdlineTests/standard_wrong_type_output_selection_output/output.json index 5a35419ef94d..dbb4af997110 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection_output/output.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection_output/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.outputSelection.fileA.A\" must be a string array", diff --git a/test/cmdlineTests/standard_wrong_type_remappings/output.json b/test/cmdlineTests/standard_wrong_type_remappings/output.json index b94919077e18..a4c327048658 100644 --- a/test/cmdlineTests/standard_wrong_type_remappings/output.json +++ b/test/cmdlineTests/standard_wrong_type_remappings/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.remappings\" must be an array of strings.", diff --git a/test/cmdlineTests/standard_wrong_type_remappings_entry/output.json b/test/cmdlineTests/standard_wrong_type_remappings_entry/output.json index d083c85be340..75162fd057c1 100644 --- a/test/cmdlineTests/standard_wrong_type_remappings_entry/output.json +++ b/test/cmdlineTests/standard_wrong_type_remappings_entry/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.remappings\" must be an array of strings", diff --git a/test/cmdlineTests/standard_wrong_type_root/output.json b/test/cmdlineTests/standard_wrong_type_root/output.json index da8fefdf5944..59f7778b13c6 100644 --- a/test/cmdlineTests/standard_wrong_type_root/output.json +++ b/test/cmdlineTests/standard_wrong_type_root/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Input is not a JSON object.", diff --git a/test/cmdlineTests/standard_wrong_type_settings/output.json b/test/cmdlineTests/standard_wrong_type_settings/output.json index a25071c85884..d75283112a30 100644 --- a/test/cmdlineTests/standard_wrong_type_settings/output.json +++ b/test/cmdlineTests/standard_wrong_type_settings/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_source/output.json b/test/cmdlineTests/standard_wrong_type_source/output.json index 98496c64333d..0da063fb1c2a 100644 --- a/test/cmdlineTests/standard_wrong_type_source/output.json +++ b/test/cmdlineTests/standard_wrong_type_source/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"sources.A\" must be an object", diff --git a/test/cmdlineTests/standard_wrong_type_sources/output.json b/test/cmdlineTests/standard_wrong_type_sources/output.json index 3f5f51fcebc3..abf248c00e3f 100644 --- a/test/cmdlineTests/standard_wrong_type_sources/output.json +++ b/test/cmdlineTests/standard_wrong_type_sources/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"sources\" is not a JSON object.", diff --git a/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json b/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json index 7135c9856258..def6ad69e095 100644 --- a/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json +++ b/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "\"settings.metadata.useLiteralContent\" must be Boolean", diff --git a/test/cmdlineTests/standard_yul/output.json b/test/cmdlineTests/standard_yul/output.json index c1b22726fb84..8d2ab0074790 100644 --- a/test/cmdlineTests/standard_yul/output.json +++ b/test/cmdlineTests/standard_yul/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "object": - { - "evm": - { + "contracts": { + "A": { + "object": { + "evm": { "assembly": " /* \"A\":38:39 */ 0x00 /* \"A\":11:19 */ @@ -20,8 +16,7 @@ /* \"A\":0:42 */ stop ", - "bytecode": - { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -49,29 +44,21 @@ } } }, - "sources": - { - "A": - { - "ast": - { - "code": - { - "block": - { + "sources": { + "A": { + "ast": { + "code": { + "block": { "nativeSrc": "0:42:0", "nodeType": "YulBlock", "src": "0:42:0", - "statements": - [ + "statements": [ { "nativeSrc": "2:17:0", "nodeType": "YulVariableDeclaration", "src": "2:17:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "17:1:0", @@ -81,8 +68,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "11:5:0", "nodeType": "YulIdentifier", @@ -92,8 +78,7 @@ "nodeType": "YulFunctionCall", "src": "11:8:0" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "6:1:0", @@ -104,13 +89,10 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "x", "nativeSrc": "31:1:0", @@ -126,8 +108,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "27:3:0", "nodeType": "YulIdentifier", @@ -146,8 +127,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "sstore", "nativeSrc": "20:6:0", "nodeType": "YulIdentifier", diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/output.json b/test/cmdlineTests/standard_yul_debug_info_print_all/output.json index 9d675a06918d..c994baf4fcc2 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_all/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C_6_deployed": - { - "evm": - { + "contracts": { + "C": { + "C_6_deployed": { + "evm": { "assembly": " /* \"input.sol\":60:101 */ mstore(0x40, 0x80) tag_2 diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json b/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json index 8cbbd326c71e..54b37f8ef858 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C_6_deployed": - { - "evm": - { + "contracts": { + "C": { + "C_6_deployed": { + "evm": { "assembly": " /* \"input.sol\":60:101 */ mstore(0x40, 0x80) tag_2 diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/output.json b/test/cmdlineTests/standard_yul_debug_info_print_none/output.json index d1e4cff4cb3d..5b8cc709fb10 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_none/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "C": - { - "C_6_deployed": - { - "evm": - { + "contracts": { + "C": { + "C_6_deployed": { + "evm": { "assembly": " mstore(0x40, 0x80) tag_2 tag_1 diff --git a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json index fb7f199a75cf..7f48fd4e93bc 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "To use 'snippet' with settings.debug.debugInfo you must select also 'location'.", diff --git a/test/cmdlineTests/standard_yul_evm_version_byzantium/output.json b/test/cmdlineTests/standard_yul_evm_version_byzantium/output.json index 9fff562796b2..bbe178353f5f 100644 --- a/test/cmdlineTests/standard_yul_evm_version_byzantium/output.json +++ b/test/cmdlineTests/standard_yul_evm_version_byzantium/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Support for EVM versions older than constantinople is deprecated and will be removed in the future.", diff --git a/test/cmdlineTests/standard_yul_immutable_references/output.json b/test/cmdlineTests/standard_yul_immutable_references/output.json index 1f75e8ad20b1..7bfbb076a389 100644 --- a/test/cmdlineTests/standard_yul_immutable_references/output.json +++ b/test/cmdlineTests/standard_yul_immutable_references/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "A": - { - "YulTest": - { - "evm": - { - "bytecode": - { + "contracts": { + "A": { + "YulTest": { + "evm": { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -16,14 +11,11 @@ "opcodes":"", "sourceMap":"" }, - "deployedBytecode": - { + "deployedBytecode": { "functionDebugData": {}, "generatedSources": [], - "immutableReferences": - { - "test": - [ + "immutableReferences": { + "test": [ { "length": 32, "start": 1 diff --git a/test/cmdlineTests/standard_yul_multiple_files/output.json b/test/cmdlineTests/standard_yul_multiple_files/output.json index cdef28c267cf..88f390204eb3 100644 --- a/test/cmdlineTests/standard_yul_multiple_files/output.json +++ b/test/cmdlineTests/standard_yul_multiple_files/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Yul mode only supports exactly one input file.", diff --git a/test/cmdlineTests/standard_yul_multiple_files_selected/output.json b/test/cmdlineTests/standard_yul_multiple_files_selected/output.json index cdef28c267cf..88f390204eb3 100644 --- a/test/cmdlineTests/standard_yul_multiple_files_selected/output.json +++ b/test/cmdlineTests/standard_yul_multiple_files_selected/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Yul mode only supports exactly one input file.", diff --git a/test/cmdlineTests/standard_yul_object/output.json b/test/cmdlineTests/standard_yul_object/output.json index 1404cd3aa7df..87d0cab8f4ff 100644 --- a/test/cmdlineTests/standard_yul_object/output.json +++ b/test/cmdlineTests/standard_yul_object/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "NamedObject": - { - "evm": - { + "contracts": { + "A": { + "NamedObject": { + "evm": { "assembly": " /* \"A\":80:81 */ 0x00 /* \"A\":39:61 */ @@ -21,8 +17,7 @@ stop data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 ", - "bytecode": - { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -52,29 +47,21 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 } } }, - "sources": - { - "A": - { - "ast": - { - "code": - { - "block": - { + "sources": { + "A": { + "ast": { + "code": { + "block": { "nativeSrc": "28:56:0", "nodeType": "YulBlock", "src": "28:56:0", - "statements": - [ + "statements": [ { "nativeSrc": "30:31:0", "nodeType": "YulVariableDeclaration", "src": "30:31:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "hexValue": "446174614e616d65", "kind": "string", @@ -85,8 +72,7 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 "value": "DataName" } ], - "functionName": - { + "functionName": { "name": "dataoffset", "nativeSrc": "39:10:0", "nodeType": "YulIdentifier", @@ -96,8 +82,7 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 "nodeType": "YulFunctionCall", "src": "39:22:0" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "34:1:0", @@ -108,13 +93,10 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "x", "nativeSrc": "73:1:0", @@ -130,8 +112,7 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "69:3:0", "nodeType": "YulIdentifier", @@ -150,8 +131,7 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 "value": "0" } ], - "functionName": - { + "functionName": { "name": "sstore", "nativeSrc": "62:6:0", "nodeType": "YulIdentifier", @@ -171,8 +151,7 @@ data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 }, "name": "NamedObject", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { "nodeType": "YulData", "value": "616263" diff --git a/test/cmdlineTests/standard_yul_object_invalid_sub/output.json b/test/cmdlineTests/standard_yul_object_invalid_sub/output.json index 98522145a6e0..fea1aa169a17 100644 --- a/test/cmdlineTests/standard_yul_object_invalid_sub/output.json +++ b/test/cmdlineTests/standard_yul_object_invalid_sub/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "TypeError: Unknown data object \"NamedObject.\". @@ -12,8 +11,7 @@ ", "message": "Unknown data object \"NamedObject.\".", "severity": "error", - "sourceLocation": - { + "sourceLocation": { "end": 64, "file": "A", "start": 50 diff --git a/test/cmdlineTests/standard_yul_object_name/output.json b/test/cmdlineTests/standard_yul_object_name/output.json index 6803c322d194..c6e98130d210 100644 --- a/test/cmdlineTests/standard_yul_object_name/output.json +++ b/test/cmdlineTests/standard_yul_object_name/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "NamedObject": - { - "evm": - { + "contracts": { + "A": { + "NamedObject": { + "evm": { "assembly": " /* \"A\":80:81 */ 0x00 /* \"A\":39:61 */ @@ -29,8 +25,7 @@ sub_0: assembly { revert } ", - "bytecode": - { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -38,8 +33,7 @@ sub_0: assembly { "opcodes":"", "sourceMap":"" }, - "deployedBytecode": - { + "deployedBytecode": { "functionDebugData": {}, "generatedSources": [], "immutableReferences": {}, @@ -76,29 +70,21 @@ sub_0: assembly { } } }, - "sources": - { - "A": - { - "ast": - { - "code": - { - "block": - { + "sources": { + "A": { + "ast": { + "code": { + "block": { "nativeSrc": "28:56:0", "nodeType": "YulBlock", "src": "28:56:0", - "statements": - [ + "statements": [ { "nativeSrc": "30:31:0", "nodeType": "YulVariableDeclaration", "src": "30:31:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "hexValue": "446174614e616d65", "kind": "string", @@ -109,8 +95,7 @@ sub_0: assembly { "value": "DataName" } ], - "functionName": - { + "functionName": { "name": "dataoffset", "nativeSrc": "39:10:0", "nodeType": "YulIdentifier", @@ -120,8 +105,7 @@ sub_0: assembly { "nodeType": "YulFunctionCall", "src": "39:22:0" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "34:1:0", @@ -132,13 +116,10 @@ sub_0: assembly { ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "x", "nativeSrc": "73:1:0", @@ -154,8 +135,7 @@ sub_0: assembly { "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "69:3:0", "nodeType": "YulIdentifier", @@ -174,8 +154,7 @@ sub_0: assembly { "value": "0" } ], - "functionName": - { + "functionName": { "name": "sstore", "nativeSrc": "62:6:0", "nodeType": "YulIdentifier", @@ -195,27 +174,21 @@ sub_0: assembly { }, "name": "NamedObject", "nodeType": "YulObject", - "subObjects": - [ + "subObjects": [ { "nodeType": "YulData", "value": "616263" }, { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "135:16:0", "nodeType": "YulBlock", "src": "135:16:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "144:1:0", @@ -233,8 +206,7 @@ sub_0: assembly { "value": "0" } ], - "functionName": - { + "functionName": { "name": "revert", "nativeSrc": "137:6:0", "nodeType": "YulIdentifier", diff --git a/test/cmdlineTests/standard_yul_optimiserSteps/output.json b/test/cmdlineTests/standard_yul_optimiserSteps/output.json index 85a34261f02b..1c72379c610b 100644 --- a/test/cmdlineTests/standard_yul_optimiserSteps/output.json +++ b/test/cmdlineTests/standard_yul_optimiserSteps/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "object": - { - "evm": - { + "contracts": { + "A": { + "object": { + "evm": { "assembly": " /* \"A\":38:39 */ 0x00 /* \"A\":11:19 */ @@ -17,8 +13,7 @@ /* \"A\":0:42 */ stop ", - "bytecode": - { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -46,29 +41,21 @@ } } }, - "sources": - { - "A": - { - "ast": - { - "code": - { - "block": - { + "sources": { + "A": { + "ast": { + "code": { + "block": { "nativeSrc": "0:42:0", "nodeType": "YulBlock", "src": "0:42:0", - "statements": - [ + "statements": [ { "nativeSrc": "2:17:0", "nodeType": "YulVariableDeclaration", "src": "2:17:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "17:1:0", @@ -78,8 +65,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "11:5:0", "nodeType": "YulIdentifier", @@ -89,8 +75,7 @@ "nodeType": "YulFunctionCall", "src": "11:8:0" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "6:1:0", @@ -101,13 +86,10 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "x", "nativeSrc": "31:1:0", @@ -123,8 +105,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "27:3:0", "nodeType": "YulIdentifier", @@ -143,8 +124,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "sstore", "nativeSrc": "20:6:0", "nodeType": "YulIdentifier", diff --git a/test/cmdlineTests/standard_yul_optimized/output.json b/test/cmdlineTests/standard_yul_optimized/output.json index d580ef6ae01f..c443b2863f15 100644 --- a/test/cmdlineTests/standard_yul_optimized/output.json +++ b/test/cmdlineTests/standard_yul_optimized/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "object": - { - "evm": - { + "contracts": { + "A": { + "object": { + "evm": { "assembly": " /* \"A\":17:18 */ 0x00 /* \"A\":11:19 */ @@ -17,8 +13,7 @@ /* \"A\":0:42 */ stop ", - "bytecode": - { + "bytecode": { "functionDebugData": {}, "generatedSources": [], "linkReferences": {}, @@ -41,29 +36,21 @@ } } }, - "sources": - { - "A": - { - "ast": - { - "code": - { - "block": - { + "sources": { + "A": { + "ast": { + "code": { + "block": { "nativeSrc": "0:42:0", "nodeType": "YulBlock", "src": "0:42:0", - "statements": - [ + "statements": [ { "nativeSrc": "2:17:0", "nodeType": "YulVariableDeclaration", "src": "2:17:0", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "kind": "number", "nativeSrc": "17:1:0", @@ -73,8 +60,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "mload", "nativeSrc": "11:5:0", "nodeType": "YulIdentifier", @@ -84,8 +70,7 @@ "nodeType": "YulFunctionCall", "src": "11:8:0" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "6:1:0", @@ -96,13 +81,10 @@ ] }, { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "name": "x", "nativeSrc": "31:1:0", @@ -118,8 +100,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "add", "nativeSrc": "27:3:0", "nodeType": "YulIdentifier", @@ -138,8 +119,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "sstore", "nativeSrc": "20:6:0", "nodeType": "YulIdentifier", diff --git a/test/cmdlineTests/standard_yul_single_file_via_urls/output.json b/test/cmdlineTests/standard_yul_single_file_via_urls/output.json index a97057c88994..e76d039f5eff 100644 --- a/test/cmdlineTests/standard_yul_single_file_via_urls/output.json +++ b/test/cmdlineTests/standard_yul_single_file_via_urls/output.json @@ -1,6 +1,5 @@ { - "errors": - [ + "errors": [ { "component": "general", "formattedMessage": "Cannot import url (\"in.yul\"): File not found. Searched the following locations: \"\".", diff --git a/test/cmdlineTests/standard_yul_stack_opt/output.json b/test/cmdlineTests/standard_yul_stack_opt/output.json index e10ef0c1724f..9d89edfb4ae9 100644 --- a/test/cmdlineTests/standard_yul_stack_opt/output.json +++ b/test/cmdlineTests/standard_yul_stack_opt/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "object": - { - "evm": - { + "contracts": { + "A": { + "object": { + "evm": { "assembly": " /* \"A\":16:17 */ 0x01 /* \"A\":27:28 */ diff --git a/test/cmdlineTests/standard_yul_stack_opt_disabled/output.json b/test/cmdlineTests/standard_yul_stack_opt_disabled/output.json index 8d58cf320415..f0752b812b44 100644 --- a/test/cmdlineTests/standard_yul_stack_opt_disabled/output.json +++ b/test/cmdlineTests/standard_yul_stack_opt_disabled/output.json @@ -1,12 +1,8 @@ { - "contracts": - { - "A": - { - "object": - { - "evm": - { + "contracts": { + "A": { + "object": { + "evm": { "assembly": " /* \"A\":16:17 */ 0x01 /* \"A\":27:28 */ diff --git a/test/cmdlineTests/stop_after_parsing_ast/output b/test/cmdlineTests/stop_after_parsing_ast/output index 163941860401..6cca9557da1b 100644 --- a/test/cmdlineTests/stop_after_parsing_ast/output +++ b/test/cmdlineTests/stop_after_parsing_ast/output @@ -7,12 +7,10 @@ JSON AST (compact format): "id": 4, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "solidity", "*" ], diff --git a/test/cmdlineTests/storage_layout_bytes/output.json b/test/cmdlineTests/storage_layout_bytes/output.json index c2ca7813c672..67091e974e2b 100644 --- a/test/cmdlineTests/storage_layout_bytes/output.json +++ b/test/cmdlineTests/storage_layout_bytes/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 4, "contract": "fileA:A", @@ -26,10 +21,8 @@ "type": "t_bytes_storage" } ], - "types": - { - "t_bytes_storage": - { + "types": { + "t_bytes_storage": { "encoding": "bytes", "label": "bytes", "numberOfBytes": "32" @@ -39,10 +32,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_dyn_array/output.json b/test/cmdlineTests/storage_layout_dyn_array/output.json index fa7ed04bad1b..f4468c411d3b 100644 --- a/test/cmdlineTests/storage_layout_dyn_array/output.json +++ b/test/cmdlineTests/storage_layout_dyn_array/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 4, "contract": "fileA:A", @@ -26,30 +21,25 @@ "type": "t_array(t_bool)dyn_storage" } ], - "types": - { - "t_array(t_bool)dyn_storage": - { + "types": { + "t_array(t_bool)dyn_storage": { "base": "t_bool", "encoding": "dynamic_array", "label": "bool[]", "numberOfBytes": "32" }, - "t_array(t_uint256)dyn_storage": - { + "t_array(t_uint256)dyn_storage": { "base": "t_uint256", "encoding": "dynamic_array", "label": "uint256[]", "numberOfBytes": "32" }, - "t_bool": - { + "t_bool": { "encoding": "inplace", "label": "bool", "numberOfBytes": "1" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" @@ -59,10 +49,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_many/output.json b/test/cmdlineTests/storage_layout_many/output.json index 68cb00682477..fa1b6f13e2a7 100644 --- a/test/cmdlineTests/storage_layout_many/output.json +++ b/test/cmdlineTests/storage_layout_many/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 15, "contract": "fileA:A", @@ -74,68 +69,57 @@ "type": "t_bytes_storage" } ], - "types": - { - "t_address": - { + "types": { + "t_address": { "encoding": "inplace", "label": "address", "numberOfBytes": "20" }, - "t_array(t_uint256)2_storage": - { + "t_array(t_uint256)2_storage": { "base": "t_uint256", "encoding": "inplace", "label": "uint256[2]", "numberOfBytes": "64" }, - "t_array(t_uint256)dyn_storage": - { + "t_array(t_uint256)dyn_storage": { "base": "t_uint256", "encoding": "dynamic_array", "label": "uint256[]", "numberOfBytes": "32" }, - "t_bool": - { + "t_bool": { "encoding": "inplace", "label": "bool", "numberOfBytes": "1" }, - "t_bytes_storage": - { + "t_bytes_storage": { "encoding": "bytes", "label": "bytes", "numberOfBytes": "32" }, - "t_mapping(t_address,t_bool)": - { + "t_mapping(t_address,t_bool)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => bool)", "numberOfBytes": "32", "value": "t_bool" }, - "t_mapping(t_uint256,t_mapping(t_address,t_bool))": - { + "t_mapping(t_uint256,t_mapping(t_address,t_bool))": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => mapping(address => bool))", "numberOfBytes": "32", "value": "t_mapping(t_address,t_bool)" }, - "t_string_storage": - { + "t_string_storage": { "encoding": "bytes", "label": "string", "numberOfBytes": "32" }, - "t_struct(S)13_storage": - { + "t_struct(S)13_storage": { "encoding": "inplace", "label": "struct A.S", - "members": - [ + "members": [ { "astId": 3, "contract": "fileA:A", @@ -171,14 +155,12 @@ ], "numberOfBytes": "128" }, - "t_uint128": - { + "t_uint128": { "encoding": "inplace", "label": "uint128", "numberOfBytes": "16" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" @@ -188,10 +170,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_mapping/output.json b/test/cmdlineTests/storage_layout_mapping/output.json index 8d13fb34b45d..9fb9f847c575 100644 --- a/test/cmdlineTests/storage_layout_mapping/output.json +++ b/test/cmdlineTests/storage_layout_mapping/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 3, "contract": "fileA:A", @@ -34,38 +29,32 @@ "type": "t_mapping(t_uint256,t_mapping(t_address,t_bool))" } ], - "types": - { - "t_address": - { + "types": { + "t_address": { "encoding": "inplace", "label": "address", "numberOfBytes": "20" }, - "t_bool": - { + "t_bool": { "encoding": "inplace", "label": "bool", "numberOfBytes": "1" }, - "t_mapping(t_address,t_bool)": - { + "t_mapping(t_address,t_bool)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => bool)", "numberOfBytes": "32", "value": "t_bool" }, - "t_mapping(t_uint256,t_mapping(t_address,t_bool))": - { + "t_mapping(t_uint256,t_mapping(t_address,t_bool))": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => mapping(address => bool))", "numberOfBytes": "32", "value": "t_mapping(t_address,t_bool)" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" @@ -75,10 +64,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_smoke/output.json b/test/cmdlineTests/storage_layout_smoke/output.json index 9fe46bb673c5..e2eaee5004e1 100644 --- a/test/cmdlineTests/storage_layout_smoke/output.json +++ b/test/cmdlineTests/storage_layout_smoke/output.json @@ -1,22 +1,16 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { + "contracts": { + "fileA": { + "A": { + "storageLayout": { "storage": [], "types": null } } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_smoke_two_contracts/output.json b/test/cmdlineTests/storage_layout_smoke_two_contracts/output.json index fc4e422a5e72..2b94484591e3 100644 --- a/test/cmdlineTests/storage_layout_smoke_two_contracts/output.json +++ b/test/cmdlineTests/storage_layout_smoke_two_contracts/output.json @@ -1,26 +1,19 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { + "contracts": { + "fileA": { + "A": { + "storageLayout": { "storage": [], "types": null } } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 }, - "fileB": - { + "fileB": { "id": 1 } } diff --git a/test/cmdlineTests/storage_layout_string/output.json b/test/cmdlineTests/storage_layout_string/output.json index 20c6f64ccd3a..2fcb974dbd30 100644 --- a/test/cmdlineTests/storage_layout_string/output.json +++ b/test/cmdlineTests/storage_layout_string/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 4, "contract": "fileA:A", @@ -26,10 +21,8 @@ "type": "t_string_storage" } ], - "types": - { - "t_string_storage": - { + "types": { + "t_string_storage": { "encoding": "bytes", "label": "string", "numberOfBytes": "32" @@ -39,10 +32,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_struct/output.json b/test/cmdlineTests/storage_layout_struct/output.json index f682d9634a3d..1fadb220e876 100644 --- a/test/cmdlineTests/storage_layout_struct/output.json +++ b/test/cmdlineTests/storage_layout_struct/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 15, "contract": "fileA:A", @@ -42,34 +37,28 @@ "type": "t_address" } ], - "types": - { - "t_address": - { + "types": { + "t_address": { "encoding": "inplace", "label": "address", "numberOfBytes": "20" }, - "t_array(t_uint256)2_storage": - { + "t_array(t_uint256)2_storage": { "base": "t_uint256", "encoding": "inplace", "label": "uint256[2]", "numberOfBytes": "64" }, - "t_array(t_uint256)dyn_storage": - { + "t_array(t_uint256)dyn_storage": { "base": "t_uint256", "encoding": "dynamic_array", "label": "uint256[]", "numberOfBytes": "32" }, - "t_struct(S)13_storage": - { + "t_struct(S)13_storage": { "encoding": "inplace", "label": "struct A.S", - "members": - [ + "members": [ { "astId": 3, "contract": "fileA:A", @@ -105,8 +94,7 @@ ], "numberOfBytes": "160" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" @@ -116,10 +104,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_struct_packed/output.json b/test/cmdlineTests/storage_layout_struct_packed/output.json index 7731bd2230d3..f91a9a0cd3d6 100644 --- a/test/cmdlineTests/storage_layout_struct_packed/output.json +++ b/test/cmdlineTests/storage_layout_struct_packed/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 15, "contract": "fileA:A", @@ -42,34 +37,28 @@ "type": "t_address" } ], - "types": - { - "t_address": - { + "types": { + "t_address": { "encoding": "inplace", "label": "address", "numberOfBytes": "20" }, - "t_array(t_uint256)2_storage": - { + "t_array(t_uint256)2_storage": { "base": "t_uint256", "encoding": "inplace", "label": "uint256[2]", "numberOfBytes": "64" }, - "t_array(t_uint256)dyn_storage": - { + "t_array(t_uint256)dyn_storage": { "base": "t_uint256", "encoding": "dynamic_array", "label": "uint256[]", "numberOfBytes": "32" }, - "t_struct(S)13_storage": - { + "t_struct(S)13_storage": { "encoding": "inplace", "label": "struct A.S", - "members": - [ + "members": [ { "astId": 3, "contract": "fileA:A", @@ -105,14 +94,12 @@ ], "numberOfBytes": "128" }, - "t_uint128": - { + "t_uint128": { "encoding": "inplace", "label": "uint128", "numberOfBytes": "16" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" @@ -122,10 +109,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_user_defined/output b/test/cmdlineTests/storage_layout_user_defined/output index f79b8413e664..bb7819c66f12 100644 --- a/test/cmdlineTests/storage_layout_user_defined/output +++ b/test/cmdlineTests/storage_layout_user_defined/output @@ -2,8 +2,7 @@ ======= storage_layout_user_defined/input.sol:C ======= Contract Storage Layout: { - "storage": - [ + "storage": [ { "astId": 7, "contract": "storage_layout_user_defined/input.sol:C", @@ -69,16 +68,13 @@ Contract Storage Layout: "type": "t_userDefinedValueType(MyInt8)4" } ], - "types": - { - "t_userDefinedValueType(MyInt128)2": - { + "types": { + "t_userDefinedValueType(MyInt128)2": { "encoding": "inplace", "label": "MyInt128", "numberOfBytes": "16" }, - "t_userDefinedValueType(MyInt8)4": - { + "t_userDefinedValueType(MyInt8)4": { "encoding": "inplace", "label": "MyInt8", "numberOfBytes": "1" diff --git a/test/cmdlineTests/storage_layout_value_types/output.json b/test/cmdlineTests/storage_layout_value_types/output.json index 10fbd762b5d2..b737adc973c3 100644 --- a/test/cmdlineTests/storage_layout_value_types/output.json +++ b/test/cmdlineTests/storage_layout_value_types/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 3, "contract": "fileA:A", @@ -42,23 +37,19 @@ "type": "t_array(t_uint256)2_storage" } ], - "types": - { - "t_address": - { + "types": { + "t_address": { "encoding": "inplace", "label": "address", "numberOfBytes": "20" }, - "t_array(t_uint256)2_storage": - { + "t_array(t_uint256)2_storage": { "base": "t_uint256", "encoding": "inplace", "label": "uint256[2]", "numberOfBytes": "64" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" @@ -68,10 +59,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/storage_layout_value_types_packed/output.json b/test/cmdlineTests/storage_layout_value_types_packed/output.json index eefb69e667e4..cea9bc81c633 100644 --- a/test/cmdlineTests/storage_layout_value_types_packed/output.json +++ b/test/cmdlineTests/storage_layout_value_types_packed/output.json @@ -1,14 +1,9 @@ { - "contracts": - { - "fileA": - { - "A": - { - "storageLayout": - { - "storage": - [ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ { "astId": 3, "contract": "fileA:A", @@ -50,35 +45,29 @@ "type": "t_array(t_uint256)2_storage" } ], - "types": - { - "t_address": - { + "types": { + "t_address": { "encoding": "inplace", "label": "address", "numberOfBytes": "20" }, - "t_array(t_uint256)2_storage": - { + "t_array(t_uint256)2_storage": { "base": "t_uint256", "encoding": "inplace", "label": "uint256[2]", "numberOfBytes": "64" }, - "t_uint128": - { + "t_uint128": { "encoding": "inplace", "label": "uint128", "numberOfBytes": "16" }, - "t_uint256": - { + "t_uint256": { "encoding": "inplace", "label": "uint256", "numberOfBytes": "32" }, - "t_uint64": - { + "t_uint64": { "encoding": "inplace", "label": "uint64", "numberOfBytes": "8" @@ -88,10 +77,8 @@ } } }, - "sources": - { - "fileA": - { + "sources": { + "fileA": { "id": 0 } } diff --git a/test/cmdlineTests/strict_asm_ast_compact_json/output b/test/cmdlineTests/strict_asm_ast_compact_json/output index 98afddcfa9d7..b4c6dc142467 100644 --- a/test/cmdlineTests/strict_asm_ast_compact_json/output +++ b/test/cmdlineTests/strict_asm_ast_compact_json/output @@ -3,26 +3,20 @@ AST: { - "code": - { - "block": - { + "code": { + "block": { "nativeSrc": "60:246:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { "nativeSrc": "60:246:0", "nodeType": "YulBlock", "src": "-1:-1:0", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { "kind": "number", "nativeSrc": "122:2:0", @@ -40,8 +34,7 @@ AST: "value": "128" } ], - "functionName": - { + "functionName": { "name": "mstore", "nativeSrc": "115:6:0", "nodeType": "YulIdentifier", diff --git a/test/cmdlineTests/viair_subobject_optimization/output b/test/cmdlineTests/viair_subobject_optimization/output index 5090c282bb24..dafba2771c5d 100644 --- a/test/cmdlineTests/viair_subobject_optimization/output +++ b/test/cmdlineTests/viair_subobject_optimization/output @@ -119,53 +119,50 @@ sub_0: assembly { jumpi(tag_7, slt(add(not(0x03), calldatasize), 0x00)) /* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */ dataSize(sub_0) - /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ - swap1 - not(0x1f) swap1 - dup2 + /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ 0x3f - dup5 + dup3 add + not(0x1f) and dup2 add - swap2 + swap1 + 0xffffffffffffffff + dup3 + gt dup2 dup4 lt - 0xffffffffffffffff - dup5 - gt or tag_9 jumpi 0x40 - swap3 - dup4 + swap2 + dup3 mstore /* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */ - dup4 dup3 + dup2 mstore 0x20 - dup3 + dup2 add - swap4 + swap3 dataOffset(sub_0) - dup6 + dup5 codecopy /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ - 0x1f - dup4 + dup2 mload - swap5 - dup6 - swap4 + swap3 + dup4 + swap2 /* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */ 0x20 /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ - dup6 + dup4 mstore mload dup1 @@ -174,21 +171,23 @@ sub_0: assembly { /* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */ 0x20 /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ - dup8 + dup6 add mstore - dup7 - dup7 + dup5 + dup5 add mcopy 0x00 - dup6 dup3 - dup7 + dup3 add + dup5 add mstore + 0x1f add + not(0x1f) and dup2 add diff --git a/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/args b/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/args new file mode 100644 index 000000000000..da9301b32f2c --- /dev/null +++ b/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/args @@ -0,0 +1 @@ +--metadata --yul-optimizations : \ No newline at end of file diff --git a/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/input.sol b/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/input.sol new file mode 100644 index 000000000000..37cd85bffa5d --- /dev/null +++ b/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/input.sol @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; +contract C { } \ No newline at end of file diff --git a/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/output b/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/output new file mode 100644 index 000000000000..7b948303ee43 --- /dev/null +++ b/test/cmdlineTests/yul_optimizer_disabled_sequence_empty/output @@ -0,0 +1,4 @@ + +======= yul_optimizer_disabled_sequence_empty/input.sol:C ======= +Metadata: +{"compiler":{"version": ""},"language":"Solidity","output":{"abi":[],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"yul_optimizer_disabled_sequence_empty/input.sol":"C"},"evmVersion":"cancun","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"details":{"constantOptimizer":false,"cse":false,"deduplicate":false,"inliner":false,"jumpdestRemover":true,"orderLiterals":false,"peephole":true,"simpleCounterForLoopUncheckedIncrement":true,"yul":false,"yulDetails":{"optimizerSteps":":"}},"runs":200},"remappings":[]},"sources":{"yul_optimizer_disabled_sequence_empty/input.sol":{"keccak256":"0xc2db3500808896ce1e69de2fe20cecab7ae2ffbb47cdf6ba8321296d95f49fc5","license":"GPL-3.0","urls":["bzz-raw://fde21393c068cd9f2d2b10ba4782db54f6f1c9a725074b17fa742531076be8a4","dweb:/ipfs/QmeTD6mR7YrWNyRowKRS7xs6cJNeMF3T49GAHzGM1bquyM"]}},"version":1} diff --git a/test/cmdlineTests/yul_optimizer_steps_disabled/err b/test/cmdlineTests/yul_optimizer_steps_disabled/err index 1abbab8bde55..c5a2e506d74b 100644 --- a/test/cmdlineTests/yul_optimizer_steps_disabled/err +++ b/test/cmdlineTests/yul_optimizer_steps_disabled/err @@ -1 +1 @@ -Error: --yul-optimizations is invalid with a non-empty sequence if Yul optimizer is disabled. +Error: --yul-optimizations is invalid with a non-empty sequence if Yul optimizer is disabled. Note that the empty optimizer sequence is properly denoted by ":". diff --git a/test/cmdlineTests/yul_string_format_ascii/output.json b/test/cmdlineTests/yul_string_format_ascii/output.json index edb76c0cd405..6847228b53a5 100644 --- a/test/cmdlineTests/yul_string_format_ascii/output.json +++ b/test/cmdlineTests/yul_string_format_ascii/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "ir": " /// @use-src 0:\"A\" object \"C_11\" { @@ -217,10 +214,8 @@ object \"C_11\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json b/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json index bfe775ca40c5..2e077e8594a4 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "ir": " /// @use-src 0:\"A\" object \"C_11\" { @@ -147,10 +144,8 @@ object \"C_11\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json index f4b14aadcfc5..d2044189a848 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "ir": " /// @use-src 0:\"A\" object \"C_11\" { @@ -160,10 +157,8 @@ object \"C_11\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/yul_string_format_ascii_long/output.json b/test/cmdlineTests/yul_string_format_ascii_long/output.json index 36d6cfd954e9..20644f3a3b73 100644 --- a/test/cmdlineTests/yul_string_format_ascii_long/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_long/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "ir": " /// @use-src 0:\"A\" object \"C_11\" { @@ -221,10 +218,8 @@ object \"C_11\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/yul_string_format_hex/output.json b/test/cmdlineTests/yul_string_format_hex/output.json index 5568fc7a0d1e..a120fa4c9b7c 100644 --- a/test/cmdlineTests/yul_string_format_hex/output.json +++ b/test/cmdlineTests/yul_string_format_hex/output.json @@ -1,10 +1,7 @@ { - "contracts": - { - "A": - { - "C": - { + "contracts": { + "A": { + "C": { "ir": " /// @use-src 0:\"A\" object \"C_11\" { @@ -160,10 +157,8 @@ object \"C_11\" { } } }, - "sources": - { - "A": - { + "sources": { + "A": { "id": 0 } } diff --git a/test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/inputs.sol b/test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/inputs.sol new file mode 100644 index 000000000000..ff982c56d495 --- /dev/null +++ b/test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/inputs.sol @@ -0,0 +1,13 @@ +==== Source: A.sol ==== +contract DummyContract1 {} +contract DummyContract2 {} +contract DummyContract3 {} + +==== Source: B.sol ==== +contract B { + function f(uint8 a_0, uint8 a_1, uint8 a_2) public pure { + a_1 = 1; + a_2 = 2; + a_0; + } +} diff --git a/test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/test.py b/test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/test.py new file mode 100755 index 000000000000..e15293b8ea61 --- /dev/null +++ b/test/cmdlineTests/~bytecode_equivalence_with_unused_contracts/test.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import os +import sys +from pathlib import Path +from textwrap import dedent + +# pylint: disable=wrong-import-position +PROJECT_ROOT = Path(__file__).parents[3] +sys.path.insert(0, str(PROJECT_ROOT / "scripts")) + +from common.cmdline_helpers import add_preamble +from common.cmdline_helpers import inside_temporary_dir +from common.cmdline_helpers import save_bytecode +from common.cmdline_helpers import solc_bin_report +from common.git_helpers import git_diff +from splitSources import split_sources + + +@inside_temporary_dir(Path(__file__).parent.name) +def test_bytecode_equivalence(): + source_file_path = Path(__file__).parent / "inputs.sol" + split_sources(source_file_path, suppress_output=True) + add_preamble(Path.cwd()) + + solc_binary = os.environ.get("SOLC") + if solc_binary is None: + raise RuntimeError( + dedent( + """\ + `solc` compiler not found. + Please ensure you set the SOLC environment variable + with the correct path to the compiler's binary. + """ + ) + ) + + # Repro for https://github.com/ethereum/solidity/issues/14829 + save_bytecode( + Path("B.bin"), + solc_bin_report( + solc_binary, + [Path("B.sol")], + via_ir=True, + optimize=True, + yul_optimizations="a:", + ), + contract="B", + ) + save_bytecode( + Path("AB.bin"), + solc_bin_report( + solc_binary, + [Path("A.sol"), Path("B.sol")], + via_ir=True, + optimize=True, + yul_optimizations="a:", + ), + contract="B", + ) + return git_diff(Path("B.bin"), Path("AB.bin")) + + +if __name__ == "__main__": + sys.exit(test_bytecode_equivalence()) diff --git a/test/cmdlineTests/~documentation_examples/test.sh b/test/cmdlineTests/~documentation_examples/test.sh index 1acf5e8a7a4f..636f9600d2a8 100755 --- a/test/cmdlineTests/~documentation_examples/test.sh +++ b/test/cmdlineTests/~documentation_examples/test.sh @@ -39,6 +39,10 @@ do then opts+=(--ignore-warnings) fi + if grep "// This will only compile via IR" "$f" >/dev/null + then + opts+=(--via-ir) + fi # Disable the version pragma in code snippets that only work with the current development version. # It's necessary because x.y.z won't match `^x.y.z` or `>=x.y.z` pragmas until it's officially released. diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol index 8dbe76212bd5..646ab00e1594 100644 --- a/test/compilationTests/corion/premium.sol +++ b/test/compilationTests/corion/premium.sol @@ -310,7 +310,7 @@ contract premium is module, safeMath { @addr The address which is needed to be checked. - @success Is the address crontact or not + @success Is the address contract or not */ uint256 _codeLength; assembly { diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol index 2503748b8b5c..96b530d26e83 100644 --- a/test/compilationTests/corion/schelling.sol +++ b/test/compilationTests/corion/schelling.sol @@ -521,7 +521,7 @@ contract schelling is module, announcementTypes, schellingVars { @aboveW Weight of votes: ABOVE @belowW Weight of votes: BELOW - @uint256 Calculatet weight + @uint256 Calculate weight */ if ( aboveW == belowW ) { return aboveW + belowW; diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol index 424b5e2bbae3..219108713b56 100644 --- a/test/compilationTests/corion/token.sol +++ b/test/compilationTests/corion/token.sol @@ -463,7 +463,7 @@ contract token is safeMath, module, announcementTypes { @addr Address to be checked - @success Is the address crontact or not + @success Is the address contract or not */ uint256 _codeLength; assembly { diff --git a/test/externalTests/brink.sh b/test/externalTests/brink.sh index d8ad001ac014..02e5fe971c65 100755 --- a/test/externalTests/brink.sh +++ b/test/externalTests/brink.sh @@ -68,8 +68,8 @@ function brink_test neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" "$CURRENT_EVM_VERSION" "$extra_settings" "$extra_optimizer_settings" - yarn install - yarn add hardhat-gas-reporter + pnpm install + pnpm install hardhat-gas-reporter replace_version_pragmas for preset in $SELECTED_PRESETS; do diff --git a/test/externalTests/ens.sh b/test/externalTests/ens.sh index a011dd2a720c..b7a053f6f7bf 100755 --- a/test/externalTests/ens.sh +++ b/test/externalTests/ens.sh @@ -62,7 +62,7 @@ function ens_test neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" - yarn install + pnpm install replace_version_pragmas neutralize_packaged_contracts diff --git a/test/externalTests/perpetual-pools.sh b/test/externalTests/perpetual-pools.sh deleted file mode 100755 index 1d7bb8f33b3e..000000000000 --- a/test/externalTests/perpetual-pools.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash - -# ------------------------------------------------------------------------------ -# This file is part of solidity. -# -# solidity is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# solidity is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with solidity. If not, see -# -# (c) 2022 solidity contributors. -#------------------------------------------------------------------------------ - -set -e - -source scripts/common.sh -source scripts/externalTests/common.sh - -REPO_ROOT=$(realpath "$(dirname "$0")/../..") - -verify_input "$@" -BINARY_TYPE="$1" -BINARY_PATH="$(realpath "$2")" -SELECTED_PRESETS="$3" - -function compile_fn { yarn build; } -function test_fn { yarn test; } - -function perpetual_pools_test -{ - local repo="https://github.com/solidity-external-tests/perpetual-pools-contracts" - local ref=pools-v2 - local config_file="hardhat.config.ts" - local config_var="config" - - local compile_only_presets=() - local settings_presets=( - "${compile_only_presets[@]}" - ir-no-optimize - ir-optimize-evm-only - ir-optimize-evm+yul - legacy-no-optimize - legacy-optimize-evm-only - legacy-optimize-evm+yul - ) - - [[ $SELECTED_PRESETS != "" ]] || SELECTED_PRESETS=$(circleci_select_steps_multiarg "${settings_presets[@]}") - print_presets_or_exit "$SELECTED_PRESETS" - - setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" - download_project "$repo" "$ref" "$DIR" - - # Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables - # them for other presets but that's fine - we want same code run for benchmarks to be comparable. - # TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/3365). - sed -i 's|\(it\)\(("Should not allow commits that are too large"\)|\1.skip\2|g' test/PoolCommitter/commit.spec.ts - sed -i 's|\(it\)\(("Should not allow for too many commitments (that bring amount over a user'\''s balance)"\)|\1.skip\2|g' test/PoolCommitter/commit.spec.ts - - neutralize_package_lock - neutralize_package_json_hooks - force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" - force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" - force_hardhat_unlimited_contract_size "$config_file" "$config_var" - - yarn install - # We set hardhat version to 2.20.0 since version 2.21.0 has issues with solidity-coverage plugin - # that often causes out-of-memory errors. - # See hardhat note about the issue here: https://github.com/NomicFoundation/hardhat/releases/tag/hardhat@2.21.0 - yarn add hardhat@2.20.0 - - replace_version_pragmas - - for preset in $SELECTED_PRESETS; do - hardhat_run_test "$config_file" "$preset" "${compile_only_presets[*]}" compile_fn test_fn "$config_var" - store_benchmark_report hardhat perpetual-pools "$repo" "$preset" - done -} - -external_test Tracer-Perpetual-Pools perpetual_pools_test diff --git a/test/externalTests/prb-math.py b/test/externalTests/prb-math.py index 2d1469fc9015..0cfefb843fa2 100755 --- a/test/externalTests/prb-math.py +++ b/test/externalTests/prb-math.py @@ -43,7 +43,7 @@ def configure(self): # Starting from version v4.0.2, the default installation method for PRBMath dependencies # has transitioned from Foundry to Node.js. subprocess.run( - ["pnpm", "install"], + ["pnpm", "install", "--no-frozen-lockfile"], env=self.env, check=True ) diff --git a/test/externalTests/uniswap.sh b/test/externalTests/uniswap.sh index 04f27ab3f77f..f3d78e6e3397 100755 --- a/test/externalTests/uniswap.sh +++ b/test/externalTests/uniswap.sh @@ -83,17 +83,17 @@ function uniswap_test # - Newer versions of ethereumjs/tx have an issue with 'gteHardfork()' method. neutralize_package_lock - yarn install - yarn add hardhat-gas-reporter + pnpm install + pnpm install hardhat-gas-reporter # With ethers.js 5.6.2 many tests for revert messages fail. # TODO: Remove when https://github.com/ethers-io/ethers.js/discussions/2849 is resolved. - yarn add ethers@5.6.1 + pnpm install ethers@5.6.1 # We set hardhat version to 2.20.0 since version 2.21.0 has issues with solidity-coverage plugin # that often causes out-of-memory errors. # See hardhat note about the issue here: https://github.com/NomicFoundation/hardhat/releases/tag/hardhat@2.21.0 - yarn add hardhat@2.20.0 + pnpm install hardhat@2.20.0 replace_version_pragmas diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index 2b01ae03c7ec..afad9d13ddc5 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(all_assembly_items) "{\"begin\":8,\"end\":18,\"name\":\"MSTORE\",\"source\":2}" "]},\"A6885B3731702DA62E8E4A8F584AC46A7F6822F4E2BA50FBA902F67B1588D23B\":\"01020304\"},\"sourceList\":[\"root.asm\",\"sub.asm\",\"verbatim.asm\"]}" }; - Json::Value jsonValue; + Json jsonValue; BOOST_CHECK(util::jsonParseStrict(json, jsonValue)); BOOST_CHECK_EQUAL(util::jsonCompactPrint(_assembly.assemblyJSON(indices)), util::jsonCompactPrint(jsonValue)); } diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index e1795d391ce2..04d41fffeb18 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -1358,11 +1358,11 @@ BOOST_AUTO_TEST_CASE(cse_verbatim_mload) auto verbatim = AssemblyItem{bytes{1, 2, 3, 4, 5}, 0, 0}; AssemblyItems input{ u256(1000), - Instruction::MLOAD, // Should not be removed + Instruction::MLOAD, // Should not be removed Instruction::POP, verbatim, u256(1000), - Instruction::MLOAD, // Should not be removed + Instruction::MLOAD, // Should not be removed Instruction::POP, }; diff --git a/test/libsolidity/ABIJson/basic_test.sol b/test/libsolidity/ABIJson/basic_test.sol index 37c833bcfa29..8f60eb728208 100644 --- a/test/libsolidity/ABIJson/basic_test.sol +++ b/test/libsolidity/ABIJson/basic_test.sol @@ -5,8 +5,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -14,8 +13,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", diff --git a/test/libsolidity/ABIJson/constructor_abi.sol b/test/libsolidity/ABIJson/constructor_abi.sol index ae07c9401138..406927f0ae8c 100644 --- a/test/libsolidity/ABIJson/constructor_abi.sol +++ b/test/libsolidity/ABIJson/constructor_abi.sol @@ -5,8 +5,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "param1", diff --git a/test/libsolidity/ABIJson/empty_name_input_parameter_with_named_one.sol b/test/libsolidity/ABIJson/empty_name_input_parameter_with_named_one.sol index d412e755acff..c3ba37b0e7f7 100644 --- a/test/libsolidity/ABIJson/empty_name_input_parameter_with_named_one.sol +++ b/test/libsolidity/ABIJson/empty_name_input_parameter_with_named_one.sol @@ -9,8 +9,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "", @@ -23,8 +22,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "ret_k", diff --git a/test/libsolidity/ABIJson/empty_name_return_parameters.sol b/test/libsolidity/ABIJson/empty_name_return_parameters.sol index 1415276fdce9..56c4de8a2442 100644 --- a/test/libsolidity/ABIJson/empty_name_return_parameters.sol +++ b/test/libsolidity/ABIJson/empty_name_return_parameters.sol @@ -7,8 +7,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "k", @@ -16,8 +15,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "", diff --git a/test/libsolidity/ABIJson/errors.sol b/test/libsolidity/ABIJson/errors.sol index 91c76ce6f44b..86b16dd85133 100644 --- a/test/libsolidity/ABIJson/errors.sol +++ b/test/libsolidity/ABIJson/errors.sol @@ -13,8 +13,7 @@ contract X { // :X // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "", @@ -25,8 +24,7 @@ contract X { // "type": "error" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -42,8 +40,7 @@ contract X { // "type": "error" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -59,11 +56,9 @@ contract X { // "type": "error" // }, // { -// "inputs": -// [ +// "inputs": [ // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256", // "name": "x", diff --git a/test/libsolidity/ABIJson/errors_referenced.sol b/test/libsolidity/ABIJson/errors_referenced.sol index ecb5b1003e2a..a624bda105c3 100644 --- a/test/libsolidity/ABIJson/errors_referenced.sol +++ b/test/libsolidity/ABIJson/errors_referenced.sol @@ -34,8 +34,7 @@ contract X is C { // :D // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "", @@ -61,8 +60,7 @@ contract X is C { // "type": "error" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "", @@ -78,8 +76,7 @@ contract X is C { // "type": "error" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "x", diff --git a/test/libsolidity/ABIJson/event_emited_in_base_contract.sol b/test/libsolidity/ABIJson/event_emited_in_base_contract.sol index f9c3d2019cbe..043b92d5552e 100644 --- a/test/libsolidity/ABIJson/event_emited_in_base_contract.sol +++ b/test/libsolidity/ABIJson/event_emited_in_base_contract.sol @@ -18,8 +18,7 @@ contract C is B {} // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint8", @@ -37,8 +36,7 @@ contract C is B {} // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint8", @@ -56,8 +54,7 @@ contract C is B {} // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint8", diff --git a/test/libsolidity/ABIJson/event_emitted_from_foreign_contract.sol b/test/libsolidity/ABIJson/event_emitted_from_foreign_contract.sol index 30c115669752..1603519c0cd7 100644 --- a/test/libsolidity/ABIJson/event_emitted_from_foreign_contract.sol +++ b/test/libsolidity/ABIJson/event_emitted_from_foreign_contract.sol @@ -17,8 +17,7 @@ contract D { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": true, // "internalType": "address", @@ -36,8 +35,7 @@ contract D { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -50,8 +48,7 @@ contract D { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": true, // "internalType": "address", @@ -64,8 +61,7 @@ contract D { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": true, // "internalType": "address", @@ -77,8 +73,7 @@ contract D { // "type": "event" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "address", // "name": "sender", @@ -97,8 +92,7 @@ contract D { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", diff --git a/test/libsolidity/ABIJson/event_file_level.sol b/test/libsolidity/ABIJson/event_file_level.sol index 5b5c39a82c68..65e260d6666b 100644 --- a/test/libsolidity/ABIJson/event_file_level.sol +++ b/test/libsolidity/ABIJson/event_file_level.sol @@ -32,8 +32,7 @@ contract D is C { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -64,8 +63,7 @@ contract D is C { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -78,8 +76,7 @@ contract D is C { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "string", diff --git a/test/libsolidity/ABIJson/event_structs.sol b/test/libsolidity/ABIJson/event_structs.sol index 83431907a7dd..6c1ec3b17499 100644 --- a/test/libsolidity/ABIJson/event_structs.sol +++ b/test/libsolidity/ABIJson/event_structs.sol @@ -9,11 +9,9 @@ contract C { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256[2]", // "name": "x", @@ -26,16 +24,14 @@ contract C { // "type": "tuple" // }, // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256", // "name": "a", // "type": "uint256" // }, // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256[2]", // "name": "x", diff --git a/test/libsolidity/ABIJson/events.sol b/test/libsolidity/ABIJson/events.sol index bab6a743652e..8c8cfc4a239d 100644 --- a/test/libsolidity/ABIJson/events.sol +++ b/test/libsolidity/ABIJson/events.sol @@ -10,8 +10,7 @@ contract test { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -36,8 +35,7 @@ contract test { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -55,8 +53,7 @@ contract test { // "type": "event" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -64,8 +61,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", diff --git a/test/libsolidity/ABIJson/events_indirect.sol b/test/libsolidity/ABIJson/events_indirect.sol index 86368028ccc2..0d11f79ecf72 100644 --- a/test/libsolidity/ABIJson/events_indirect.sol +++ b/test/libsolidity/ABIJson/events_indirect.sol @@ -15,8 +15,7 @@ contract test { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -35,8 +34,7 @@ contract test { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", @@ -60,8 +58,7 @@ contract test { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": false, // "internalType": "uint256", diff --git a/test/libsolidity/ABIJson/function_type.sol b/test/libsolidity/ABIJson/function_type.sol index 51e36b92b5da..ab20bbb14e56 100644 --- a/test/libsolidity/ABIJson/function_type.sol +++ b/test/libsolidity/ABIJson/function_type.sol @@ -5,8 +5,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "function (uint256) external returns (uint256)", // "name": "x", diff --git a/test/libsolidity/ABIJson/function_type_extended.sol b/test/libsolidity/ABIJson/function_type_extended.sol index 6257bb4c47ed..cac235d6cfcf 100644 --- a/test/libsolidity/ABIJson/function_type_extended.sol +++ b/test/libsolidity/ABIJson/function_type_extended.sol @@ -5,8 +5,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "function (contract test) external returns (contract test[])", // "name": "x", diff --git a/test/libsolidity/ABIJson/global_struct.sol b/test/libsolidity/ABIJson/global_struct.sol index 11ce8246feab..960cda232313 100644 --- a/test/libsolidity/ABIJson/global_struct.sol +++ b/test/libsolidity/ABIJson/global_struct.sol @@ -8,11 +8,9 @@ contract C { // :C // [ // { -// "inputs": -// [ +// "inputs": [ // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256", // "name": "a", @@ -30,11 +28,9 @@ contract C { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256", // "name": "a", diff --git a/test/libsolidity/ABIJson/inherited.sol b/test/libsolidity/ABIJson/inherited.sol index cdd8296d8efc..681cc892b84f 100644 --- a/test/libsolidity/ABIJson/inherited.sol +++ b/test/libsolidity/ABIJson/inherited.sol @@ -11,8 +11,7 @@ contract Derived is Base { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": true, // "internalType": "bytes32", @@ -24,8 +23,7 @@ contract Derived is Base { // "type": "event" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "p", @@ -33,8 +31,7 @@ contract Derived is Base { // } // ], // "name": "baseFunction", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "i", @@ -51,8 +48,7 @@ contract Derived is Base { // [ // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": true, // "internalType": "bytes32", @@ -65,8 +61,7 @@ contract Derived is Base { // }, // { // "anonymous": false, -// "inputs": -// [ +// "inputs": [ // { // "indexed": true, // "internalType": "uint256", @@ -78,8 +73,7 @@ contract Derived is Base { // "type": "event" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "p", @@ -87,8 +81,7 @@ contract Derived is Base { // } // ], // "name": "baseFunction", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "i", @@ -99,8 +92,7 @@ contract Derived is Base { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "bytes32", // "name": "p", @@ -108,8 +100,7 @@ contract Derived is Base { // } // ], // "name": "derivedFunction", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "bytes32", // "name": "i", diff --git a/test/libsolidity/ABIJson/library_function.sol b/test/libsolidity/ABIJson/library_function.sol index 5fe404e95b39..2a27729fc914 100644 --- a/test/libsolidity/ABIJson/library_function.sol +++ b/test/libsolidity/ABIJson/library_function.sol @@ -12,8 +12,7 @@ library test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256[]", // "name": "c", @@ -26,8 +25,7 @@ library test { // } // ], // "name": "f1", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256[]", // "name": "e", diff --git a/test/libsolidity/ABIJson/mapping.sol b/test/libsolidity/ABIJson/mapping.sol index e84b716f2a43..1c5e29fd870b 100644 --- a/test/libsolidity/ABIJson/mapping.sol +++ b/test/libsolidity/ABIJson/mapping.sol @@ -7,8 +7,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "address", // "name": "owner", @@ -21,8 +20,7 @@ contract test { // } // ], // "name": "allowance", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "value", @@ -33,8 +31,7 @@ contract test { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "bytes32", // "name": "", @@ -42,8 +39,7 @@ contract test { // } // ], // "name": "commits", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "address", // "name": "sender", @@ -54,8 +50,7 @@ contract test { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "bytes32", // "name": "", @@ -63,8 +58,7 @@ contract test { // } // ], // "name": "something", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "bytes32", // "name": "", diff --git a/test/libsolidity/ABIJson/multiple_methods.sol b/test/libsolidity/ABIJson/multiple_methods.sol index f4738e6ea16e..6ff81c4a6bb2 100644 --- a/test/libsolidity/ABIJson/multiple_methods.sol +++ b/test/libsolidity/ABIJson/multiple_methods.sol @@ -6,8 +6,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -15,8 +14,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", @@ -27,8 +25,7 @@ contract test { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "b", @@ -36,8 +33,7 @@ contract test { // } // ], // "name": "g", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "e", diff --git a/test/libsolidity/ABIJson/multiple_methods_order.sol b/test/libsolidity/ABIJson/multiple_methods_order.sol index 606c80db3ce6..fdc9b6d64362 100644 --- a/test/libsolidity/ABIJson/multiple_methods_order.sol +++ b/test/libsolidity/ABIJson/multiple_methods_order.sol @@ -7,8 +7,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "b", @@ -16,8 +15,7 @@ contract test { // } // ], // "name": "c", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "e", @@ -28,8 +26,7 @@ contract test { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -37,8 +34,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", diff --git a/test/libsolidity/ABIJson/multiple_params.sol b/test/libsolidity/ABIJson/multiple_params.sol index e223fc3eb590..9657905c9848 100644 --- a/test/libsolidity/ABIJson/multiple_params.sol +++ b/test/libsolidity/ABIJson/multiple_params.sol @@ -5,8 +5,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -19,8 +18,7 @@ contract test { // } // ], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", diff --git a/test/libsolidity/ABIJson/payable_constructor_abi.sol b/test/libsolidity/ABIJson/payable_constructor_abi.sol index 579e83efb10f..aa74e2a3f3ed 100644 --- a/test/libsolidity/ABIJson/payable_constructor_abi.sol +++ b/test/libsolidity/ABIJson/payable_constructor_abi.sol @@ -5,8 +5,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "param1", diff --git a/test/libsolidity/ABIJson/pure_function.sol b/test/libsolidity/ABIJson/pure_function.sol index c98431eb2a4e..38c51ebf5277 100644 --- a/test/libsolidity/ABIJson/pure_function.sol +++ b/test/libsolidity/ABIJson/pure_function.sol @@ -6,8 +6,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint32", // "name": "a", @@ -15,8 +14,7 @@ contract test { // } // ], // "name": "boo", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "b", @@ -27,8 +25,7 @@ contract test { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -41,8 +38,7 @@ contract test { // } // ], // "name": "foo", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", diff --git a/test/libsolidity/ABIJson/return_param_in_abi.sol b/test/libsolidity/ABIJson/return_param_in_abi.sol index 23995d62a323..754c474a0a47 100644 --- a/test/libsolidity/ABIJson/return_param_in_abi.sol +++ b/test/libsolidity/ABIJson/return_param_in_abi.sol @@ -11,8 +11,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "enum test.ActionChoices", // "name": "param", @@ -25,8 +24,7 @@ contract test { // { // "inputs": [], // "name": "ret", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "enum test.ActionChoices", // "name": "", diff --git a/test/libsolidity/ABIJson/return_structs.sol b/test/libsolidity/ABIJson/return_structs.sol index 9a1e493d5087..a0bcb84b4c31 100644 --- a/test/libsolidity/ABIJson/return_structs.sol +++ b/test/libsolidity/ABIJson/return_structs.sol @@ -11,24 +11,21 @@ contract C { // { // "inputs": [], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "x", // "type": "uint256" // }, // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256", // "name": "a", // "type": "uint256" // }, // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256[2]", // "name": "x", diff --git a/test/libsolidity/ABIJson/return_structs_with_contracts.sol b/test/libsolidity/ABIJson/return_structs_with_contracts.sol index 135c3295f766..9c8e81d148f7 100644 --- a/test/libsolidity/ABIJson/return_structs_with_contracts.sol +++ b/test/libsolidity/ABIJson/return_structs_with_contracts.sol @@ -10,11 +10,9 @@ contract C { // { // "inputs": [], // "name": "f", -// "outputs": -// [ +// "outputs": [ // { -// "components": -// [ +// "components": [ // { // "internalType": "contract C[]", // "name": "x", diff --git a/test/libsolidity/ABIJson/structs_and_arrays.sol b/test/libsolidity/ABIJson/structs_and_arrays.sol index b2c6bc0ad971..a4f1bc4d6b19 100644 --- a/test/libsolidity/ABIJson/structs_and_arrays.sol +++ b/test/libsolidity/ABIJson/structs_and_arrays.sol @@ -6,8 +6,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "string", // "name": "a", diff --git a/test/libsolidity/ABIJson/structs_in_libraries.sol b/test/libsolidity/ABIJson/structs_in_libraries.sol index 3f278337f0bc..edc76327a7af 100644 --- a/test/libsolidity/ABIJson/structs_in_libraries.sol +++ b/test/libsolidity/ABIJson/structs_in_libraries.sol @@ -9,19 +9,16 @@ library L { // :L // [ // { -// "inputs": -// [ +// "inputs": [ // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256", // "name": "a", // "type": "uint256" // }, // { -// "components": -// [ +// "components": [ // { // "internalType": "uint256[2]", // "name": "x", diff --git a/test/libsolidity/ABIJson/user_defined_value_type.sol b/test/libsolidity/ABIJson/user_defined_value_type.sol index 3bd034e6a9b0..d20ff9903c30 100644 --- a/test/libsolidity/ABIJson/user_defined_value_type.sol +++ b/test/libsolidity/ABIJson/user_defined_value_type.sol @@ -33,8 +33,7 @@ contract C { // { // "inputs": [], // "name": "myAddress", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "C.MyAddress", // "name": "", @@ -47,8 +46,7 @@ contract C { // { // "inputs": [], // "name": "myByte1", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "MyByte1", // "name": "", @@ -61,8 +59,7 @@ contract C { // { // "inputs": [], // "name": "myBytes32", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "C.MyBytes32", // "name": "", @@ -75,8 +72,7 @@ contract C { // { // "inputs": [], // "name": "myInt", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "MyInt", // "name": "", @@ -89,8 +85,7 @@ contract C { // { // "inputs": [], // "name": "myUInt8", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "C.MyUInt8", // "name": "", @@ -101,8 +96,7 @@ contract C { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "C.MyAddress", // "name": "a", @@ -115,8 +109,7 @@ contract C { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "MyByte1", // "name": "a", @@ -129,8 +122,7 @@ contract C { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "C.MyBytes32", // "name": "a", @@ -143,8 +135,7 @@ contract C { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "MyInt", // "name": "a", @@ -157,8 +148,7 @@ contract C { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "C.MyUInt8", // "name": "a", diff --git a/test/libsolidity/ABIJson/view_function.sol b/test/libsolidity/ABIJson/view_function.sol index d5f54ecdeefe..88f03d6365aa 100644 --- a/test/libsolidity/ABIJson/view_function.sol +++ b/test/libsolidity/ABIJson/view_function.sol @@ -6,8 +6,7 @@ contract test { // :test // [ // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint32", // "name": "a", @@ -15,8 +14,7 @@ contract test { // } // ], // "name": "boo", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "b", @@ -27,8 +25,7 @@ contract test { // "type": "function" // }, // { -// "inputs": -// [ +// "inputs": [ // { // "internalType": "uint256", // "name": "a", @@ -41,8 +38,7 @@ contract test { // } // ], // "name": "foo", -// "outputs": -// [ +// "outputs": [ // { // "internalType": "uint256", // "name": "d", diff --git a/test/libsolidity/ASTJSON/abstract_contract.json b/test/libsolidity/ASTJSON/abstract_contract.json index 48c20b43584d..fb82b35b29a5 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.json +++ b/test/libsolidity/ASTJSON/abstract_contract.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": true, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "18:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "37:4:1", @@ -43,15 +37,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "34:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/abstract_contract.sol b/test/libsolidity/ASTJSON/abstract_contract.sol index 3ef96612f5fb..bddbc177931a 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.sol +++ b/test/libsolidity/ASTJSON/abstract_contract.sol @@ -2,4 +2,5 @@ abstract contract C { constructor() { } } + // ---- diff --git a/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json b/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json index d9ba04e6cfd0..fedcbd99e8da 100644 --- a/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json +++ b/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": true, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "18:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "37:4:1", @@ -30,15 +27,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "34:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index adf79823ec30..3e8c7955a281 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 39 ] }, "id": 40, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,15 +16,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 39, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 39 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "functionSelector": "97682884", @@ -40,46 +35,39 @@ "src": "17:44:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_address_payable_$", "typeString": "mapping(address => address payable)" }, - "typeName": - { + "typeName": { "id": 3, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 1, "name": "address", "nodeType": "ElementaryTypeName", "src": "25:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Mapping", "src": "17:35:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_address_payable_$", "typeString": "mapping(address => address payable)" }, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 2, "name": "address", "nodeType": "ElementaryTypeName", "src": "36:15:1", "stateMutability": "payable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -88,20 +76,16 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 37, "nodeType": "Block", "src": "134:122:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 12 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 12, @@ -113,20 +97,17 @@ "src": "144:17:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" }, - "typeName": - { + "typeName": { "id": 11, "name": "address", "nodeType": "ElementaryTypeName", "src": "144:15:1", "stateMutability": "payable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -135,33 +116,28 @@ } ], "id": 16, - "initialValue": - { - "baseExpression": - { + "initialValue": { + "baseExpression": { "id": 13, "name": "m", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4, "src": "164:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_address_payable_$", "typeString": "mapping(address => address payable)" } }, "id": 15, - "indexExpression": - { + "indexExpression": { "id": 14, "name": "arg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6, "src": "166:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -172,8 +148,7 @@ "lValueRequested": false, "nodeType": "IndexAccess", "src": "164:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -182,46 +157,40 @@ "src": "144:26:1" }, { - "expression": - { + "expression": { "id": 19, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "leftHandSide": - { + "leftHandSide": { "id": 17, "name": "r", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 9, "src": "180:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "nodeType": "Assignment", "operator": "=", - "rightHandSide": - { + "rightHandSide": { "id": 18, "name": "arg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6, "src": "184:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "src": "180:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -231,12 +200,10 @@ "src": "180:7:1" }, { - "assignments": - [ + "assignments": [ 22 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 22, @@ -248,20 +215,17 @@ "src": "197:9:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, - "typeName": - { + "typeName": { "id": 21, "name": "address", "nodeType": "ElementaryTypeName", "src": "197:7:1", "stateMutability": "nonpayable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -270,10 +234,8 @@ } ], "id": 27, - "initialValue": - { - "arguments": - [ + "initialValue": { + "arguments": [ { "id": 25, "name": "this", @@ -281,17 +243,14 @@ "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "217:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$39", "typeString": "contract C" } } ], - "expression": - { - "argumentTypes": - [ + "expression": { + "argumentTypes": [ { "typeIdentifier": "t_contract$_C_$39", "typeString": "contract C" @@ -304,13 +263,11 @@ "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "209:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, - "typeName": - { + "typeName": { "id": 23, "name": "address", "nodeType": "ElementaryTypeName", @@ -329,8 +286,7 @@ "nodeType": "FunctionCall", "src": "209:13:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -339,40 +295,34 @@ "src": "197:25:1" }, { - "expression": - { + "expression": { "id": 35, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "leftHandSide": - { - "baseExpression": - { + "leftHandSide": { + "baseExpression": { "id": 28, "name": "m", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4, "src": "232:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_address_payable_$", "typeString": "mapping(address => address payable)" } }, "id": 30, - "indexExpression": - { + "indexExpression": { "id": 29, "name": "c", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, "src": "234:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -383,18 +333,15 @@ "lValueRequested": true, "nodeType": "IndexAccess", "src": "232:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "nodeType": "Assignment", "operator": "=", - "rightHandSide": - { - "arguments": - [ + "rightHandSide": { + "arguments": [ { "hexValue": "30", "id": 33, @@ -405,18 +352,15 @@ "lValueRequested": false, "nodeType": "Literal", "src": "247:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], - "expression": - { - "argumentTypes": - [ + "expression": { + "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" @@ -429,13 +373,11 @@ "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "239:8:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_address_payable_$", "typeString": "type(address payable)" }, - "typeName": - { + "typeName": { "id": 31, "name": "address", "nodeType": "ElementaryTypeName", @@ -455,15 +397,13 @@ "nodeType": "FunctionCall", "src": "239:10:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, "src": "232:17:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -482,12 +422,10 @@ "name": "f", "nameLocation": "76:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -499,20 +437,17 @@ "src": "78:19:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" }, - "typeName": - { + "typeName": { "id": 5, "name": "address", "nodeType": "ElementaryTypeName", "src": "78:15:1", "stateMutability": "payable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } @@ -522,12 +457,10 @@ ], "src": "77:21:1" }, - "returnParameters": - { + "returnParameters": { "id": 10, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 9, @@ -539,20 +472,17 @@ "src": "115:17:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" }, - "typeName": - { + "typeName": { "id": 8, "name": "address", "nodeType": "ElementaryTypeName", "src": "115:15:1", "stateMutability": "payable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } diff --git a/test/libsolidity/ASTJSON/address_payable.sol b/test/libsolidity/ASTJSON/address_payable.sol index f9ebb124ebaf..28c9c8a20da4 100644 --- a/test/libsolidity/ASTJSON/address_payable.sol +++ b/test/libsolidity/ASTJSON/address_payable.sol @@ -7,4 +7,5 @@ contract C { m[c] = payable(0); } } + // ---- diff --git a/test/libsolidity/ASTJSON/address_payable_parseOnly.json b/test/libsolidity/ASTJSON/address_payable_parseOnly.json index 02b809cc96da..84e60f1cdd80 100644 --- a/test/libsolidity/ASTJSON/address_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/address_payable_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 40, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,8 +12,7 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 4, @@ -26,13 +24,11 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 1, "name": "address", "nodeType": "ElementaryTypeName", @@ -44,8 +40,7 @@ "typeDescriptions": {}, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 2, "name": "address", "nodeType": "ElementaryTypeName", @@ -57,20 +52,16 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 37, "nodeType": "Block", "src": "134:122:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 12 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 12, @@ -82,8 +73,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 11, "name": "address", "nodeType": "ElementaryTypeName", @@ -95,10 +85,8 @@ } ], "id": 16, - "initialValue": - { - "baseExpression": - { + "initialValue": { + "baseExpression": { "id": 13, "name": "m", "nodeType": "Identifier", @@ -107,8 +95,7 @@ "typeDescriptions": {} }, "id": 15, - "indexExpression": - { + "indexExpression": { "id": 14, "name": "arg", "nodeType": "Identifier", @@ -124,11 +111,9 @@ "src": "144:26:1" }, { - "expression": - { + "expression": { "id": 19, - "leftHandSide": - { + "leftHandSide": { "id": 17, "name": "r", "nodeType": "Identifier", @@ -138,8 +123,7 @@ }, "nodeType": "Assignment", "operator": "=", - "rightHandSide": - { + "rightHandSide": { "id": 18, "name": "arg", "nodeType": "Identifier", @@ -155,12 +139,10 @@ "src": "180:7:1" }, { - "assignments": - [ + "assignments": [ 22 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 22, @@ -172,8 +154,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 21, "name": "address", "nodeType": "ElementaryTypeName", @@ -185,10 +166,8 @@ } ], "id": 27, - "initialValue": - { - "arguments": - [ + "initialValue": { + "arguments": [ { "id": 25, "name": "this", @@ -198,14 +177,12 @@ "typeDescriptions": {} } ], - "expression": - { + "expression": { "id": 24, "nodeType": "ElementaryTypeNameExpression", "src": "209:7:1", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 23, "name": "address", "nodeType": "ElementaryTypeName", @@ -225,13 +202,10 @@ "src": "197:25:1" }, { - "expression": - { + "expression": { "id": 35, - "leftHandSide": - { - "baseExpression": - { + "leftHandSide": { + "baseExpression": { "id": 28, "name": "m", "nodeType": "Identifier", @@ -240,8 +214,7 @@ "typeDescriptions": {} }, "id": 30, - "indexExpression": - { + "indexExpression": { "id": 29, "name": "c", "nodeType": "Identifier", @@ -255,10 +228,8 @@ }, "nodeType": "Assignment", "operator": "=", - "rightHandSide": - { - "arguments": - [ + "rightHandSide": { + "arguments": [ { "hexValue": "30", "id": 33, @@ -269,14 +240,12 @@ "value": "0" } ], - "expression": - { + "expression": { "id": 32, "nodeType": "ElementaryTypeNameExpression", "src": "239:8:1", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 31, "name": "address", "nodeType": "ElementaryTypeName", @@ -309,12 +278,10 @@ "name": "f", "nameLocation": "76:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -326,8 +293,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "name": "address", "nodeType": "ElementaryTypeName", @@ -340,12 +306,10 @@ ], "src": "77:21:1" }, - "returnParameters": - { + "returnParameters": { "id": 10, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 9, @@ -357,8 +321,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 8, "name": "address", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json index 1cd97e1765a3..e87f505f01e8 100644 --- a/test/libsolidity/ASTJSON/array_type_name.json +++ b/test/libsolidity/ASTJSON/array_type_name.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 4 ] }, "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,15 +16,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 4, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 4 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 3, @@ -39,21 +34,17 @@ "src": "13:8:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage", "typeString": "uint256[]" }, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "13:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -61,8 +52,7 @@ "id": 2, "nodeType": "ArrayTypeName", "src": "13:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", "typeString": "uint256[]" } diff --git a/test/libsolidity/ASTJSON/array_type_name_parseOnly.json b/test/libsolidity/ASTJSON/array_type_name_parseOnly.json index 1e0b72ca07f2..6c61e8d7d0bd 100644 --- a/test/libsolidity/ASTJSON/array_type_name_parseOnly.json +++ b/test/libsolidity/ASTJSON/array_type_name_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,8 +12,7 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 3, @@ -26,10 +24,8 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/assembly/call.json b/test/libsolidity/ASTJSON/assembly/call.json index d92cf05fe8e4..6d5ffe9b6ff7 100644 --- a/test/libsolidity/ASTJSON/assembly/call.json +++ b/test/libsolidity/ASTJSON/assembly/call.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,39 +16,30 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "37:59:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "56:34:1", "nodeType": "YulBlock", "src": "56:34:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "67:1:1", @@ -109,8 +97,7 @@ "value": "6" } ], - "functionName": - { + "functionName": { "name": "call", "nativeSrc": "62:4:1", "nodeType": "YulIdentifier", @@ -121,8 +108,7 @@ "src": "62:25:1" } ], - "functionName": - { + "functionName": { "name": "pop", "nativeSrc": "58:3:1", "nodeType": "YulIdentifier", @@ -154,15 +140,13 @@ "name": "j", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/call.sol b/test/libsolidity/ASTJSON/assembly/call.sol index 1735fd7f7e22..09d1ce184378 100644 --- a/test/libsolidity/ASTJSON/assembly/call.sol +++ b/test/libsolidity/ASTJSON/assembly/call.sol @@ -3,4 +3,5 @@ contract C { assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/call_parseOnly.json b/test/libsolidity/ASTJSON/assembly/call_parseOnly.json index 803a1e4f5f1e..1e7c5b1f8ea3 100644 --- a/test/libsolidity/ASTJSON/assembly/call_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/call_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,32 +12,24 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "37:59:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "56:34:1", "nodeType": "YulBlock", "src": "56:34:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "67:1:1", @@ -96,8 +87,7 @@ "value": "6" } ], - "functionName": - { + "functionName": { "name": "call", "nativeSrc": "62:4:1", "nodeType": "YulIdentifier", @@ -108,8 +98,7 @@ "src": "62:25:1" } ], - "functionName": - { + "functionName": { "name": "pop", "nativeSrc": "58:3:1", "nodeType": "YulIdentifier", @@ -140,15 +129,13 @@ "name": "j", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.json b/test/libsolidity/ASTJSON/assembly/empty_block.json index 3ec3c2eec018..1829d057d900 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,31 +16,25 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:31:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:6:1", "nodeType": "YulBlock", "src": "61:6:1", - "statements": - [ + "statements": [ { "nativeSrc": "63:2:1", "nodeType": "YulBlock", @@ -68,15 +59,13 @@ "name": "g", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.sol b/test/libsolidity/ASTJSON/assembly/empty_block.sol index 33bb796ea615..23c2babbe36d 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.sol +++ b/test/libsolidity/ASTJSON/assembly/empty_block.sol @@ -3,4 +3,5 @@ contract C { assembly { {} } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json b/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json index ee8e7b7330fb..92404c15f00d 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,24 +12,19 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:31:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:6:1", "nodeType": "YulBlock", "src": "61:6:1", - "statements": - [ + "statements": [ { "nativeSrc": "63:2:1", "nodeType": "YulBlock", @@ -54,15 +48,13 @@ "name": "g", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.json b/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.json index 9d64279da848..b9435a41cecc 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.json +++ b/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,37 +16,30 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "39:30:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "52:14:1", "nodeType": "YulBlock", "src": "52:14:1", - "statements": - [ + "statements": [ { "nativeSrc": "57:5:1", "nodeType": "YulVariableDeclaration", "src": "57:5:1", - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "61:1:1", @@ -77,15 +67,13 @@ "name": "f", "nameLocation": "23:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "24:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.sol b/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.sol index 5b396dd44156..bfc5ff95fd42 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.sol +++ b/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration.sol @@ -5,4 +5,5 @@ contract C { } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration_parseOnly.json b/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration_parseOnly.json index 5f12f280ba9b..bba11cc633f7 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/empty_let_variable_declaration_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,30 +12,24 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "39:30:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "52:14:1", "nodeType": "YulBlock", "src": "52:14:1", - "statements": - [ + "statements": [ { "nativeSrc": "57:5:1", "nodeType": "YulVariableDeclaration", "src": "57:5:1", - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "61:1:1", @@ -63,15 +56,13 @@ "name": "f", "nameLocation": "23:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "24:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/function.json b/test/libsolidity/ASTJSON/assembly/function.json index a3b908ac18b9..c409d615e926 100644 --- a/test/libsolidity/ASTJSON/assembly/function.json +++ b/test/libsolidity/ASTJSON/assembly/function.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,47 +16,36 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:68:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:43:1", "nodeType": "YulBlock", "src": "61:43:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "76:22:1", "nodeType": "YulBlock", "src": "76:22:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "92:2:1", @@ -69,8 +55,7 @@ "value": "20" } ], - "functionName": - { + "functionName": { "name": "blockhash", "nativeSrc": "82:9:1", "nodeType": "YulIdentifier", @@ -81,8 +66,7 @@ "src": "82:13:1" } ], - "functionName": - { + "functionName": { "name": "pop", "nativeSrc": "78:3:1", "nodeType": "YulIdentifier", @@ -104,11 +88,9 @@ "src": "63:35:1" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "g", "nativeSrc": "99:1:1", "nodeType": "YulIdentifier", @@ -140,15 +122,13 @@ "name": "h", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/function.sol b/test/libsolidity/ASTJSON/assembly/function.sol index 1edf2f2de24d..6020f1f51318 100644 --- a/test/libsolidity/ASTJSON/assembly/function.sol +++ b/test/libsolidity/ASTJSON/assembly/function.sol @@ -3,4 +3,5 @@ contract C { assembly { function g() { pop(blockhash(20)) } g() } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/function_parseOnly.json b/test/libsolidity/ASTJSON/assembly/function_parseOnly.json index 04f5c2721b70..2e681ed63f9d 100644 --- a/test/libsolidity/ASTJSON/assembly/function_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/function_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,40 +12,30 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:68:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:43:1", "nodeType": "YulBlock", "src": "61:43:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "76:22:1", "nodeType": "YulBlock", "src": "76:22:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "92:2:1", @@ -56,8 +45,7 @@ "value": "20" } ], - "functionName": - { + "functionName": { "name": "blockhash", "nativeSrc": "82:9:1", "nodeType": "YulIdentifier", @@ -68,8 +56,7 @@ "src": "82:13:1" } ], - "functionName": - { + "functionName": { "name": "pop", "nativeSrc": "78:3:1", "nodeType": "YulIdentifier", @@ -91,11 +78,9 @@ "src": "63:35:1" }, { - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "g", "nativeSrc": "99:1:1", "nodeType": "YulIdentifier", @@ -126,15 +111,13 @@ "name": "h", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/leave.json b/test/libsolidity/ASTJSON/assembly/leave.json index 51c94f542c76..e7fbf9f6f6e1 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.json +++ b/test/libsolidity/ASTJSON/assembly/leave.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,39 +16,31 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "37:51:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "56:26:1", "nodeType": "YulBlock", "src": "56:26:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "71:9:1", "nodeType": "YulBlock", "src": "71:9:1", - "statements": - [ + "statements": [ { "nativeSrc": "73:5:1", "nodeType": "YulLeave", @@ -82,15 +71,13 @@ "name": "l", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/leave.sol b/test/libsolidity/ASTJSON/assembly/leave.sol index 39f1cafedb22..5ae4a9e0dd09 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.sol +++ b/test/libsolidity/ASTJSON/assembly/leave.sol @@ -3,4 +3,5 @@ contract C { assembly { function f() { leave } } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json b/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json index ee34743eac32..c71ffd3fed1f 100644 --- a/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,32 +12,25 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "37:51:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "56:26:1", "nodeType": "YulBlock", "src": "56:26:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "71:9:1", "nodeType": "YulBlock", "src": "71:9:1", - "statements": - [ + "statements": [ { "nativeSrc": "73:5:1", "nodeType": "YulLeave", @@ -68,15 +60,13 @@ "name": "l", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/loop.json b/test/libsolidity/ASTJSON/assembly/loop.json index d3d20992d772..01efb79e6b2d 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.json +++ b/test/libsolidity/ASTJSON/assembly/loop.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,39 +16,31 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:74:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:49:1", "nodeType": "YulBlock", "src": "61:49:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "90:18:1", "nodeType": "YulBlock", "src": "90:18:1", - "statements": - [ + "statements": [ { "nativeSrc": "92:5:1", "nodeType": "YulBreak", @@ -64,8 +53,7 @@ } ] }, - "condition": - { + "condition": { "kind": "number", "nativeSrc": "70:1:1", "nodeType": "YulLiteral", @@ -75,21 +63,16 @@ }, "nativeSrc": "63:45:1", "nodeType": "YulForLoop", - "post": - { + "post": { "nativeSrc": "72:17:1", "nodeType": "YulBlock", "src": "72:17:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "84:1:1", @@ -99,8 +82,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "sload", "nativeSrc": "78:5:1", "nodeType": "YulIdentifier", @@ -111,8 +93,7 @@ "src": "78:8:1" } ], - "functionName": - { + "functionName": { "name": "pop", "nativeSrc": "74:3:1", "nodeType": "YulIdentifier", @@ -128,8 +109,7 @@ } ] }, - "pre": - { + "pre": { "nativeSrc": "67:2:1", "nodeType": "YulBlock", "src": "67:2:1", @@ -155,15 +135,13 @@ "name": "g", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/loop.sol b/test/libsolidity/ASTJSON/assembly/loop.sol index baa45e62c489..bba8d282f63d 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.sol +++ b/test/libsolidity/ASTJSON/assembly/loop.sol @@ -3,4 +3,5 @@ contract C { assembly { for {} 1 { pop(sload(0)) } { break continue } } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json b/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json index 24dbbdc4eaf8..8fecb9dfd3e9 100644 --- a/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,32 +12,25 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:74:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:49:1", "nodeType": "YulBlock", "src": "61:49:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "90:18:1", "nodeType": "YulBlock", "src": "90:18:1", - "statements": - [ + "statements": [ { "nativeSrc": "92:5:1", "nodeType": "YulBreak", @@ -51,8 +43,7 @@ } ] }, - "condition": - { + "condition": { "kind": "number", "nativeSrc": "70:1:1", "nodeType": "YulLiteral", @@ -62,21 +53,16 @@ }, "nativeSrc": "63:45:1", "nodeType": "YulForLoop", - "post": - { + "post": { "nativeSrc": "72:17:1", "nodeType": "YulBlock", "src": "72:17:1", - "statements": - [ + "statements": [ { - "expression": - { - "arguments": - [ + "expression": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "kind": "number", "nativeSrc": "84:1:1", @@ -86,8 +72,7 @@ "value": "0" } ], - "functionName": - { + "functionName": { "name": "sload", "nativeSrc": "78:5:1", "nodeType": "YulIdentifier", @@ -98,8 +83,7 @@ "src": "78:8:1" } ], - "functionName": - { + "functionName": { "name": "pop", "nativeSrc": "74:3:1", "nodeType": "YulIdentifier", @@ -115,8 +99,7 @@ } ] }, - "pre": - { + "pre": { "nativeSrc": "67:2:1", "nodeType": "YulBlock", "src": "67:2:1", @@ -141,15 +124,13 @@ "name": "g", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index 3c9fd53ec03c..c4c2b0ae44ef 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 8 ] }, "id": 9, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,42 +16,33 @@ "contractKind": "contract", "fullyImplemented": true, "id": 8, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 8 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 6, "nodeType": "Block", "src": "57:95:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "72:76:1", "nodeType": "YulBlock", "src": "72:76:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "94:35:1", "nodeType": "YulBlock", "src": "94:35:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "118:3:1", "nodeType": "YulBlock", "src": "118:3:1", @@ -76,8 +64,7 @@ "nativeSrc": "136:6:1", "nodeType": "YulAssignment", "src": "136:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "141:1:1", "nodeType": "YulLiteral", @@ -85,8 +72,7 @@ "type": "", "value": "2" }, - "variableNames": - [ + "variableNames": [ { "name": "x", "nativeSrc": "136:1:1", @@ -98,8 +84,7 @@ ] }, "evmVersion": %EVMVERSION%, - "externalReferences": - [ + "externalReferences": [ { "declaration": 3, "isOffset": false, @@ -122,19 +107,16 @@ "name": "f", "nameLocation": "24:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "25:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 3, @@ -146,19 +128,16 @@ "src": "49:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "49:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.sol b/test/libsolidity/ASTJSON/assembly/nested_functions.sol index 42479fa94ad3..396efa0bf8a2 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.sol +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.sol @@ -8,4 +8,5 @@ contract C { } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json b/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json index b924b42cfd0e..acb05ca8695f 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 9, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,35 +12,27 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 6, "nodeType": "Block", "src": "57:95:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "72:76:1", "nodeType": "YulBlock", "src": "72:76:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "94:35:1", "nodeType": "YulBlock", "src": "94:35:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "nativeSrc": "118:3:1", "nodeType": "YulBlock", "src": "118:3:1", @@ -63,8 +54,7 @@ "nativeSrc": "136:6:1", "nodeType": "YulAssignment", "src": "136:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "141:1:1", "nodeType": "YulLiteral", @@ -72,8 +62,7 @@ "type": "", "value": "2" }, - "variableNames": - [ + "variableNames": [ { "name": "x", "nativeSrc": "136:1:1", @@ -99,19 +88,16 @@ "name": "f", "nameLocation": "24:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "25:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 3, @@ -123,8 +109,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index 799239b3afc6..8599bf3a8978 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 12 ] }, "id": 13, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,20 +16,17 @@ "contractKind": "contract", "fullyImplemented": true, "id": 12, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 12 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "canonicalName": "C.S", "id": 3, - "members": - [ + "members": [ { "constant": false, "id": 2, @@ -44,19 +38,16 @@ "src": "28:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "28:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -82,21 +73,17 @@ "src": "42:3:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_struct$_S_$3_storage", "typeString": "struct C.S" }, - "typeName": - { + "typeName": { "id": 5, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 4, "name": "S", - "nameLocations": - [ + "nameLocations": [ "42:1:1" ], "nodeType": "IdentifierPath", @@ -105,8 +92,7 @@ }, "referencedDeclaration": 3, "src": "42:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_struct$_S_$3_storage_ptr", "typeString": "struct C.S" } @@ -114,34 +100,28 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 10, "nodeType": "Block", "src": "76:70:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "95:45:1", "nodeType": "YulBlock", "src": "95:45:1", - "statements": - [ + "statements": [ { "nativeSrc": "97:17:1", "nodeType": "YulVariableDeclaration", "src": "97:17:1", - "value": - { + "value": { "name": "s.offset", "nativeSrc": "106:8:1", "nodeType": "YulIdentifier", "src": "106:8:1" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "101:1:1", @@ -155,10 +135,8 @@ "nativeSrc": "115:23:1", "nodeType": "YulVariableDeclaration", "src": "115:23:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "s.slot", "nativeSrc": "128:6:1", @@ -174,8 +152,7 @@ "value": "2" } ], - "functionName": - { + "functionName": { "name": "mul", "nativeSrc": "124:3:1", "nodeType": "YulIdentifier", @@ -185,8 +162,7 @@ "nodeType": "YulFunctionCall", "src": "124:14:1" }, - "variables": - [ + "variables": [ { "name": "y", "nativeSrc": "119:1:1", @@ -199,8 +175,7 @@ ] }, "evmVersion": %EVMVERSION%, - "externalReferences": - [ + "externalReferences": [ { "declaration": 6, "isOffset": true, @@ -232,15 +207,13 @@ "name": "e", "nameLocation": "60:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "61:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.sol b/test/libsolidity/ASTJSON/assembly/slot_offset.sol index 0cc2b07c116b..d3c8f75542e2 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.sol +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.sol @@ -5,4 +5,5 @@ contract C { assembly { let x := s.offset let y := mul(s.slot, 2) } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json b/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json index ef8dc8b0adb8..5363931c4ae4 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 13, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,12 +12,10 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 3, - "members": - [ + "members": [ { "constant": false, "id": 2, @@ -30,8 +27,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", @@ -58,16 +54,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 4, "name": "S", - "nameLocations": - [ + "nameLocations": [ "42:1:1" ], "nodeType": "IdentifierPath", @@ -79,34 +72,28 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 10, "nodeType": "Block", "src": "76:70:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "95:45:1", "nodeType": "YulBlock", "src": "95:45:1", - "statements": - [ + "statements": [ { "nativeSrc": "97:17:1", "nodeType": "YulVariableDeclaration", "src": "97:17:1", - "value": - { + "value": { "name": "s.offset", "nativeSrc": "106:8:1", "nodeType": "YulIdentifier", "src": "106:8:1" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "101:1:1", @@ -120,10 +107,8 @@ "nativeSrc": "115:23:1", "nodeType": "YulVariableDeclaration", "src": "115:23:1", - "value": - { - "arguments": - [ + "value": { + "arguments": [ { "name": "s.slot", "nativeSrc": "128:6:1", @@ -139,8 +124,7 @@ "value": "2" } ], - "functionName": - { + "functionName": { "name": "mul", "nativeSrc": "124:3:1", "nodeType": "YulIdentifier", @@ -150,8 +134,7 @@ "nodeType": "YulFunctionCall", "src": "124:14:1" }, - "variables": - [ + "variables": [ { "name": "y", "nativeSrc": "119:1:1", @@ -178,15 +161,13 @@ "name": "e", "nameLocation": "60:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "61:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.json b/test/libsolidity/ASTJSON/assembly/stringlit.json index ab27a3d16ff6..2a27e55b2ccd 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,37 +16,30 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "37:43:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "56:18:1", "nodeType": "YulBlock", "src": "56:18:1", - "statements": - [ + "statements": [ { "nativeSrc": "58:14:1", "nodeType": "YulVariableDeclaration", "src": "58:14:1", - "value": - { + "value": { "hexValue": "616263", "kind": "string", "nativeSrc": "67:5:1", @@ -58,8 +48,7 @@ "type": "", "value": "abc" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "62:1:1", @@ -87,15 +76,13 @@ "name": "m", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.sol b/test/libsolidity/ASTJSON/assembly/stringlit.sol index 6f5278ac17f1..e382095ad0be 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.sol +++ b/test/libsolidity/ASTJSON/assembly/stringlit.sol @@ -3,4 +3,5 @@ contract C { assembly { let x := "abc" } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json b/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json index 3cb2a907287d..3d021620e1cf 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,30 +12,24 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "37:43:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "56:18:1", "nodeType": "YulBlock", "src": "56:18:1", - "statements": - [ + "statements": [ { "nativeSrc": "58:14:1", "nodeType": "YulVariableDeclaration", "src": "58:14:1", - "value": - { + "value": { "hexValue": "616263", "kind": "string", "nativeSrc": "67:5:1", @@ -45,8 +38,7 @@ "type": "", "value": "abc" }, - "variables": - [ + "variables": [ { "name": "x", "nativeSrc": "62:1:1", @@ -73,15 +65,13 @@ "name": "m", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index 99c69e048bfb..1a418931bc88 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,37 +16,30 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:154:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:129:1", "nodeType": "YulBlock", "src": "61:129:1", - "statements": - [ + "statements": [ { "nativeSrc": "75:10:1", "nodeType": "YulVariableDeclaration", "src": "75:10:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "84:1:1", "nodeType": "YulLiteral", @@ -57,8 +47,7 @@ "type": "", "value": "0" }, - "variables": - [ + "variables": [ { "name": "v", "nativeSrc": "79:1:1", @@ -69,22 +58,18 @@ ] }, { - "cases": - [ + "cases": [ { - "body": - { + "body": { "nativeSrc": "139:10:1", "nodeType": "YulBlock", "src": "139:10:1", - "statements": - [ + "statements": [ { "nativeSrc": "141:6:1", "nodeType": "YulAssignment", "src": "141:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "146:1:1", "nodeType": "YulLiteral", @@ -92,8 +77,7 @@ "type": "", "value": "1" }, - "variableNames": - [ + "variableNames": [ { "name": "v", "nativeSrc": "141:1:1", @@ -107,8 +91,7 @@ "nativeSrc": "132:17:1", "nodeType": "YulCase", "src": "132:17:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "137:1:1", "nodeType": "YulLiteral", @@ -118,19 +101,16 @@ } }, { - "body": - { + "body": { "nativeSrc": "170:10:1", "nodeType": "YulBlock", "src": "170:10:1", - "statements": - [ + "statements": [ { "nativeSrc": "172:6:1", "nodeType": "YulAssignment", "src": "172:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "177:1:1", "nodeType": "YulLiteral", @@ -138,8 +118,7 @@ "type": "", "value": "2" }, - "variableNames": - [ + "variableNames": [ { "name": "v", "nativeSrc": "172:1:1", @@ -156,11 +135,9 @@ "value": "default" } ], - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "calldatasize", "nativeSrc": "105:12:1", "nodeType": "YulIdentifier", @@ -192,15 +169,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/switch.sol b/test/libsolidity/ASTJSON/assembly/switch.sol index a7a23d26aac3..c04d311b09e4 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.sol +++ b/test/libsolidity/ASTJSON/assembly/switch.sol @@ -8,4 +8,5 @@ contract C { } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.json b/test/libsolidity/ASTJSON/assembly/switch_default.json index 07f804f3cb74..9d016e261099 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,37 +16,29 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:58:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:33:1", "nodeType": "YulBlock", "src": "61:33:1", - "statements": - [ + "statements": [ { - "cases": - [ + "cases": [ { - "body": - { + "body": { "nativeSrc": "79:2:1", "nodeType": "YulBlock", "src": "79:2:1", @@ -58,8 +47,7 @@ "nativeSrc": "72:9:1", "nodeType": "YulCase", "src": "72:9:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "77:1:1", "nodeType": "YulLiteral", @@ -69,8 +57,7 @@ } }, { - "body": - { + "body": { "nativeSrc": "90:2:1", "nodeType": "YulBlock", "src": "90:2:1", @@ -82,8 +69,7 @@ "value": "default" } ], - "expression": - { + "expression": { "kind": "number", "nativeSrc": "70:1:1", "nodeType": "YulLiteral", @@ -113,15 +99,13 @@ "name": "g", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.sol b/test/libsolidity/ASTJSON/assembly/switch_default.sol index 0760bb7dfdb7..1f61896fe275 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.sol +++ b/test/libsolidity/ASTJSON/assembly/switch_default.sol @@ -3,4 +3,5 @@ contract C { assembly { switch 0 case 0 {} default {} } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json b/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json index 2ec302770814..22523b478e5f 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,30 +12,23 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:58:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:33:1", "nodeType": "YulBlock", "src": "61:33:1", - "statements": - [ + "statements": [ { - "cases": - [ + "cases": [ { - "body": - { + "body": { "nativeSrc": "79:2:1", "nodeType": "YulBlock", "src": "79:2:1", @@ -45,8 +37,7 @@ "nativeSrc": "72:9:1", "nodeType": "YulCase", "src": "72:9:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "77:1:1", "nodeType": "YulLiteral", @@ -56,8 +47,7 @@ } }, { - "body": - { + "body": { "nativeSrc": "90:2:1", "nodeType": "YulBlock", "src": "90:2:1", @@ -69,8 +59,7 @@ "value": "default" } ], - "expression": - { + "expression": { "kind": "number", "nativeSrc": "70:1:1", "nodeType": "YulLiteral", @@ -99,15 +88,13 @@ "name": "g", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json b/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json index 2412ea48dd0c..dc16d43f916a 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,30 +12,24 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "42:154:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "61:129:1", "nodeType": "YulBlock", "src": "61:129:1", - "statements": - [ + "statements": [ { "nativeSrc": "75:10:1", "nodeType": "YulVariableDeclaration", "src": "75:10:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "84:1:1", "nodeType": "YulLiteral", @@ -44,8 +37,7 @@ "type": "", "value": "0" }, - "variables": - [ + "variables": [ { "name": "v", "nativeSrc": "79:1:1", @@ -56,22 +48,18 @@ ] }, { - "cases": - [ + "cases": [ { - "body": - { + "body": { "nativeSrc": "139:10:1", "nodeType": "YulBlock", "src": "139:10:1", - "statements": - [ + "statements": [ { "nativeSrc": "141:6:1", "nodeType": "YulAssignment", "src": "141:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "146:1:1", "nodeType": "YulLiteral", @@ -79,8 +67,7 @@ "type": "", "value": "1" }, - "variableNames": - [ + "variableNames": [ { "name": "v", "nativeSrc": "141:1:1", @@ -94,8 +81,7 @@ "nativeSrc": "132:17:1", "nodeType": "YulCase", "src": "132:17:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "137:1:1", "nodeType": "YulLiteral", @@ -105,19 +91,16 @@ } }, { - "body": - { + "body": { "nativeSrc": "170:10:1", "nodeType": "YulBlock", "src": "170:10:1", - "statements": - [ + "statements": [ { "nativeSrc": "172:6:1", "nodeType": "YulAssignment", "src": "172:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "177:1:1", "nodeType": "YulLiteral", @@ -125,8 +108,7 @@ "type": "", "value": "2" }, - "variableNames": - [ + "variableNames": [ { "name": "v", "nativeSrc": "172:1:1", @@ -143,11 +125,9 @@ "value": "default" } ], - "expression": - { + "expression": { "arguments": [], - "functionName": - { + "functionName": { "name": "calldatasize", "nativeSrc": "105:12:1", "nodeType": "YulIdentifier", @@ -178,15 +158,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/var_access.json b/test/libsolidity/ASTJSON/assembly/var_access.json index ae7845815fa2..86bc76fa78e5 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.json +++ b/test/libsolidity/ASTJSON/assembly/var_access.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 9 ] }, "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 9, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 9 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "42:51:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -54,19 +45,16 @@ "src": "52:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", "src": "52:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -79,19 +67,16 @@ "src": "52:6:1" }, { - "AST": - { + "AST": { "nativeSrc": "77:10:1", "nodeType": "YulBlock", "src": "77:10:1", - "statements": - [ + "statements": [ { "nativeSrc": "79:6:1", "nodeType": "YulAssignment", "src": "79:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "84:1:1", "nodeType": "YulLiteral", @@ -99,8 +84,7 @@ "type": "", "value": "7" }, - "variableNames": - [ + "variableNames": [ { "name": "x", "nativeSrc": "79:1:1", @@ -112,8 +96,7 @@ ] }, "evmVersion": %EVMVERSION%, - "externalReferences": - [ + "externalReferences": [ { "declaration": 4, "isOffset": false, @@ -136,15 +119,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/assembly/var_access.sol b/test/libsolidity/ASTJSON/assembly/var_access.sol index e4b7423fde04..768f38c3342c 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.sol +++ b/test/libsolidity/ASTJSON/assembly/var_access.sol @@ -4,4 +4,5 @@ contract C { assembly { x := 7 } } } + // ---- diff --git a/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json b/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json index ca3fcf92c91e..129104bbcda4 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "42:51:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", @@ -57,19 +50,16 @@ "src": "52:6:1" }, { - "AST": - { + "AST": { "nativeSrc": "77:10:1", "nodeType": "YulBlock", "src": "77:10:1", - "statements": - [ + "statements": [ { "nativeSrc": "79:6:1", "nodeType": "YulAssignment", "src": "79:6:1", - "value": - { + "value": { "kind": "number", "nativeSrc": "84:1:1", "nodeType": "YulLiteral", @@ -77,8 +67,7 @@ "type": "", "value": "7" }, - "variableNames": - [ + "variableNames": [ { "name": "x", "nativeSrc": "79:1:1", @@ -104,15 +93,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json b/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json index 07886a166338..f94345ffcd92 100644 --- a/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json +++ b/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.json @@ -1,28 +1,22 @@ [ { "absolutePath": "L", - "exportedSymbols": - { - "L": - [ + "exportedSymbols": { + "L": [ 78 ], - "free1": - [ + "free1": [ 65 ], - "free2": - [ + "free2": [ 69 ] }, "id": 79, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 64, "nodeType": "Block", "src": "17:2:1", @@ -35,15 +29,13 @@ "name": "free1", "nameLocation": "9:5:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 62, "nodeType": "ParameterList", "parameters": [], "src": "14:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 63, "nodeType": "ParameterList", "parameters": [], @@ -56,8 +48,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 68, "nodeType": "Block", "src": "37:2:1", @@ -70,15 +61,13 @@ "name": "free2", "nameLocation": "29:5:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 66, "nodeType": "ParameterList", "parameters": [], "src": "34:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 67, "nodeType": "ParameterList", "parameters": [], @@ -98,18 +87,15 @@ "contractKind": "library", "fullyImplemented": true, "id": 78, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 78 ], "name": "L", "nameLocation": "48:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 72, "nodeType": "Block", "src": "78:2:1", @@ -122,15 +108,13 @@ "name": "g", "nameLocation": "65:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 70, "nodeType": "ParameterList", "parameters": [], "src": "66:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 71, "nodeType": "ParameterList", "parameters": [], @@ -143,8 +127,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 76, "nodeType": "Block", "src": "107:2:1", @@ -157,15 +140,13 @@ "name": "h", "nameLocation": "94:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 74, "nodeType": "ParameterList", "parameters": [], "src": "95:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 75, "nodeType": "ParameterList", "parameters": [], @@ -188,33 +169,26 @@ }, { "absolutePath": "A", - "exportedSymbols": - { - "A": - [ + "exportedSymbols": { + "A": [ 22 ], - "B": - [ + "B": [ 37 ], - "L": - [ + "L": [ 78 ], - "free1": - [ + "free1": [ 65 ], - "free2": - [ + "free2": [ 69 ] }, "id": 38, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "absolutePath": "L", "file": "L", @@ -235,49 +209,39 @@ "contractKind": "contract", "fullyImplemented": true, "id": 22, - "internalFunctionIDs": - { + "internalFunctionIDs": { "69": 1, "73": 2, "77": 3 }, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 22 ], "name": "A", "nameLocation": "21:1:2", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 20, "nodeType": "Block", "src": "49:60:2", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 4, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 78, "src": "60:1:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$78_$", "typeString": "type(library L)" } @@ -292,8 +256,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 73, "src": "60:3:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -307,8 +270,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "59:5:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -324,8 +286,7 @@ "nodeType": "FunctionCall", "src": "59:7:2", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -335,14 +296,11 @@ "src": "59:7:2" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 10, "name": "free2", @@ -350,8 +308,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 69, "src": "77:5:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -365,8 +322,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "76:7:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -382,8 +338,7 @@ "nodeType": "FunctionCall", "src": "76:9:2", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -393,25 +348,20 @@ "src": "76:9:2" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 14, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 78, "src": "96:1:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$78_$", "typeString": "type(library L)" } @@ -426,8 +376,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 77, "src": "96:3:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -441,8 +390,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "95:5:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -458,8 +406,7 @@ "nodeType": "FunctionCall", "src": "95:7:2", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -478,15 +425,13 @@ "name": "f", "nameLocation": "38:1:2", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], "src": "39:2:2" }, - "returnParameters": - { + "returnParameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], @@ -512,48 +457,38 @@ "contractKind": "contract", "fullyImplemented": true, "id": 37, - "internalFunctionIDs": - { + "internalFunctionIDs": { "69": 1, "77": 2 }, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 37 ], "name": "B", "nameLocation": "121:1:2", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 35, "nodeType": "Block", "src": "149:43:2", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 25, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 78, "src": "160:1:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$78_$", "typeString": "type(library L)" } @@ -568,8 +503,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 77, "src": "160:3:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -583,8 +517,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "159:5:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -600,8 +533,7 @@ "nodeType": "FunctionCall", "src": "159:7:2", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -611,14 +543,11 @@ "src": "159:7:2" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 31, "name": "free2", @@ -626,8 +555,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 69, "src": "177:5:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -641,8 +569,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "176:7:2", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -658,8 +585,7 @@ "nodeType": "FunctionCall", "src": "176:9:2", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -678,15 +604,13 @@ "name": "f", "nameLocation": "138:1:2", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 23, "nodeType": "ParameterList", "parameters": [], "src": "139:2:2" }, - "returnParameters": - { + "returnParameters": { "id": 24, "nodeType": "ParameterList", "parameters": [], @@ -709,29 +633,23 @@ }, { "absolutePath": "C", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 60 ], - "L": - [ + "L": [ 78 ], - "free1": - [ + "free1": [ 65 ], - "free2": - [ + "free2": [ 69 ] }, "id": 61, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "absolutePath": "L", "file": "L", @@ -752,49 +670,39 @@ "contractKind": "contract", "fullyImplemented": true, "id": 60, - "internalFunctionIDs": - { + "internalFunctionIDs": { "69": 1, "73": 2, "77": 3 }, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 60 ], "name": "C", "nameLocation": "21:1:3", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 58, "nodeType": "Block", "src": "49:60:3", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 42, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 78, "src": "60:1:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$78_$", "typeString": "type(library L)" } @@ -809,8 +717,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 73, "src": "60:3:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -824,8 +731,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "59:5:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -841,8 +747,7 @@ "nodeType": "FunctionCall", "src": "59:7:3", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -852,14 +757,11 @@ "src": "59:7:3" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 48, "name": "free2", @@ -867,8 +769,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 69, "src": "77:5:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -882,8 +783,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "76:7:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -899,8 +799,7 @@ "nodeType": "FunctionCall", "src": "76:9:3", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -910,25 +809,20 @@ "src": "76:9:3" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 52, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 78, "src": "96:1:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$78_$", "typeString": "type(library L)" } @@ -943,8 +837,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 77, "src": "96:3:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -958,8 +851,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "95:5:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -975,8 +867,7 @@ "nodeType": "FunctionCall", "src": "95:7:3", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -995,15 +886,13 @@ "name": "f", "nameLocation": "38:1:3", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 40, "nodeType": "ParameterList", "parameters": [], "src": "39:2:3" }, - "returnParameters": - { + "returnParameters": { "id": 41, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.sol b/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.sol index 6e0b28c82ac3..bf3222902131 100644 --- a/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.sol +++ b/test/libsolidity/ASTJSON/ast_internal_function_different_ids_export.sol @@ -1,5 +1,4 @@ ==== Source: L ==== - function free1() {} function free2() {} library L { @@ -8,7 +7,6 @@ library L { } ==== Source: A ==== - import "L"; contract A { function f() public { @@ -25,7 +23,6 @@ contract B { } ==== Source: C ==== - import "L"; contract C { function f() public { diff --git a/test/libsolidity/ASTJSON/ast_internal_function_id_export.json b/test/libsolidity/ASTJSON/ast_internal_function_id_export.json index d452f2d99fec..cbbc962c027a 100644 --- a/test/libsolidity/ASTJSON/ast_internal_function_id_export.json +++ b/test/libsolidity/ASTJSON/ast_internal_function_id_export.json @@ -1,39 +1,30 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 128 ], - "D": - [ + "D": [ 141 ], - "L": - [ + "L": [ 53 ], - "free1": - [ + "free1": [ 4 ], - "free2": - [ + "free2": [ 8 ], - "free3": - [ + "free3": [ 12 ] }, "id": 142, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "17:2:1", @@ -46,15 +37,13 @@ "name": "free1", "nameLocation": "9:5:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "14:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -67,8 +56,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "37:2:1", @@ -81,15 +69,13 @@ "name": "free2", "nameLocation": "29:5:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], "src": "34:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], @@ -102,8 +88,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 11, "nodeType": "Block", "src": "57:2:1", @@ -116,15 +101,13 @@ "name": "free3", "nameLocation": "49:5:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 9, "nodeType": "ParameterList", "parameters": [], "src": "54:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], @@ -144,25 +127,21 @@ "contractKind": "library", "fullyImplemented": true, "id": 53, - "internalFunctionIDs": - { + "internalFunctionIDs": { "20": 3, "24": 4, "4": 1, "8": 2 }, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 53 ], "name": "L", "nameLocation": "68:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "100:2:1", @@ -176,15 +155,13 @@ "name": "ext", "nameLocation": "85:3:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], "src": "88:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], @@ -197,8 +174,7 @@ "visibility": "external" }, { - "body": - { + "body": { "id": 19, "nodeType": "Block", "src": "132:2:1", @@ -211,15 +187,13 @@ "name": "inr1", "nameLocation": "116:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 17, "nodeType": "ParameterList", "parameters": [], "src": "120:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 18, "nodeType": "ParameterList", "parameters": [], @@ -232,8 +206,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 23, "nodeType": "Block", "src": "164:2:1", @@ -246,15 +219,13 @@ "name": "inr2", "nameLocation": "148:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 21, "nodeType": "ParameterList", "parameters": [], "src": "152:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 22, "nodeType": "ParameterList", "parameters": [], @@ -267,8 +238,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 27, "nodeType": "Block", "src": "196:2:1", @@ -281,15 +251,13 @@ "name": "inr3", "nameLocation": "180:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 25, "nodeType": "ParameterList", "parameters": [], "src": "184:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 26, "nodeType": "ParameterList", "parameters": [], @@ -302,24 +270,20 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 39, "nodeType": "Block", "src": "228:51:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "id": 31, "name": "free1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4, "src": "238:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -329,16 +293,14 @@ "src": "238:5:1" }, { - "expression": - { + "expression": { "id": 33, "name": "inr1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 20, "src": "253:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -348,18 +310,15 @@ "src": "253:4:1" }, { - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 35, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, "src": "267:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$53_$", "typeString": "type(library L)" } @@ -374,8 +333,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 16, "src": "267:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_delegatecall_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -394,15 +352,13 @@ "name": "access", "nameLocation": "212:6:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 29, "nodeType": "ParameterList", "parameters": [], "src": "218:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 30, "nodeType": "ParameterList", "parameters": [], @@ -415,22 +371,17 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 51, "nodeType": "Block", "src": "313:44:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 43, "name": "free2", @@ -438,8 +389,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 8, "src": "324:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -453,8 +403,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "323:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -470,8 +419,7 @@ "nodeType": "FunctionCall", "src": "323:9:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -481,14 +429,11 @@ "src": "323:9:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 47, "name": "inr2", @@ -496,8 +441,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 24, "src": "343:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -511,8 +455,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "342:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -528,8 +471,7 @@ "nodeType": "FunctionCall", "src": "342:8:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -548,15 +490,13 @@ "name": "expression", "nameLocation": "293:10:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 41, "nodeType": "ParameterList", "parameters": [], "src": "303:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 42, "nodeType": "ParameterList", "parameters": [], @@ -582,8 +522,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 128, - "internalFunctionIDs": - { + "internalFunctionIDs": { "20": 3, "24": 4, "4": 1, @@ -591,18 +530,15 @@ "73": 6, "8": 2 }, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 128 ], "name": "C", "nameLocation": "369:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 56, "nodeType": "Block", "src": "402:2:1", @@ -616,15 +552,13 @@ "name": "ext1", "nameLocation": "386:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 54, "nodeType": "ParameterList", "parameters": [], "src": "390:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 55, "nodeType": "ParameterList", "parameters": [], @@ -637,8 +571,7 @@ "visibility": "external" }, { - "body": - { + "body": { "id": 60, "nodeType": "Block", "src": "434:2:1", @@ -652,15 +585,13 @@ "name": "ext2", "nameLocation": "418:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 58, "nodeType": "ParameterList", "parameters": [], "src": "422:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 59, "nodeType": "ParameterList", "parameters": [], @@ -673,8 +604,7 @@ "visibility": "external" }, { - "body": - { + "body": { "id": 64, "nodeType": "Block", "src": "466:2:1", @@ -688,15 +618,13 @@ "name": "ext3", "nameLocation": "450:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 62, "nodeType": "ParameterList", "parameters": [], "src": "454:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 63, "nodeType": "ParameterList", "parameters": [], @@ -709,8 +637,7 @@ "visibility": "external" }, { - "body": - { + "body": { "id": 68, "nodeType": "Block", "src": "498:2:1", @@ -723,15 +650,13 @@ "name": "inr1", "nameLocation": "482:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 66, "nodeType": "ParameterList", "parameters": [], "src": "486:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 67, "nodeType": "ParameterList", "parameters": [], @@ -744,8 +669,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 72, "nodeType": "Block", "src": "530:2:1", @@ -758,15 +682,13 @@ "name": "inr2", "nameLocation": "514:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 70, "nodeType": "ParameterList", "parameters": [], "src": "518:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 71, "nodeType": "ParameterList", "parameters": [], @@ -779,8 +701,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 76, "nodeType": "Block", "src": "562:2:1", @@ -793,15 +714,13 @@ "name": "inr3", "nameLocation": "546:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 74, "nodeType": "ParameterList", "parameters": [], "src": "550:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 75, "nodeType": "ParameterList", "parameters": [], @@ -814,26 +733,21 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 96, "nodeType": "Block", "src": "594:86:1", - "statements": - [ + "statements": [ { - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 80, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "604:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$128", "typeString": "contract C" } @@ -848,8 +762,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 57, "src": "604:9:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$__$returns$__$", "typeString": "function () external" } @@ -859,16 +772,14 @@ "src": "604:9:1" }, { - "expression": - { + "expression": { "id": 84, "name": "inr1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 69, "src": "623:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -878,16 +789,14 @@ "src": "623:4:1" }, { - "expression": - { + "expression": { "id": 86, "name": "free1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4, "src": "637:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -897,18 +806,15 @@ "src": "637:5:1" }, { - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 88, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, "src": "652:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$53_$", "typeString": "type(library L)" } @@ -923,8 +829,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 20, "src": "652:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -934,18 +839,15 @@ "src": "652:6:1" }, { - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 92, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, "src": "668:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$53_$", "typeString": "type(library L)" } @@ -960,8 +862,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 16, "src": "668:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_delegatecall_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -980,15 +881,13 @@ "name": "access", "nameLocation": "578:6:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 78, "nodeType": "ParameterList", "parameters": [], "src": "584:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 79, "nodeType": "ParameterList", "parameters": [], @@ -1001,33 +900,26 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 126, "nodeType": "Block", "src": "714:106:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 100, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "725:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$128", "typeString": "contract C" } @@ -1042,8 +934,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 61, "src": "725:9:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$__$returns$__$", "typeString": "function () external" } @@ -1057,8 +948,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "724:11:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$__$returns$__$", "typeString": "function () external" } @@ -1074,8 +964,7 @@ "nodeType": "FunctionCall", "src": "724:13:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1085,14 +974,11 @@ "src": "724:13:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 106, "name": "inr2", @@ -1100,8 +986,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 73, "src": "748:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1115,8 +1000,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "747:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1132,8 +1016,7 @@ "nodeType": "FunctionCall", "src": "747:8:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1143,14 +1026,11 @@ "src": "747:8:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { "id": 110, "name": "free2", @@ -1158,8 +1038,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 8, "src": "766:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1173,8 +1052,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "765:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1190,8 +1068,7 @@ "nodeType": "FunctionCall", "src": "765:9:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1201,25 +1078,20 @@ "src": "765:9:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 114, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, "src": "785:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$53_$", "typeString": "type(library L)" } @@ -1234,8 +1106,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 24, "src": "785:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1249,8 +1120,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "784:8:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1266,8 +1136,7 @@ "nodeType": "FunctionCall", "src": "784:10:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1277,25 +1146,20 @@ "src": "784:10:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "components": - [ + "components": [ { - "expression": - { + "expression": { "id": 120, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 53, "src": "805:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$53_$", "typeString": "type(library L)" } @@ -1310,8 +1174,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 16, "src": "805:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_delegatecall_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1325,8 +1188,7 @@ "lValueRequested": false, "nodeType": "TupleExpression", "src": "804:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_delegatecall_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1342,8 +1204,7 @@ "nodeType": "FunctionCall", "src": "804:9:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1362,15 +1223,13 @@ "name": "expression", "nameLocation": "694:10:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 98, "nodeType": "ParameterList", "parameters": [], "src": "704:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 99, "nodeType": "ParameterList", "parameters": [], @@ -1390,15 +1249,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 129, "name": "C", - "nameLocations": - [ + "nameLocations": [ "837:1:1" ], "nodeType": "IdentifierPath", @@ -1415,8 +1271,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 141, - "internalFunctionIDs": - { + "internalFunctionIDs": { "20": 3, "24": 4, "4": 1, @@ -1424,30 +1279,24 @@ "73": 6, "8": 2 }, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 141, 128 ], "name": "D", "nameLocation": "832:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 139, "nodeType": "Block", "src": "859:47:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 133, "name": "access", @@ -1455,8 +1304,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 97, "src": "869:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1472,8 +1320,7 @@ "nodeType": "FunctionCall", "src": "869:8:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1483,11 +1330,9 @@ "src": "869:8:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 136, "name": "expression", @@ -1495,8 +1340,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 127, "src": "887:10:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -1512,8 +1356,7 @@ "nodeType": "FunctionCall", "src": "887:12:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -1531,15 +1374,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 131, "nodeType": "ParameterList", "parameters": [], "src": "856:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 132, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/base_constructor_call.json b/test/libsolidity/ASTJSON/base_constructor_call.json index 2c3c68c40d3a..408cb947704a 100644 --- a/test/libsolidity/ASTJSON/base_constructor_call.json +++ b/test/libsolidity/ASTJSON/base_constructor_call.json @@ -1,20 +1,16 @@ { "absolutePath": "a", - "exportedSymbols": - { - "A": - [ + "exportedSymbols": { + "A": [ 7 ], - "C": - [ + "C": [ 17 ] }, "id": 18, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -23,18 +19,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 7, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 7 ], "name": "A", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 5, "nodeType": "Block", "src": "31:2:1", @@ -47,12 +40,10 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -64,19 +55,16 @@ "src": "25:4:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "25:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -86,8 +74,7 @@ ], "src": "24:6:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -107,15 +94,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 8, "name": "A", - "nameLocations": - [ + "nameLocations": [ "50:1:1" ], "nodeType": "IdentifierPath", @@ -132,19 +116,16 @@ "contractKind": "contract", "fullyImplemented": true, "id": 17, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 17, 7 ], "name": "C", "nameLocation": "45:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "73:2:1", @@ -153,11 +134,9 @@ "id": 16, "implemented": true, "kind": "constructor", - "modifiers": - [ + "modifiers": [ { - "arguments": - [ + "arguments": [ { "hexValue": "32", "id": 12, @@ -168,8 +147,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "70:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, @@ -178,12 +156,10 @@ ], "id": 13, "kind": "baseConstructorSpecifier", - "modifierName": - { + "modifierName": { "id": 11, "name": "A", - "nameLocations": - [ + "nameLocations": [ "68:1:1" ], "nodeType": "IdentifierPath", @@ -197,15 +173,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], "src": "65:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json b/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json index 730a05178c62..07a57a9db788 100644 --- a/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json +++ b/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 18, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "A", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 5, "nodeType": "Block", "src": "31:2:1", @@ -30,12 +27,10 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -47,8 +42,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", @@ -60,8 +54,7 @@ ], "src": "24:6:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -78,15 +71,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 8, "name": "A", - "nameLocations": - [ + "nameLocations": [ "50:1:1" ], "nodeType": "IdentifierPath", @@ -103,11 +93,9 @@ "name": "C", "nameLocation": "45:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "73:2:1", @@ -116,11 +104,9 @@ "id": 16, "implemented": true, "kind": "constructor", - "modifiers": - [ + "modifiers": [ { - "arguments": - [ + "arguments": [ { "hexValue": "32", "id": 12, @@ -132,12 +118,10 @@ } ], "id": 13, - "modifierName": - { + "modifierName": { "id": 11, "name": "A", - "nameLocations": - [ + "nameLocations": [ "68:1:1" ], "nodeType": "IdentifierPath", @@ -150,15 +134,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], "src": "65:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index 53e622b5ddab..2c18d73f240a 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "28:4:1", @@ -43,15 +37,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "25:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/constructor.sol b/test/libsolidity/ASTJSON/constructor.sol index b48aa1be342a..b2b1c646048b 100644 --- a/test/libsolidity/ASTJSON/constructor.sol +++ b/test/libsolidity/ASTJSON/constructor.sol @@ -2,4 +2,5 @@ contract C { constructor() { } } + // ---- diff --git a/test/libsolidity/ASTJSON/constructor_parseOnly.json b/test/libsolidity/ASTJSON/constructor_parseOnly.json index 9b1d4cfc4460..4645d6d3be0e 100644 --- a/test/libsolidity/ASTJSON/constructor_parseOnly.json +++ b/test/libsolidity/ASTJSON/constructor_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "28:4:1", @@ -30,15 +27,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "25:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/contract_dep_order.json b/test/libsolidity/ASTJSON/contract_dep_order.json index 67eff600b68f..396957617446 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order.json +++ b/test/libsolidity/ASTJSON/contract_dep_order.json @@ -1,32 +1,25 @@ { "absolutePath": "a", - "exportedSymbols": - { - "A": - [ + "exportedSymbols": { + "A": [ 1 ], - "B": - [ + "B": [ 4 ], - "C": - [ + "C": [ 7 ], - "D": - [ + "D": [ 10 ], - "E": - [ + "E": [ 13 ] }, "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -35,8 +28,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 1, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 1 ], "name": "A", @@ -50,15 +42,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 2, "name": "A", - "nameLocations": - [ + "nameLocations": [ "29:1:1" ], "nodeType": "IdentifierPath", @@ -75,8 +64,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 4, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 4, 1 ], @@ -91,15 +79,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 5, "name": "B", - "nameLocations": - [ + "nameLocations": [ "49:1:1" ], "nodeType": "IdentifierPath", @@ -116,8 +101,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 7, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 7, 4, 1 @@ -133,15 +117,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 8, "name": "C", - "nameLocations": - [ + "nameLocations": [ "69:1:1" ], "nodeType": "IdentifierPath", @@ -158,8 +139,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 10, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 10, 7, 4, @@ -176,15 +156,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 11, "name": "D", - "nameLocations": - [ + "nameLocations": [ "89:1:1" ], "nodeType": "IdentifierPath", @@ -201,8 +178,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 13, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 13, 10, 7, diff --git a/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json b/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json index ba8c377cf7cd..022d93b9e865 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json +++ b/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -20,15 +19,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 2, "name": "A", - "nameLocations": - [ + "nameLocations": [ "29:1:1" ], "nodeType": "IdentifierPath", @@ -52,15 +48,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 5, "name": "B", - "nameLocations": - [ + "nameLocations": [ "49:1:1" ], "nodeType": "IdentifierPath", @@ -84,15 +77,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 8, "name": "C", - "nameLocations": - [ + "nameLocations": [ "69:1:1" ], "nodeType": "IdentifierPath", @@ -116,15 +106,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 11, "name": "D", - "nameLocations": - [ + "nameLocations": [ "89:1:1" ], "nodeType": "IdentifierPath", diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index 43224bc64d1d..9558eb3fc4ff 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -1,25 +1,21 @@ [ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 2 ] }, "id": 3, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], "canonicalName": "C", "contractDependencies": [], "contractKind": "contract", - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "0:27:1", @@ -27,8 +23,7 @@ }, "fullyImplemented": true, "id": 2, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 2 ], "name": "C", @@ -45,25 +40,21 @@ }, { "absolutePath": "b", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], "canonicalName": "C", "contractDependencies": [], "contractKind": "contract", - "documentation": - { + "documentation": { "id": 4, "nodeType": "StructuredDocumentation", "src": "0:61:2", @@ -71,8 +62,7 @@ }, "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", @@ -89,17 +79,14 @@ }, { "absolutePath": "c", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 23 ] }, "id": 24, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -108,19 +95,16 @@ "contractKind": "contract", "fullyImplemented": true, "id": 23, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 23 ], "name": "C", "nameLocation": "9:1:3", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, - "documentation": - { + "documentation": { "id": 7, "nodeType": "StructuredDocumentation", "src": "15:32:3", @@ -136,19 +120,16 @@ "src": "48:17:3", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 8, "name": "uint", "nodeType": "ElementaryTypeName", "src": "48:4:3", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -157,8 +138,7 @@ }, { "anonymous": false, - "documentation": - { + "documentation": { "id": 10, "nodeType": "StructuredDocumentation", "src": "69:26:3", @@ -169,8 +149,7 @@ "name": "Evt", "nameLocation": "102:3:3", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], @@ -179,13 +158,11 @@ "src": "96:12:3" }, { - "body": - { + "body": { "id": 16, "nodeType": "Block", "src": "153:6:3", - "statements": - [ + "statements": [ { "id": 15, "nodeType": "PlaceholderStatement", @@ -193,8 +170,7 @@ } ] }, - "documentation": - { + "documentation": { "id": 13, "nodeType": "StructuredDocumentation", "src": "111:26:3", @@ -204,8 +180,7 @@ "name": "mod", "nameLocation": "147:3:3", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], @@ -216,15 +191,13 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 21, "nodeType": "Block", "src": "209:2:3", "statements": [] }, - "documentation": - { + "documentation": { "id": 18, "nodeType": "StructuredDocumentation", "src": "162:25:3", @@ -238,15 +211,13 @@ "name": "fn", "nameLocation": "197:2:3", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], "src": "199:2:3" }, - "returnParameters": - { + "returnParameters": { "id": 20, "nodeType": "ParameterList", "parameters": [], @@ -262,8 +233,7 @@ "scope": 24, "src": "0:213:3", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 12 ] } diff --git a/test/libsolidity/ASTJSON/documentation.sol b/test/libsolidity/ASTJSON/documentation.sol index 6bbf4042af60..471b7a4761c7 100644 --- a/test/libsolidity/ASTJSON/documentation.sol +++ b/test/libsolidity/ASTJSON/documentation.sol @@ -1,19 +1,17 @@ ==== Source: a ==== - /**This contract is empty*/ contract C {} ==== Source: b ==== - /**This contract is empty and has a line-breaking comment.*/ contract C {} ==== Source: c ==== - contract C { /** Some comment on state var.*/ uint public state; /** Some comment on Evt.*/ event Evt(); /** Some comment on mod.*/ modifier mod() { _; } /** Some comment on fn.*/ function fn() public {} } + // ---- diff --git a/test/libsolidity/ASTJSON/documentation_local_variable.json b/test/libsolidity/ASTJSON/documentation_local_variable.json index 62d76e782c2b..1e22c91616b2 100644 --- a/test/libsolidity/ASTJSON/documentation_local_variable.json +++ b/test/libsolidity/ASTJSON/documentation_local_variable.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 41 ] }, "id": 42, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 41, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 41 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 26, "nodeType": "Block", "src": "42:330:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 5 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 5, @@ -54,19 +45,16 @@ "src": "109:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", "src": "109:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -76,8 +64,7 @@ ], "documentation": "Documentation for x; will appear in ast json", "id": 7, - "initialValue": - { + "initialValue": { "hexValue": "31", "id": 6, "isConstant": false, @@ -87,8 +74,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "118:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, @@ -98,20 +84,16 @@ "src": "109:10:1" }, { - "body": - { + "body": { "id": 24, "nodeType": "Block", "src": "270:96:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 21 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 21, @@ -123,19 +105,16 @@ "src": "345:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 20, "name": "uint", "nodeType": "ElementaryTypeName", "src": "345:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -145,8 +124,7 @@ ], "documentation": "documentation for j; will appear in ast json", "id": 23, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 22, "isConstant": false, @@ -156,8 +134,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "354:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, @@ -168,10 +145,8 @@ } ] }, - "condition": - { - "commonType": - { + "condition": { + "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, @@ -180,24 +155,21 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "leftExpression": - { + "leftExpression": { "id": 13, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10, "src": "236:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", - "rightExpression": - { + "rightExpression": { "hexValue": "3130", "id": 14, "isConstant": false, @@ -207,29 +179,24 @@ "lValueRequested": false, "nodeType": "Literal", "src": "240:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_10_by_1", "typeString": "int_const 10" }, "value": "10" }, "src": "236:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 25, - "initializationExpression": - { - "assignments": - [ + "initializationExpression": { + "assignments": [ 10 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 10, @@ -241,19 +208,16 @@ "src": "212:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 9, "name": "uint", "nodeType": "ElementaryTypeName", "src": "212:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -262,8 +226,7 @@ } ], "id": 12, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 11, "isConstant": false, @@ -273,8 +236,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "221:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, @@ -284,10 +246,8 @@ "src": "212:10:1" }, "isSimpleCounterLoop": true, - "loopExpression": - { - "expression": - { + "loopExpression": { + "expression": { "id": 17, "isConstant": false, "isLValue": false, @@ -297,22 +257,19 @@ "operator": "++", "prefix": true, "src": "256:3:1", - "subExpression": - { + "subExpression": { "id": 16, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10, "src": "258:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -334,15 +291,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -355,8 +310,7 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 39, "nodeType": "Block", "src": "662:2:1", @@ -370,12 +324,10 @@ "name": "g", "nameLocation": "386:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 37, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 30, @@ -387,19 +339,16 @@ "src": "463:11:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 29, "name": "uint", "nodeType": "ElementaryTypeName", "src": "463:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -417,19 +366,16 @@ "src": "550:11:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 32, "name": "uint", "nodeType": "ElementaryTypeName", "src": "550:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -447,19 +393,16 @@ "src": "637:11:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 35, "name": "uint", "nodeType": "ElementaryTypeName", "src": "637:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -469,8 +412,7 @@ ], "src": "387:267:1" }, - "returnParameters": - { + "returnParameters": { "id": 38, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json b/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json index 8725838394e8..97939eaa15c9 100644 --- a/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 42, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 26, "nodeType": "Block", "src": "42:330:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 5 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 5, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", @@ -54,8 +47,7 @@ ], "documentation": "Documentation for x; will appear in ast json", "id": 7, - "initialValue": - { + "initialValue": { "hexValue": "31", "id": 6, "kind": "number", @@ -68,20 +60,16 @@ "src": "109:10:1" }, { - "body": - { + "body": { "id": 24, "nodeType": "Block", "src": "270:96:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 21 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 21, @@ -93,8 +81,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 20, "name": "uint", "nodeType": "ElementaryTypeName", @@ -106,8 +93,7 @@ ], "documentation": "documentation for j; will appear in ast json", "id": 23, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 22, "kind": "number", @@ -121,12 +107,10 @@ } ] }, - "condition": - { + "condition": { "commonType": {}, "id": 15, - "leftExpression": - { + "leftExpression": { "id": 13, "name": "i", "nodeType": "Identifier", @@ -136,8 +120,7 @@ }, "nodeType": "BinaryOperation", "operator": "<", - "rightExpression": - { + "rightExpression": { "hexValue": "3130", "id": 14, "kind": "number", @@ -150,14 +133,11 @@ "typeDescriptions": {} }, "id": 25, - "initializationExpression": - { - "assignments": - [ + "initializationExpression": { + "assignments": [ 10 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 10, @@ -169,8 +149,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 9, "name": "uint", "nodeType": "ElementaryTypeName", @@ -181,8 +160,7 @@ } ], "id": 12, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 11, "kind": "number", @@ -194,17 +172,14 @@ "nodeType": "VariableDeclarationStatement", "src": "212:10:1" }, - "loopExpression": - { - "expression": - { + "loopExpression": { + "expression": { "id": 17, "nodeType": "UnaryOperation", "operator": "++", "prefix": true, "src": "256:3:1", - "subExpression": - { + "subExpression": { "id": 16, "name": "i", "nodeType": "Identifier", @@ -230,15 +205,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -250,8 +223,7 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 39, "nodeType": "Block", "src": "662:2:1", @@ -264,12 +236,10 @@ "name": "g", "nameLocation": "386:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 37, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 30, @@ -281,8 +251,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 29, "name": "uint", "nodeType": "ElementaryTypeName", @@ -302,8 +271,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 32, "name": "uint", "nodeType": "ElementaryTypeName", @@ -323,8 +291,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 35, "name": "uint", "nodeType": "ElementaryTypeName", @@ -336,8 +303,7 @@ ], "src": "387:267:1" }, - "returnParameters": - { + "returnParameters": { "id": 38, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/documentation_on_statements.json b/test/libsolidity/ASTJSON/documentation_on_statements.json index cc4a1ef3c166..350d7868672f 100644 --- a/test/libsolidity/ASTJSON/documentation_on_statements.json +++ b/test/libsolidity/ASTJSON/documentation_on_statements.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 27 ] }, "id": 28, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,15 +16,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 27, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 27 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 2, @@ -39,19 +34,16 @@ "src": "45:6:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "45:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -59,47 +51,39 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 25, "nodeType": "Block", "src": "99:229:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "id": 21, "nodeType": "Block", "src": "156:66:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "id": 19, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "leftHandSide": - { + "leftHandSide": { "id": 17, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, "src": "205:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "*=", - "rightHandSide": - { + "rightHandSide": { "hexValue": "32", "id": 18, "isConstant": false, @@ -109,16 +93,14 @@ "lValueRequested": false, "nodeType": "Literal", "src": "210:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "src": "205:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -129,10 +111,8 @@ } ] }, - "condition": - { - "commonType": - { + "condition": { + "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, @@ -141,24 +121,21 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "leftExpression": - { + "leftExpression": { "id": 11, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 8, "src": "143:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", - "rightExpression": - { + "rightExpression": { "hexValue": "3230", "id": 12, "isConstant": false, @@ -168,29 +145,24 @@ "lValueRequested": false, "nodeType": "Literal", "src": "147:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_20_by_1", "typeString": "int_const 20" }, "value": "20" }, "src": "143:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 22, - "initializationExpression": - { - "assignments": - [ + "initializationExpression": { + "assignments": [ 8 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 8, @@ -202,19 +174,16 @@ "src": "131:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 7, "name": "uint", "nodeType": "ElementaryTypeName", "src": "131:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -223,8 +192,7 @@ } ], "id": 10, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 9, "isConstant": false, @@ -234,8 +202,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "140:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, @@ -245,10 +212,8 @@ "src": "131:10:1" }, "isSimpleCounterLoop": true, - "loopExpression": - { - "expression": - { + "loopExpression": { + "expression": { "id": 15, "isConstant": false, "isLValue": false, @@ -258,22 +223,19 @@ "operator": "++", "prefix": false, "src": "151:3:1", - "subExpression": - { + "subExpression": { "id": 14, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 8, "src": "151:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -286,16 +248,14 @@ "src": "126:96:1" }, { - "expression": - { + "expression": { "id": 23, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, "src": "320:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -315,19 +275,16 @@ "name": "f", "nameLocation": "66:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "67:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 5, @@ -339,19 +296,16 @@ "src": "91:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", "src": "91:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } diff --git a/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json b/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json index 3872027cbb54..e266c2e5b330 100644 --- a/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 28, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,8 +12,7 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 2, @@ -26,8 +24,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", @@ -37,27 +34,21 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 25, "nodeType": "Block", "src": "99:229:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "id": 21, "nodeType": "Block", "src": "156:66:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "id": 19, - "leftHandSide": - { + "leftHandSide": { "id": 17, "name": "x", "nodeType": "Identifier", @@ -67,8 +58,7 @@ }, "nodeType": "Assignment", "operator": "*=", - "rightHandSide": - { + "rightHandSide": { "hexValue": "32", "id": 18, "kind": "number", @@ -86,12 +76,10 @@ } ] }, - "condition": - { + "condition": { "commonType": {}, "id": 13, - "leftExpression": - { + "leftExpression": { "id": 11, "name": "i", "nodeType": "Identifier", @@ -101,8 +89,7 @@ }, "nodeType": "BinaryOperation", "operator": "<", - "rightExpression": - { + "rightExpression": { "hexValue": "3230", "id": 12, "kind": "number", @@ -115,14 +102,11 @@ "typeDescriptions": {} }, "id": 22, - "initializationExpression": - { - "assignments": - [ + "initializationExpression": { + "assignments": [ 8 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 8, @@ -134,8 +118,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 7, "name": "uint", "nodeType": "ElementaryTypeName", @@ -146,8 +129,7 @@ } ], "id": 10, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 9, "kind": "number", @@ -159,17 +141,14 @@ "nodeType": "VariableDeclarationStatement", "src": "131:10:1" }, - "loopExpression": - { - "expression": - { + "loopExpression": { + "expression": { "id": 15, "nodeType": "UnaryOperation", "operator": "++", "prefix": false, "src": "151:3:1", - "subExpression": - { + "subExpression": { "id": 14, "name": "i", "nodeType": "Identifier", @@ -187,8 +166,7 @@ "src": "126:96:1" }, { - "expression": - { + "expression": { "id": 23, "name": "x", "nodeType": "Identifier", @@ -209,19 +187,16 @@ "name": "f", "nameLocation": "66:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "67:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 5, @@ -233,8 +208,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/documentation_parseOnly.json b/test/libsolidity/ASTJSON/documentation_parseOnly.json index 7f446279b613..c6215818d624 100644 --- a/test/libsolidity/ASTJSON/documentation_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_parseOnly.json @@ -3,15 +3,13 @@ "absolutePath": "a", "id": 3, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "0:27:1", @@ -33,15 +31,13 @@ "absolutePath": "b", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "documentation": - { + "documentation": { "id": 4, "nodeType": "StructuredDocumentation", "src": "0:61:2", @@ -63,8 +59,7 @@ "absolutePath": "c", "id": 24, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -74,8 +69,7 @@ "name": "C", "nameLocation": "9:1:3", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 9, @@ -87,8 +81,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 8, "name": "uint", "nodeType": "ElementaryTypeName", @@ -99,8 +92,7 @@ }, { "anonymous": false, - "documentation": - { + "documentation": { "id": 10, "nodeType": "StructuredDocumentation", "src": "69:26:3", @@ -110,8 +102,7 @@ "name": "Evt", "nameLocation": "102:3:3", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], @@ -120,13 +111,11 @@ "src": "96:12:3" }, { - "body": - { + "body": { "id": 16, "nodeType": "Block", "src": "153:6:3", - "statements": - [ + "statements": [ { "id": 15, "nodeType": "PlaceholderStatement", @@ -134,8 +123,7 @@ } ] }, - "documentation": - { + "documentation": { "id": 13, "nodeType": "StructuredDocumentation", "src": "111:26:3", @@ -145,8 +133,7 @@ "name": "mod", "nameLocation": "147:3:3", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], @@ -157,15 +144,13 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 21, "nodeType": "Block", "src": "209:2:3", "statements": [] }, - "documentation": - { + "documentation": { "id": 18, "nodeType": "StructuredDocumentation", "src": "162:25:3", @@ -178,15 +163,13 @@ "name": "fn", "nameLocation": "197:2:3", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], "src": "199:2:3" }, - "returnParameters": - { + "returnParameters": { "id": 20, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/documentation_triple.json b/test/libsolidity/ASTJSON/documentation_triple.json index cd44bd4eb60d..bc3c3d8878cd 100644 --- a/test/libsolidity/ASTJSON/documentation_triple.json +++ b/test/libsolidity/ASTJSON/documentation_triple.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 28 ] }, "id": 29, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,19 +16,16 @@ "contractKind": "contract", "fullyImplemented": true, "id": 28, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 28 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "17:8:1", @@ -46,19 +40,16 @@ "src": "30:6:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "30:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -66,48 +57,40 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 26, "nodeType": "Block", "src": "84:181:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "id": 22, "nodeType": "Block", "src": "142:75:1", - "statements": - [ + "statements": [ { "documentation": "tee\n s \"t\" 3", - "expression": - { + "expression": { "id": 20, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "leftHandSide": - { + "leftHandSide": { "id": 18, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6, "src": "200:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "*=", - "rightHandSide": - { + "rightHandSide": { "hexValue": "32", "id": 19, "isConstant": false, @@ -117,16 +100,14 @@ "lValueRequested": false, "nodeType": "Literal", "src": "205:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, "value": "2" }, "src": "200:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -137,10 +118,8 @@ } ] }, - "condition": - { - "commonType": - { + "condition": { + "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, @@ -149,24 +128,21 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "leftExpression": - { + "leftExpression": { "id": 12, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 9, "src": "129:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", - "rightExpression": - { + "rightExpression": { "hexValue": "3230", "id": 13, "isConstant": false, @@ -176,30 +152,25 @@ "lValueRequested": false, "nodeType": "Literal", "src": "133:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_20_by_1", "typeString": "int_const 20" }, "value": "20" }, "src": "129:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "documentation": "test2", "id": 23, - "initializationExpression": - { - "assignments": - [ + "initializationExpression": { + "assignments": [ 9 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 9, @@ -211,19 +182,16 @@ "src": "117:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 8, "name": "uint", "nodeType": "ElementaryTypeName", "src": "117:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -232,8 +200,7 @@ } ], "id": 11, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 10, "isConstant": false, @@ -243,8 +210,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "126:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, @@ -254,10 +220,8 @@ "src": "117:10:1" }, "isSimpleCounterLoop": true, - "loopExpression": - { - "expression": - { + "loopExpression": { + "expression": { "id": 16, "isConstant": false, "isLValue": false, @@ -267,22 +231,19 @@ "operator": "++", "prefix": false, "src": "137:3:1", - "subExpression": - { + "subExpression": { "id": 15, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 9, "src": "137:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -296,16 +257,14 @@ }, { "documentation": "tes \"t4\" ", - "expression": - { + "expression": { "id": 24, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6, "src": "257:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -325,19 +284,16 @@ "name": "f", "nameLocation": "51:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "52:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -349,19 +305,16 @@ "src": "76:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", "src": "76:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } diff --git a/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json b/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json index 5ccc2631ca99..7f24ded91141 100644 --- a/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 29, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,8 +12,7 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 3, @@ -26,8 +24,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", @@ -37,28 +34,22 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 26, "nodeType": "Block", "src": "84:181:1", - "statements": - [ + "statements": [ { - "body": - { + "body": { "id": 22, "nodeType": "Block", "src": "142:75:1", - "statements": - [ + "statements": [ { "documentation": "tee\n s \"t\" 3", - "expression": - { + "expression": { "id": 20, - "leftHandSide": - { + "leftHandSide": { "id": 18, "name": "x", "nodeType": "Identifier", @@ -68,8 +59,7 @@ }, "nodeType": "Assignment", "operator": "*=", - "rightHandSide": - { + "rightHandSide": { "hexValue": "32", "id": 19, "kind": "number", @@ -87,12 +77,10 @@ } ] }, - "condition": - { + "condition": { "commonType": {}, "id": 14, - "leftExpression": - { + "leftExpression": { "id": 12, "name": "i", "nodeType": "Identifier", @@ -102,8 +90,7 @@ }, "nodeType": "BinaryOperation", "operator": "<", - "rightExpression": - { + "rightExpression": { "hexValue": "3230", "id": 13, "kind": "number", @@ -117,14 +104,11 @@ }, "documentation": "test2", "id": 23, - "initializationExpression": - { - "assignments": - [ + "initializationExpression": { + "assignments": [ 9 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 9, @@ -136,8 +120,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 8, "name": "uint", "nodeType": "ElementaryTypeName", @@ -148,8 +131,7 @@ } ], "id": 11, - "initialValue": - { + "initialValue": { "hexValue": "30", "id": 10, "kind": "number", @@ -161,17 +143,14 @@ "nodeType": "VariableDeclarationStatement", "src": "117:10:1" }, - "loopExpression": - { - "expression": - { + "loopExpression": { + "expression": { "id": 16, "nodeType": "UnaryOperation", "operator": "++", "prefix": false, "src": "137:3:1", - "subExpression": - { + "subExpression": { "id": 15, "name": "i", "nodeType": "Identifier", @@ -190,8 +169,7 @@ }, { "documentation": "tes \"t4\" ", - "expression": - { + "expression": { "id": 24, "name": "x", "nodeType": "Identifier", @@ -212,19 +190,16 @@ "name": "f", "nameLocation": "51:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "52:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -236,8 +211,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/enum_natspec.json b/test/libsolidity/ASTJSON/enum_natspec.json index f3cc7b8df8aa..e55e3705d22d 100644 --- a/test/libsolidity/ASTJSON/enum_natspec.json +++ b/test/libsolidity/ASTJSON/enum_natspec.json @@ -1,28 +1,23 @@ { "absolutePath": "a", - "exportedSymbols": - { - "Color": - [ + "exportedSymbols": { + "Color": [ 4 ] }, "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "Color", - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "0:112:1", "text": "@title example of title\n @author example of author\n @notice example of notice\n @dev example of dev" }, "id": 4, - "members": - [ + "members": [ { "id": 2, "name": "Red", diff --git a/test/libsolidity/ASTJSON/enum_natspec_parseOnly.json b/test/libsolidity/ASTJSON/enum_natspec_parseOnly.json index b5a38af6c449..723df77c1ff5 100644 --- a/test/libsolidity/ASTJSON/enum_natspec_parseOnly.json +++ b/test/libsolidity/ASTJSON/enum_natspec_parseOnly.json @@ -2,19 +2,16 @@ "absolutePath": "a", "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "0:112:1", "text": "@title example of title\n @author example of author\n @notice example of notice\n @dev example of dev" }, "id": 4, - "members": - [ + "members": [ { "id": 2, "name": "Red", diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json index 31615f657b6a..de507a79ef48 100644 --- a/test/libsolidity/ASTJSON/enum_value.json +++ b/test/libsolidity/ASTJSON/enum_value.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 4 ] }, "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,20 +16,17 @@ "contractKind": "contract", "fullyImplemented": true, "id": 4, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 4 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "canonicalName": "C.E", "id": 3, - "members": - [ + "members": [ { "id": 1, "name": "A", diff --git a/test/libsolidity/ASTJSON/enum_value_declaration.json b/test/libsolidity/ASTJSON/enum_value_declaration.json index acdcc736e25e..324911fa90f8 100644 --- a/test/libsolidity/ASTJSON/enum_value_declaration.json +++ b/test/libsolidity/ASTJSON/enum_value_declaration.json @@ -1,25 +1,20 @@ { "absolutePath": "a", - "exportedSymbols": - { - "A": - [ + "exportedSymbols": { + "A": [ 3 ], - "f": - [ + "f": [ 13 ] }, "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "A", "id": 3, - "members": - [ + "members": [ { "id": 1, "name": "X", @@ -41,26 +36,21 @@ "src": "0:15:1" }, { - "body": - { + "body": { "id": 12, "nodeType": "Block", "src": "46:15:1", - "statements": - [ + "statements": [ { - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 9, "name": "A", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, "src": "55:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_enum$_A_$3_$", "typeString": "type(enum A)" } @@ -75,8 +65,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 1, "src": "55:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_enum$_A_$3", "typeString": "enum A" } @@ -95,19 +84,16 @@ "name": "f", "nameLocation": "25:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "26:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 7, @@ -119,21 +105,17 @@ "src": "43:1:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_enum$_A_$3", "typeString": "enum A" }, - "typeName": - { + "typeName": { "id": 6, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 5, "name": "A", - "nameLocations": - [ + "nameLocations": [ "43:1:1" ], "nodeType": "IdentifierPath", @@ -142,8 +124,7 @@ }, "referencedDeclaration": 3, "src": "43:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_enum$_A_$3", "typeString": "enum A" } diff --git a/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json b/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json index 8fa574fa74d6..93499e815628 100644 --- a/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json +++ b/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json @@ -2,12 +2,10 @@ "absolutePath": "a", "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 3, - "members": - [ + "members": [ { "id": 1, "name": "X", @@ -29,18 +27,14 @@ "src": "0:15:1" }, { - "body": - { + "body": { "id": 12, "nodeType": "Block", "src": "46:15:1", - "statements": - [ + "statements": [ { - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 9, "name": "A", "nodeType": "Identifier", @@ -68,19 +62,16 @@ "name": "f", "nameLocation": "25:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "26:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 7, @@ -92,16 +83,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 6, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 5, "name": "A", - "nameLocations": - [ + "nameLocations": [ "43:1:1" ], "nodeType": "IdentifierPath", diff --git a/test/libsolidity/ASTJSON/enum_value_parseOnly.json b/test/libsolidity/ASTJSON/enum_value_parseOnly.json index 006e2db36077..564c71273eff 100644 --- a/test/libsolidity/ASTJSON/enum_value_parseOnly.json +++ b/test/libsolidity/ASTJSON/enum_value_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,12 +12,10 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 3, - "members": - [ + "members": [ { "id": 1, "name": "A", diff --git a/test/libsolidity/ASTJSON/event_aggregated_contract.json b/test/libsolidity/ASTJSON/event_aggregated_contract.json index e312320c126a..d1bf17c75b29 100644 --- a/test/libsolidity/ASTJSON/event_aggregated_contract.json +++ b/test/libsolidity/ASTJSON/event_aggregated_contract.json @@ -1,20 +1,16 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 10 ], - "D": - [ + "D": [ 30 ] }, "id": 31, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -23,15 +19,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 10, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 10 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "ffae15ba29768297c9b951e2e14bc33dc84599d1572acc234266fc70392babc8", @@ -39,8 +33,7 @@ "name": "e", "nameLocation": "23:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -49,19 +42,15 @@ "src": "17:10:1" }, { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "52:25:1", - "statements": - [ + "statements": [ { - "eventCall": - { + "eventCall": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 5, "name": "e", @@ -69,8 +58,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 2, "src": "67:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -86,8 +74,7 @@ "nodeType": "FunctionCall", "src": "67:3:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -106,15 +93,13 @@ "name": "f", "nameLocation": "41:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "42:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -130,8 +115,7 @@ "scope": 31, "src": "0:79:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2 ] }, @@ -139,22 +123,19 @@ "abstract": false, "baseContracts": [], "canonicalName": "D", - "contractDependencies": - [ + "contractDependencies": [ 10 ], "contractKind": "contract", "fullyImplemented": true, "id": 30, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 30 ], "name": "D", "nameLocation": "89:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 13, @@ -166,21 +147,17 @@ "src": "97:3:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" }, - "typeName": - { + "typeName": { "id": 12, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 11, "name": "C", - "nameLocations": - [ + "nameLocations": [ "97:1:1" ], "nodeType": "IdentifierPath", @@ -189,8 +166,7 @@ }, "referencedDeclaration": 10, "src": "97:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" } @@ -198,42 +174,35 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 28, "nodeType": "Block", "src": "120:43:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "id": 21, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "leftHandSide": - { + "leftHandSide": { "id": 16, "name": "c", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13, "src": "130:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" } }, "nodeType": "Assignment", "operator": "=", - "rightHandSide": - { + "rightHandSide": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 19, "isConstant": false, @@ -242,21 +211,17 @@ "lValueRequested": false, "nodeType": "NewExpression", "src": "134:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_creation_nonpayable$__$returns$_t_contract$_C_$10_$", "typeString": "function () returns (contract C)" }, - "typeName": - { + "typeName": { "id": 18, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 17, "name": "C", - "nameLocations": - [ + "nameLocations": [ "138:1:1" ], "nodeType": "IdentifierPath", @@ -265,8 +230,7 @@ }, "referencedDeclaration": 10, "src": "138:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" } @@ -283,15 +247,13 @@ "nodeType": "FunctionCall", "src": "134:7:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" } }, "src": "130:11:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" } @@ -301,22 +263,18 @@ "src": "130:11:1" }, { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "expression": - { + "expression": { "id": 23, "name": "c", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 13, "src": "151:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$10", "typeString": "contract C" } @@ -331,8 +289,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 9, "src": "151:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$__$returns$__$", "typeString": "function () external" } @@ -348,8 +305,7 @@ "nodeType": "FunctionCall", "src": "151:5:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -367,15 +323,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], "src": "117:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 15, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json index b59164fcb049..cdbe3041eb35 100644 --- a/test/libsolidity/ASTJSON/event_definition.json +++ b/test/libsolidity/ASTJSON/event_definition.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 3 ] }, "id": 4, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,15 +16,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 3, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 3 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028", @@ -35,8 +30,7 @@ "name": "E", "nameLocation": "19:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -48,8 +42,7 @@ "scope": 4, "src": "0:25:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2 ] } diff --git a/test/libsolidity/ASTJSON/event_definition_parseOnly.json b/test/libsolidity/ASTJSON/event_definition_parseOnly.json index 9116b3d2da28..25745fdc6e12 100644 --- a/test/libsolidity/ASTJSON/event_definition_parseOnly.json +++ b/test/libsolidity/ASTJSON/event_definition_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 4, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,16 +12,14 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "id": 2, "name": "E", "nameLocation": "19:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/event_emited_in_base_contract.json b/test/libsolidity/ASTJSON/event_emited_in_base_contract.json index 6b183b493111..40bb3bae44aa 100644 --- a/test/libsolidity/ASTJSON/event_emited_in_base_contract.json +++ b/test/libsolidity/ASTJSON/event_emited_in_base_contract.json @@ -1,24 +1,19 @@ { "absolutePath": "a", - "exportedSymbols": - { - "B": - [ + "exportedSymbols": { + "B": [ 16 ], - "C": - [ + "C": [ 19 ], - "L": - [ + "L": [ 5 ] }, "id": 20, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -27,15 +22,13 @@ "contractKind": "library", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "L", "nameLocation": "10:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "870e3024466c178150e2490c7cfb455e33c0db877113af040f89189d07946664", @@ -43,12 +36,10 @@ "name": "E", "nameLocation": "20:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -61,19 +52,16 @@ "src": "22:5:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "22:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } @@ -89,8 +77,7 @@ "scope": 20, "src": "0:31:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 4 ] }, @@ -102,28 +89,22 @@ "contractKind": "contract", "fullyImplemented": true, "id": 16, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 16 ], "name": "B", "nameLocation": "41:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 14, "nodeType": "Block", "src": "63:28:1", - "statements": - [ + "statements": [ { - "eventCall": - { - "arguments": - [ + "eventCall": { + "arguments": [ { "hexValue": "30", "id": 11, @@ -134,33 +115,28 @@ "lValueRequested": false, "nodeType": "Literal", "src": "82:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], - "expression": - { - "argumentTypes": - [ + "expression": { + "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], - "expression": - { + "expression": { "id": 8, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, "src": "78:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$5_$", "typeString": "type(library L)" } @@ -175,8 +151,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 4, "src": "78:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$_t_uint8_$returns$__$", "typeString": "function (uint8)" } @@ -192,8 +167,7 @@ "nodeType": "FunctionCall", "src": "78:6:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -211,15 +185,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], "src": "60:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], @@ -235,22 +207,18 @@ "scope": 20, "src": "32:61:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 4 ] }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 17, "name": "B", - "nameLocations": - [ + "nameLocations": [ "108:1:1" ], "nodeType": "IdentifierPath", @@ -267,8 +235,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 19, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 19, 16 ], @@ -279,8 +246,7 @@ "scope": 20, "src": "94:18:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 4 ] } diff --git a/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract.json b/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract.json index 2d70e2f9feb8..92de58cf8b2a 100644 --- a/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract.json +++ b/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract.json @@ -1,20 +1,16 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ], - "D": - [ + "D": [ 19 ] }, "id": 20, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -23,15 +19,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "bd1155618a34fd53d1a2de9f705f42f3582842cba0b985b25c59888d86e0c929", @@ -39,12 +33,10 @@ "name": "E", "nameLocation": "23:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -57,20 +49,17 @@ "src": "25:22:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, - "typeName": - { + "typeName": { "id": 1, "name": "address", "nodeType": "ElementaryTypeName", "src": "25:7:1", "stateMutability": "nonpayable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -86,8 +75,7 @@ "scope": 20, "src": "0:51:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 4 ] }, @@ -99,39 +87,31 @@ "contractKind": "contract", "fullyImplemented": true, "id": 19, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 19 ], "name": "D", "nameLocation": "61:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 17, "nodeType": "Block", "src": "106:37:1", - "statements": - [ + "statements": [ { - "eventCall": - { - "arguments": - [ + "eventCall": { + "arguments": [ { - "expression": - { + "expression": { "id": 13, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "125:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } @@ -145,32 +125,27 @@ "memberName": "sender", "nodeType": "MemberAccess", "src": "125:10:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], - "expression": - { - "argumentTypes": - [ + "expression": { + "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], - "expression": - { + "expression": { "id": 10, "name": "C", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, "src": "121:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_C_$5_$", "typeString": "type(contract C)" } @@ -185,8 +160,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 4, "src": "121:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$_t_address_$returns$__$", "typeString": "function (address)" } @@ -202,8 +176,7 @@ "nodeType": "FunctionCall", "src": "121:15:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -222,12 +195,10 @@ "name": "test", "nameLocation": "78:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 8, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 7, @@ -239,20 +210,17 @@ "src": "83:14:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, - "typeName": - { + "typeName": { "id": 6, "name": "address", "nodeType": "ElementaryTypeName", "src": "83:7:1", "stateMutability": "nonpayable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -262,8 +230,7 @@ ], "src": "82:16:1" }, - "returnParameters": - { + "returnParameters": { "id": 9, "nodeType": "ParameterList", "parameters": [], @@ -279,8 +246,7 @@ "scope": 20, "src": "52:93:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 4 ] } diff --git a/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract_parseOnly.json b/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract_parseOnly.json index b6c0ca5e0315..60ccdff44c14 100644 --- a/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract_parseOnly.json +++ b/test/libsolidity/ASTJSON/event_emitted_from_foreign_contract_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 20, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,20 +12,17 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "id": 4, "name": "E", "nameLocation": "23:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -39,8 +35,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "address", "nodeType": "ElementaryTypeName", @@ -69,24 +64,18 @@ "name": "D", "nameLocation": "61:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 17, "nodeType": "Block", "src": "106:37:1", - "statements": - [ + "statements": [ { - "eventCall": - { - "arguments": - [ + "eventCall": { + "arguments": [ { - "expression": - { + "expression": { "id": 13, "name": "msg", "nodeType": "Identifier", @@ -102,10 +91,8 @@ "typeDescriptions": {} } ], - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 10, "name": "C", "nodeType": "Identifier", @@ -141,12 +128,10 @@ "name": "test", "nameLocation": "78:4:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 8, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 7, @@ -158,8 +143,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 6, "name": "address", "nodeType": "ElementaryTypeName", @@ -172,8 +156,7 @@ ], "src": "82:16:1" }, - "returnParameters": - { + "returnParameters": { "id": 9, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/event_inheritance.json b/test/libsolidity/ASTJSON/event_inheritance.json index afa79e916c3c..d9a78da03a67 100644 --- a/test/libsolidity/ASTJSON/event_inheritance.json +++ b/test/libsolidity/ASTJSON/event_inheritance.json @@ -1,24 +1,19 @@ { "absolutePath": "a", - "exportedSymbols": - { - "B": - [ + "exportedSymbols": { + "B": [ 3 ], - "C": - [ + "C": [ 8 ], - "D": - [ + "D": [ 13 ] }, "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -27,15 +22,13 @@ "contractKind": "interface", "fullyImplemented": true, "id": 3, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 3 ], "name": "B", "nameLocation": "10:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "dbec0351ad6bb0c1f07ea56e236e3e692fde2259f0165fd422f241da339b7e4f", @@ -43,8 +36,7 @@ "name": "EB", "nameLocation": "24:2:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -56,22 +48,18 @@ "scope": 14, "src": "0:31:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2 ] }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 4, "name": "B", - "nameLocations": - [ + "nameLocations": [ "46:1:1" ], "nodeType": "IdentifierPath", @@ -88,16 +76,14 @@ "contractKind": "contract", "fullyImplemented": true, "id": 8, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 8, 3 ], "name": "C", "nameLocation": "41:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "a08b3367d3fa83ea27f8951ffb5d9d160cbfadbd80816b47f677e7699d76f5a0", @@ -105,8 +91,7 @@ "name": "EC", "nameLocation": "60:2:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], @@ -118,23 +103,19 @@ "scope": 14, "src": "32:35:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2, 7 ] }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 9, "name": "C", - "nameLocations": - [ + "nameLocations": [ "82:1:1" ], "nodeType": "IdentifierPath", @@ -151,8 +132,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 13, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 13, 8, 3 @@ -160,8 +140,7 @@ "name": "D", "nameLocation": "77:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "caa54b91a2314ab89b39714b1cd283762e53a2f59cfb997d6770e2824c39db0d", @@ -169,8 +148,7 @@ "name": "ED", "nameLocation": "96:2:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], @@ -182,8 +160,7 @@ "scope": 14, "src": "68:35:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2, 7, 12 diff --git a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types.sol b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types.sol index 6fe58c39c168..a2291057003d 100644 --- a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types.sol +++ b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types.sol @@ -1,4 +1,5 @@ contract C { event E(function() internal); } + // ---- diff --git a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json index 3ff426cb2230..44c1fb536895 100644 --- a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json +++ b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 8, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,20 +12,17 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "id": 6, "name": "E", "nameLocation": "23:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 5, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 4, @@ -39,19 +35,16 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "nodeType": "FunctionTypeName", - "parameterTypes": - { + "parameterTypes": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "33:2:1" }, - "returnParameterTypes": - { + "returnParameterTypes": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fail_after_parsing.sol b/test/libsolidity/ASTJSON/fail_after_parsing.sol index 882b4c950267..052900e93ce1 100644 --- a/test/libsolidity/ASTJSON/fail_after_parsing.sol +++ b/test/libsolidity/ASTJSON/fail_after_parsing.sol @@ -1,15 +1,12 @@ function g() public; - interface I { struct S { S s; } - function f(E storage e) { error E; emit E(); - ++c; uint calldata c = 123.4; } } + // ---- -// failAfter: Parsed diff --git a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json index f1d958617427..6f841649c897 100644 --- a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json +++ b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 30, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 3, "implemented": false, @@ -12,15 +11,13 @@ "name": "g", "nameLocation": "9:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "10:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -40,12 +37,10 @@ "name": "I", "nameLocation": "31:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 7, - "members": - [ + "members": [ { "constant": false, "id": 6, @@ -57,16 +52,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 4, "name": "S", - "nameLocations": - [ + "nameLocations": [ "50:1:1" ], "nodeType": "IdentifierPath", @@ -85,20 +77,16 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 27, "nodeType": "Block", "src": "85:88:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 15 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 15, @@ -110,16 +98,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 14, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 13, "name": "error", - "nameLocations": - [ + "nameLocations": [ "95:5:1" ], "nodeType": "IdentifierPath", @@ -136,11 +121,9 @@ "src": "95:7:1" }, { - "eventCall": - { + "eventCall": { "arguments": [], - "expression": - { + "expression": { "id": 17, "name": "E", "nodeType": "Identifier", @@ -161,15 +144,13 @@ "src": "112:8:1" }, { - "expression": - { + "expression": { "id": 21, "nodeType": "UnaryOperation", "operator": "++", "prefix": true, "src": "130:3:1", - "subExpression": - { + "subExpression": { "id": 20, "name": "c", "nodeType": "Identifier", @@ -184,12 +165,10 @@ "src": "130:3:1" }, { - "assignments": - [ + "assignments": [ 24 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 24, @@ -201,8 +180,7 @@ "stateVariable": false, "storageLocation": "calldata", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 23, "name": "uint", "nodeType": "ElementaryTypeName", @@ -213,8 +191,7 @@ } ], "id": 26, - "initialValue": - { + "initialValue": { "hexValue": "3132332e34", "id": 25, "kind": "number", @@ -235,12 +212,10 @@ "name": "f", "nameLocation": "70:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 10, @@ -252,16 +227,13 @@ "stateVariable": false, "storageLocation": "storage", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 9, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 8, "name": "E", - "nameLocations": - [ + "nameLocations": [ "72:1:1" ], "nodeType": "IdentifierPath", @@ -275,8 +247,7 @@ ], "src": "71:13:1" }, - "returnParameters": - { + "returnParameters": { "id": 12, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index f68c72ce6600..93646f2afa5c 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "43:5:1", @@ -43,15 +37,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fallback.sol b/test/libsolidity/ASTJSON/fallback.sol index 170e77958c97..219d85db593a 100644 --- a/test/libsolidity/ASTJSON/fallback.sol +++ b/test/libsolidity/ASTJSON/fallback.sol @@ -2,4 +2,5 @@ contract C { fallback() external payable { } } + // ---- diff --git a/test/libsolidity/ASTJSON/fallback_and_receive_ether.json b/test/libsolidity/ASTJSON/fallback_and_receive_ether.json index f41559d2a640..5504719ecb2f 100644 --- a/test/libsolidity/ASTJSON/fallback_and_receive_ether.json +++ b/test/libsolidity/ASTJSON/fallback_and_receive_ether.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 9 ] }, "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 9, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 9 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "42:5:1", @@ -43,15 +37,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "22:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -64,8 +56,7 @@ "visibility": "external" }, { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "78:5:1", @@ -78,15 +69,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], "src": "58:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fallback_and_receive_ether.sol b/test/libsolidity/ASTJSON/fallback_and_receive_ether.sol index 7eb712582db6..89acccf5a603 100644 --- a/test/libsolidity/ASTJSON/fallback_and_receive_ether.sol +++ b/test/libsolidity/ASTJSON/fallback_and_receive_ether.sol @@ -4,4 +4,5 @@ contract C { fallback() external payable { } } + // ---- diff --git a/test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json b/test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json index 215bf3a83bd9..34260824fe6e 100644 --- a/test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json +++ b/test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "42:5:1", @@ -30,15 +27,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "22:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -50,8 +45,7 @@ "visibility": "external" }, { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "78:5:1", @@ -64,15 +58,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], "src": "58:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fallback_parseOnly.json b/test/libsolidity/ASTJSON/fallback_parseOnly.json index eb81fafbe930..6991b32b4114 100644 --- a/test/libsolidity/ASTJSON/fallback_parseOnly.json +++ b/test/libsolidity/ASTJSON/fallback_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "43:5:1", @@ -30,15 +27,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index 790351764550..e3eacc1ecc95 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "34:2:1", @@ -43,15 +37,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "22:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/fallback_payable.sol b/test/libsolidity/ASTJSON/fallback_payable.sol index 7eff747af373..d66d378aff8d 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.sol +++ b/test/libsolidity/ASTJSON/fallback_payable.sol @@ -1,4 +1,5 @@ contract C { fallback() external {} } + // ---- diff --git a/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json b/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json index e1810828a39d..f14d2f1ed645 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "34:2:1", @@ -30,15 +27,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "22:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index e1a5156cf77d..563b65438cd1 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 17 ] }, "id": 18, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 17, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 17 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "127:2:1", @@ -44,12 +38,10 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -61,28 +53,23 @@ "src": "24:44:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_payable$__$returns$_t_uint256_$", "typeString": "function () payable external returns (uint256)" }, - "typeName": - { + "typeName": { "id": 5, "nodeType": "FunctionTypeName", - "parameterTypes": - { + "parameterTypes": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "32:2:1" }, - "returnParameterTypes": - { + "returnParameterTypes": { "id": 4, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 3, @@ -94,19 +81,16 @@ "src": "61:4:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "61:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -118,8 +102,7 @@ }, "src": "24:44:1", "stateMutability": "payable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_payable$__$returns$_t_uint256_$", "typeString": "function () payable external returns (uint256)" }, @@ -130,12 +113,10 @@ ], "src": "23:46:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 13, @@ -147,28 +128,23 @@ "src": "86:40:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$", "typeString": "function () view external returns (uint256)" }, - "typeName": - { + "typeName": { "id": 12, "nodeType": "FunctionTypeName", - "parameterTypes": - { + "parameterTypes": { "id": 8, "nodeType": "ParameterList", "parameters": [], "src": "94:2:1" }, - "returnParameterTypes": - { + "returnParameterTypes": { "id": 11, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 10, @@ -180,19 +156,16 @@ "src": "120:4:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 9, "name": "uint", "nodeType": "ElementaryTypeName", "src": "120:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -204,8 +177,7 @@ }, "src": "86:40:1", "stateMutability": "view", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_external_view$__$returns$_t_uint256_$", "typeString": "function () view external returns (uint256)" }, diff --git a/test/libsolidity/ASTJSON/function_type_parseOnly.json b/test/libsolidity/ASTJSON/function_type_parseOnly.json index 64b09d5d9d9b..765c51780e00 100644 --- a/test/libsolidity/ASTJSON/function_type_parseOnly.json +++ b/test/libsolidity/ASTJSON/function_type_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 18, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "127:2:1", @@ -30,12 +27,10 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -47,23 +42,19 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "nodeType": "FunctionTypeName", - "parameterTypes": - { + "parameterTypes": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "32:2:1" }, - "returnParameterTypes": - { + "returnParameterTypes": { "id": 4, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 3, @@ -75,8 +66,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", @@ -98,12 +88,10 @@ ], "src": "23:46:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 13, @@ -115,23 +103,19 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 12, "nodeType": "FunctionTypeName", - "parameterTypes": - { + "parameterTypes": { "id": 8, "nodeType": "ParameterList", "parameters": [], "src": "94:2:1" }, - "returnParameterTypes": - { + "returnParameterTypes": { "id": 11, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 10, @@ -143,8 +127,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 9, "name": "uint", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/global_enum.json b/test/libsolidity/ASTJSON/global_enum.json index 0b673cffbf9d..17a92954f5c6 100644 --- a/test/libsolidity/ASTJSON/global_enum.json +++ b/test/libsolidity/ASTJSON/global_enum.json @@ -1,21 +1,17 @@ { "absolutePath": "a", - "exportedSymbols": - { - "E": - [ + "exportedSymbols": { + "E": [ 2 ] }, "id": 3, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "E", "id": 2, - "members": - [ + "members": [ { "id": 1, "name": "A", diff --git a/test/libsolidity/ASTJSON/global_enum_parseOnly.json b/test/libsolidity/ASTJSON/global_enum_parseOnly.json index 887d5997cd05..c390db5b3792 100644 --- a/test/libsolidity/ASTJSON/global_enum_parseOnly.json +++ b/test/libsolidity/ASTJSON/global_enum_parseOnly.json @@ -2,12 +2,10 @@ "absolutePath": "a", "id": 3, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 2, - "members": - [ + "members": [ { "id": 1, "name": "A", diff --git a/test/libsolidity/ASTJSON/global_struct.json b/test/libsolidity/ASTJSON/global_struct.json index 2c14a5e41446..f7f937d04bd8 100644 --- a/test/libsolidity/ASTJSON/global_struct.json +++ b/test/libsolidity/ASTJSON/global_struct.json @@ -1,21 +1,17 @@ { "absolutePath": "a", - "exportedSymbols": - { - "S": - [ + "exportedSymbols": { + "S": [ 3 ] }, "id": 4, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "S", "id": 3, - "members": - [ + "members": [ { "constant": false, "id": 2, @@ -27,19 +23,16 @@ "src": "11:9:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "11:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } diff --git a/test/libsolidity/ASTJSON/global_struct_parseOnly.json b/test/libsolidity/ASTJSON/global_struct_parseOnly.json index 418cb79faf12..5f90ab8a1028 100644 --- a/test/libsolidity/ASTJSON/global_struct_parseOnly.json +++ b/test/libsolidity/ASTJSON/global_struct_parseOnly.json @@ -2,12 +2,10 @@ "absolutePath": "a", "id": 4, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 3, - "members": - [ + "members": [ { "constant": false, "id": 2, @@ -19,8 +17,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint256", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/indirect_event.json b/test/libsolidity/ASTJSON/indirect_event.json index fcbe81756275..691e814e51ef 100644 --- a/test/libsolidity/ASTJSON/indirect_event.json +++ b/test/libsolidity/ASTJSON/indirect_event.json @@ -1,21 +1,17 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 25 ], - "L": - [ + "L": [ 10 ] }, "id": 26, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -24,15 +20,13 @@ "contractKind": "library", "fullyImplemented": true, "id": 10, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 10 ], "name": "L", "nameLocation": "44:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028", @@ -40,8 +34,7 @@ "name": "E", "nameLocation": "58:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -50,19 +43,15 @@ "src": "52:10:1" }, { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "89:13:1", - "statements": - [ + "statements": [ { - "eventCall": - { + "eventCall": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 5, "name": "E", @@ -70,8 +59,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 2, "src": "96:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -87,8 +75,7 @@ "nodeType": "FunctionCall", "src": "96:3:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -106,15 +93,13 @@ "name": "f", "nameLocation": "76:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "77:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -130,8 +115,7 @@ "scope": 26, "src": "36:68:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2 ] }, @@ -143,15 +127,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 25, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 25 ], "name": "C", "nameLocation": "114:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "eventSelector": "70a5d861ef9816388422765f41d618eb3abdf490acb37354b539729e37b09f0e", @@ -159,8 +141,7 @@ "name": "H", "nameLocation": "128:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], @@ -169,30 +150,24 @@ "src": "122:10:1" }, { - "body": - { + "body": { "id": 23, "nodeType": "Block", "src": "157:20:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], - "expression": - { + "expression": { "id": 15, "name": "L", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10, "src": "159:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_L_$10_$", "typeString": "type(library L)" } @@ -207,8 +182,7 @@ "nodeType": "MemberAccess", "referencedDeclaration": 9, "src": "159:3:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -224,8 +198,7 @@ "nodeType": "FunctionCall", "src": "159:5:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -235,11 +208,9 @@ "src": "159:5:1" }, { - "eventCall": - { + "eventCall": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 20, "name": "H", @@ -247,8 +218,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 12, "src": "171:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_event_nonpayable$__$returns$__$", "typeString": "function ()" } @@ -264,8 +234,7 @@ "nodeType": "FunctionCall", "src": "171:3:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -284,15 +253,13 @@ "name": "g", "nameLocation": "146:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], "src": "147:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], @@ -308,8 +275,7 @@ "scope": 26, "src": "105:74:1", "usedErrors": [], - "usedEvents": - [ + "usedEvents": [ 2, 12 ] diff --git a/test/libsolidity/ASTJSON/indirect_event_parseOnly.json b/test/libsolidity/ASTJSON/indirect_event_parseOnly.json index 17ca036d3259..82ce0cd15f68 100644 --- a/test/libsolidity/ASTJSON/indirect_event_parseOnly.json +++ b/test/libsolidity/ASTJSON/indirect_event_parseOnly.json @@ -3,8 +3,7 @@ "id": 26, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -14,16 +13,14 @@ "name": "L", "nameLocation": "44:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "id": 2, "name": "E", "nameLocation": "58:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -32,19 +29,15 @@ "src": "52:10:1" }, { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "89:13:1", - "statements": - [ + "statements": [ { - "eventCall": - { + "eventCall": { "arguments": [], - "expression": - { + "expression": { "id": 5, "name": "E", "nodeType": "Identifier", @@ -73,15 +66,13 @@ "name": "f", "nameLocation": "76:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "77:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -106,16 +97,14 @@ "name": "C", "nameLocation": "114:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "anonymous": false, "id": 12, "name": "H", "nameLocation": "128:1:1", "nodeType": "EventDefinition", - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], @@ -124,21 +113,16 @@ "src": "122:10:1" }, { - "body": - { + "body": { "id": 23, "nodeType": "Block", "src": "157:20:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { - "expression": - { + "expression": { + "expression": { "id": 15, "name": "L", "nodeType": "Identifier", @@ -166,11 +150,9 @@ "src": "159:5:1" }, { - "eventCall": - { + "eventCall": { "arguments": [], - "expression": - { + "expression": { "id": 20, "name": "H", "nodeType": "Identifier", @@ -199,15 +181,13 @@ "name": "g", "nameLocation": "146:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], "src": "147:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 14, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json index ae210c949620..4365a9e435c7 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier.json @@ -1,20 +1,16 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C1": - [ + "exportedSymbols": { + "C1": [ 1 ], - "C2": - [ + "C2": [ 4 ] }, "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -23,8 +19,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 1, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 1 ], "name": "C1", @@ -38,15 +33,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 2, "name": "C1", - "nameLocations": - [ + "nameLocations": [ "30:2:1" ], "nodeType": "IdentifierPath", @@ -63,8 +55,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 4, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 4, 1 ], diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json b/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json index 171391b36d5e..a334485a9881 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 5, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -20,15 +19,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 2, "name": "C1", - "nameLocations": - [ + "nameLocations": [ "30:2:1" ], "nodeType": "IdentifierPath", diff --git a/test/libsolidity/ASTJSON/license.json b/test/libsolidity/ASTJSON/license.json index 4c0882637f2d..f12ed7e3e056 100644 --- a/test/libsolidity/ASTJSON/license.json +++ b/test/libsolidity/ASTJSON/license.json @@ -1,17 +1,14 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 1 ] }, "id": 2, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -20,8 +17,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 1, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 1 ], "name": "C", diff --git a/test/libsolidity/ASTJSON/license_parseOnly.json b/test/libsolidity/ASTJSON/license_parseOnly.json index f2958f15ffad..def7f2c62337 100644 --- a/test/libsolidity/ASTJSON/license_parseOnly.json +++ b/test/libsolidity/ASTJSON/license_parseOnly.json @@ -3,8 +3,7 @@ "id": 2, "license": "GPL-3.0", "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index 9bcd5e8fd9f2..f5a6aad08139 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "c": - [ + "exportedSymbols": { + "c": [ 11 ] }, "id": 12, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 11, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 11 ], "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "33:19:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -54,19 +45,16 @@ "src": "35:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", "src": "35:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -75,10 +63,8 @@ } ], "id": 8, - "initialValue": - { - "commonType": - { + "initialValue": { + "commonType": { "typeIdentifier": "t_rational_5_by_1", "typeString": "int_const 5" }, @@ -87,8 +73,7 @@ "isLValue": false, "isPure": true, "lValueRequested": false, - "leftExpression": - { + "leftExpression": { "hexValue": "32", "id": 5, "isConstant": false, @@ -98,8 +83,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "44:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, @@ -107,8 +91,7 @@ }, "nodeType": "BinaryOperation", "operator": "+", - "rightExpression": - { + "rightExpression": { "hexValue": "33", "id": 6, "isConstant": false, @@ -118,16 +101,14 @@ "lValueRequested": false, "nodeType": "Literal", "src": "48:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_3_by_1", "typeString": "int_const 3" }, "value": "3" }, "src": "44:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_5_by_1", "typeString": "int_const 5" } @@ -145,15 +126,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json index 2cb372dd26ac..56587809e8fb 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 12, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "33:19:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", @@ -53,12 +46,10 @@ } ], "id": 8, - "initialValue": - { + "initialValue": { "commonType": {}, "id": 7, - "leftExpression": - { + "leftExpression": { "hexValue": "32", "id": 5, "kind": "number", @@ -69,8 +60,7 @@ }, "nodeType": "BinaryOperation", "operator": "+", - "rightExpression": - { + "rightExpression": { "hexValue": "33", "id": 6, "kind": "number", @@ -94,15 +84,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index c22aeb40c28b..d3e76eaac4c0 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "c": - [ + "exportedSymbols": { + "c": [ 15 ] }, "id": 16, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,15 +16,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 15, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 15 ], "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 3, @@ -39,21 +34,17 @@ "src": "13:8:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage", "typeString": "uint256[]" }, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "13:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -61,8 +52,7 @@ "id": 2, "nodeType": "ArrayTypeName", "src": "13:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", "typeString": "uint256[]" } @@ -70,20 +60,16 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 13, "nodeType": "Block", "src": "43:25:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 10 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 10, @@ -95,21 +81,17 @@ "src": "45:16:1", "stateVariable": false, "storageLocation": "storage", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", "typeString": "uint256[]" }, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 8, "name": "uint", "nodeType": "ElementaryTypeName", "src": "45:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -117,8 +99,7 @@ "id": 9, "nodeType": "ArrayTypeName", "src": "45:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", "typeString": "uint256[]" } @@ -127,16 +108,14 @@ } ], "id": 12, - "initialValue": - { + "initialValue": { "id": 11, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, "src": "64:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage", "typeString": "uint256[] storage ref" } @@ -154,15 +133,13 @@ "name": "f", "nameLocation": "32:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "33:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json b/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json index 1bf50bed601c..597bd383bbd3 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 16, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,8 +12,7 @@ "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 3, @@ -26,10 +24,8 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", @@ -44,20 +40,16 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 13, "nodeType": "Block", "src": "43:25:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 10 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 10, @@ -69,10 +61,8 @@ "stateVariable": false, "storageLocation": "storage", "typeDescriptions": {}, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 8, "name": "uint", "nodeType": "ElementaryTypeName", @@ -88,8 +78,7 @@ } ], "id": 12, - "initialValue": - { + "initialValue": { "id": 11, "name": "a", "nodeType": "Identifier", @@ -109,15 +98,13 @@ "name": "f", "nameLocation": "32:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], "src": "33:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/mappings.json b/test/libsolidity/ASTJSON/mappings.json index 81bf19db1a85..c1b9cfc4807a 100644 --- a/test/libsolidity/ASTJSON/mappings.json +++ b/test/libsolidity/ASTJSON/mappings.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 23 ] }, "id": 24, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,20 +16,17 @@ "contractKind": "contract", "fullyImplemented": true, "id": 23, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 23 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "canonicalName": "C.E", "id": 4, - "members": - [ + "members": [ { "id": 1, "name": "A", @@ -71,26 +65,21 @@ "src": "40:20:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_contract$_C_$23_$_t_bool_$", "typeString": "mapping(contract C => bool)" }, - "typeName": - { + "typeName": { "id": 8, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 6, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 5, "name": "C", - "nameLocations": - [ + "nameLocations": [ "48:1:1" ], "nodeType": "IdentifierPath", @@ -99,29 +88,25 @@ }, "referencedDeclaration": 23, "src": "48:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_contract$_C_$23", "typeString": "contract C" } }, "nodeType": "Mapping", "src": "40:18:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_contract$_C_$23_$_t_bool_$", "typeString": "mapping(contract C => bool)" }, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 7, "name": "bool", "nodeType": "ElementaryTypeName", "src": "53:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } @@ -140,45 +125,38 @@ "src": "66:26:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", "typeString": "mapping(address => bool)" }, - "typeName": - { + "typeName": { "id": 12, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 10, "name": "address", "nodeType": "ElementaryTypeName", "src": "74:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Mapping", "src": "66:24:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", "typeString": "mapping(address => bool)" }, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 11, "name": "bool", "nodeType": "ElementaryTypeName", "src": "85:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } @@ -197,26 +175,21 @@ "src": "98:20:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_enum$_E_$4_$_t_bool_$", "typeString": "mapping(enum C.E => bool)" }, - "typeName": - { + "typeName": { "id": 17, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 15, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 14, "name": "E", - "nameLocations": - [ + "nameLocations": [ "106:1:1" ], "nodeType": "IdentifierPath", @@ -225,29 +198,25 @@ }, "referencedDeclaration": 4, "src": "106:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_enum$_E_$4", "typeString": "enum C.E" } }, "nodeType": "Mapping", "src": "98:18:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_enum$_E_$4_$_t_bool_$", "typeString": "mapping(enum C.E => bool)" }, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 16, "name": "bool", "nodeType": "ElementaryTypeName", "src": "111:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } @@ -266,45 +235,38 @@ "src": "124:46:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" }, - "typeName": - { + "typeName": { "id": 21, "keyName": "keyAddress", "keyNameLocation": "140:10:1", - "keyType": - { + "keyType": { "id": 19, "name": "address", "nodeType": "ElementaryTypeName", "src": "132:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "Mapping", "src": "124:44:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" }, "valueName": "value", "valueNameLocation": "162:5:1", - "valueType": - { + "valueType": { "id": 20, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "154:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } diff --git a/test/libsolidity/ASTJSON/mappings.sol b/test/libsolidity/ASTJSON/mappings.sol index 5412ca601eb9..05912d21f703 100644 --- a/test/libsolidity/ASTJSON/mappings.sol +++ b/test/libsolidity/ASTJSON/mappings.sol @@ -5,4 +5,5 @@ contract C { mapping(E => bool) c; mapping(address keyAddress => uint256 value) d; } + // ---- diff --git a/test/libsolidity/ASTJSON/mappings_parseOnly.json b/test/libsolidity/ASTJSON/mappings_parseOnly.json index 84cfb4004a4d..4edc75ffde9b 100644 --- a/test/libsolidity/ASTJSON/mappings_parseOnly.json +++ b/test/libsolidity/ASTJSON/mappings_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 24, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,12 +12,10 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 4, - "members": - [ + "members": [ { "id": 1, "name": "A", @@ -57,21 +54,17 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 8, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 6, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 5, "name": "C", - "nameLocations": - [ + "nameLocations": [ "48:1:1" ], "nodeType": "IdentifierPath", @@ -85,8 +78,7 @@ "typeDescriptions": {}, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 7, "name": "bool", "nodeType": "ElementaryTypeName", @@ -107,13 +99,11 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 12, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 10, "name": "address", "nodeType": "ElementaryTypeName", @@ -125,8 +115,7 @@ "typeDescriptions": {}, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 11, "name": "bool", "nodeType": "ElementaryTypeName", @@ -147,21 +136,17 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 17, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 15, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 14, "name": "E", - "nameLocations": - [ + "nameLocations": [ "106:1:1" ], "nodeType": "IdentifierPath", @@ -175,8 +160,7 @@ "typeDescriptions": {}, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 16, "name": "bool", "nodeType": "ElementaryTypeName", @@ -197,13 +181,11 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 21, "keyName": "keyAddress", "keyNameLocation": "140:10:1", - "keyType": - { + "keyType": { "id": 19, "name": "address", "nodeType": "ElementaryTypeName", @@ -215,8 +197,7 @@ "typeDescriptions": {}, "valueName": "value", "valueNameLocation": "162:5:1", - "valueType": - { + "valueType": { "id": 20, "name": "uint256", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index 30ebcb7c20b2..485e0f0c1b2a 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 14 ] }, "id": 15, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,23 +16,19 @@ "contractKind": "contract", "fullyImplemented": true, "id": 14, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 14 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 5, "nodeType": "Block", "src": "32:6:1", - "statements": - [ + "statements": [ { "id": 4, "nodeType": "PlaceholderStatement", @@ -47,12 +40,10 @@ "name": "M", "nameLocation": "22:1:1", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -64,19 +55,16 @@ "src": "24:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "24:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -91,8 +79,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 12, "nodeType": "Block", "src": "64:2:1", @@ -102,11 +89,9 @@ "id": 13, "implemented": true, "kind": "function", - "modifiers": - [ + "modifiers": [ { - "arguments": - [ + "arguments": [ { "hexValue": "31", "id": 9, @@ -117,8 +102,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "54:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, @@ -127,12 +111,10 @@ ], "id": 10, "kind": "modifierInvocation", - "modifierName": - { + "modifierName": { "id": 8, "name": "M", - "nameLocations": - [ + "nameLocations": [ "52:1:1" ], "nodeType": "IdentifierPath", @@ -146,15 +128,13 @@ "name": "F", "nameLocation": "48:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "49:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json b/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json index f8067952a28c..22ed7bdc6677 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json +++ b/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 15, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,16 +12,13 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 5, "nodeType": "Block", "src": "32:6:1", - "statements": - [ + "statements": [ { "id": 4, "nodeType": "PlaceholderStatement", @@ -34,12 +30,10 @@ "name": "M", "nameLocation": "22:1:1", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -51,8 +45,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", @@ -69,8 +62,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 12, "nodeType": "Block", "src": "64:2:1", @@ -79,11 +71,9 @@ "id": 13, "implemented": true, "kind": "function", - "modifiers": - [ + "modifiers": [ { - "arguments": - [ + "arguments": [ { "hexValue": "31", "id": 9, @@ -95,12 +85,10 @@ } ], "id": 10, - "modifierName": - { + "modifierName": { "id": 8, "name": "M", - "nameLocations": - [ + "nameLocations": [ "52:1:1" ], "nodeType": "IdentifierPath", @@ -113,15 +101,13 @@ "name": "F", "nameLocation": "48:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "49:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index 30ebcb7c20b2..485e0f0c1b2a 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 14 ] }, "id": 15, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,23 +16,19 @@ "contractKind": "contract", "fullyImplemented": true, "id": 14, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 14 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 5, "nodeType": "Block", "src": "32:6:1", - "statements": - [ + "statements": [ { "id": 4, "nodeType": "PlaceholderStatement", @@ -47,12 +40,10 @@ "name": "M", "nameLocation": "22:1:1", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -64,19 +55,16 @@ "src": "24:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "24:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -91,8 +79,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 12, "nodeType": "Block", "src": "64:2:1", @@ -102,11 +89,9 @@ "id": 13, "implemented": true, "kind": "function", - "modifiers": - [ + "modifiers": [ { - "arguments": - [ + "arguments": [ { "hexValue": "31", "id": 9, @@ -117,8 +102,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "54:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, @@ -127,12 +111,10 @@ ], "id": 10, "kind": "modifierInvocation", - "modifierName": - { + "modifierName": { "id": 8, "name": "M", - "nameLocations": - [ + "nameLocations": [ "52:1:1" ], "nodeType": "IdentifierPath", @@ -146,15 +128,13 @@ "name": "F", "nameLocation": "48:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "49:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json b/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json index f8067952a28c..22ed7bdc6677 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 15, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,16 +12,13 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 5, "nodeType": "Block", "src": "32:6:1", - "statements": - [ + "statements": [ { "id": 4, "nodeType": "PlaceholderStatement", @@ -34,12 +30,10 @@ "name": "M", "nameLocation": "22:1:1", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 2, @@ -51,8 +45,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", @@ -69,8 +62,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 12, "nodeType": "Block", "src": "64:2:1", @@ -79,11 +71,9 @@ "id": 13, "implemented": true, "kind": "function", - "modifiers": - [ + "modifiers": [ { - "arguments": - [ + "arguments": [ { "hexValue": "31", "id": 9, @@ -95,12 +85,10 @@ } ], "id": 10, - "modifierName": - { + "modifierName": { "id": 8, "name": "M", - "nameLocations": - [ + "nameLocations": [ "52:1:1" ], "nodeType": "IdentifierPath", @@ -113,15 +101,13 @@ "name": "F", "nameLocation": "48:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "49:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/mutability.json b/test/libsolidity/ASTJSON/mutability.json index b6318d84e5e9..cb7ace3b32e6 100644 --- a/test/libsolidity/ASTJSON/mutability.json +++ b/test/libsolidity/ASTJSON/mutability.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 10 ] }, "id": 11, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,15 +16,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 10, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 10 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "functionSelector": "0dbe671f", @@ -40,25 +35,21 @@ "src": "17:27:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "17:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "value": - { + "value": { "hexValue": "34", "id": 2, "isConstant": false, @@ -68,8 +59,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "43:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_4_by_1", "typeString": "int_const 4" }, @@ -89,25 +79,21 @@ "src": "50:26:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", "src": "50:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "value": - { + "value": { "hexValue": "32", "id": 5, "isConstant": false, @@ -117,8 +103,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "75:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, @@ -138,25 +123,21 @@ "src": "82:17:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 7, "name": "uint", "nodeType": "ElementaryTypeName", "src": "82:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "value": - { + "value": { "hexValue": "33", "id": 8, "isConstant": false, @@ -166,8 +147,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "98:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_3_by_1", "typeString": "int_const 3" }, diff --git a/test/libsolidity/ASTJSON/mutability.sol b/test/libsolidity/ASTJSON/mutability.sol index 3f67c29e0981..7688186e773f 100644 --- a/test/libsolidity/ASTJSON/mutability.sol +++ b/test/libsolidity/ASTJSON/mutability.sol @@ -4,4 +4,5 @@ contract C uint public constant b = 2; uint public c = 3; } + // ---- diff --git a/test/libsolidity/ASTJSON/mutability_parseOnly.json b/test/libsolidity/ASTJSON/mutability_parseOnly.json index 637f8e11416c..74ae78f84c07 100644 --- a/test/libsolidity/ASTJSON/mutability_parseOnly.json +++ b/test/libsolidity/ASTJSON/mutability_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 11, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,8 +12,7 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 3, @@ -26,16 +24,14 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 1, "name": "uint", "nodeType": "ElementaryTypeName", "src": "17:4:1", "typeDescriptions": {} }, - "value": - { + "value": { "hexValue": "34", "id": 2, "kind": "number", @@ -57,16 +53,14 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", "src": "50:4:1", "typeDescriptions": {} }, - "value": - { + "value": { "hexValue": "32", "id": 5, "kind": "number", @@ -88,16 +82,14 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 7, "name": "uint", "nodeType": "ElementaryTypeName", "src": "82:4:1", "typeDescriptions": {} }, - "value": - { + "value": { "hexValue": "33", "id": 8, "kind": "number", diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 0058e56eb322..b13ab7f8a132 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 15 ] }, "id": 16, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 15, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 15 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 13, "nodeType": "Block", "src": "33:45:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -54,19 +45,16 @@ "src": "35:15:1", "stateVariable": false, "storageLocation": "memory", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, - "typeName": - { + "typeName": { "id": 3, "name": "string", "nodeType": "ElementaryTypeName", "src": "35:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } @@ -75,13 +63,10 @@ } ], "id": 12, - "initialValue": - { - "arguments": - [ + "initialValue": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "hexValue": "ff", "id": 9, @@ -92,17 +77,14 @@ "lValueRequested": false, "nodeType": "Literal", "src": "66:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", "typeString": "literal_string hex\"ff\"" } } ], - "expression": - { - "argumentTypes": - [ + "expression": { + "argumentTypes": [ { "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", "typeString": "literal_string hex\"ff\"" @@ -115,13 +97,11 @@ "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "60:5:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_bytes_storage_ptr_$", "typeString": "type(bytes storage pointer)" }, - "typeName": - { + "typeName": { "id": 7, "name": "bytes", "nodeType": "ElementaryTypeName", @@ -140,17 +120,14 @@ "nodeType": "FunctionCall", "src": "60:14:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } } ], - "expression": - { - "argumentTypes": - [ + "expression": { + "argumentTypes": [ { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" @@ -163,13 +140,11 @@ "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "53:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_type$_t_string_storage_ptr_$", "typeString": "type(string storage pointer)" }, - "typeName": - { + "typeName": { "id": 5, "name": "string", "nodeType": "ElementaryTypeName", @@ -188,8 +163,7 @@ "nodeType": "FunctionCall", "src": "53:22:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" } @@ -207,15 +181,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json index bbc350f96dfe..34a99dba3461 100644 --- a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json +++ b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 16, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 13, "nodeType": "Block", "src": "33:45:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "memory", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "name": "string", "nodeType": "ElementaryTypeName", @@ -53,13 +46,10 @@ } ], "id": 12, - "initialValue": - { - "arguments": - [ + "initialValue": { + "arguments": [ { - "arguments": - [ + "arguments": [ { "hexValue": "ff", "id": 9, @@ -69,14 +59,12 @@ "typeDescriptions": {} } ], - "expression": - { + "expression": { "id": 8, "nodeType": "ElementaryTypeNameExpression", "src": "60:5:1", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 7, "name": "bytes", "nodeType": "ElementaryTypeName", @@ -93,14 +81,12 @@ "typeDescriptions": {} } ], - "expression": - { + "expression": { "id": 6, "nodeType": "ElementaryTypeNameExpression", "src": "53:6:1", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "name": "string", "nodeType": "ElementaryTypeName", @@ -128,15 +114,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/not_existing_import.sol b/test/libsolidity/ASTJSON/not_existing_import.sol index ad3c100c499b..6353c7527bde 100644 --- a/test/libsolidity/ASTJSON/not_existing_import.sol +++ b/test/libsolidity/ASTJSON/not_existing_import.sol @@ -4,5 +4,5 @@ contract C is NotExisting.X NotExisting.SomeStruct public myStruct; constructor() {} } + // ---- -// failAfter: Parsed diff --git a/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json b/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json index ea08150fd372..04c5c69ab1c8 100644 --- a/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json +++ b/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 12, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "absolutePath": "notexisting.sol", "file": "notexisting.sol", @@ -16,15 +15,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 2, "name": "NotExisting.X", - "nameLocations": - [ + "nameLocations": [ "55:11:1", "67:1:1" ], @@ -42,8 +38,7 @@ "name": "C", "nameLocation": "50:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "constant": false, "id": 6, @@ -55,16 +50,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 4, "name": "NotExisting.SomeStruct", - "nameLocations": - [ + "nameLocations": [ "72:11:1", "84:10:1" ], @@ -77,8 +69,7 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "127:2:1", @@ -91,15 +82,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], "src": "124:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index 35d36eac4e9f..927d0d498150 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -1,24 +1,19 @@ { "absolutePath": "a", - "exportedSymbols": - { - "A": - [ + "exportedSymbols": { + "A": [ 5 ], - "B": - [ + "B": [ 16 ], - "C": - [ + "C": [ 29 ] }, "id": 30, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -27,18 +22,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "A", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "44:2:1", @@ -52,15 +44,13 @@ "name": "faa", "nameLocation": "23:3:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "26:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -80,15 +70,12 @@ }, { "abstract": true, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 6, "name": "A", - "nameLocations": - [ + "nameLocations": [ "72:1:1" ], "nodeType": "IdentifierPath", @@ -105,16 +92,14 @@ "contractKind": "contract", "fullyImplemented": false, "id": 16, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 16, 5 ], "name": "B", "nameLocation": "67:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "functionSelector": "c2985578", "id": 10, @@ -124,15 +109,13 @@ "name": "foo", "nameLocation": "86:3:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], "src": "89:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 9, "nodeType": "ParameterList", "parameters": [], @@ -145,12 +128,10 @@ "visibility": "public" }, { - "baseFunctions": - [ + "baseFunctions": [ 4 ], - "body": - { + "body": { "id": 14, "nodeType": "Block", "src": "148:2:1", @@ -164,22 +145,19 @@ "name": "faa", "nameLocation": "118:3:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 12, "nodeType": "OverrideSpecifier", "overrides": [], "src": "139:8:1" }, - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], "src": "121:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], @@ -199,15 +177,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 17, "name": "B", - "nameLocations": - [ + "nameLocations": [ "167:1:1" ], "nodeType": "IdentifierPath", @@ -224,8 +199,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 29, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 29, 16, 5 @@ -233,15 +207,12 @@ "name": "C", "nameLocation": "162:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "baseFunctions": - [ + "baseFunctions": [ 10 ], - "body": - { + "body": { "id": 22, "nodeType": "Block", "src": "203:3:1", @@ -255,22 +226,19 @@ "name": "foo", "nameLocation": "181:3:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 20, "nodeType": "OverrideSpecifier", "overrides": [], "src": "194:8:1" }, - "parameters": - { + "parameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], "src": "184:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 21, "nodeType": "ParameterList", "parameters": [], @@ -283,12 +251,10 @@ "visibility": "public" }, { - "baseFunctions": - [ + "baseFunctions": [ 15 ], - "body": - { + "body": { "id": 27, "nodeType": "Block", "src": "239:3:1", @@ -302,22 +268,19 @@ "name": "faa", "nameLocation": "217:3:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 25, "nodeType": "OverrideSpecifier", "overrides": [], "src": "230:8:1" }, - "parameters": - { + "parameters": { "id": 24, "nodeType": "ParameterList", "parameters": [], "src": "220:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 26, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/override.sol b/test/libsolidity/ASTJSON/override.sol index a03244985744..1aaa58c600ab 100644 --- a/test/libsolidity/ASTJSON/override.sol +++ b/test/libsolidity/ASTJSON/override.sol @@ -9,4 +9,5 @@ contract C is B { function foo() public override { } function faa() public override { } } + // ---- diff --git a/test/libsolidity/ASTJSON/override_parseOnly.json b/test/libsolidity/ASTJSON/override_parseOnly.json index 3a927f5f2f12..7b9bcd268a38 100644 --- a/test/libsolidity/ASTJSON/override_parseOnly.json +++ b/test/libsolidity/ASTJSON/override_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 30, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "A", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "44:2:1", @@ -30,15 +27,13 @@ "name": "faa", "nameLocation": "23:3:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "26:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -56,15 +51,12 @@ }, { "abstract": true, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 6, "name": "A", - "nameLocations": - [ + "nameLocations": [ "72:1:1" ], "nodeType": "IdentifierPath", @@ -81,8 +73,7 @@ "name": "B", "nameLocation": "67:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 10, "implemented": false, @@ -91,15 +82,13 @@ "name": "foo", "nameLocation": "86:3:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], "src": "89:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 9, "nodeType": "ParameterList", "parameters": [], @@ -111,8 +100,7 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 14, "nodeType": "Block", "src": "148:2:1", @@ -125,22 +113,19 @@ "name": "faa", "nameLocation": "118:3:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 12, "nodeType": "OverrideSpecifier", "overrides": [], "src": "139:8:1" }, - "parameters": - { + "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], "src": "121:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], @@ -158,15 +143,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 17, "name": "B", - "nameLocations": - [ + "nameLocations": [ "167:1:1" ], "nodeType": "IdentifierPath", @@ -183,11 +165,9 @@ "name": "C", "nameLocation": "162:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 22, "nodeType": "Block", "src": "203:3:1", @@ -200,22 +180,19 @@ "name": "foo", "nameLocation": "181:3:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 20, "nodeType": "OverrideSpecifier", "overrides": [], "src": "194:8:1" }, - "parameters": - { + "parameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], "src": "184:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 21, "nodeType": "ParameterList", "parameters": [], @@ -227,8 +204,7 @@ "visibility": "public" }, { - "body": - { + "body": { "id": 27, "nodeType": "Block", "src": "239:3:1", @@ -241,22 +217,19 @@ "name": "faa", "nameLocation": "217:3:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 25, "nodeType": "OverrideSpecifier", "overrides": [], "src": "230:8:1" }, - "parameters": - { + "parameters": { "id": 24, "nodeType": "ParameterList", "parameters": [], "src": "220:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 26, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json index 96a46c1484c3..dbc9bdd1db2a 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement.json +++ b/test/libsolidity/ASTJSON/placeholder_statement.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,23 +16,19 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "24:6:1", - "statements": - [ + "statements": [ { "id": 2, "nodeType": "PlaceholderStatement", @@ -47,8 +40,7 @@ "name": "M", "nameLocation": "22:1:1", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json b/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json index 8af17040246f..58610047d29c 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json +++ b/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,16 +12,13 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "24:6:1", - "statements": - [ + "statements": [ { "id": 2, "nodeType": "PlaceholderStatement", @@ -34,8 +30,7 @@ "name": "M", "nameLocation": "22:1:1", "nodeType": "ModifierDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/pragma_experimental_solidity_parseOnly.json b/test/libsolidity/ASTJSON/pragma_experimental_solidity_parseOnly.json index b1ac937a2427..a962a1cc1f88 100644 --- a/test/libsolidity/ASTJSON/pragma_experimental_solidity_parseOnly.json +++ b/test/libsolidity/ASTJSON/pragma_experimental_solidity_parseOnly.json @@ -3,12 +3,10 @@ "experimentalSolidity": true, "id": 2, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 1, - "literals": - [ + "literals": [ "experimental", "solidity" ], diff --git a/test/libsolidity/ASTJSON/receive_ether.json b/test/libsolidity/ASTJSON/receive_ether.json index 2790493993ee..d02c84a498f6 100644 --- a/test/libsolidity/ASTJSON/receive_ether.json +++ b/test/libsolidity/ASTJSON/receive_ether.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 5 ] }, "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,18 +16,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "42:5:1", @@ -43,15 +37,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "22:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/receive_ether.sol b/test/libsolidity/ASTJSON/receive_ether.sol index 1e59dc1317bc..f75a43b2dfd1 100644 --- a/test/libsolidity/ASTJSON/receive_ether.sol +++ b/test/libsolidity/ASTJSON/receive_ether.sol @@ -2,4 +2,5 @@ contract C { receive() external payable { } } + // ---- diff --git a/test/libsolidity/ASTJSON/receive_ether_parseOnly.json b/test/libsolidity/ASTJSON/receive_ether_parseOnly.json index f9aede155ec7..9f0c4f60a8ea 100644 --- a/test/libsolidity/ASTJSON/receive_ether_parseOnly.json +++ b/test/libsolidity/ASTJSON/receive_ether_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 6, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "42:5:1", @@ -30,15 +27,13 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "22:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index 1c1138cbafb3..f5b8bcf06c57 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "c": - [ + "exportedSymbols": { + "c": [ 11 ] }, "id": 12, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 11, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 11 ], "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "33:20:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 7 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 7, @@ -54,21 +45,17 @@ "src": "35:15:1", "stateVariable": false, "storageLocation": "memory", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr", "typeString": "uint256[]" }, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", "src": "35:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -76,8 +63,7 @@ "id": 6, "nodeType": "ArrayTypeName", "src": "35:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", "typeString": "uint256[]" } @@ -99,15 +85,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/short_type_name_parseOnly.json b/test/libsolidity/ASTJSON/short_type_name_parseOnly.json index 3c4acfa775ed..27e1919c2fc2 100644 --- a/test/libsolidity/ASTJSON/short_type_name_parseOnly.json +++ b/test/libsolidity/ASTJSON/short_type_name_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 12, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "33:20:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 7 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 7, @@ -41,10 +35,8 @@ "stateVariable": false, "storageLocation": "memory", "typeDescriptions": {}, - "typeName": - { - "baseType": - { + "typeName": { + "baseType": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", @@ -72,15 +64,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index 447b1e5b7705..59ce1f39dae7 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "c": - [ + "exportedSymbols": { + "c": [ 12 ] }, "id": 13, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 12, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 12 ], "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 10, "nodeType": "Block", "src": "33:25:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 8 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 8, @@ -54,23 +45,18 @@ "src": "35:20:1", "stateVariable": false, "storageLocation": "memory", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_array$_t_uint256_$dyn_memory_ptr_$dyn_memory_ptr", "typeString": "uint256[][]" }, - "typeName": - { - "baseType": - { - "baseType": - { + "typeName": { + "baseType": { + "baseType": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", "src": "35:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -78,8 +64,7 @@ "id": 6, "nodeType": "ArrayTypeName", "src": "35:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", "typeString": "uint256[]" } @@ -87,8 +72,7 @@ "id": 7, "nodeType": "ArrayTypeName", "src": "35:8:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr", "typeString": "uint256[][]" } @@ -110,15 +94,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json b/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json index 07c782d47bb4..9a7e6fccf7a8 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 13, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "c", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 10, "nodeType": "Block", "src": "33:25:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 8 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 8, @@ -41,12 +35,9 @@ "stateVariable": false, "storageLocation": "memory", "typeDescriptions": {}, - "typeName": - { - "baseType": - { - "baseType": - { + "typeName": { + "baseType": { + "baseType": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", @@ -79,15 +70,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json index d3b114bbcba4..d1fc5b13b3a8 100644 --- a/test/libsolidity/ASTJSON/smoke.json +++ b/test/libsolidity/ASTJSON/smoke.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 1 ] }, "id": 2, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,8 +16,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 1, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 1 ], "name": "C", diff --git a/test/libsolidity/ASTJSON/smoke_parseOnly.json b/test/libsolidity/ASTJSON/smoke_parseOnly.json index 1160fea91e75..22b597ce9d87 100644 --- a/test/libsolidity/ASTJSON/smoke_parseOnly.json +++ b/test/libsolidity/ASTJSON/smoke_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 2, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index caeaf027ab3f..526069063b3f 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 12 ] }, "id": 13, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 12, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 12 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 10, "nodeType": "Block", "src": "33:20:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -54,19 +45,16 @@ "src": "35:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", "src": "35:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -75,8 +63,7 @@ } ], "id": 6, - "initialValue": - { + "initialValue": { "hexValue": "32", "id": 5, "isConstant": false, @@ -86,8 +73,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "44:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", "typeString": "int_const 2" }, @@ -97,8 +83,7 @@ "src": "35:10:1" }, { - "expression": - { + "expression": { "id": 8, "isConstant": false, "isLValue": false, @@ -108,22 +93,19 @@ "operator": "++", "prefix": false, "src": "47:3:1", - "subExpression": - { + "subExpression": { "id": 7, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4, "src": "47:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -142,15 +124,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/source_location_parseOnly.json b/test/libsolidity/ASTJSON/source_location_parseOnly.json index ec25111bd349..877092a04579 100644 --- a/test/libsolidity/ASTJSON/source_location_parseOnly.json +++ b/test/libsolidity/ASTJSON/source_location_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 13, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 10, "nodeType": "Block", "src": "33:20:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", @@ -53,8 +46,7 @@ } ], "id": 6, - "initialValue": - { + "initialValue": { "hexValue": "32", "id": 5, "kind": "number", @@ -67,15 +59,13 @@ "src": "35:10:1" }, { - "expression": - { + "expression": { "id": 8, "nodeType": "UnaryOperation", "operator": "++", "prefix": false, "src": "47:3:1", - "subExpression": - { + "subExpression": { "id": 7, "name": "x", "nodeType": "Identifier", @@ -98,15 +88,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/string.json b/test/libsolidity/ASTJSON/string.json index c7706e3bfc01..d4b37e2e16d2 100644 --- a/test/libsolidity/ASTJSON/string.json +++ b/test/libsolidity/ASTJSON/string.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 9 ] }, "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 9, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 9 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "33:36:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -54,19 +45,16 @@ "src": "35:15:1", "stateVariable": false, "storageLocation": "memory", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, - "typeName": - { + "typeName": { "id": 3, "name": "string", "nodeType": "ElementaryTypeName", "src": "35:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } @@ -75,8 +63,7 @@ } ], "id": 6, - "initialValue": - { + "initialValue": { "hexValue": "48656c6c6f20576f726c64", "id": 5, "isConstant": false, @@ -86,8 +73,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "53:13:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_stringliteral_592fa743889fc7f92ac2a37bb1f5ba1daf2a5c84741ca0e0061d243a2e6707ba", "typeString": "literal_string \"Hello World\"" }, @@ -106,15 +92,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/string_parseOnly.json b/test/libsolidity/ASTJSON/string_parseOnly.json index 5f97eb1f917e..4f8006e57206 100644 --- a/test/libsolidity/ASTJSON/string_parseOnly.json +++ b/test/libsolidity/ASTJSON/string_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "33:36:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "memory", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "name": "string", "nodeType": "ElementaryTypeName", @@ -53,8 +46,7 @@ } ], "id": 6, - "initialValue": - { + "initialValue": { "hexValue": "48656c6c6f20576f726c64", "id": 5, "kind": "string", @@ -75,15 +67,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/struct_natspec.json b/test/libsolidity/ASTJSON/struct_natspec.json index d8b38a8033d3..0a17909df628 100644 --- a/test/libsolidity/ASTJSON/struct_natspec.json +++ b/test/libsolidity/ASTJSON/struct_natspec.json @@ -1,28 +1,23 @@ { "absolutePath": "a", - "exportedSymbols": - { - "Example": - [ + "exportedSymbols": { + "Example": [ 8 ] }, "id": 9, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "Example", - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "0:112:1", "text": "@title example of title\n @author example of author\n @notice example of notice\n @dev example of dev" }, "id": 8, - "members": - [ + "members": [ { "constant": false, "id": 3, @@ -34,19 +29,16 @@ "src": "133:11:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" }, - "typeName": - { + "typeName": { "id": 2, "name": "string", "nodeType": "ElementaryTypeName", "src": "133:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } @@ -64,19 +56,16 @@ "src": "150:10:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, - "typeName": - { + "typeName": { "id": 4, "name": "bool", "nodeType": "ElementaryTypeName", "src": "150:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } @@ -94,19 +83,16 @@ "src": "166:13:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 6, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "166:7:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } diff --git a/test/libsolidity/ASTJSON/struct_natspec_parseOnly.json b/test/libsolidity/ASTJSON/struct_natspec_parseOnly.json index b80aaf377cb8..6ba465580b09 100644 --- a/test/libsolidity/ASTJSON/struct_natspec_parseOnly.json +++ b/test/libsolidity/ASTJSON/struct_natspec_parseOnly.json @@ -2,19 +2,16 @@ "absolutePath": "a", "id": 9, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { - "documentation": - { + "documentation": { "id": 1, "nodeType": "StructuredDocumentation", "src": "0:112:1", "text": "@title example of title\n @author example of author\n @notice example of notice\n @dev example of dev" }, "id": 8, - "members": - [ + "members": [ { "constant": false, "id": 3, @@ -26,8 +23,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 2, "name": "string", "nodeType": "ElementaryTypeName", @@ -47,8 +43,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 4, "name": "bool", "nodeType": "ElementaryTypeName", @@ -68,8 +63,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 6, "name": "uint256", "nodeType": "ElementaryTypeName", diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 0ed997a32fa3..132a7a9071bc 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -1,24 +1,19 @@ { "absolutePath": "a", - "exportedSymbols": - { - "A": - [ + "exportedSymbols": { + "A": [ 5 ], - "B": - [ + "B": [ 10 ], - "C": - [ + "C": [ 22 ] }, "id": 23, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -27,18 +22,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 5, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 5 ], "name": "A", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "45:2:1", @@ -52,15 +44,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -86,18 +76,15 @@ "contractKind": "contract", "fullyImplemented": true, "id": 10, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 10 ], "name": "B", "nameLocation": "59:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "95:2:1", @@ -111,15 +98,13 @@ "name": "f", "nameLocation": "76:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], "src": "77:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], @@ -139,15 +124,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 11, "name": "A", - "nameLocations": - [ + "nameLocations": [ "114:1:1" ], "nodeType": "IdentifierPath", @@ -159,12 +141,10 @@ "src": "114:1:1" }, { - "baseName": - { + "baseName": { "id": 13, "name": "B", - "nameLocations": - [ + "nameLocations": [ "117:1:1" ], "nodeType": "IdentifierPath", @@ -181,8 +161,7 @@ "contractKind": "contract", "fullyImplemented": true, "id": 22, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 22, 10, 5 @@ -190,16 +169,13 @@ "name": "C", "nameLocation": "109:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "baseFunctions": - [ + "baseFunctions": [ 4, 9 ], - "body": - { + "body": { "id": 20, "nodeType": "Block", "src": "160:2:1", @@ -213,17 +189,14 @@ "name": "f", "nameLocation": "134:1:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 18, "nodeType": "OverrideSpecifier", - "overrides": - [ + "overrides": [ { "id": 16, "name": "A", - "nameLocations": - [ + "nameLocations": [ "154:1:1" ], "nodeType": "IdentifierPath", @@ -233,8 +206,7 @@ { "id": 17, "name": "B", - "nameLocations": - [ + "nameLocations": [ "157:1:1" ], "nodeType": "IdentifierPath", @@ -244,15 +216,13 @@ ], "src": "145:14:1" }, - "parameters": - { + "parameters": { "id": 15, "nodeType": "ParameterList", "parameters": [], "src": "135:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/two_base_functions.sol b/test/libsolidity/ASTJSON/two_base_functions.sol index 0a00bcc14505..89c8e207a531 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.sol +++ b/test/libsolidity/ASTJSON/two_base_functions.sol @@ -7,4 +7,5 @@ contract B { contract C is A, B { function f() public override(A, B) {} } + // ---- diff --git a/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json b/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json index e448be836bf8..2e9691ac9870 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json +++ b/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 23, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,11 +12,9 @@ "name": "A", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 3, "nodeType": "Block", "src": "45:2:1", @@ -30,15 +27,13 @@ "name": "f", "nameLocation": "26:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "27:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], @@ -63,11 +58,9 @@ "name": "B", "nameLocation": "59:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "95:2:1", @@ -80,15 +73,13 @@ "name": "f", "nameLocation": "76:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], "src": "77:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], @@ -106,15 +97,12 @@ }, { "abstract": false, - "baseContracts": - [ + "baseContracts": [ { - "baseName": - { + "baseName": { "id": 11, "name": "A", - "nameLocations": - [ + "nameLocations": [ "114:1:1" ], "nodeType": "IdentifierPath", @@ -125,12 +113,10 @@ "src": "114:1:1" }, { - "baseName": - { + "baseName": { "id": 13, "name": "B", - "nameLocations": - [ + "nameLocations": [ "117:1:1" ], "nodeType": "IdentifierPath", @@ -147,11 +133,9 @@ "name": "C", "nameLocation": "109:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 20, "nodeType": "Block", "src": "160:2:1", @@ -164,17 +148,14 @@ "name": "f", "nameLocation": "134:1:1", "nodeType": "FunctionDefinition", - "overrides": - { + "overrides": { "id": 18, "nodeType": "OverrideSpecifier", - "overrides": - [ + "overrides": [ { "id": 16, "name": "A", - "nameLocations": - [ + "nameLocations": [ "154:1:1" ], "nodeType": "IdentifierPath", @@ -183,8 +164,7 @@ { "id": 17, "name": "B", - "nameLocations": - [ + "nameLocations": [ "157:1:1" ], "nodeType": "IdentifierPath", @@ -193,15 +173,13 @@ ], "src": "145:14:1" }, - "parameters": - { + "parameters": { "id": 15, "nodeType": "ParameterList", "parameters": [], "src": "135:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/unicode.json b/test/libsolidity/ASTJSON/unicode.json index 0ff1426f17e2..2521e690e747 100644 --- a/test/libsolidity/ASTJSON/unicode.json +++ b/test/libsolidity/ASTJSON/unicode.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 9 ] }, "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,30 +16,24 @@ "contractKind": "contract", "fullyImplemented": true, "id": 9, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 9 ], "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "33:42:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -54,19 +45,16 @@ "src": "35:15:1", "stateVariable": false, "storageLocation": "memory", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, - "typeName": - { + "typeName": { "id": 3, "name": "string", "nodeType": "ElementaryTypeName", "src": "35:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } @@ -75,8 +63,7 @@ } ], "id": 6, - "initialValue": - { + "initialValue": { "hexValue": "48656c6c6f20f09f9883", "id": 5, "isConstant": false, @@ -86,8 +73,7 @@ "lValueRequested": false, "nodeType": "Literal", "src": "53:19:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_stringliteral_cd7a99177cebb3d14b8cc54e313dbf76867c71cd6fbb9a33ce3870dc80e9992b", "typeString": "literal_string hex\"48656c6c6f20f09f9883\"" }, @@ -106,15 +92,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/unicode_parseOnly.json b/test/libsolidity/ASTJSON/unicode_parseOnly.json index c8fb780c40cc..0567c08a088d 100644 --- a/test/libsolidity/ASTJSON/unicode_parseOnly.json +++ b/test/libsolidity/ASTJSON/unicode_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 10, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,23 +12,18 @@ "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 7, "nodeType": "Block", "src": "33:42:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 4 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 4, @@ -41,8 +35,7 @@ "stateVariable": false, "storageLocation": "memory", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 3, "name": "string", "nodeType": "ElementaryTypeName", @@ -53,8 +46,7 @@ } ], "id": 6, - "initialValue": - { + "initialValue": { "hexValue": "48656c6c6f20f09f9883", "id": 5, "kind": "unicodeString", @@ -75,15 +67,13 @@ "name": "f", "nameLocation": "22:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "23:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/used_errors.json b/test/libsolidity/ASTJSON/used_errors.json index 12a59f9cbf10..9db7b6a98357 100644 --- a/test/libsolidity/ASTJSON/used_errors.json +++ b/test/libsolidity/ASTJSON/used_errors.json @@ -1,32 +1,26 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 19 ], - "X": - [ + "X": [ 2 ], - "f": - [ + "f": [ 9 ] }, "id": 20, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "errorSelector": "c1599bd9", "id": 2, "name": "X", "nameLocation": "6:1:1", "nodeType": "ErrorDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -35,19 +29,15 @@ "src": "0:10:1" }, { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "29:15:1", - "statements": - [ + "statements": [ { - "errorCall": - { + "errorCall": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 5, "name": "X", @@ -55,10 +45,9 @@ "overloadedDeclarations": [], "referencedDeclaration": 2, "src": "38:1:1", - "typeDescriptions": - { - "typeIdentifier": "t_function_error_pure$__$returns$__$", - "typeString": "function () pure" + "typeDescriptions": { + "typeIdentifier": "t_function_error_pure$__$returns$_t_error_$", + "typeString": "function () pure returns (error)" } }, "id": 6, @@ -72,10 +61,9 @@ "nodeType": "FunctionCall", "src": "38:3:1", "tryCall": false, - "typeDescriptions": - { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" + "typeDescriptions": { + "typeIdentifier": "t_error", + "typeString": "error" } }, "id": 7, @@ -91,15 +79,13 @@ "name": "f", "nameLocation": "20:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "21:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -119,23 +105,20 @@ "contractKind": "contract", "fullyImplemented": true, "id": 19, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 19 ], "name": "C", "nameLocation": "54:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "errorSelector": "2bc80f3a", "id": 11, "name": "T", "nameLocation": "68:1:1", "nodeType": "ErrorDefinition", - "parameters": - { + "parameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], @@ -144,19 +127,15 @@ "src": "62:10:1" }, { - "body": - { + "body": { "id": 17, "nodeType": "Block", "src": "97:8:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "argumentTypes": [], "id": 14, "name": "f", @@ -164,8 +143,7 @@ "overloadedDeclarations": [], "referencedDeclaration": 9, "src": "99:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$__$returns$__$", "typeString": "function () pure" } @@ -181,8 +159,7 @@ "nodeType": "FunctionCall", "src": "99:3:1", "tryCall": false, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } @@ -201,15 +178,13 @@ "name": "h", "nameLocation": "86:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 12, "nodeType": "ParameterList", "parameters": [], "src": "87:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], @@ -224,8 +199,7 @@ ], "scope": 20, "src": "45:62:1", - "usedErrors": - [ + "usedErrors": [ 2, 11 ], diff --git a/test/libsolidity/ASTJSON/used_errors.sol b/test/libsolidity/ASTJSON/used_errors.sol index 97f7a27f48e2..24c03982fed6 100644 --- a/test/libsolidity/ASTJSON/used_errors.sol +++ b/test/libsolidity/ASTJSON/used_errors.sol @@ -4,4 +4,5 @@ contract C { error T(); function h() public { f(); } } + // ---- diff --git a/test/libsolidity/ASTJSON/used_errors_parseOnly.json b/test/libsolidity/ASTJSON/used_errors_parseOnly.json index 115ea2aee567..402291f29dfd 100644 --- a/test/libsolidity/ASTJSON/used_errors_parseOnly.json +++ b/test/libsolidity/ASTJSON/used_errors_parseOnly.json @@ -2,15 +2,13 @@ "absolutePath": "a", "id": 20, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 2, "name": "X", "nameLocation": "6:1:1", "nodeType": "ErrorDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], @@ -19,19 +17,15 @@ "src": "0:10:1" }, { - "body": - { + "body": { "id": 8, "nodeType": "Block", "src": "29:15:1", - "statements": - [ + "statements": [ { - "errorCall": - { + "errorCall": { "arguments": [], - "expression": - { + "expression": { "id": 5, "name": "X", "nodeType": "Identifier", @@ -60,15 +54,13 @@ "name": "f", "nameLocation": "20:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 3, "nodeType": "ParameterList", "parameters": [], "src": "21:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 4, "nodeType": "ParameterList", "parameters": [], @@ -88,15 +80,13 @@ "name": "C", "nameLocation": "54:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 11, "name": "T", "nameLocation": "68:1:1", "nodeType": "ErrorDefinition", - "parameters": - { + "parameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], @@ -105,19 +95,15 @@ "src": "62:10:1" }, { - "body": - { + "body": { "id": 17, "nodeType": "Block", "src": "97:8:1", - "statements": - [ + "statements": [ { - "expression": - { + "expression": { "arguments": [], - "expression": - { + "expression": { "id": 14, "name": "f", "nodeType": "Identifier", @@ -146,15 +132,13 @@ "name": "h", "nameLocation": "86:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 12, "nodeType": "ParameterList", "parameters": [], "src": "87:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/userDefinedValueType.json b/test/libsolidity/ASTJSON/userDefinedValueType.json index adf1172f05a9..51f8ee553bd5 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType.json +++ b/test/libsolidity/ASTJSON/userDefinedValueType.json @@ -1,28 +1,22 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 27 ], - "MyAddress": - [ + "MyAddress": [ 2 ], - "MyUInt": - [ + "MyUInt": [ 4 ], - "f": - [ + "f": [ 16 ] }, "id": 28, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "MyAddress", "id": 2, @@ -30,15 +24,13 @@ "nameLocation": "5:9:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "0:26:1", - "underlyingType": - { + "underlyingType": { "id": 1, "name": "address", "nodeType": "ElementaryTypeName", "src": "18:7:1", "stateMutability": "nonpayable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -51,34 +43,28 @@ "nameLocation": "32:6:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "27:20:1", - "underlyingType": - { + "underlyingType": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", "src": "42:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "61:34:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 9 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 9, @@ -90,21 +76,17 @@ "src": "67:11:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_MyAddress_$2", "typeString": "MyAddress" }, - "typeName": - { + "typeName": { "id": 8, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 7, "name": "MyAddress", - "nameLocations": - [ + "nameLocations": [ "67:9:1" ], "nodeType": "IdentifierPath", @@ -113,8 +95,7 @@ }, "referencedDeclaration": 2, "src": "67:9:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_MyAddress_$2", "typeString": "MyAddress" } @@ -127,12 +108,10 @@ "src": "67:11:1" }, { - "assignments": - [ + "assignments": [ 13 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 13, @@ -144,21 +123,17 @@ "src": "84:8:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_MyUInt_$4", "typeString": "MyUInt" }, - "typeName": - { + "typeName": { "id": 12, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 11, "name": "MyUInt", - "nameLocations": - [ + "nameLocations": [ "84:6:1" ], "nodeType": "IdentifierPath", @@ -167,8 +142,7 @@ }, "referencedDeclaration": 4, "src": "84:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_MyUInt_$4", "typeString": "MyUInt" } @@ -189,15 +163,13 @@ "name": "f", "nameLocation": "57:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], "src": "58:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], @@ -217,15 +189,13 @@ "contractKind": "contract", "fullyImplemented": true, "id": 27, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 27 ], "name": "C", "nameLocation": "105:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "canonicalName": "C.MyAddress", "id": 18, @@ -233,15 +203,13 @@ "nameLocation": "118:9:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "113:26:1", - "underlyingType": - { + "underlyingType": { "id": 17, "name": "address", "nodeType": "ElementaryTypeName", "src": "131:7:1", "stateMutability": "nonpayable", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } @@ -254,14 +222,12 @@ "nameLocation": "149:6:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "144:20:1", - "underlyingType": - { + "underlyingType": { "id": 19, "name": "uint", "nodeType": "ElementaryTypeName", "src": "159:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -279,26 +245,21 @@ "src": "169:37:1", "stateVariable": true, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_userDefinedValueType$_MyAddress_$18_$_t_userDefinedValueType$_MyUInt_$20_$", "typeString": "mapping(C.MyAddress => C.MyUInt)" }, - "typeName": - { + "typeName": { "id": 25, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 22, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 21, "name": "MyAddress", - "nameLocations": - [ + "nameLocations": [ "177:9:1" ], "nodeType": "IdentifierPath", @@ -307,31 +268,26 @@ }, "referencedDeclaration": 18, "src": "177:9:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_MyAddress_$18", "typeString": "C.MyAddress" } }, "nodeType": "Mapping", "src": "169:28:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_mapping$_t_userDefinedValueType$_MyAddress_$18_$_t_userDefinedValueType$_MyUInt_$20_$", "typeString": "mapping(C.MyAddress => C.MyUInt)" }, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 24, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 23, "name": "MyUInt", - "nameLocations": - [ + "nameLocations": [ "190:6:1" ], "nodeType": "IdentifierPath", @@ -340,8 +296,7 @@ }, "referencedDeclaration": 20, "src": "190:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_MyUInt_$20", "typeString": "C.MyUInt" } diff --git a/test/libsolidity/ASTJSON/userDefinedValueType.sol b/test/libsolidity/ASTJSON/userDefinedValueType.sol index d5ef2e00b9f8..f1124f8cd6fd 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType.sol +++ b/test/libsolidity/ASTJSON/userDefinedValueType.sol @@ -9,4 +9,5 @@ contract C { type MyUInt is uint; mapping(MyAddress => MyUInt) public m; } + // ---- diff --git a/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json b/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json index 90e48a98276b..c3bb96ddd4df 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json +++ b/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json @@ -2,16 +2,14 @@ "absolutePath": "a", "id": 28, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "id": 2, "name": "MyAddress", "nameLocation": "5:9:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "0:26:1", - "underlyingType": - { + "underlyingType": { "id": 1, "name": "address", "nodeType": "ElementaryTypeName", @@ -26,8 +24,7 @@ "nameLocation": "32:6:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "27:20:1", - "underlyingType": - { + "underlyingType": { "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", @@ -36,20 +33,16 @@ } }, { - "body": - { + "body": { "id": 15, "nodeType": "Block", "src": "61:34:1", - "statements": - [ + "statements": [ { - "assignments": - [ + "assignments": [ 9 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 9, @@ -61,16 +54,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 8, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 7, "name": "MyAddress", - "nameLocations": - [ + "nameLocations": [ "67:9:1" ], "nodeType": "IdentifierPath", @@ -87,12 +77,10 @@ "src": "67:11:1" }, { - "assignments": - [ + "assignments": [ 13 ], - "declarations": - [ + "declarations": [ { "constant": false, "id": 13, @@ -104,16 +92,13 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 12, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 11, "name": "MyUInt", - "nameLocations": - [ + "nameLocations": [ "84:6:1" ], "nodeType": "IdentifierPath", @@ -138,15 +123,13 @@ "name": "f", "nameLocation": "57:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 5, "nodeType": "ParameterList", "parameters": [], "src": "58:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], @@ -166,16 +149,14 @@ "name": "C", "nameLocation": "105:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "id": 18, "name": "MyAddress", "nameLocation": "118:9:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "113:26:1", - "underlyingType": - { + "underlyingType": { "id": 17, "name": "address", "nodeType": "ElementaryTypeName", @@ -190,8 +171,7 @@ "nameLocation": "149:6:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "144:20:1", - "underlyingType": - { + "underlyingType": { "id": 19, "name": "uint", "nodeType": "ElementaryTypeName", @@ -210,21 +190,17 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 25, "keyName": "", "keyNameLocation": "-1:-1:-1", - "keyType": - { + "keyType": { "id": 22, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 21, "name": "MyAddress", - "nameLocations": - [ + "nameLocations": [ "177:9:1" ], "nodeType": "IdentifierPath", @@ -238,16 +214,13 @@ "typeDescriptions": {}, "valueName": "", "valueNameLocation": "-1:-1:-1", - "valueType": - { + "valueType": { "id": 24, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 23, "name": "MyUInt", - "nameLocations": - [ + "nameLocations": [ "190:6:1" ], "nodeType": "IdentifierPath", diff --git a/test/libsolidity/ASTJSON/user_defined_operator.json b/test/libsolidity/ASTJSON/user_defined_operator.json index ed72de49dd28..b39d2e07ea10 100644 --- a/test/libsolidity/ASTJSON/user_defined_operator.json +++ b/test/libsolidity/ASTJSON/user_defined_operator.json @@ -1,28 +1,22 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 49 ], - "I8": - [ + "I8": [ 2 ], - "sub": - [ + "sub": [ 20 ], - "unsub": - [ + "unsub": [ 30 ] }, "id": 50, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "canonicalName": "I8", "id": 2, @@ -30,29 +24,24 @@ "nameLocation": "5:2:1", "nodeType": "UserDefinedValueTypeDefinition", "src": "0:16:1", - "underlyingType": - { + "underlyingType": { "id": 1, "name": "int8", "nodeType": "ElementaryTypeName", "src": "11:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_int8", "typeString": "int8" } } }, { - "functionList": - [ + "functionList": [ { - "definition": - { + "definition": { "id": 3, "name": "sub", - "nameLocations": - [ + "nameLocations": [ "24:3:1" ], "nodeType": "IdentifierPath", @@ -62,12 +51,10 @@ "operator": "-" }, { - "definition": - { + "definition": { "id": 4, "name": "unsub", - "nameLocations": - [ + "nameLocations": [ "34:5:1" ], "nodeType": "IdentifierPath", @@ -81,16 +68,13 @@ "id": 7, "nodeType": "UsingForDirective", "src": "17:43:1", - "typeName": - { + "typeName": { "id": 6, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 5, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "50:2:1" ], "nodeType": "IdentifierPath", @@ -99,16 +83,14 @@ }, "referencedDeclaration": 2, "src": "50:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } } }, { - "body": - { + "body": { "id": 19, "nodeType": "Block", "src": "100:2:1", @@ -121,12 +103,10 @@ "name": "sub", "nameLocation": "70:3:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 14, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 10, @@ -138,21 +118,17 @@ "src": "74:2:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 9, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 8, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "74:2:1" ], "nodeType": "IdentifierPath", @@ -161,8 +137,7 @@ }, "referencedDeclaration": 2, "src": "74:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -180,21 +155,17 @@ "src": "78:2:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 12, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 11, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "78:2:1" ], "nodeType": "IdentifierPath", @@ -203,8 +174,7 @@ }, "referencedDeclaration": 2, "src": "78:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -214,12 +184,10 @@ ], "src": "73:8:1" }, - "returnParameters": - { + "returnParameters": { "id": 18, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 17, @@ -231,21 +199,17 @@ "src": "96:2:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 16, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 15, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "96:2:1" ], "nodeType": "IdentifierPath", @@ -254,8 +218,7 @@ }, "referencedDeclaration": 2, "src": "96:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -272,8 +235,7 @@ "visibility": "internal" }, { - "body": - { + "body": { "id": 29, "nodeType": "Block", "src": "140:2:1", @@ -286,12 +248,10 @@ "name": "unsub", "nameLocation": "112:5:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 24, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 23, @@ -303,21 +263,17 @@ "src": "118:2:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 22, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 21, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "118:2:1" ], "nodeType": "IdentifierPath", @@ -326,8 +282,7 @@ }, "referencedDeclaration": 2, "src": "118:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -337,12 +292,10 @@ ], "src": "117:4:1" }, - "returnParameters": - { + "returnParameters": { "id": 28, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 27, @@ -354,21 +307,17 @@ "src": "136:2:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 26, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 25, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "136:2:1" ], "nodeType": "IdentifierPath", @@ -377,8 +326,7 @@ }, "referencedDeclaration": 2, "src": "136:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -402,28 +350,22 @@ "contractKind": "contract", "fullyImplemented": true, "id": 49, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 49 ], "name": "C", "nameLocation": "152:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 47, "nodeType": "Block", "src": "208:30:1", - "statements": - [ + "statements": [ { - "expression": - { - "commonType": - { + "expression": { + "commonType": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, @@ -433,8 +375,7 @@ "isLValue": false, "isPure": false, "lValueRequested": false, - "leftExpression": - { + "leftExpression": { "function": 30, "id": 43, "isConstant": false, @@ -445,45 +386,39 @@ "operator": "-", "prefix": true, "src": "225:2:1", - "subExpression": - { + "subExpression": { "id": 42, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 33, "src": "226:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } }, - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } }, "nodeType": "BinaryOperation", "operator": "-", - "rightExpression": - { + "rightExpression": { "id": 44, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "230:1:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } }, "src": "225:6:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -503,12 +438,10 @@ "name": "f", "nameLocation": "169:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 37, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 33, @@ -520,21 +453,17 @@ "src": "171:4:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 32, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 31, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "171:2:1" ], "nodeType": "IdentifierPath", @@ -543,8 +472,7 @@ }, "referencedDeclaration": 2, "src": "171:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -562,21 +490,17 @@ "src": "177:4:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 35, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 34, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "177:2:1" ], "nodeType": "IdentifierPath", @@ -585,8 +509,7 @@ }, "referencedDeclaration": 2, "src": "177:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } @@ -596,12 +519,10 @@ ], "src": "170:12:1" }, - "returnParameters": - { + "returnParameters": { "id": 41, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 40, @@ -613,21 +534,17 @@ "src": "204:2:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" }, - "typeName": - { + "typeName": { "id": 39, "nodeType": "UserDefinedTypeName", - "pathNode": - { + "pathNode": { "id": 38, "name": "I8", - "nameLocations": - [ + "nameLocations": [ "204:2:1" ], "nodeType": "IdentifierPath", @@ -636,8 +553,7 @@ }, "referencedDeclaration": 2, "src": "204:2:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_userDefinedValueType$_I8_$2", "typeString": "I8" } diff --git a/test/libsolidity/ASTJSON/user_defined_operator.sol b/test/libsolidity/ASTJSON/user_defined_operator.sol index bfbdf7b9bf83..df5d0ed32609 100644 --- a/test/libsolidity/ASTJSON/user_defined_operator.sol +++ b/test/libsolidity/ASTJSON/user_defined_operator.sol @@ -7,4 +7,5 @@ contract C { return -a - b; } } + // ---- diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json index f3094980ff12..b62ec8e865cc 100644 --- a/test/libsolidity/ASTJSON/using_for_directive.json +++ b/test/libsolidity/ASTJSON/using_for_directive.json @@ -1,34 +1,26 @@ { "absolutePath": "a", - "exportedSymbols": - { - "C": - [ + "exportedSymbols": { + "C": [ 13 ], - "L": - [ + "L": [ 4 ], - "f": - [ + "f": [ 10 ] }, "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { - "functionList": - [ + "functionList": [ { - "function": - { + "function": { "id": 1, "name": "f", - "nameLocations": - [ + "nameLocations": [ "7:1:1" ], "nodeType": "IdentifierPath", @@ -41,14 +33,12 @@ "id": 3, "nodeType": "UsingForDirective", "src": "0:19:1", - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "14:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -62,8 +52,7 @@ "contractKind": "library", "fullyImplemented": true, "id": 4, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 4 ], "name": "L", @@ -76,8 +65,7 @@ "usedEvents": [] }, { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "50:2:1", @@ -90,12 +78,10 @@ "name": "f", "nameLocation": "42:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -107,19 +93,16 @@ "src": "44:4:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, - "typeName": - { + "typeName": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", "src": "44:4:1", - "typeDescriptions": - { + "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } @@ -129,8 +112,7 @@ ], "src": "43:6:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], @@ -150,24 +132,20 @@ "contractKind": "contract", "fullyImplemented": true, "id": 13, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 13 ], "name": "C", "nameLocation": "62:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "global": false, "id": 12, - "libraryName": - { + "libraryName": { "id": 11, "name": "L", - "nameLocations": - [ + "nameLocations": [ "72:1:1" ], "nodeType": "IdentifierPath", diff --git a/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json b/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json index 9360227d435e..4858081c23fb 100644 --- a/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json +++ b/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json @@ -2,18 +2,14 @@ "absolutePath": "a", "id": 14, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { - "functionList": - [ + "functionList": [ { - "function": - { + "function": { "id": 1, "name": "f", - "nameLocations": - [ + "nameLocations": [ "7:1:1" ], "nodeType": "IdentifierPath", @@ -25,8 +21,7 @@ "id": 3, "nodeType": "UsingForDirective", "src": "0:19:1", - "typeName": - { + "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", @@ -49,8 +44,7 @@ "usedEvents": [] }, { - "body": - { + "body": { "id": 9, "nodeType": "Block", "src": "50:2:1", @@ -63,12 +57,10 @@ "name": "f", "nameLocation": "42:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 7, "nodeType": "ParameterList", - "parameters": - [ + "parameters": [ { "constant": false, "id": 6, @@ -80,8 +72,7 @@ "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, - "typeName": - { + "typeName": { "id": 5, "name": "uint", "nodeType": "ElementaryTypeName", @@ -93,8 +84,7 @@ ], "src": "43:6:1" }, - "returnParameters": - { + "returnParameters": { "id": 8, "nodeType": "ParameterList", "parameters": [], @@ -114,17 +104,14 @@ "name": "C", "nameLocation": "62:1:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { "global": false, "id": 12, - "libraryName": - { + "libraryName": { "id": 11, "name": "L", - "nameLocations": - [ + "nameLocations": [ "72:1:1" ], "nodeType": "IdentifierPath", diff --git a/test/libsolidity/ASTJSON/yul_hex_literal.json b/test/libsolidity/ASTJSON/yul_hex_literal.json index 0498289c6729..22d8c6d8e91f 100644 --- a/test/libsolidity/ASTJSON/yul_hex_literal.json +++ b/test/libsolidity/ASTJSON/yul_hex_literal.json @@ -1,16 +1,13 @@ { "absolutePath": "a", - "exportedSymbols": - { - "Sample": - [ + "exportedSymbols": { + "Sample": [ 6 ] }, "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -19,37 +16,30 @@ "contractKind": "contract", "fullyImplemented": true, "id": 6, - "linearizedBaseContracts": - [ + "linearizedBaseContracts": [ 6 ], "name": "Sample", "nameLocation": "9:6:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "47:167:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "66:142:1", "nodeType": "YulBlock", "src": "66:142:1", - "statements": - [ + "statements": [ { "nativeSrc": "80:15:1", "nodeType": "YulVariableDeclaration", "src": "80:15:1", - "value": - { + "value": { "hexValue": "74657374", "kind": "string", "nativeSrc": "89:6:1", @@ -58,8 +48,7 @@ "type": "", "value": "test" }, - "variables": - [ + "variables": [ { "name": "a", "nativeSrc": "84:1:1", @@ -73,8 +62,7 @@ "nativeSrc": "108:54:1", "nodeType": "YulVariableDeclaration", "src": "108:54:1", - "value": - { + "value": { "hexValue": "112233445566778899aabbccddeeff6677889900", "kind": "string", "nativeSrc": "117:45:1", @@ -82,8 +70,7 @@ "src": "117:45:1", "type": "" }, - "variables": - [ + "variables": [ { "name": "b", "nativeSrc": "112:1:1", @@ -97,8 +84,7 @@ "nativeSrc": "175:23:1", "nodeType": "YulVariableDeclaration", "src": "175:23:1", - "value": - { + "value": { "hexValue": "1234abcd", "kind": "string", "nativeSrc": "184:14:1", @@ -106,8 +92,7 @@ "src": "184:14:1", "type": "" }, - "variables": - [ + "variables": [ { "name": "c", "nativeSrc": "179:1:1", @@ -135,15 +120,13 @@ "name": "f", "nameLocation": "31:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "32:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTJSON/yul_hex_literal.sol b/test/libsolidity/ASTJSON/yul_hex_literal.sol index c3b57a8fe8d2..f441866c1d1b 100644 --- a/test/libsolidity/ASTJSON/yul_hex_literal.sol +++ b/test/libsolidity/ASTJSON/yul_hex_literal.sol @@ -7,4 +7,5 @@ contract Sample { } } } + // ---- diff --git a/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json b/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json index 023c13cc7423..d26e2e29695f 100644 --- a/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json +++ b/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json @@ -2,8 +2,7 @@ "absolutePath": "a", "id": 7, "nodeType": "SourceUnit", - "nodes": - [ + "nodes": [ { "abstract": false, "baseContracts": [], @@ -13,30 +12,24 @@ "name": "Sample", "nameLocation": "9:6:1", "nodeType": "ContractDefinition", - "nodes": - [ + "nodes": [ { - "body": - { + "body": { "id": 4, "nodeType": "Block", "src": "47:167:1", - "statements": - [ + "statements": [ { - "AST": - { + "AST": { "nativeSrc": "66:142:1", "nodeType": "YulBlock", "src": "66:142:1", - "statements": - [ + "statements": [ { "nativeSrc": "80:15:1", "nodeType": "YulVariableDeclaration", "src": "80:15:1", - "value": - { + "value": { "hexValue": "74657374", "kind": "string", "nativeSrc": "89:6:1", @@ -45,8 +38,7 @@ "type": "", "value": "test" }, - "variables": - [ + "variables": [ { "name": "a", "nativeSrc": "84:1:1", @@ -60,8 +52,7 @@ "nativeSrc": "108:54:1", "nodeType": "YulVariableDeclaration", "src": "108:54:1", - "value": - { + "value": { "hexValue": "112233445566778899aabbccddeeff6677889900", "kind": "string", "nativeSrc": "117:45:1", @@ -69,8 +60,7 @@ "src": "117:45:1", "type": "" }, - "variables": - [ + "variables": [ { "name": "b", "nativeSrc": "112:1:1", @@ -84,8 +74,7 @@ "nativeSrc": "175:23:1", "nodeType": "YulVariableDeclaration", "src": "175:23:1", - "value": - { + "value": { "hexValue": "1234abcd", "kind": "string", "nativeSrc": "184:14:1", @@ -93,8 +82,7 @@ "src": "184:14:1", "type": "" }, - "variables": - [ + "variables": [ { "name": "c", "nativeSrc": "179:1:1", @@ -121,15 +109,13 @@ "name": "f", "nameLocation": "31:1:1", "nodeType": "FunctionDefinition", - "parameters": - { + "parameters": { "id": 1, "nodeType": "ParameterList", "parameters": [], "src": "32:2:1" }, - "returnParameters": - { + "returnParameters": { "id": 2, "nodeType": "ParameterList", "parameters": [], diff --git a/test/libsolidity/ASTPropertyTest.cpp b/test/libsolidity/ASTPropertyTest.cpp index 8dc2c2930bfc..05c9b8786db8 100644 --- a/test/libsolidity/ASTPropertyTest.cpp +++ b/test/libsolidity/ASTPropertyTest.cpp @@ -108,20 +108,20 @@ void ASTPropertyTest::readExpectations() m_expectation = formatExpectations(false /* _obtainedResult */); } -void ASTPropertyTest::extractTestsFromAST(Json::Value const& _astJson) +void ASTPropertyTest::extractTestsFromAST(Json const& _astJson) { - std::queue nodesToVisit; + std::queue nodesToVisit; nodesToVisit.push(_astJson); while (!nodesToVisit.empty()) { - Json::Value& node = nodesToVisit.front(); + Json& node = nodesToVisit.front(); - if (node.isArray()) + if (node.is_array()) for (auto&& member: node) nodesToVisit.push(member); - else if (node.isObject()) - for (std::string const& memberName: node.getMemberNames()) + else if (node.is_object()) + for (auto const& [memberName, value]: node.items()) { if (memberName != "documentation") { @@ -129,9 +129,8 @@ void ASTPropertyTest::extractTestsFromAST(Json::Value const& _astJson) continue; } - std::string nodeDocstring = node["documentation"].isObject() ? - node["documentation"]["text"].asString() : - node["documentation"].asString(); + std::string nodeDocstring = value.is_object() ? + value["text"].get() : value.get(); soltestAssert(!nodeDocstring.empty()); std::vector pairs = readKeyValuePairs(nodeDocstring); @@ -150,17 +149,22 @@ void ASTPropertyTest::extractTestsFromAST(Json::Value const& _astJson) ); m_tests[testId].property = testedProperty; - soltestAssert(node.isMember("nodeType")); - std::optional propertyNode = jsonValueByPath(node, testedProperty); + soltestAssert(node.contains("nodeType")); + std::optional propertyNode = jsonValueByPath(node, testedProperty); soltestAssert( propertyNode.has_value(), - node["nodeType"].asString() + " node does not have a property named \""s + testedProperty + "\"" + node["nodeType"].get() + " node does not have a property named \""s + testedProperty + "\"" ); soltestAssert( - !propertyNode->isObject() && !propertyNode->isArray(), + !propertyNode->is_object() && !propertyNode->is_array(), "Property \"" + testedProperty + "\" is an object or an array." ); - m_tests[testId].obtainedValue = propertyNode->asString(); + if (propertyNode->is_string()) + m_tests[testId].obtainedValue = propertyNode->get(); + else if (propertyNode->is_boolean()) + m_tests[testId].obtainedValue = fmt::format("{}", propertyNode->get()); + else + soltestAssert(false); } } @@ -195,8 +199,8 @@ TestCase::TestResult ASTPropertyTest::run(std::ostream& _stream, std::string con SourceReferenceFormatter::formatErrorInformation(compiler.errors(), compiler, _formatted) )); - Json::Value astJson = ASTJsonExporter(compiler.state()).toJson(compiler.ast("A")); - soltestAssert(astJson); + Json astJson = ASTJsonExporter(compiler.state()).toJson(compiler.ast("A")); + soltestAssert(!astJson.empty()); extractTestsFromAST(astJson); diff --git a/test/libsolidity/ASTPropertyTest.h b/test/libsolidity/ASTPropertyTest.h index e4cec05280b5..6130cedb299e 100644 --- a/test/libsolidity/ASTPropertyTest.h +++ b/test/libsolidity/ASTPropertyTest.h @@ -56,7 +56,7 @@ class ASTPropertyTest: public TestCase void readExpectations(); std::vector readKeyValuePairs(std::string const& _input); - void extractTestsFromAST(Json::Value const& _astJson); + void extractTestsFromAST(Json const& _astJson); std::string formatExpectations(bool _obtainedResult = true); std::vector m_testOrder; diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index e7b2c03ec284..93581a58274e 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -200,7 +200,7 @@ CHECK_ERROR_OR_WARNING(text, type, substrings, false, true) #define CHECK_WARNING(text, substring) \ CHECK_ERROR_OR_WARNING(text, Warning, std::vector{(substring)}, true, false) -// [checkWarningAllowMulti(text, substring)] aserts that the compilation down to typechecking +// [checkWarningAllowMulti(text, substring)] asserts that the compilation down to typechecking // emits a warning and with a message containing [substring]. // Because of the limitations of the preprocessor, you cannot use {"abc", "def"} as arguments, // but have to replace them by (std::vector{"abc", "def"}) (note the parentheses) diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index 4786a2a86327..14722535e446 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -82,18 +82,18 @@ void GasTest::parseExpectations(std::istream& _stream) void GasTest::printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const { - Json::Value estimates = compiler().gasEstimates(compiler().lastContractName()); - for (auto groupIt = estimates.begin(); groupIt != estimates.end(); ++groupIt) + Json estimates = compiler().gasEstimates(compiler().lastContractName()); + for (auto& [key, group] : estimates.items()) { - _stream << _linePrefix << groupIt.key().asString() << ":" << std::endl; - for (auto it = groupIt->begin(); it != groupIt->end(); ++it) + _stream << _linePrefix << key << ":" << std::endl; + for (auto& [elementKey, value] : group.items()) { _stream << _linePrefix << " "; - if (it.key().asString().empty()) + if (elementKey.empty()) _stream << "fallback"; else - _stream << it.key().asString(); - _stream << ": " << it->asString() << std::endl; + _stream << elementKey; + _stream << ": " << value.get() << std::endl; } } } @@ -128,14 +128,14 @@ TestCase::TestResult GasTest::run(std::ostream& _stream, std::string const& _lin return TestResult::FatalError; } - Json::Value estimateGroups = compiler().gasEstimates(compiler().lastContractName()); + Json estimateGroups = compiler().gasEstimates(compiler().lastContractName()); if ( m_expectations.size() == estimateGroups.size() && boost::all(m_expectations, [&](auto const& expectations) { auto const& estimates = estimateGroups[expectations.first]; return estimates.size() == expectations.second.size() && boost::all(expectations.second, [&](auto const& entry) { - return entry.second == estimates[entry.first].asString(); + return entry.second == estimates[entry.first].template get(); }); }) ) diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index 1a7a6ba69633..f7a434dcfd25 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -36,30 +36,30 @@ namespace /// TODO: share this between StandardCompiler.cpp /// Helper to match a specific error type and message -bool containsError(Json::Value const& _compilerResult, std::string const& _type, std::string const& _message) +bool containsError(Json const& _compilerResult, std::string const& _type, std::string const& _message) { - if (!_compilerResult.isMember("errors")) + if (!_compilerResult.contains("errors")) return false; for (auto const& error: _compilerResult["errors"]) { - BOOST_REQUIRE(error.isObject()); - BOOST_REQUIRE(error["type"].isString()); - BOOST_REQUIRE(error["message"].isString()); - if ((error["type"].asString() == _type) && (error["message"].asString() == _message)) + BOOST_REQUIRE(error.is_object()); + BOOST_REQUIRE(error["type"].is_string()); + BOOST_REQUIRE(error["message"].is_string()); + if ((error["type"].get() == _type) && (error["message"].get() == _message)) return true; } return false; } -Json::Value compile(std::string const& _input, CStyleReadFileCallback _callback = nullptr) +Json compile(std::string const& _input, CStyleReadFileCallback _callback = nullptr) { char* output_ptr = solidity_compile(_input.c_str(), _callback, nullptr); std::string output(output_ptr); solidity_free(output_ptr); solidity_reset(); - Json::Value ret; + Json ret; BOOST_REQUIRE(util::jsonParseStrict(output, ret)); return ret; } @@ -100,14 +100,14 @@ BOOST_AUTO_TEST_CASE(standard_compilation) } } )"; - Json::Value result = compile(input); - BOOST_REQUIRE(result.isObject()); + Json result = compile(input); + BOOST_REQUIRE(result.is_object()); // Only tests some assumptions. The StandardCompiler is tested properly in another suite. - BOOST_CHECK(result.isMember("sources")); + BOOST_CHECK(result.contains("sources")); // This used to test that it is a member, but we did not actually request any output, // so there should not be a contract member. - BOOST_CHECK(!result.isMember("contracts")); + BOOST_CHECK(!result.contains("contracts")); } BOOST_AUTO_TEST_CASE(missing_callback) @@ -122,8 +122,8 @@ BOOST_AUTO_TEST_CASE(missing_callback) } } )"; - Json::Value result = compile(input); - BOOST_REQUIRE(result.isObject()); + Json result = compile(input); + BOOST_REQUIRE(result.is_object()); BOOST_CHECK(containsError(result, "ParserError", "Source \"missing.sol\" not found: File not supplied initially.")); } @@ -168,8 +168,8 @@ BOOST_AUTO_TEST_CASE(with_callback) } }; - Json::Value result = compile(input, callback); - BOOST_REQUIRE(result.isObject()); + Json result = compile(input, callback); + BOOST_REQUIRE(result.is_object()); // This ensures that "found.sol" was properly loaded which triggered the second import statement. BOOST_CHECK(containsError(result, "ParserError", "Source \"missing.sol\" not found: Missing file.")); diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index 029419af11c5..94687f99006d 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -57,17 +57,17 @@ std::optional compileAndCheckLicenseMetadata(std::string const& _co BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata(_contractName); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); BOOST_CHECK_EQUAL(metadata["sources"].size(), 1); - BOOST_REQUIRE(metadata["sources"].isMember("A.sol")); + BOOST_REQUIRE(metadata["sources"].contains("A.sol")); - if (metadata["sources"]["A.sol"].isMember("license")) + if (metadata["sources"]["A.sol"].contains("license")) { - BOOST_REQUIRE(metadata["sources"]["A.sol"]["license"].isString()); - return metadata["sources"]["A.sol"]["license"].asString(); + BOOST_REQUIRE(metadata["sources"]["A.sol"]["license"].is_string()); + return metadata["sources"]["A.sol"]["license"].get(); } else return std::nullopt; @@ -288,12 +288,12 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources) BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("A"); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); BOOST_CHECK_EQUAL(metadata["sources"].size(), 1); - BOOST_CHECK(metadata["sources"].isMember("A")); + BOOST_CHECK(metadata["sources"].contains("A")); } BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) @@ -329,14 +329,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("C"); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); BOOST_CHECK_EQUAL(metadata["sources"].size(), 3); - BOOST_CHECK(metadata["sources"].isMember("A")); - BOOST_CHECK(metadata["sources"].isMember("B")); - BOOST_CHECK(metadata["sources"].isMember("C")); + BOOST_CHECK(metadata["sources"].contains("A")); + BOOST_CHECK(metadata["sources"].contains("B")); + BOOST_CHECK(metadata["sources"].contains("C")); } BOOST_AUTO_TEST_CASE(metadata_useLiteralContent) @@ -357,16 +357,16 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent) compilerStack.useMetadataLiteralSources(_literal); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string metadata_str = compilerStack.metadata("test"); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(metadata_str, metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); - BOOST_CHECK(metadata.isMember("settings")); - BOOST_CHECK(metadata["settings"].isMember("metadata")); - BOOST_CHECK(metadata["settings"]["metadata"].isMember("bytecodeHash")); + BOOST_CHECK(metadata.contains("settings")); + BOOST_CHECK(metadata["settings"].contains("metadata")); + BOOST_CHECK(metadata["settings"]["metadata"].contains("bytecodeHash")); if (_literal) { - BOOST_CHECK(metadata["settings"]["metadata"].isMember("useLiteralContent")); - BOOST_CHECK(metadata["settings"]["metadata"]["useLiteralContent"].asBool()); + BOOST_CHECK(metadata["settings"]["metadata"].contains("useLiteralContent")); + BOOST_CHECK(metadata["settings"]["metadata"]["useLiteralContent"].get()); } }; @@ -391,17 +391,17 @@ BOOST_AUTO_TEST_CASE(metadata_viair) compilerStack.setViaIR(_viaIR); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(compilerStack.metadata("test"), metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); - BOOST_CHECK(metadata.isMember("settings")); + BOOST_CHECK(metadata.contains("settings")); if (_viaIR) { - BOOST_CHECK(metadata["settings"].isMember("viaIR")); - BOOST_CHECK(metadata["settings"]["viaIR"].asBool()); + BOOST_CHECK(metadata["settings"].contains("viaIR")); + BOOST_CHECK(metadata["settings"]["viaIR"].get()); } else - BOOST_CHECK(!metadata["settings"].isMember("viaIR")); + BOOST_CHECK(!metadata["settings"].contains("viaIR")); BOOST_CHECK(compilerStack.cborMetadata("test") == compilerStack.cborMetadata("test", _viaIR)); BOOST_CHECK(compilerStack.cborMetadata("test") != compilerStack.cborMetadata("test", !_viaIR)); @@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE(metadata_revert_strings) BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("A"); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); @@ -469,14 +469,14 @@ BOOST_AUTO_TEST_CASE(metadata_optimiser_sequence) BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("C"); - Json::Value metadata; + Json metadata; BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK(solidity::test::isValidMetadata(metadata)); - BOOST_CHECK(metadata["settings"]["optimizer"].isMember("details")); - BOOST_CHECK(metadata["settings"]["optimizer"]["details"].isMember("yulDetails")); - BOOST_CHECK(metadata["settings"]["optimizer"]["details"]["yulDetails"].isMember("optimizerSteps")); + BOOST_CHECK(metadata["settings"]["optimizer"].contains("details")); + BOOST_CHECK(metadata["settings"]["optimizer"]["details"].contains("yulDetails")); + BOOST_CHECK(metadata["settings"]["optimizer"]["details"]["yulDetails"].contains("optimizerSteps")); - std::string const metadataOptimizerSteps = metadata["settings"]["optimizer"]["details"]["yulDetails"]["optimizerSteps"].asString(); + std::string const metadataOptimizerSteps = metadata["settings"]["optimizer"]["details"]["yulDetails"]["optimizerSteps"].get(); std::string const expectedMetadataOptimiserSteps = _optimizerSequence + ":" + _optimizerCleanupSequence; BOOST_CHECK_EQUAL(metadataOptimizerSteps, expectedMetadataOptimiserSteps); }; diff --git a/test/libsolidity/NatspecJSONTest.cpp b/test/libsolidity/NatspecJSONTest.cpp index 9f1ba1d7de00..7dff638f0de5 100644 --- a/test/libsolidity/NatspecJSONTest.cpp +++ b/test/libsolidity/NatspecJSONTest.cpp @@ -67,7 +67,7 @@ void NatspecJSONTest::parseCustomExpectations(std::istream& _stream) std::string rawJSON = extractExpectationJSON(_stream); std::string jsonErrors; - Json::Value parsedJSON; + Json parsedJSON; bool jsonParsingSuccessful = jsonParseStrict(rawJSON, parsedJSON, &jsonErrors); if (!jsonParsingSuccessful) BOOST_THROW_EXCEPTION(std::runtime_error(fmt::format( @@ -86,7 +86,7 @@ void NatspecJSONTest::parseCustomExpectations(std::istream& _stream) bool NatspecJSONTest::expectationsMatch() { - // NOTE: Comparing pretty printed Json::Values to avoid using its operator==, which fails to + // NOTE: Comparing pretty printed Jsons to avoid using its operator==, which fails to // compare equal numbers as equal. For example, for 'version' field the value is sometimes int, // sometimes uint and they compare as different even when both are 1. return diff --git a/test/libsolidity/NatspecJSONTest.h b/test/libsolidity/NatspecJSONTest.h index 762b88d10659..619ece83b165 100644 --- a/test/libsolidity/NatspecJSONTest.h +++ b/test/libsolidity/NatspecJSONTest.h @@ -44,7 +44,7 @@ enum class NatspecJSONKind std::ostream& operator<<(std::ostream& _output, NatspecJSONKind _kind); -using NatspecMap = std::map>; +using NatspecMap = std::map>; using SerializedNatspecMap = std::map>; class NatspecJSONTest: public SyntaxTest diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 381ec5bda54e..b0bdb95cb9c4 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -157,7 +157,7 @@ std::map SemanticTest::makeBuiltins() { soltestAssert(_call.arguments.parameters.empty(), "No arguments expected."); return toBigEndian(u256(storageEmpty(m_contractAddress) ? 1 : 0)); - } + } }, { "account", @@ -429,7 +429,7 @@ TestCase::TestResult SemanticTest::runTest( { soltestAssert( m_allowNonExistingFunctions || - m_compiler.interfaceSymbols(m_compiler.lastContractName(m_sources.mainSourceFile))["methods"].isMember(test.call().signature), + m_compiler.interfaceSymbols(m_compiler.lastContractName(m_sources.mainSourceFile))["methods"].contains(test.call().signature), "The function " + test.call().signature + " is not known to the compiler" ); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index e34df0307c79..e321a5298603 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1680,29 +1680,29 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi) //BOOST_AUTO_TEST_CASE(assignment_to_const_array_vars) //{ -// char const* sourceCode = R"( -// contract C { -// uint[3] constant x = [uint(1), 2, 3]; -// uint constant y = x[0] + x[1] + x[2]; -// function f() public returns (uint) { return y; } -// } -// )"; -// compileAndRun(sourceCode); -// ABI_CHECK(callContractFunction("f()"), encodeArgs(1 + 2 + 3)); +// char const* sourceCode = R"( +// contract C { +// uint[3] constant x = [uint(1), 2, 3]; +// uint constant y = x[0] + x[1] + x[2]; +// function f() public returns (uint) { return y; } +// } +// )"; +// compileAndRun(sourceCode); +// ABI_CHECK(callContractFunction("f()"), encodeArgs(1 + 2 + 3)); //} // Disabled until https://github.com/ethereum/solidity/issues/715 is implemented //BOOST_AUTO_TEST_CASE(constant_struct) //{ -// char const* sourceCode = R"( -// contract C { -// struct S { uint x; uint[] y; } -// S constant x = S(5, new uint[](4)); -// function f() public returns (uint) { return x.x; } -// } -// )"; -// compileAndRun(sourceCode); -// ABI_CHECK(callContractFunction("f()"), encodeArgs(5)); +// char const* sourceCode = R"( +// contract C { +// struct S { uint x; uint[] y; } +// S constant x = S(5, new uint[](4)); +// function f() public returns (uint) { return x.x; } +// } +// )"; +// compileAndRun(sourceCode); +// ABI_CHECK(callContractFunction("f()"), encodeArgs(5)); //} BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 27f1a7e847bb..d52ad6b9c48a 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(retain_information_in_branches) numSHA3s++; }); // TEST DISABLED - OPTIMIZER IS NOT EFFECTIVE ON THIS ONE ANYMORE -// BOOST_CHECK_EQUAL(1, numSHA3s); +// BOOST_CHECK_EQUAL(1, numSHA3s); } BOOST_AUTO_TEST_CASE(store_tags_as_unions) @@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(store_tags_as_unions) numSHA3s++; }); // TEST DISABLED UNTIL 93693404 IS IMPLEMENTED -// BOOST_CHECK_EQUAL(2, numSHA3s); +// BOOST_CHECK_EQUAL(2, numSHA3s); } BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug) diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 7fafa2a62e08..cdb6c5bd2d9d 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -55,97 +56,97 @@ langutil::Error::Severity str2Severity(std::string const& _cat) } /// Helper to match a specific error type and message -bool containsError(Json::Value const& _compilerResult, std::string const& _type, std::string const& _message) +bool containsError(Json const& _compilerResult, std::string const& _type, std::string const& _message) { - if (!_compilerResult.isMember("errors")) + if (!_compilerResult.contains("errors")) return false; for (auto const& error: _compilerResult["errors"]) { - BOOST_REQUIRE(error.isObject()); - BOOST_REQUIRE(error["type"].isString()); - BOOST_REQUIRE(error["message"].isString()); - if ((error["type"].asString() == _type) && (error["message"].asString() == _message)) + BOOST_REQUIRE(error.is_object()); + BOOST_REQUIRE(error["type"].is_string()); + BOOST_REQUIRE(error["message"].is_string()); + if ((error["type"].get() == _type) && (error["message"].get() == _message)) return true; } return false; } -bool containsAtMostWarnings(Json::Value const& _compilerResult) +bool containsAtMostWarnings(Json const& _compilerResult) { - if (!_compilerResult.isMember("errors")) + if (!_compilerResult.contains("errors")) return true; for (auto const& error: _compilerResult["errors"]) { - BOOST_REQUIRE(error.isObject()); - BOOST_REQUIRE(error["severity"].isString()); - if (langutil::Error::isError(str2Severity(error["severity"].asString()))) + BOOST_REQUIRE(error.is_object()); + BOOST_REQUIRE(error["severity"].is_string()); + if (langutil::Error::isError(str2Severity(error["severity"].get()))) return false; } return true; } -Json::Value getContractResult(Json::Value const& _compilerResult, std::string const& _file, std::string const& _name) +Json getContractResult(Json const& _compilerResult, std::string const& _file, std::string const& _name) { - if ( - !_compilerResult["contracts"].isObject() || - !_compilerResult["contracts"][_file].isObject() || - !_compilerResult["contracts"][_file][_name].isObject() + if (!_compilerResult.contains("contracts") || + !_compilerResult["contracts"].is_object() || + !_compilerResult["contracts"][_file].is_object() || + !_compilerResult["contracts"][_file][_name].is_object() ) - return Json::Value(); + return Json(); return _compilerResult["contracts"][_file][_name]; } -void checkLinkReferencesSchema(Json::Value const& _contractResult) +void checkLinkReferencesSchema(Json const& _contractResult) { - BOOST_TEST_REQUIRE(_contractResult.isObject()); - BOOST_TEST_REQUIRE(_contractResult["evm"]["bytecode"].isObject()); + BOOST_TEST_REQUIRE(_contractResult.is_object()); + BOOST_TEST_REQUIRE(_contractResult["evm"]["bytecode"].is_object()); - Json::Value const& linkReferenceResult = _contractResult["evm"]["bytecode"]["linkReferences"]; - BOOST_TEST_REQUIRE(linkReferenceResult.isObject()); + Json const& linkReferenceResult = _contractResult["evm"]["bytecode"]["linkReferences"]; + BOOST_TEST_REQUIRE(linkReferenceResult.is_object()); - for (std::string const& fileName: linkReferenceResult.getMemberNames()) + for (auto const& [fileName, references]: linkReferenceResult.items()) { - BOOST_TEST_REQUIRE(linkReferenceResult[fileName].isObject()); - for (std::string const& libraryName: linkReferenceResult[fileName].getMemberNames()) + BOOST_TEST_REQUIRE(references.is_object()); + for (auto const& [libraryName, libraryValue]: references.items()) { - BOOST_TEST_REQUIRE(linkReferenceResult[fileName][libraryName].isArray()); - BOOST_TEST_REQUIRE(!linkReferenceResult[fileName][libraryName].empty()); - for (int i = 0; i < static_cast(linkReferenceResult.size()); ++i) + BOOST_TEST_REQUIRE(libraryValue.is_array()); + BOOST_TEST_REQUIRE(!libraryValue.empty()); + for (size_t i = 0; i < static_cast(linkReferenceResult.size()); ++i) { - BOOST_TEST_REQUIRE(linkReferenceResult[fileName][libraryName][i].isObject()); - BOOST_TEST_REQUIRE(linkReferenceResult[fileName][libraryName][i].size() == 2); - BOOST_TEST_REQUIRE(linkReferenceResult[fileName][libraryName][i]["length"].isUInt()); - BOOST_TEST_REQUIRE(linkReferenceResult[fileName][libraryName][i]["start"].isUInt()); + BOOST_TEST_REQUIRE(libraryValue[i].is_object()); + BOOST_TEST_REQUIRE(libraryValue[i].size() == 2); + BOOST_TEST_REQUIRE(libraryValue[i]["length"].is_number_unsigned()); + BOOST_TEST_REQUIRE(libraryValue[i]["start"].is_number_unsigned()); } } } } -void expectLinkReferences(Json::Value const& _contractResult, std::map> const& _expectedLinkReferences) +void expectLinkReferences(Json const& _contractResult, std::map> const& _expectedLinkReferences) { checkLinkReferencesSchema(_contractResult); - Json::Value const& linkReferenceResult = _contractResult["evm"]["bytecode"]["linkReferences"]; + Json const& linkReferenceResult = _contractResult["evm"]["bytecode"]["linkReferences"]; BOOST_TEST(linkReferenceResult.size() == _expectedLinkReferences.size()); for (auto const& [fileName, libraries]: _expectedLinkReferences) { - BOOST_TEST(linkReferenceResult.isMember(fileName)); + BOOST_TEST(linkReferenceResult.contains(fileName)); BOOST_TEST(linkReferenceResult[fileName].size() == libraries.size()); for (std::string const& libraryName: libraries) - BOOST_TEST(linkReferenceResult[fileName].isMember(libraryName)); + BOOST_TEST(linkReferenceResult[fileName].contains(libraryName)); } } -Json::Value compile(std::string _input) +Json compile(std::string _input) { StandardCompiler compiler; std::string output = compiler.compile(std::move(_input)); - Json::Value ret; + Json ret; BOOST_REQUIRE(util::jsonParseStrict(output, ret)); return ret; } @@ -156,25 +157,24 @@ BOOST_AUTO_TEST_SUITE(StandardCompiler) BOOST_AUTO_TEST_CASE(assume_object_input) { - Json::Value result; + Json result; /// Use the native JSON interface of StandardCompiler to trigger these frontend::StandardCompiler compiler; - result = compiler.compile(Json::Value()); + result = compiler.compile(Json()); BOOST_CHECK(containsError(result, "JSONError", "Input is not a JSON object.")); - result = compiler.compile(Json::Value("INVALID")); + result = compiler.compile(Json("INVALID")); BOOST_CHECK(containsError(result, "JSONError", "Input is not a JSON object.")); /// Use the string interface of StandardCompiler to trigger these result = compile(""); - BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n* Line 1, Column 1\n A valid JSON document must be either an array or an object value.\n")); + BOOST_CHECK(containsError(result, "JSONError", "parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON")); result = compile("invalid"); - BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n* Line 1, Column 2\n Extra non-whitespace after JSON value.\n")); + BOOST_CHECK(containsError(result, "JSONError", "parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'i'")); result = compile("\"invalid\""); - BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n A valid JSON document must be either an array or an object value.\n")); - BOOST_CHECK(!containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n")); + BOOST_CHECK(containsError(result, "JSONError", "Input is not a JSON object.")); result = compile("{}"); - BOOST_CHECK(!containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n")); + BOOST_CHECK(containsError(result, "JSONError", "No input sources specified.")); BOOST_CHECK(!containsAtMostWarnings(result)); } @@ -186,7 +186,7 @@ BOOST_AUTO_TEST_CASE(invalid_language) "sources": { "name": { "content": "abc" } } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Only \"Solidity\", \"Yul\", \"SolidityAST\" or \"EVMAssembly\" is supported as a language.")); } @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(valid_language) "language": "Solidity" } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(!containsError(result, "JSONError", "Only \"Solidity\" or \"Yul\" is supported as a language.")); } @@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(no_sources) "language": "Solidity" } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "No input sources specified.")); } @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(no_sources_empty_object) "sources": {} } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "No input sources specified.")); } @@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(no_sources_empty_array) "sources": [] } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "\"sources\" is not a JSON object.")); } @@ -244,7 +244,7 @@ BOOST_AUTO_TEST_CASE(sources_is_array) "sources": ["aa", "bb"] } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "\"sources\" is not a JSON object.")); } @@ -262,8 +262,8 @@ BOOST_AUTO_TEST_CASE(unexpected_trailing_test) } } )"; - Json::Value result = compile(input); - BOOST_CHECK(containsError(result, "JSONError", "* Line 10, Column 2\n Extra non-whitespace after JSON value.\n")); + Json result = compile(input); + BOOST_CHECK(containsError(result, "JSONError", "parse error at line 10, column 2: syntax error while parsing value - unexpected '}'; expected end of input")); } BOOST_AUTO_TEST_CASE(smoke_test) @@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(smoke_test) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); } @@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(optimizer_enabled_not_boolean) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "The \"enabled\" setting must be a Boolean.")); } @@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(optimizer_runs_not_a_number) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number.")); } @@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(optimizer_runs_not_an_unsigned_number) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number.")); } @@ -367,28 +367,28 @@ BOOST_AUTO_TEST_CASE(basic_compilation) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); - BOOST_CHECK(contract["devdoc"].isObject()); + BOOST_CHECK(contract["devdoc"].is_object()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["devdoc"]), R"({"kind":"dev","methods":{},"version":1})"); - BOOST_CHECK(contract["userdoc"].isObject()); + BOOST_CHECK(contract["userdoc"].is_object()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["userdoc"]), R"({"kind":"user","methods":{},"version":1})"); - BOOST_CHECK(contract["evm"].isObject()); + BOOST_CHECK(contract["evm"].is_object()); /// @TODO check evm.methodIdentifiers, legacyAssembly, bytecode, deployedBytecode - BOOST_CHECK(contract["evm"]["bytecode"].isObject()); - BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString()); + BOOST_CHECK(contract["evm"]["bytecode"].is_object()); + BOOST_CHECK(contract["evm"]["bytecode"]["object"].is_string()); BOOST_CHECK_EQUAL( - solidity::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].asString()), + solidity::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].get()), std::string("6080604052348015600e575f80fd5b5060") + (VersionIsRelease ? "3e" : util::toHex(bytes{uint8_t(60 + VersionStringStrict.size())})) + "80601a5f395ff3fe60806040525f80fdfe" ); - BOOST_CHECK(contract["evm"]["assembly"].isString()); - BOOST_CHECK(contract["evm"]["assembly"].asString().find( + BOOST_CHECK(contract["evm"]["assembly"].is_string()); + BOOST_CHECK(contract["evm"]["assembly"].get().find( " /* \"fileA\":0:14 contract A { } */\n mstore(0x40, 0x80)\n " "callvalue\n dup1\n " "iszero\n tag_1\n jumpi\n " @@ -400,22 +400,22 @@ BOOST_AUTO_TEST_CASE(basic_compilation) "0x00\n " "dup1\n revert\n\n auxdata: 0xa26469706673582212" ) == 0); - BOOST_CHECK(contract["evm"]["gasEstimates"].isObject()); + BOOST_CHECK(contract["evm"]["gasEstimates"].is_object()); BOOST_CHECK_EQUAL(contract["evm"]["gasEstimates"].size(), 1); - BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"].isObject()); + BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"].is_object()); BOOST_CHECK_EQUAL(contract["evm"]["gasEstimates"]["creation"].size(), 3); - BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"]["codeDepositCost"].isString()); - BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"]["executionCost"].isString()); - BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"]["totalCost"].isString()); + BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"]["codeDepositCost"].is_string()); + BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"]["executionCost"].is_string()); + BOOST_CHECK(contract["evm"]["gasEstimates"]["creation"]["totalCost"].is_string()); BOOST_CHECK_EQUAL( - u256(contract["evm"]["gasEstimates"]["creation"]["codeDepositCost"].asString()) + - u256(contract["evm"]["gasEstimates"]["creation"]["executionCost"].asString()), - u256(contract["evm"]["gasEstimates"]["creation"]["totalCost"].asString()) + u256(contract["evm"]["gasEstimates"]["creation"]["codeDepositCost"].get()) + + u256(contract["evm"]["gasEstimates"]["creation"]["executionCost"].get()), + u256(contract["evm"]["gasEstimates"]["creation"]["totalCost"].get()) ); // Lets take the top level `.code` section (the "deployer code"), that should expose most of the features of // the assembly JSON. What we want to check here is Operation, Push, PushTag, PushSub, PushSubSize and Tag. - BOOST_CHECK(contract["evm"]["legacyAssembly"].isObject()); - BOOST_CHECK(contract["evm"]["legacyAssembly"][".code"].isArray()); + BOOST_CHECK(contract["evm"]["legacyAssembly"].is_object()); + BOOST_CHECK(contract["evm"]["legacyAssembly"][".code"].is_array()); BOOST_CHECK_EQUAL( util::jsonCompactPrint(contract["evm"]["legacyAssembly"][".code"]), "[{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"source\":0,\"value\":\"80\"}," @@ -440,11 +440,11 @@ BOOST_AUTO_TEST_CASE(basic_compilation) "{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"source\":0,\"value\":\"0\"}," "{\"begin\":0,\"end\":14,\"name\":\"RETURN\",\"source\":0}]" ); - BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); - BOOST_CHECK(result["sources"].isObject()); - BOOST_CHECK(result["sources"]["fileA"].isObject()); - BOOST_CHECK(result["sources"]["fileA"]["ast"].isObject()); + BOOST_CHECK(contract["metadata"].is_string()); + BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].get())); + BOOST_CHECK(result["sources"].is_object()); + BOOST_CHECK(result["sources"]["fileA"].is_object()); + BOOST_CHECK(result["sources"]["fileA"]["ast"].is_object()); BOOST_CHECK_EQUAL( util::jsonCompactPrint(result["sources"]["fileA"]["ast"]), "{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]},\"id\":2,\"nodeType\":\"SourceUnit\",\"nodes\":[{\"abstract\":false," @@ -476,14 +476,14 @@ BOOST_AUTO_TEST_CASE(compilation_error) } } )"; - Json::Value result = compile(input); - BOOST_CHECK(result.isMember("errors")); + Json result = compile(input); + BOOST_CHECK(result.contains("errors")); BOOST_CHECK(result["errors"].size() >= 1); for (auto const& error: result["errors"]) { - BOOST_REQUIRE(error.isObject()); - BOOST_REQUIRE(error["message"].isString()); - if (error["message"].asString().find("pre-release compiler") == std::string::npos) + BOOST_REQUIRE(error.is_object()); + BOOST_REQUIRE(error["message"].is_string()); + if (error["message"].get().find("pre-release compiler") == std::string::npos) { BOOST_CHECK_EQUAL( util::jsonCompactPrint(error), @@ -516,11 +516,11 @@ BOOST_AUTO_TEST_CASE(output_selection_explicit) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } @@ -545,11 +545,11 @@ BOOST_AUTO_TEST_CASE(output_selection_all_contracts) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } @@ -574,11 +574,11 @@ BOOST_AUTO_TEST_CASE(output_selection_all_files_single_contract) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } @@ -603,11 +603,11 @@ BOOST_AUTO_TEST_CASE(output_selection_all_files_all_contracts) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } @@ -632,11 +632,11 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"); } @@ -664,11 +664,11 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"); } @@ -693,11 +693,11 @@ BOOST_AUTO_TEST_CASE(filename_with_colon) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "http://github.com/ethereum/solidity/std/StandardToken.sol", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isArray()); + Json contract = getContractResult(result, "http://github.com/ethereum/solidity/std/StandardToken.sol", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["abi"].is_array()); BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } @@ -725,10 +725,10 @@ BOOST_AUTO_TEST_CASE(library_filename_with_colon) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); expectLinkReferences(contract, {{"git:library.sol", {"L"}}}); } @@ -747,7 +747,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_top_level) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "\"libraries\" is not a JSON object.")); } @@ -768,7 +768,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_entry) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Library entry is not a JSON object.")); } @@ -791,7 +791,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_hex) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Invalid library address (\"0x4200000000000000000000000000000000000xx1\") supplied.")); } @@ -815,7 +815,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_length) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Library address is of invalid length.")); } @@ -838,7 +838,7 @@ BOOST_AUTO_TEST_CASE(libraries_missing_hex_prefix) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Library address is not prefixed with \"0x\".")); } @@ -874,9 +874,9 @@ BOOST_AUTO_TEST_CASE(library_linking) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_TEST(containsAtMostWarnings(result)); - Json::Value contractResult = getContractResult(result, "fileA", "A"); + Json contractResult = getContractResult(result, "fileA", "A"); expectLinkReferences(contractResult, {{"library2.sol", {"L2"}}}); } @@ -906,9 +906,9 @@ BOOST_AUTO_TEST_CASE(linking_yul) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_TEST(containsAtMostWarnings(result)); - Json::Value contractResult = getContractResult(result, "fileA", "a"); + Json contractResult = getContractResult(result, "fileA", "a"); expectLinkReferences(contractResult, {}); } @@ -938,9 +938,9 @@ BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_TEST(containsAtMostWarnings(result)); - Json::Value contractResult = getContractResult(result, "fileA", "a"); + Json contractResult = getContractResult(result, "fileA", "a"); expectLinkReferences(contractResult, {{"", {""}}}); } @@ -970,9 +970,9 @@ BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_TEST(containsAtMostWarnings(result)); - Json::Value contractResult = getContractResult(result, "fileA", "a"); + Json contractResult = getContractResult(result, "fileA", "a"); expectLinkReferences(contractResult, {{"", {"L"}}}); } @@ -1002,9 +1002,9 @@ BOOST_AUTO_TEST_CASE(linking_yul_same_library_name_different_files) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_TEST(containsAtMostWarnings(result)); - Json::Value contractResult = getContractResult(result, "fileA", "a"); + Json contractResult = getContractResult(result, "fileA", "a"); expectLinkReferences(contractResult, {{"fileC", {"L"}}}); } @@ -1027,37 +1027,37 @@ BOOST_AUTO_TEST_CASE(evm_version) } )"; }; - Json::Value result; + Json result; result = compile(inputForVersion("\"evmVersion\": \"homestead\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"homestead\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"homestead\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"tangerineWhistle\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"tangerineWhistle\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"tangerineWhistle\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"spuriousDragon\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"spuriousDragon\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"spuriousDragon\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"byzantium\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"byzantium\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"byzantium\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"constantinople\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"constantinople\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"constantinople\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"petersburg\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"petersburg\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"petersburg\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"istanbul\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"istanbul\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"istanbul\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"berlin\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"berlin\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"berlin\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"london\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"london\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"london\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"paris\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"paris\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"paris\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"shanghai\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"shanghai\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"shanghai\"") != std::string::npos); result = compile(inputForVersion("\"evmVersion\": \"cancun\",")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"cancun\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"cancun\"") != std::string::npos); // test default result = compile(inputForVersion("")); - BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].asString().find("\"evmVersion\":\"cancun\"") != std::string::npos); + BOOST_CHECK(result["contracts"]["fileA"]["A"]["metadata"].get().find("\"evmVersion\":\"cancun\"") != std::string::npos); // test invalid result = compile(inputForVersion("\"evmVersion\": \"invalid\",")); - BOOST_CHECK(result["errors"][0]["message"].asString() == "Invalid EVM version requested."); + BOOST_CHECK(result["errors"][0]["message"].get() == "Invalid EVM version requested."); } BOOST_AUTO_TEST_CASE(optimizer_settings_default_disabled) @@ -1077,19 +1077,19 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_default_disabled) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - Json::Value metadata; - BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); - - Json::Value const& optimizer = metadata["settings"]["optimizer"]; - BOOST_CHECK(optimizer.isMember("enabled")); - BOOST_CHECK(optimizer["enabled"].asBool() == false); - BOOST_CHECK(!optimizer.isMember("details")); - BOOST_CHECK(optimizer["runs"].asUInt() == 200); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + Json metadata; + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].get(), metadata)); + + Json const& optimizer = metadata["settings"]["optimizer"]; + BOOST_CHECK(optimizer.contains("enabled")); + BOOST_CHECK(optimizer["enabled"].get() == false); + BOOST_CHECK(!optimizer.contains("details")); + BOOST_CHECK(optimizer["runs"].get() == 200); } BOOST_AUTO_TEST_CASE(optimizer_settings_default_enabled) @@ -1110,19 +1110,19 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_default_enabled) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - Json::Value metadata; - BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); - - Json::Value const& optimizer = metadata["settings"]["optimizer"]; - BOOST_CHECK(optimizer.isMember("enabled")); - BOOST_CHECK(optimizer["enabled"].asBool() == true); - BOOST_CHECK(!optimizer.isMember("details")); - BOOST_CHECK(optimizer["runs"].asUInt() == 200); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + Json metadata; + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].get(), metadata)); + + Json const& optimizer = metadata["settings"]["optimizer"]; + BOOST_CHECK(optimizer.contains("enabled")); + BOOST_CHECK(optimizer["enabled"].get() == true); + BOOST_CHECK(!optimizer.contains("details")); + BOOST_CHECK(optimizer["runs"].get() == 200); } BOOST_AUTO_TEST_CASE(optimizer_settings_details_exactly_as_default_disabled) @@ -1150,20 +1150,20 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_exactly_as_default_disabled) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - Json::Value metadata; - BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); - - Json::Value const& optimizer = metadata["settings"]["optimizer"]; - BOOST_CHECK(optimizer.isMember("enabled")); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + Json metadata; + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].get(), metadata)); + + Json const& optimizer = metadata["settings"]["optimizer"]; + BOOST_CHECK(optimizer.contains("enabled")); // enabled is switched to false instead! - BOOST_CHECK(optimizer["enabled"].asBool() == false); - BOOST_CHECK(!optimizer.isMember("details")); - BOOST_CHECK(optimizer["runs"].asUInt() == 200); + BOOST_CHECK(optimizer["enabled"].get() == false); + BOOST_CHECK(!optimizer.contains("details")); + BOOST_CHECK(optimizer["runs"].get() == 200); } BOOST_AUTO_TEST_CASE(optimizer_settings_details_different) @@ -1193,36 +1193,36 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_different) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - Json::Value metadata; - BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); - - Json::Value const& optimizer = metadata["settings"]["optimizer"]; - BOOST_CHECK(!optimizer.isMember("enabled")); - BOOST_CHECK(optimizer.isMember("details")); - BOOST_CHECK(optimizer["details"]["constantOptimizer"].asBool() == true); - BOOST_CHECK(optimizer["details"]["cse"].asBool() == false); - BOOST_CHECK(optimizer["details"]["deduplicate"].asBool() == true); - BOOST_CHECK(optimizer["details"]["jumpdestRemover"].asBool() == true); - BOOST_CHECK(optimizer["details"]["orderLiterals"].asBool() == false); - BOOST_CHECK(optimizer["details"]["peephole"].asBool() == true); - BOOST_CHECK(optimizer["details"]["yul"].asBool() == true); - BOOST_CHECK(optimizer["details"]["yulDetails"].isObject()); - BOOST_CHECK( - util::convertContainer>(optimizer["details"]["yulDetails"].getMemberNames()) == - (std::set{"stackAllocation", "optimizerSteps"}) - ); - BOOST_CHECK(optimizer["details"]["yulDetails"]["stackAllocation"].asBool() == true); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + Json metadata; + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].get(), metadata)); + + Json const& optimizer = metadata["settings"]["optimizer"]; + BOOST_CHECK(!optimizer.contains("enabled")); + BOOST_CHECK(optimizer.contains("details")); + BOOST_CHECK(optimizer["details"]["constantOptimizer"].get() == true); + BOOST_CHECK(optimizer["details"]["cse"].get() == false); + BOOST_CHECK(optimizer["details"]["deduplicate"].get() == true); + BOOST_CHECK(optimizer["details"]["jumpdestRemover"].get() == true); + BOOST_CHECK(optimizer["details"]["orderLiterals"].get() == false); + BOOST_CHECK(optimizer["details"]["peephole"].get() == true); + BOOST_CHECK(optimizer["details"]["yul"].get() == true); + BOOST_CHECK(optimizer["details"]["yulDetails"].is_object()); +// BOOST_CHECK( +// util::convertContainer>(optimizer["details"]["yulDetails"].getMemberNames()) == +// (std::set{"stackAllocation", "optimizerSteps"}) +// ); + BOOST_CHECK(optimizer["details"]["yulDetails"]["stackAllocation"].get() == true); BOOST_CHECK( - optimizer["details"]["yulDetails"]["optimizerSteps"].asString() == + optimizer["details"]["yulDetails"]["optimizerSteps"].get() == OptimiserSettings::DefaultYulOptimiserSteps + ":"s + OptimiserSettings::DefaultYulOptimiserCleanupSteps ); - BOOST_CHECK_EQUAL(optimizer["details"].getMemberNames().size(), 10); - BOOST_CHECK(optimizer["runs"].asUInt() == 600); + BOOST_CHECK_EQUAL(optimizer["details"].size(), 10); + BOOST_CHECK(optimizer["runs"].get() == 600); } BOOST_AUTO_TEST_CASE(metadata_without_compilation) @@ -1250,12 +1250,12 @@ BOOST_AUTO_TEST_CASE(metadata_without_compilation) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].get())); } @@ -1281,13 +1281,13 @@ BOOST_AUTO_TEST_CASE(license_in_metadata) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - Json::Value metadata; - BOOST_REQUIRE(util::jsonParseStrict(contract["metadata"].asString(), metadata)); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + Json metadata; + BOOST_REQUIRE(util::jsonParseStrict(contract["metadata"].get(), metadata)); BOOST_CHECK_EQUAL(metadata["sources"]["fileA"]["license"], "GPL-3.0"); BOOST_CHECK_EQUAL(metadata["sources"]["fileB"]["license"], "MIT"); BOOST_CHECK_EQUAL(metadata["sources"]["fileC"]["license"], "MIT AND GPL-3.0"); @@ -1317,14 +1317,14 @@ BOOST_AUTO_TEST_CASE(common_pattern) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); - BOOST_CHECK(contract["evm"]["bytecode"].isObject()); - BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString()); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.is_object()); + BOOST_CHECK(contract["metadata"].is_string()); + BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].get())); + BOOST_CHECK(contract["evm"]["bytecode"].is_object()); + BOOST_CHECK(contract["evm"]["bytecode"]["object"].is_string()); } BOOST_AUTO_TEST_CASE(use_stack_optimization) @@ -1375,17 +1375,17 @@ BOOST_AUTO_TEST_CASE(use_stack_optimization) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); BOOST_CHECK(containsAtMostWarnings(result)); - Json::Value contract = getContractResult(result, "fileA", "A"); - BOOST_REQUIRE(contract.isObject()); - BOOST_REQUIRE(contract["evm"]["bytecode"]["object"].isString()); - BOOST_CHECK(contract["evm"]["bytecode"]["object"].asString().length() > 20); + Json contract = getContractResult(result, "fileA", "A"); + BOOST_REQUIRE(contract.is_object()); + BOOST_REQUIRE(contract["evm"]["bytecode"]["object"].is_string()); + BOOST_CHECK(contract["evm"]["bytecode"]["object"].get().length() > 20); // Now disable stack optimizations and UnusedFunctionParameterPruner (p) // results in "stack too deep" @@ -1398,10 +1398,10 @@ BOOST_AUTO_TEST_CASE(use_stack_optimization) parsedInput["settings"]["optimizer"]["details"]["yulDetails"]["optimizerSteps"] = optimiserSteps; result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["errors"].isArray()); + BOOST_REQUIRE(result["errors"].is_array()); BOOST_CHECK(result["errors"][0]["severity"] == "error"); - BOOST_REQUIRE(result["errors"][0]["message"].isString()); - BOOST_CHECK(result["errors"][0]["message"].asString().find("When compiling inline assembly") != std::string::npos); + BOOST_REQUIRE(result["errors"][0]["message"].is_string()); + BOOST_CHECK(result["errors"][0]["message"].get().find("When compiling inline assembly") != std::string::npos); BOOST_CHECK(result["errors"][0]["type"] == "CompilerError"); } @@ -1427,22 +1427,22 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["contracts"].isObject()); + BOOST_REQUIRE(result["contracts"].is_object()); BOOST_REQUIRE(result["contracts"].size() == 1); - BOOST_REQUIRE(result["contracts"]["A"].isObject()); + BOOST_REQUIRE(result["contracts"]["A"].is_object()); BOOST_REQUIRE(result["contracts"]["A"].size() == 1); - BOOST_REQUIRE(result["contracts"]["A"]["C"].isObject()); - BOOST_REQUIRE(result["contracts"]["A"]["C"]["evm"].isObject()); - BOOST_REQUIRE(result["contracts"]["A"]["C"]["evm"]["bytecode"].isObject()); - BOOST_REQUIRE(result["sources"].isObject()); + BOOST_REQUIRE(result["contracts"]["A"]["C"].is_object()); + BOOST_REQUIRE(result["contracts"]["A"]["C"]["evm"].is_object()); + BOOST_REQUIRE(result["contracts"]["A"]["C"]["evm"]["bytecode"].is_object()); + BOOST_REQUIRE(result["sources"].is_object()); BOOST_REQUIRE(result["sources"].size() == 1); - BOOST_REQUIRE(result["sources"]["A"].isObject()); + BOOST_REQUIRE(result["sources"]["A"].is_object()); } @@ -1468,22 +1468,22 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_colon_source) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["contracts"].isObject()); + BOOST_REQUIRE(result["contracts"].is_object()); BOOST_REQUIRE(result["contracts"].size() == 1); - BOOST_REQUIRE(result["contracts"][":A"].isObject()); + BOOST_REQUIRE(result["contracts"][":A"].is_object()); BOOST_REQUIRE(result["contracts"][":A"].size() == 1); - BOOST_REQUIRE(result["contracts"][":A"]["C"].isObject()); - BOOST_REQUIRE(result["contracts"][":A"]["C"]["evm"].isObject()); - BOOST_REQUIRE(result["contracts"][":A"]["C"]["evm"]["bytecode"].isObject()); - BOOST_REQUIRE(result["sources"].isObject()); + BOOST_REQUIRE(result["contracts"][":A"]["C"].is_object()); + BOOST_REQUIRE(result["contracts"][":A"]["C"]["evm"].is_object()); + BOOST_REQUIRE(result["contracts"][":A"]["C"]["evm"]["bytecode"].is_object()); + BOOST_REQUIRE(result["sources"].is_object()); BOOST_REQUIRE(result["sources"].size() == 1); - BOOST_REQUIRE(result["sources"][":A"].isObject()); + BOOST_REQUIRE(result["sources"][":A"].is_object()); } BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_empty_source) @@ -1508,22 +1508,22 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_empty_source) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["contracts"].isObject()); + BOOST_REQUIRE(result["contracts"].is_object()); BOOST_REQUIRE(result["contracts"].size() == 1); - BOOST_REQUIRE(result["contracts"][""].isObject()); + BOOST_REQUIRE(result["contracts"][""].is_object()); BOOST_REQUIRE(result["contracts"][""].size() == 1); - BOOST_REQUIRE(result["contracts"][""]["C"].isObject()); - BOOST_REQUIRE(result["contracts"][""]["C"]["evm"].isObject()); - BOOST_REQUIRE(result["contracts"][""]["C"]["evm"]["bytecode"].isObject()); - BOOST_REQUIRE(result["sources"].isObject()); + BOOST_REQUIRE(result["contracts"][""]["C"].is_object()); + BOOST_REQUIRE(result["contracts"][""]["C"]["evm"].is_object()); + BOOST_REQUIRE(result["contracts"][""]["C"]["evm"]["bytecode"].is_object()); + BOOST_REQUIRE(result["sources"].is_object()); BOOST_REQUIRE(result["sources"].size() == 1); - BOOST_REQUIRE(result["sources"][""].isObject()); + BOOST_REQUIRE(result["sources"][""].is_object()); } BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_multiple_sources) @@ -1552,23 +1552,23 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_multiple_sources) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["contracts"].isObject()); + BOOST_REQUIRE(result["contracts"].is_object()); BOOST_REQUIRE(result["contracts"].size() == 1); - BOOST_REQUIRE(result["contracts"]["B"].isObject()); + BOOST_REQUIRE(result["contracts"]["B"].is_object()); BOOST_REQUIRE(result["contracts"]["B"].size() == 1); - BOOST_REQUIRE(result["contracts"]["B"]["D"].isObject()); - BOOST_REQUIRE(result["contracts"]["B"]["D"]["evm"].isObject()); - BOOST_REQUIRE(result["contracts"]["B"]["D"]["evm"]["bytecode"].isObject()); - BOOST_REQUIRE(result["sources"].isObject()); + BOOST_REQUIRE(result["contracts"]["B"]["D"].is_object()); + BOOST_REQUIRE(result["contracts"]["B"]["D"]["evm"].is_object()); + BOOST_REQUIRE(result["contracts"]["B"]["D"]["evm"]["bytecode"].is_object()); + BOOST_REQUIRE(result["sources"].is_object()); BOOST_REQUIRE(result["sources"].size() == 2); - BOOST_REQUIRE(result["sources"]["A"].isObject()); - BOOST_REQUIRE(result["sources"]["B"].isObject()); + BOOST_REQUIRE(result["sources"]["A"].is_object()); + BOOST_REQUIRE(result["sources"]["B"].is_object()); } BOOST_AUTO_TEST_CASE(stopAfter_invalid_value) @@ -1588,7 +1588,7 @@ BOOST_AUTO_TEST_CASE(stopAfter_invalid_value) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Invalid value for \"settings.stopAfter\". Only valid value is \"parsing\".")); } @@ -1609,7 +1609,7 @@ BOOST_AUTO_TEST_CASE(stopAfter_invalid_type) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "\"settings.stopAfter\" must be a string.")); } @@ -1630,7 +1630,7 @@ BOOST_AUTO_TEST_CASE(stopAfter_bin_conflict) } } )"; - Json::Value result = compile(input); + Json result = compile(input); BOOST_CHECK(containsError(result, "JSONError", "Requested output selection conflicts with \"settings.stopAfter\".")); } @@ -1650,10 +1650,10 @@ BOOST_AUTO_TEST_CASE(stopAfter_ast_output) } } )"; - Json::Value result = compile(input); - BOOST_CHECK(result["sources"].isObject()); - BOOST_CHECK(result["sources"]["a.sol"].isObject()); - BOOST_CHECK(result["sources"]["a.sol"]["ast"].isObject()); + Json result = compile(input); + BOOST_CHECK(result["sources"].is_object()); + BOOST_CHECK(result["sources"]["a.sol"].is_object()); + BOOST_CHECK(result["sources"]["a.sol"]["ast"].is_object()); } BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract) @@ -1679,21 +1679,21 @@ BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["contracts"].isObject()); + BOOST_REQUIRE(result["contracts"].is_object()); BOOST_REQUIRE(result["contracts"].size() == 1); - BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].isObject()); + BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].is_object()); BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].size() == 1); - BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"].isObject()); - BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"].isObject()); - BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["ir"].isString()); - BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"]["bytecode"].isObject()); - BOOST_REQUIRE(result["sources"].isObject()); + BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"].is_object()); + BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"].is_object()); + BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["ir"].is_string()); + BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"]["bytecode"].is_object()); + BOOST_REQUIRE(result["sources"].is_object()); BOOST_REQUIRE(result["sources"].size() == 2); } @@ -1717,20 +1717,20 @@ BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract_yul) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - BOOST_REQUIRE(result["contracts"].isObject()); + BOOST_REQUIRE(result["contracts"].is_object()); BOOST_REQUIRE(result["contracts"].size() == 1); - BOOST_REQUIRE(result["contracts"]["A.sol"].isObject()); + BOOST_REQUIRE(result["contracts"]["A.sol"].is_object()); BOOST_REQUIRE(result["contracts"]["A.sol"].size() == 1); - BOOST_REQUIRE(result["contracts"]["A.sol"]["C"].isObject()); - BOOST_REQUIRE(result["contracts"]["A.sol"]["C"]["ir"].isString()); + BOOST_REQUIRE(result["contracts"]["A.sol"]["C"].is_object()); + BOOST_REQUIRE(result["contracts"]["A.sol"]["C"]["ir"].is_string()); - const std::string& irCode = result["contracts"]["A.sol"]["C"]["ir"].asString(); + const std::string& irCode = result["contracts"]["A.sol"]["C"]["ir"].get(); // Make sure C and B contracts are deployed BOOST_REQUIRE(irCode.find("object \"C") != std::string::npos); @@ -1742,7 +1742,7 @@ BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract_yul) BOOST_REQUIRE(irCode.find("object \"D") == std::string::npos); - BOOST_REQUIRE(result["sources"].isObject()); + BOOST_REQUIRE(result["sources"].is_object()); BOOST_REQUIRE(result["sources"].size() == 1); } @@ -1766,13 +1766,13 @@ BOOST_AUTO_TEST_CASE(source_location_of_bare_block) } )"; - Json::Value parsedInput; + Json parsedInput; BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); solidity::frontend::StandardCompiler compiler; - Json::Value result = compiler.compile(parsedInput); + Json result = compiler.compile(parsedInput); - std::string sourceMap = result["contracts"]["A.sol"]["A"]["evm"]["bytecode"]["sourceMap"].asString(); + std::string sourceMap = result["contracts"]["A.sol"]["A"]["evm"]["bytecode"]["sourceMap"].get(); // Check that the bare block's source location is referenced. std::string sourceRef = diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index f17898c042a5..f350ea4624b1 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -51,6 +51,16 @@ SyntaxTest::SyntaxTest( if (!util::contains(compileViaYulAllowedValues, m_compileViaYul)) BOOST_THROW_EXCEPTION(std::runtime_error("Invalid compileViaYul value: " + m_compileViaYul + ".")); m_optimiseYul = m_reader.boolSetting("optimize-yul", true); + + static std::map const pipelineStages = { + {"parsing", PipelineStage::Parsing}, + {"analysis", PipelineStage::Analysis}, + {"compilation", PipelineStage::Compilation} + }; + std::string stopAfter = m_reader.stringSetting("stopAfter", "compilation"); + if (!pipelineStages.count(stopAfter)) + BOOST_THROW_EXCEPTION(std::runtime_error("Invalid stopAfter value: " + stopAfter + ".")); + m_stopAfter = pipelineStages.at(stopAfter); } void SyntaxTest::setupCompiler(CompilerStack& _compiler) @@ -72,7 +82,7 @@ void SyntaxTest::parseAndAnalyze() { try { - runFramework(withPreamble(m_sources.sources), PipelineStage::Compilation); + runFramework(withPreamble(m_sources.sources), m_stopAfter); if (!pipelineSuccessful() && stageSuccessful(PipelineStage::Analysis) && !compiler().isExperimentalAnalysis()) { ErrorList const& errors = compiler().errors(); diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index 95df3c6cd80c..085a32f944ea 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -55,6 +55,7 @@ class SyntaxTest: public AnalysisFramework, public solidity::test::CommonSyntaxT bool m_optimiseYul{}; std::string m_compileViaYul{}; langutil::Error::Severity m_minSeverity{}; + PipelineStage m_stopAfter; }; } diff --git a/test/libsolidity/gasTests/abiv2_optimised.sol b/test/libsolidity/gasTests/abiv2_optimised.sol index 8f407e6ede24..2989c1acd8f9 100644 --- a/test/libsolidity/gasTests/abiv2_optimised.sol +++ b/test/libsolidity/gasTests/abiv2_optimised.sol @@ -17,9 +17,9 @@ contract C { // optimize-yul: true // ---- // creation: -// codeDepositCost: 634600 -// executionCost: 668 -// totalCost: 635268 +// codeDepositCost: 618200 +// executionCost: 649 +// totalCost: 618849 // external: // a(): 2283 // b(uint256): 4649 diff --git a/test/libsolidity/natspecJSON/dev_multiple_params_mixed_whitespace.sol b/test/libsolidity/natspecJSON/dev_multiple_params_mixed_whitespace.sol index 61f45aa6204d..fc3fd4d71f90 100644 --- a/test/libsolidity/natspecJSON/dev_multiple_params_mixed_whitespace.sol +++ b/test/libsolidity/natspecJSON/dev_multiple_params_mixed_whitespace.sol @@ -1,7 +1,7 @@ contract test { - /// @dev Multiplies a number by 7 and adds second parameter - /// @param a Documentation for the first parameter - /// @param second Documentation for the second parameter + /// @dev Multiplies a number by 7 and adds second parameter + /// @param a Documentation for the first parameter + /// @param second Documentation for the second parameter function mul(uint a, uint second) public returns (uint d) { return a * 7 + second; } } diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol index b4ef43c44172..8d74a34f48bb 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol @@ -21,6 +21,6 @@ contract C { } // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb -// gas irOptimized: 203149 +// gas irOptimized: 203173 // gas legacy: 206263 -// gas legacyOptimized: 203156 +// gas legacyOptimized: 203172 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index 3dd5dd269340..a518a3750ede 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -59,10 +59,10 @@ contract C { // EVMVersion: >homestead // ---- // test_bytes() -> -// gas irOptimized: 306908 +// gas irOptimized: 314884 // gas legacy: 305827 -// gas legacyOptimized: 255013 +// gas legacyOptimized: 253681 // test_uint256() -> -// gas irOptimized: 435054 +// gas irOptimized: 448346 // gas legacy: 421315 -// gas legacyOptimized: 352838 +// gas legacyOptimized: 351650 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index efffab86c1cf..c8eb95418906 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -24,6 +24,6 @@ contract C { // ---- // library: L // f() -> 8, 7, 1, 2, 7, 12 -// gas irOptimized: 166475 +// gas irOptimized: 166759 // gas legacy: 169283 // gas legacyOptimized: 167248 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 5457e7f6743e..b80d14d6b02b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -60,10 +60,10 @@ contract C { // EVMVersion: >homestead // ---- // test_bytes() -> -// gas irOptimized: 306908 +// gas irOptimized: 314884 // gas legacy: 305827 -// gas legacyOptimized: 255013 +// gas legacyOptimized: 253681 // test_uint256() -> -// gas irOptimized: 435054 +// gas irOptimized: 448346 // gas legacy: 421315 -// gas legacyOptimized: 352838 +// gas legacyOptimized: 351650 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol index c0d5f5d3fb9c..f07d4039d5d7 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol @@ -50,6 +50,6 @@ contract C { // f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3 -// gas irOptimized: 111708 +// gas irOptimized: 111816 // gas legacy: 113892 -// gas legacyOptimized: 111646 +// gas legacyOptimized: 111658 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol index c41905e2a491..bb3ad1aad1a9 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol @@ -30,9 +30,9 @@ contract C is B { } // ---- // test() -> 77 -// gas irOptimized: 55148 -// gas irOptimized code: 55200 +// gas irOptimized: 55117 +// gas irOptimized code: 56800 // gas legacy: 57266 // gas legacy code: 94600 -// gas legacyOptimized: 55173 -// gas legacyOptimized code: 55200 +// gas legacyOptimized: 55195 +// gas legacyOptimized code: 55000 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index f749e403b567..cdce1b95a529 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -20,6 +20,6 @@ contract C { // f(uint256[][1]): 32, 32, 0 -> true // f(uint256[][1]): 32, 32, 1, 42 -> true // f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true -// gas irOptimized: 117157 +// gas irOptimized: 120978 // gas legacy: 101568 // gas legacyOptimized: 119092 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol index 46df313331e4..81c9c46c6efa 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol @@ -33,8 +33,8 @@ contract C { // f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1, 5, 6 -> 0x20, 0x40, 5, 2 // f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1 -> FAILURE // f_storage(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0x60, 0x20, 1, 2 -// gas irOptimized: 111395 +// gas irOptimized: 111415 // gas legacy: 112709 -// gas legacyOptimized: 111852 +// gas legacyOptimized: 111847 // f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0x80, 0x20, 2, 5, 6 // f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol index 14699df57219..7eb93d401989 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol @@ -18,10 +18,10 @@ contract C { // EVMVersion: >homestead // ---- // h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324 -// gas irOptimized: 180103 +// gas irOptimized: 180086 // gas legacy: 184235 -// gas legacyOptimized: 180873 +// gas legacyOptimized: 180857 // i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224 -// gas irOptimized: 112104 +// gas irOptimized: 112031 // gas legacy: 115091 -// gas legacyOptimized: 112666 +// gas legacyOptimized: 112657 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol index 9f59c43155ee..93e20b475e9c 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol @@ -8,6 +8,6 @@ contract C { } // ---- // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" -// gas irOptimized: 135452 +// gas irOptimized: 135505 // gas legacy: 137096 -// gas legacyOptimized: 135834 +// gas legacyOptimized: 135824 diff --git a/test/libsolidity/semanticTests/array/array_memory_index_access.sol b/test/libsolidity/semanticTests/array/array_memory_index_access.sol index d313e7acb234..49fc58c45de4 100644 --- a/test/libsolidity/semanticTests/array/array_memory_index_access.sol +++ b/test/libsolidity/semanticTests/array/array_memory_index_access.sol @@ -26,7 +26,7 @@ contract C { // index(uint256): 10 -> true // index(uint256): 20 -> true // index(uint256): 0xFF -> true -// gas irOptimized: 108291 +// gas irOptimized: 108272 // gas legacy: 181523 // gas legacyOptimized: 117443 // accessIndex(uint256,int256): 10, 1 -> 2 diff --git a/test/libsolidity/semanticTests/array/array_storage_index_access.sol b/test/libsolidity/semanticTests/array/array_storage_index_access.sol index 2589e4709dae..2957e6d98d61 100644 --- a/test/libsolidity/semanticTests/array/array_storage_index_access.sol +++ b/test/libsolidity/semanticTests/array/array_storage_index_access.sol @@ -16,38 +16,38 @@ contract C { // ---- // test_indices(uint256): 1 -> // test_indices(uint256): 129 -> -// gas irOptimized: 3003025 +// gas irOptimized: 3017687 // gas legacy: 3038654 // gas legacyOptimized: 2995964 // test_indices(uint256): 5 -> -// gas irOptimized: 576296 +// gas irOptimized: 579670 // gas legacy: 573810 // gas legacyOptimized: 571847 // test_indices(uint256): 10 -> -// gas irOptimized: 157009 +// gas irOptimized: 157953 // gas legacy: 160108 // gas legacyOptimized: 156996 // test_indices(uint256): 15 -> -// gas irOptimized: 171409 +// gas irOptimized: 172733 // gas legacy: 175973 // gas legacyOptimized: 171596 // test_indices(uint256): 0xFF -> -// gas irOptimized: 5645329 +// gas irOptimized: 5673823 // gas legacy: 5715748 // gas legacyOptimized: 5632556 // test_indices(uint256): 1000 -> -// gas irOptimized: 18068701 +// gas irOptimized: 18173005 // gas legacy: 18347810 // gas legacyOptimized: 18037248 // test_indices(uint256): 129 -> -// gas irOptimized: 4136840 +// gas irOptimized: 4166279 // gas legacy: 4140113 // gas legacyOptimized: 4108272 // test_indices(uint256): 128 -> -// gas irOptimized: 395769 +// gas irOptimized: 405522 // gas legacy: 433498 // gas legacyOptimized: 400909 // test_indices(uint256): 1 -> -// gas irOptimized: 580232 +// gas irOptimized: 583437 // gas legacy: 576715 // gas legacyOptimized: 575542 diff --git a/test/libsolidity/semanticTests/array/array_storage_index_boundary_test.sol b/test/libsolidity/semanticTests/array/array_storage_index_boundary_test.sol index c77aad0a4515..494c99782f22 100644 --- a/test/libsolidity/semanticTests/array/array_storage_index_boundary_test.sol +++ b/test/libsolidity/semanticTests/array/array_storage_index_boundary_test.sol @@ -16,11 +16,11 @@ contract C { // test_boundary_check(uint256,uint256): 1, 1 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 10, 10 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 256, 256 -> FAILURE, hex"4e487b71", 0x32 -// gas irOptimized: 137913 +// gas irOptimized: 147246 // gas legacy: 133633 // gas legacyOptimized: 114354 // test_boundary_check(uint256,uint256): 256, 255 -> 0 -// gas irOptimized: 140048 +// gas irOptimized: 149422 // gas legacy: 135949 // gas legacyOptimized: 116533 // test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/array/array_storage_index_zeroed_test.sol b/test/libsolidity/semanticTests/array/array_storage_index_zeroed_test.sol index 593358659341..de260b373574 100644 --- a/test/libsolidity/semanticTests/array/array_storage_index_zeroed_test.sol +++ b/test/libsolidity/semanticTests/array/array_storage_index_zeroed_test.sol @@ -52,18 +52,18 @@ contract C { // ---- // test_zeroed_indicies(uint256): 1 -> // test_zeroed_indicies(uint256): 5 -> -// gas irOptimized: 131315 +// gas irOptimized: 133763 // gas legacy: 131671 // gas legacyOptimized: 129994 // test_zeroed_indicies(uint256): 10 -> -// gas irOptimized: 224578 +// gas irOptimized: 228556 // gas legacy: 225237 // gas legacyOptimized: 222359 // test_zeroed_indicies(uint256): 15 -> -// gas irOptimized: 321962 +// gas irOptimized: 327360 // gas legacy: 322937 // gas legacyOptimized: 318919 // test_zeroed_indicies(uint256): 0xFF -> -// gas irOptimized: 5080806 +// gas irOptimized: 5180120 // gas legacy: 5093941 // gas legacyOptimized: 5020727 diff --git a/test/libsolidity/semanticTests/array/array_storage_length_access.sol b/test/libsolidity/semanticTests/array/array_storage_length_access.sol index 0669a320971d..47fddc5547bc 100644 --- a/test/libsolidity/semanticTests/array/array_storage_length_access.sol +++ b/test/libsolidity/semanticTests/array/array_storage_length_access.sol @@ -16,7 +16,7 @@ contract C { // gas legacy: 128571 // gas legacyOptimized: 110143 // set_get_length(uint256): 0xFFF -> 0xFFF -// gas irOptimized: 1209119 +// gas irOptimized: 1209116 // gas legacy: 1689548 // gas legacyOptimized: 1393535 // set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/array/array_storage_push_empty.sol b/test/libsolidity/semanticTests/array/array_storage_push_empty.sol index 80376b423f62..b84cdd90a374 100644 --- a/test/libsolidity/semanticTests/array/array_storage_push_empty.sol +++ b/test/libsolidity/semanticTests/array/array_storage_push_empty.sol @@ -12,11 +12,11 @@ contract C { // EVMVersion: >=petersburg // ---- // pushEmpty(uint256): 128 -// gas irOptimized: 401024 +// gas irOptimized: 410745 // gas legacy: 400640 // gas legacyOptimized: 388804 // pushEmpty(uint256): 256 -// gas irOptimized: 683700 +// gas irOptimized: 698285 // gas legacy: 685108 // gas legacyOptimized: 671480 // pushEmpty(uint256): 38869 -> FAILURE # out-of-gas # diff --git a/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol b/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol index 4b5b407eaff5..607e1ecd3547 100644 --- a/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol +++ b/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol @@ -21,11 +21,11 @@ contract C { // gas legacy: 77730 // gas legacyOptimized: 77162 // set_get_length(uint256): 0xFF -> 0xFF -// gas irOptimized: 158881 +// gas irOptimized: 168565 // gas legacy: 696850 // gas legacyOptimized: 134488 // set_get_length(uint256): 0xFFF -> 0xFFF -// gas irOptimized: 1762213 +// gas irOptimized: 1908127 // gas legacy: 9857362 // gas legacyOptimized: 1393660 // set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/array/array_storage_push_pop.sol b/test/libsolidity/semanticTests/array/array_storage_push_pop.sol index 5befbe2282b2..78a74ab5d4ff 100644 --- a/test/libsolidity/semanticTests/array/array_storage_push_pop.sol +++ b/test/libsolidity/semanticTests/array/array_storage_push_pop.sol @@ -17,11 +17,11 @@ contract C { // gas legacy: 105722 // gas legacyOptimized: 103508 // set_get_length(uint256): 0xFF -> 0 -// gas irOptimized: 815997 +// gas irOptimized: 833586 // gas legacy: 808020 // gas legacyOptimized: 784467 // set_get_length(uint256): 0xFFF -> 0 -// gas irOptimized: 12746889 +// gas irOptimized: 13029438 // gas legacy: 12612192 // gas legacyOptimized: 12239199 // set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol index 95280054aae7..918185e9afa2 100644 --- a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol @@ -12,9 +12,9 @@ contract Test { } // ---- // set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06 -// gas irOptimized: 186557 +// gas irOptimized: 185219 // gas legacy: 211054 -// gas legacyOptimized: 206042 +// gas legacyOptimized: 206077 // data(uint256,uint256): 0x02, 0x02 -> 0x09 // data(uint256,uint256): 0x05, 0x01 -> 0x11 // data(uint256,uint256): 0x06, 0x00 -> FAILURE diff --git a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol index 3e0f02225bce..401f97a1c97a 100644 --- a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol +++ b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol @@ -17,6 +17,6 @@ contract c { } // ---- // test() -> 0 -// gas irOptimized: 123560 +// gas irOptimized: 122719 // gas legacy: 147098 // gas legacyOptimized: 144200 diff --git a/test/libsolidity/semanticTests/array/bytes_length_member.sol b/test/libsolidity/semanticTests/array/bytes_length_member.sol index 0a3c58b3ac92..105bbfba8d53 100644 --- a/test/libsolidity/semanticTests/array/bytes_length_member.sol +++ b/test/libsolidity/semanticTests/array/bytes_length_member.sol @@ -13,7 +13,7 @@ contract c { // ---- // getLength() -> 0 // set(): 1, 2 -> true -// gas irOptimized: 110393 +// gas irOptimized: 110425 // gas legacy: 110952 // gas legacyOptimized: 110576 // getLength() -> 68 diff --git a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol index 19acb7cba14b..342f3218fcb4 100644 --- a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol +++ b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol @@ -8,11 +8,11 @@ contract C { } // ---- // constructor(): 1, 2, 3 -> -// gas irOptimized: 124816 +// gas irOptimized: 124991 // gas irOptimized code: 14800 // gas legacy: 134317 // gas legacy code: 46200 -// gas legacyOptimized: 127062 +// gas legacyOptimized: 127166 // gas legacyOptimized code: 23400 // a(uint256): 0 -> 1 // a(uint256): 1 -> 2 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol index 80ecd3e1cef4..96580c47db8c 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol @@ -20,7 +20,7 @@ contract c { } // ---- // store(uint256[9],uint8[3][]): 21, 22, 23, 24, 25, 26, 27, 28, 29, 0x140, 4, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33 -> 32 -// gas irOptimized: 648315 +// gas irOptimized: 647725 // gas legacy: 694356 -// gas legacyOptimized: 693864 +// gas legacyOptimized: 693850 // retrieve() -> 9, 28, 9, 28, 4, 3, 32 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol index 600f00a98110..9609215a7dca 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol @@ -46,6 +46,6 @@ contract C { } // ---- // f() -> true -// gas irOptimized: 117264 +// gas irOptimized: 122592 // gas legacy: 124660 // gas legacyOptimized: 122801 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol index 0bdcda1d9e7f..6c0ba7af6928 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol @@ -13,6 +13,6 @@ contract C { } // ---- // f() -> 0 -// gas irOptimized: 107453 +// gas irOptimized: 108246 // gas legacy: 108218 // gas legacyOptimized: 107625 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol index 6e81269d8a50..2176655fe389 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol @@ -18,6 +18,6 @@ contract c { } // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000 -// gas irOptimized: 207889 +// gas irOptimized: 208459 // gas legacy: 220707 // gas legacyOptimized: 220098 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol index 385f2ecfbf1e..20aee3a293f4 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol @@ -35,12 +35,12 @@ contract c { } // ---- // test() -> 0x02000202 -// gas irOptimized: 4547793 +// gas irOptimized: 4549703 // gas legacy: 4475396 // gas legacyOptimized: 4447665 // storageEmpty -> 1 // clear() -> 0, 0 -// gas irOptimized: 4474777 +// gas irOptimized: 4478226 // gas legacy: 4407188 // gas legacyOptimized: 4381336 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol index 737e4b32bc1d..0420f953bb56 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol @@ -12,6 +12,6 @@ contract c { } // ---- // test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10 -// gas irOptimized: 689656 +// gas irOptimized: 689558 // gas legacy: 686178 -// gas legacyOptimized: 685628 +// gas legacyOptimized: 685612 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol index d477dc6cf978..e292809b800a 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol @@ -17,6 +17,6 @@ contract c { } // ---- // test() -> 5, 4 -// gas irOptimized: 205044 +// gas irOptimized: 205667 // gas legacy: 213863 // gas legacyOptimized: 212902 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol index 0571195861b7..44fede749cc4 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol @@ -21,6 +21,6 @@ contract c { } // ---- // test() -> 3, 4 -// gas irOptimized: 169565 +// gas irOptimized: 169669 // gas legacy: 175424 // gas legacyOptimized: 172535 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol index 99dd1ca934ff..1f102ea14a7c 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol @@ -15,7 +15,7 @@ contract c { // ---- // setData1(uint256,uint256,uint256): 10, 5, 4 -> // copyStorageStorage() -> -// gas irOptimized: 111348 +// gas irOptimized: 111353 // gas legacy: 109272 // gas legacyOptimized: 109262 // getData2(uint256): 5 -> 10, 4 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol index 30173409eb77..03c1f4e8753c 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol @@ -17,6 +17,6 @@ contract c { } // ---- // test() -> 5, 4 -// gas irOptimized: 252929 +// gas irOptimized: 253591 // gas legacy: 250892 // gas legacyOptimized: 250046 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol index 971469dec64f..f4bf1b2d2131 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol @@ -11,6 +11,6 @@ contract c { } // ---- // test() -> 9, 4 -// gas irOptimized: 123135 +// gas irOptimized: 123180 // gas legacy: 123567 // gas legacyOptimized: 123202 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol index 0d613e5e946b..145a8060edb1 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol @@ -14,6 +14,6 @@ contract c { } // ---- // test() -> 8, 0 -// gas irOptimized: 196259 +// gas irOptimized: 196251 // gas legacy: 194843 // gas legacyOptimized: 194281 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol index cfb623393c87..7fa5ee515f87 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol @@ -17,7 +17,7 @@ contract c { } // ---- // test() -> 4, 5 -// gas irOptimized: 190694 +// gas irOptimized: 190628 // gas legacy: 190852 // gas legacyOptimized: 189658 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol index 6bd31ca5af46..d88ac0674672 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol @@ -15,6 +15,6 @@ contract C { } // ---- // f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3 -// gas irOptimized: 161624 +// gas irOptimized: 161793 // gas legacy: 162203 -// gas legacyOptimized: 159934 +// gas legacyOptimized: 159953 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol index 10a48a18c574..ebfbdeab9720 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol @@ -17,6 +17,6 @@ contract c { } // ---- // test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 100980 +// gas irOptimized: 100495 // gas legacy: 158142 -// gas legacyOptimized: 141096 +// gas legacyOptimized: 141020 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol index a839e3bb44b2..309753066510 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol @@ -18,6 +18,6 @@ contract c { } // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x0 -// gas irOptimized: 273372 +// gas irOptimized: 273545 // gas legacy: 282604 // gas legacyOptimized: 281510 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol index f9e1cbd27ef1..b08487417547 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol @@ -18,6 +18,6 @@ contract c { } // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x00 -// gas irOptimized: 233118 +// gas irOptimized: 232997 // gas legacy: 235697 // gas legacyOptimized: 235193 diff --git a/test/libsolidity/semanticTests/array/copying/array_elements_to_mapping.sol b/test/libsolidity/semanticTests/array/copying/array_elements_to_mapping.sol index b1e8659be8df..085f72ed96c1 100644 --- a/test/libsolidity/semanticTests/array/copying/array_elements_to_mapping.sol +++ b/test/libsolidity/semanticTests/array/copying/array_elements_to_mapping.sol @@ -52,9 +52,9 @@ contract C { } // ---- // from_storage() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 -// gas irOptimized: 150004 +// gas irOptimized: 149880 // gas legacy: 150745 -// gas legacyOptimized: 148678 +// gas legacyOptimized: 148700 // from_storage_ptr() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 // from_memory() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 // from_calldata(uint8[][]): 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol index 919e83298675..ac37f794e147 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol @@ -38,10 +38,10 @@ contract c { // compileViaYul: true // ---- // test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// gas irOptimized: 180716 +// gas irOptimized: 181041 // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// gas irOptimized: 157544 +// gas irOptimized: 157604 // test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65 -// gas irOptimized: 134634 +// gas irOptimized: 134813 // test4(uint256[2][2]): 23, 42, 23, 42 -> 65 -// gas irOptimized: 111252 +// gas irOptimized: 111177 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol index eb4b1bbb9aab..e2228f993f07 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol @@ -38,12 +38,12 @@ contract Test { } // ---- // test() -> 24 -// gas irOptimized: 226666 +// gas irOptimized: 226743 // gas legacy: 227084 // gas legacyOptimized: 226529 // test1() -> 3 // test2() -> 6 // test3() -> 24 -// gas irOptimized: 141225 +// gas irOptimized: 141325 // gas legacy: 142238 // gas legacyOptimized: 141365 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol index 01329504d2a9..ab3c172d3399 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol @@ -45,7 +45,7 @@ contract C { } // ---- // copyExternalStorageArrayOfFunctionType() -> true -// gas irOptimized: 104592 +// gas irOptimized: 104566 // gas legacy: 108554 -// gas legacyOptimized: 102413 +// gas legacyOptimized: 102405 // copyInternalArrayOfFunctionType() -> true diff --git a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol index 50756d0b0c3d..2bb3bcf333e3 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol @@ -48,8 +48,8 @@ contract C { } // ---- // copyExternalStorageArraysOfFunctionType() -> true -// gas irOptimized: 104265 +// gas irOptimized: 104238 // gas legacy: 108295 -// gas legacyOptimized: 102146 +// gas legacyOptimized: 102162 // copyInternalArrayOfFunctionType() -> true // gas legacy: 104178 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol index 546a6e49e48d..3147401cfa1d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol @@ -17,4 +17,4 @@ contract C { // compileViaYul: true // ---- // f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 -// gas irOptimized: 119704 +// gas irOptimized: 120747 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol index 38e26e480add..5b3fe1f7016f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol @@ -19,4 +19,4 @@ contract C { // compileViaYul: true // ---- // f() -> 10, 11, 12 -// gas irOptimized: 118362 +// gas irOptimized: 118796 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol index c6e6c58765ac..09037719a6f0 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol @@ -23,4 +23,4 @@ contract C { // compileViaYul: true // ---- // f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1 -// gas irOptimized: 326771 +// gas irOptimized: 327456 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol index 510e7c9a4a62..8b6ad78ea777 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol @@ -26,4 +26,4 @@ contract C { // compileViaYul: true // ---- // f() -> 3, 3, 3, 1 -// gas irOptimized: 181890 +// gas irOptimized: 181932 diff --git a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol index 5c44ef16a54d..82e65edf1d49 100644 --- a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol +++ b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol @@ -12,6 +12,6 @@ contract C { } // ---- // f() -> 1, 2, 3 -// gas irOptimized: 131915 +// gas irOptimized: 131939 // gas legacy: 134606 // gas legacyOptimized: 131938 diff --git a/test/libsolidity/semanticTests/array/copying/array_to_mapping.sol b/test/libsolidity/semanticTests/array/copying/array_to_mapping.sol index 50ea19a1eab4..75a68759b6e0 100644 --- a/test/libsolidity/semanticTests/array/copying/array_to_mapping.sol +++ b/test/libsolidity/semanticTests/array/copying/array_to_mapping.sol @@ -37,8 +37,8 @@ contract C { } // ---- // from_storage() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 -// gas irOptimized: 147871 +// gas irOptimized: 147761 // gas legacy: 148896 -// gas legacyOptimized: 146901 +// gas legacyOptimized: 146923 // from_storage_ptr() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 // from_memory() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 diff --git a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol index 0deb396d3d66..af2983b066bd 100644 --- a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol @@ -12,7 +12,7 @@ contract Test { // set(uint24[]): 0x20, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -> 18 // gas irOptimized: 99616 // gas legacy: 103509 -// gas legacyOptimized: 101390 +// gas legacyOptimized: 101266 // data(uint256): 7 -> 8 // data(uint256): 15 -> 16 // data(uint256): 18 -> FAILURE diff --git a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol index 19e5ddebd443..e61b7dff7a5f 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol @@ -5,11 +5,11 @@ contract c { } // ---- // set(uint256): 1, 2 -> true -// gas irOptimized: 110558 +// gas irOptimized: 110550 // gas legacy: 111312 // gas legacyOptimized: 110741 // set(uint256): 2, 2, 3, 4, 5 -> true -// gas irOptimized: 177509 +// gas irOptimized: 177501 // gas legacy: 178314 // gas legacyOptimized: 177716 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol index 24565b4c62a6..ea364d4378ec 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol @@ -17,25 +17,25 @@ contract c { // ---- // f(uint256): 0 -> 0x20, 0x00 // f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00 -// gas irOptimized: 103283 +// gas irOptimized: 103269 // gas legacy: 112883 -// gas legacyOptimized: 112629 +// gas legacyOptimized: 112647 // f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671 -// gas irOptimized: 117740 +// gas irOptimized: 117928 // gas legacy: 128943 -// gas legacyOptimized: 128864 +// gas legacyOptimized: 128854 // f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 124080 +// gas irOptimized: 124200 // gas legacy: 136071 -// gas legacyOptimized: 135479 +// gas legacyOptimized: 135469 // f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992 -// gas irOptimized: 127140 +// gas irOptimized: 127350 // gas legacy: 148671 -// gas legacyOptimized: 148709 +// gas legacyOptimized: 148699 // f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000 // gas legacy: 59345 // gas legacyOptimized: 57279 // f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968 -// gas irOptimized: 416966 +// gas irOptimized: 417312 // gas legacy: 458976 -// gas legacyOptimized: 460674 +// gas legacyOptimized: 460664 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol index 706232d589f7..1da1d0a40c78 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol @@ -9,6 +9,6 @@ contract C { } // ---- // f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1 -// gas irOptimized: 110968 +// gas irOptimized: 111096 // gas legacy: 111551 -// gas legacyOptimized: 111339 +// gas legacyOptimized: 111323 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_to_mapping.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_to_mapping.sol index e6bf7671a1b0..48460586d280 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_to_mapping.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_to_mapping.sol @@ -14,4 +14,4 @@ contract C { // compileViaYul: true // ---- // from_calldata(uint8[][]): 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14 -// gas irOptimized: 139683 +// gas irOptimized: 139587 diff --git a/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol b/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol index 36b94d7c3974..e6284072d1f9 100644 --- a/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol +++ b/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol @@ -16,8 +16,8 @@ contract C { } // ---- // constructor() -// gas irOptimized: 89121 -// gas irOptimized code: 137200 +// gas irOptimized: 90065 +// gas irOptimized code: 149000 // gas legacy: 89553 // gas legacy code: 126200 // gas legacyOptimized: 83556 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol index 33a4c7045af5..7c0459ef139e 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol @@ -35,12 +35,12 @@ contract C { } // ---- // f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000 -// gas irOptimized: 179420 +// gas irOptimized: 179408 // gas legacy: 180675 -// gas legacyOptimized: 179700 +// gas legacyOptimized: 179686 // g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000 -// gas irOptimized: 106349 +// gas irOptimized: 106344 // gas legacy: 109394 -// gas legacyOptimized: 106614 +// gas legacyOptimized: 106600 // h() -> 0x40, 0x60, 0x00, 0x00 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol index d4599cdb7e58..1fd42ab34621 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol @@ -46,6 +46,6 @@ contract C { } // ---- // f() -> 0xff -// gas irOptimized: 143412 +// gas irOptimized: 143867 // gas legacy: 153395 -// gas legacyOptimized: 146720 +// gas legacyOptimized: 146689 diff --git a/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol b/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol index fb2177901239..a6a64942d2ad 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol @@ -15,6 +15,6 @@ contract C { } // ---- // test() -> 7 -// gas irOptimized: 122455 +// gas irOptimized: 122461 // gas legacy: 205176 // gas legacyOptimized: 204971 diff --git a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol index 85c396fb4e12..48d02bdc7737 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol @@ -7,7 +7,7 @@ contract c { } // ---- // set(): 1, 2, 3, 4, 5 -> true -// gas irOptimized: 177376 +// gas irOptimized: 177344 // gas legacy: 177954 // gas legacyOptimized: 177550 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_calldata_to_storage.sol index ea5625f21d39..672e7435f1a9 100644 --- a/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_calldata_to_storage.sol @@ -31,8 +31,8 @@ contract C { // compileViaYul: true // ---- // test1((uint8[],uint8[2])[][][]): 0x20, 1, 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -// gas irOptimized: 327874 +// gas irOptimized: 327921 // test2((uint8[],uint8[2])[][1][]): 0x20, 2, 0x40, 0x0160, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13, 0x20, 1, 0x20, 0x60, 31, 37, 2, 23, 29 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 140879 +// gas irOptimized: 141162 // test3((uint8[],uint8[2])[1][][2]): 0x20, 0x40, 0x60, 0, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 188535 +// gas irOptimized: 188442 diff --git a/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_memory_to_storage.sol index 96f24f77da19..f232d8aba9d4 100644 --- a/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/elements_of_nested_array_of_structs_memory_to_storage.sol @@ -31,8 +31,8 @@ contract C { // compileViaYul: true // ---- // test1((uint8[],uint8[2])[][][]): 0x20, 1, 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -// gas irOptimized: 332660 +// gas irOptimized: 332567 // test2((uint8[],uint8[2])[][1][]): 0x20, 2, 0x40, 0x0160, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13, 0x20, 1, 0x20, 0x60, 31, 37, 2, 23, 29 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 145150 +// gas irOptimized: 145409 // test3((uint8[],uint8[2])[1][][2]): 0x20, 0x40, 0x60, 0, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 192598 +// gas irOptimized: 192248 diff --git a/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol index 56a415079084..097c7b4d10d2 100644 --- a/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol @@ -46,11 +46,11 @@ contract C { } // ---- // test() -> 0x20, 0x14, "[a called][b called]" -// gas irOptimized: 116546 +// gas irOptimized: 116530 // gas legacy: 118845 -// gas legacyOptimized: 116887 +// gas legacyOptimized: 116844 // test2() -> 0x20, 0x14, "[b called][a called]" // test3() -> 0x20, 0x14, "[b called][a called]" -// gas irOptimized: 103147 +// gas irOptimized: 103150 // gas legacy: 102654 -// gas legacyOptimized: 101581 +// gas legacyOptimized: 101556 diff --git a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol index 79882a74b267..c5497547900f 100644 --- a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol @@ -18,6 +18,6 @@ contract C { } // ---- // f() -> 3 -// gas irOptimized: 127422 +// gas irOptimized: 128296 // gas legacy: 129050 -// gas legacyOptimized: 128222 +// gas legacyOptimized: 128210 diff --git a/test/libsolidity/semanticTests/array/copying/nested_array_element_storage_to_storage.sol b/test/libsolidity/semanticTests/array/copying/nested_array_element_storage_to_storage.sol index f85b8eb9f31b..ad00ee8c513b 100644 --- a/test/libsolidity/semanticTests/array/copying/nested_array_element_storage_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/nested_array_element_storage_to_storage.sol @@ -70,15 +70,15 @@ contract C { } // ---- // test1() -> -// gas irOptimized: 150468 +// gas irOptimized: 150488 // gas legacy: 150949 // gas legacyOptimized: 150906 // test2() -> FAILURE -// gas irOptimized: 150378 +// gas irOptimized: 150389 // gas legacy: 150673 // gas legacyOptimized: 150576 // test3() -> -// gas irOptimized: 123762 +// gas irOptimized: 124300 // gas legacy: 125333 // gas legacyOptimized: 125127 // test4() -> FAILURE diff --git a/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_calldata_to_storage.sol index 844a86304ee7..3b774f56e4eb 100644 --- a/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_calldata_to_storage.sol @@ -29,8 +29,8 @@ contract C { // compileViaYul: true // ---- // test1((uint8[],uint8[2])[][]): 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -// gas irOptimized: 304747 +// gas irOptimized: 304794 // test2((uint8[],uint8[2])[][1]): 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 116464 +// gas irOptimized: 116653 // test3((uint8[],uint8[2])[1][]): 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 188024 +// gas irOptimized: 188000 diff --git a/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_memory_to_storage.sol index 209a6ee696e9..35e7943b8b62 100644 --- a/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_memory_to_storage.sol @@ -29,8 +29,8 @@ contract C { // compileViaYul: true // ---- // test1((uint8[],uint8[2])[][]): 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -// gas irOptimized: 309074 +// gas irOptimized: 309078 // test2((uint8[],uint8[2])[][1]): 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 118256 +// gas irOptimized: 118314 // test3((uint8[],uint8[2])[1][]): 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -// gas irOptimized: 190993 +// gas irOptimized: 191051 diff --git a/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_storage_to_storage.sol b/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_storage_to_storage.sol index c356e029f6b6..d0d1691597ee 100644 --- a/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_storage_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/nested_array_of_structs_storage_to_storage.sol @@ -63,7 +63,7 @@ contract C { // compileViaYul: true // ---- // test1() -// gas irOptimized: 123202 +// gas irOptimized: 123195 // test2() -// gas irOptimized: 123027 +// gas irOptimized: 123018 // test3() diff --git a/test/libsolidity/semanticTests/array/copying/nested_dynamic_array_element_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/nested_dynamic_array_element_calldata_to_storage.sol index dfb7c27aca40..a4222be0b4f1 100644 --- a/test/libsolidity/semanticTests/array/copying/nested_dynamic_array_element_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/nested_dynamic_array_element_calldata_to_storage.sol @@ -30,7 +30,7 @@ contract C { // compileViaYul: true // ---- // test(uint8[][][]): 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0x80, 1, 7, 2, 8, 9 -// gas irOptimized: 138040 +// gas irOptimized: 137897 // test2(uint8[][]): 0x20, 2, 0x40, 0x80, 1, 7, 2, 8, 9 -// gas irOptimized: 164246 +// gas irOptimized: 164506 // gas legacyOptimized: 120228 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol index 9a2fbb4d9d58..ac92189e48de 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol @@ -17,6 +17,6 @@ contract C { } // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 -// gas irOptimized: 205783 +// gas irOptimized: 206440 // gas legacy: 211765 // gas legacyOptimized: 211181 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol index 0e8cff97fd57..b743a5825a75 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol @@ -11,6 +11,6 @@ contract C { } // ---- // f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000 -// gas irOptimized: 202162 +// gas irOptimized: 202083 // gas legacy: 204328 -// gas legacyOptimized: 202887 +// gas legacyOptimized: 202900 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol index 3606d7d60188..da7187a27e65 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol @@ -18,6 +18,6 @@ contract C { } // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 -// gas irOptimized: 205783 +// gas irOptimized: 206440 // gas legacy: 211770 // gas legacyOptimized: 211186 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol index cfbf5c874575..d4a348ea4095 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol @@ -24,6 +24,6 @@ contract C { } // ---- // f() -> 11, 0x0c, 1, 0x15, 22, 4 -// gas irOptimized: 291047 +// gas irOptimized: 291212 // gas legacy: 293407 // gas legacyOptimized: 290218 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol index 3ba5604a79f5..c5bd7d0b0c28 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol @@ -13,6 +13,6 @@ contract C { } // ---- // f() -> 2, 3, 4 -// gas irOptimized: 109108 +// gas irOptimized: 114338 // gas legacy: 122235 // gas legacyOptimized: 118411 diff --git a/test/libsolidity/semanticTests/array/create_memory_array.sol b/test/libsolidity/semanticTests/array/create_memory_array.sol index d507f080f36f..a95499fd8aa5 100644 --- a/test/libsolidity/semanticTests/array/create_memory_array.sol +++ b/test/libsolidity/semanticTests/array/create_memory_array.sol @@ -18,6 +18,6 @@ contract C { } // ---- // f() -> "A", 8, 4, "B" -// gas irOptimized: 125822 +// gas irOptimized: 136664 // gas legacy: 121382 // gas legacyOptimized: 115488 diff --git a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol index fffea685a8cb..5deaa7d4e80c 100644 --- a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol +++ b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol @@ -16,6 +16,6 @@ contract c { } // ---- // test1() -> true -// gas irOptimized: 204782 +// gas irOptimized: 218452 // gas legacy: 242256 -// gas legacyOptimized: 241192 +// gas legacyOptimized: 241182 diff --git a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol index eb950d1834c2..380e30242536 100644 --- a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol @@ -14,7 +14,7 @@ contract c { // ---- // storageEmpty -> 1 // fill() -> -// gas irOptimized: 519017 +// gas irOptimized: 519494 // gas legacy: 518936 // gas legacyOptimized: 515555 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol index 2f6769a24189..62b611a878e5 100644 --- a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol @@ -41,7 +41,7 @@ contract c { // ---- // getLengths() -> 0, 0 // setLengths(uint256,uint256): 48, 49 -> -// gas irOptimized: 110797 +// gas irOptimized: 112674 // gas legacy: 108273 // gas legacyOptimized: 100269 // getLengths() -> 48, 49 diff --git a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol index 7621d05bdcfd..2db14a939e5a 100644 --- a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol @@ -16,7 +16,7 @@ contract c { // ---- // storageEmpty -> 1 // fill() -> 8 -// gas irOptimized: 122742 +// gas irOptimized: 122985 // gas legacy: 121602 // gas legacyOptimized: 120589 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol index b4d9a30ec068..cc009b7e9e6b 100644 --- a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol @@ -10,7 +10,7 @@ contract c { // ---- // storageEmpty -> 1 // fill() -> -// gas irOptimized: 464834 +// gas irOptimized: 465013 // gas legacy: 468818 // gas legacyOptimized: 466238 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol index 0fb513543bea..e4bf3a7197e7 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -18,9 +18,9 @@ contract B { } // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 -// gas irOptimized: 59204 -// gas irOptimized code: 55200 +// gas irOptimized: 59212 +// gas irOptimized code: 56600 // gas legacy: 68001 // gas legacy code: 162000 -// gas legacyOptimized: 60037 +// gas legacyOptimized: 59997 // gas legacyOptimized code: 70600 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol index 0eb0f1e90e7d..817d06c0f5a6 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol @@ -9,7 +9,7 @@ contract Creator { } // ---- // constructor(): 1, 2, 3, 4 -> -// gas irOptimized: 103927 +// gas irOptimized: 104102 // gas irOptimized code: 22400 // gas legacy: 115186 // gas legacy code: 59000 diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index e35e24bbf12a..e9517c0e38a1 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -42,9 +42,9 @@ contract C { } // ---- // test() -> 5, 6, 7 -// gas irOptimized: 86128 -// gas irOptimized code: 169600 +// gas irOptimized: 86484 +// gas irOptimized code: 161200 // gas legacy: 97576 // gas legacy code: 342800 -// gas legacyOptimized: 87851 -// gas legacyOptimized code: 190800 +// gas legacyOptimized: 87811 +// gas legacyOptimized code: 193000 diff --git a/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol b/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol index ddf67aa90fbf..5fd53c6d1299 100644 --- a/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol +++ b/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol @@ -40,9 +40,9 @@ contract C { // copyFromStorageShort() // x() -> 0x20, 3, 0x6162630000000000000000000000000000000000000000000000000000000000 // copyFromStorageLong() -// gas irOptimized: 121106 +// gas irOptimized: 121104 // gas legacy: 121904 -// gas legacyOptimized: 121398 +// gas legacyOptimized: 121388 // x() -> 0x20, 0x25, 0x3132333435363738393031323334353637383930313233343536373839303132, 0x3334353637000000000000000000000000000000000000000000000000000000 // copyToStorage() // x() -> 0x20, 0x25, 0x3132333435363738393031323334353637383930313233343536373839303132, 0x3334353637000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol index a08d27ac0b38..be1916ef131f 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol @@ -23,7 +23,7 @@ contract c { } // ---- // test() -> 1, 2, 3 -// gas irOptimized: 1827730 +// gas irOptimized: 1828226 // gas legacy: 1822466 // gas legacyOptimized: 1813404 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol index 1b69ab336bc7..73870d4285a0 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol @@ -18,7 +18,7 @@ contract c { } // ---- // test() -> 38, 28, 18 -// gas irOptimized: 148538 +// gas irOptimized: 148380 // gas legacy: 151184 // gas legacyOptimized: 142418 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol index d2e5995c0070..e0fc1658154f 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol @@ -18,7 +18,7 @@ contract c { } // ---- // test() -> 20, 10 -// gas irOptimized: 126068 +// gas irOptimized: 125889 // gas legacy: 127216 // gas legacyOptimized: 122224 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol index a3ba9d4d2111..c567c4509eaf 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol @@ -16,7 +16,7 @@ contract c { } // ---- // test() -> true -// gas irOptimized: 140154 +// gas irOptimized: 138848 // gas legacy: 178397 // gas legacyOptimized: 163832 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol index a014e761ea24..d9d2d9d2d94e 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol @@ -15,7 +15,7 @@ contract c { } // ---- // test() -> -// gas irOptimized: 113782 +// gas irOptimized: 113679 // gas legacy: 131245 // gas legacyOptimized: 126668 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol index 674b0841e6b4..490de759b550 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol @@ -9,6 +9,6 @@ contract c { } // ---- // test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 107183 +// gas irOptimized: 106778 // gas legacy: 121245 // gas legacyOptimized: 120370 diff --git a/test/libsolidity/semanticTests/array/push/array_push.sol b/test/libsolidity/semanticTests/array/push/array_push.sol index 3e7ceb5a8b7d..6198ba163595 100644 --- a/test/libsolidity/semanticTests/array/push/array_push.sol +++ b/test/libsolidity/semanticTests/array/push/array_push.sol @@ -16,6 +16,6 @@ contract c { } // ---- // test() -> 5, 4, 3, 3 -// gas irOptimized: 111363 +// gas irOptimized: 111834 // gas legacy: 111807 // gas legacyOptimized: 111122 diff --git a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol index a010a9938ac7..4bcac0f13829 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol @@ -12,6 +12,6 @@ contract C { } // ---- // f(uint120[]): 0x20, 3, 1, 2, 3 -> 1 -// gas irOptimized: 112812 +// gas irOptimized: 112853 // gas legacy: 113659 -// gas legacyOptimized: 113482 +// gas legacyOptimized: 113466 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct.sol b/test/libsolidity/semanticTests/array/push/array_push_struct.sol index 06c5db88b73c..b6db507ea385 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct.sol @@ -20,6 +20,6 @@ contract c { } // ---- // test() -> 2, 3, 4, 5 -// gas irOptimized: 135103 +// gas irOptimized: 135329 // gas legacy: 147443 // gas legacyOptimized: 146434 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol index 4a33f816d773..37de90cb695a 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol @@ -16,6 +16,6 @@ contract c { } // ---- // test((uint16,uint16,uint16[3],uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5 -// gas irOptimized: 137061 +// gas irOptimized: 137153 // gas legacy: 142423 -// gas legacyOptimized: 137991 +// gas legacyOptimized: 137981 diff --git a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol index 5f1fe0fac770..763cb9a040e1 100644 --- a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol +++ b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol @@ -15,6 +15,6 @@ contract c { } // ---- // test() -> 0 -// gas irOptimized: 167700 +// gas irOptimized: 167569 // gas legacy: 206219 // gas legacyOptimized: 197297 diff --git a/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol b/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol index 30ed47920d9c..aeaeb9ee72a2 100644 --- a/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol +++ b/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol @@ -13,6 +13,6 @@ contract C { } // ---- // f() -> -// gas irOptimized: 179112 +// gas irOptimized: 179534 // gas legacy: 181014 -// gas legacyOptimized: 180422 +// gas legacyOptimized: 180398 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol index 6901e32b8b54..00e454516330 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol @@ -27,14 +27,14 @@ contract C { // ---- // l() -> 0 // f(uint256,uint256): 42, 64 -> -// gas irOptimized: 112266 +// gas irOptimized: 112288 // gas legacy: 107920 // gas legacyOptimized: 101897 // l() -> 1 // ll(uint256): 0 -> 43 // a(uint256,uint256): 0, 42 -> 64 // f(uint256,uint256): 84, 128 -> -// gas irOptimized: 118686 +// gas irOptimized: 118708 // gas legacy: 109972 // gas legacyOptimized: 96331 // l() -> 2 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol index b19ebcc7367f..b013a7ebbcf1 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol @@ -21,7 +21,7 @@ contract C { // ---- // l() -> 0 // g(uint256): 70 -> -// gas irOptimized: 180849 +// gas irOptimized: 181778 // gas legacy: 175185 // gas legacyOptimized: 175005 // l() -> 70 diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index a7608f6e0c81..621860c075c8 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -24,7 +24,7 @@ contract Main { } // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 -// gas irOptimized: 99524 +// gas irOptimized: 99552 // gas irOptimized code: 12400 // gas legacy: 101554 // gas legacy code: 23600 diff --git a/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol b/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol index 8d0cb0a01294..dab01b5983c6 100644 --- a/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol +++ b/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol @@ -28,12 +28,12 @@ contract C { // compileViaYul: also // ---- // constructor() -> -// gas irOptimized: 81932 -// gas irOptimized code: 355200 +// gas irOptimized: 82100 +// gas irOptimized code: 357600 // gas legacy: 101472 // gas legacy code: 604200 -// gas legacyOptimized: 85004 -// gas legacyOptimized code: 392400 +// gas legacyOptimized: 84956 +// gas legacyOptimized code: 391800 // h() -> 0x20, 0x40, 0x00, 0 // ~ emit ev(uint256[],uint256): 0x40, 0x21, 0x02, 0x00, 0x00 // g() -> 0x20, 0x40, 0, 0x00 diff --git a/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol b/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol index aedf5ada4f57..09dcd034796d 100644 --- a/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol @@ -9,7 +9,7 @@ contract c { // EVMVersion: >=byzantium // ---- // (): 1, 2, 3, 4, 5 -> -// gas irOptimized: 155130 +// gas irOptimized: 155125 // gas legacy: 155473 // gas legacyOptimized: 155295 // checkIfDataIsEmpty() -> false diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index 3e60ba451c8c..685b1a93890c 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -24,9 +24,9 @@ contract Creator { } // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 -// gas irOptimized: 328126 -// gas irOptimized code: 96400 +// gas irOptimized: 327784 +// gas irOptimized code: 94000 // gas legacy: 336626 // gas legacy code: 244800 -// gas legacyOptimized: 329599 -// gas legacyOptimized code: 115000 +// gas legacyOptimized: 329518 +// gas legacyOptimized code: 117000 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index c0b9df16c34d..0310d58d7a93 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -24,9 +24,9 @@ contract Creator { } // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" -// gas irOptimized: 169361 -// gas irOptimized code: 99200 +// gas irOptimized: 169292 +// gas irOptimized code: 99600 // gas legacy: 172944 // gas legacy code: 239800 -// gas legacyOptimized: 169858 -// gas legacyOptimized code: 117000 +// gas legacyOptimized: 169818 +// gas legacyOptimized code: 118600 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol index 0918a970e272..4194e14a69c0 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol @@ -8,11 +8,11 @@ contract Test { } // ---- // constructor(): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> -// gas irOptimized: 180756 -// gas irOptimized code: 79200 +// gas irOptimized: 181465 +// gas irOptimized code: 78400 // gas legacy: 195165 // gas legacy code: 109400 -// gas legacyOptimized: 181600 +// gas legacyOptimized: 181609 // gas legacyOptimized code: 71400 // m_x() -> 7 // m_s() -> 0x20, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" diff --git a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol index e6ce445ada39..327c41d9be81 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol @@ -9,11 +9,11 @@ contract C { } // ---- // constructor(): 1, 2, 3, 4 -> -// gas irOptimized: 147975 +// gas irOptimized: 148129 // gas irOptimized code: 23000 // gas legacy: 157978 // gas legacy code: 60400 -// gas legacyOptimized: 150011 +// gas legacyOptimized: 149974 // gas legacyOptimized code: 26200 // a() -> 1 // b(uint256): 0 -> 2 diff --git a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol index b1dc80a408d8..583f1ca37b3f 100644 --- a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol @@ -17,7 +17,7 @@ contract C { } // ---- // f(), 2000 ether -> true -// gas irOptimized: 117641 +// gas irOptimized: 117623 // gas irOptimized code: 1800 // gas legacy: 117821 // gas legacy code: 4800 diff --git a/test/libsolidity/semanticTests/errors/errors_by_parameter_type.sol b/test/libsolidity/semanticTests/errors/errors_by_parameter_type.sol new file mode 100644 index 000000000000..bc70b5bef757 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/errors_by_parameter_type.sol @@ -0,0 +1,45 @@ +pragma abicoder v2; + +struct S { + uint256 a; + bool b; + string s; +} + +error E(); +error E1(uint256); +error E2(string); +error E3(S); +error E4(address); +error E5(function() external pure); + +contract C { + function a() external pure { + require(false, E()); + } + function b() external pure { + require(false, E1(1)); + } + function c() external pure { + require(false, E2("string literal")); + } + function d() external pure { + require(false, E3(S(1, true, "string literal"))); + } + function e() external view { + require(false, E4(address(this))); + } + function f() external view { + require(false, E5(this.a)); + } +} + +// ==== +// compileViaYul: true +// ---- +// a() -> FAILURE, hex"92bbf6e8" +// b() -> FAILURE, hex"47e26897", hex"0000000000000000000000000000000000000000000000000000000000000001" +// c() -> FAILURE, hex"8f372c34", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"000000000000000000000000000000000000000000000000000000000000000e", hex"737472696e67206c69746572616c000000000000000000000000000000000000" +// d() -> FAILURE, hex"5717173e", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"000000000000000000000000000000000000000000000000000000000000000e", hex"737472696e67206c69746572616c000000000000000000000000000000000000" +// e() -> FAILURE, hex"7efef9ea", hex"000000000000000000000000c06afe3a8444fc0004668591e8306bfb9968e79e" +// f() -> FAILURE, hex"0c3f12eb", hex"c06afe3a8444fc0004668591e8306bfb9968e79e0dbe671f0000000000000000" diff --git a/test/libsolidity/semanticTests/errors/require_different_errors_same_parameters.sol b/test/libsolidity/semanticTests/errors/require_different_errors_same_parameters.sol new file mode 100644 index 000000000000..37cbb207da59 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_different_errors_same_parameters.sol @@ -0,0 +1,21 @@ +error AnError(uint256, string, uint256); +error AnotherError(uint256, string, uint256); + +contract C +{ + function f() external pure + { + require(false, AnError(1, "two", 3)); + } + + function g() external pure + { + require(false, AnotherError(4, "five", 6)); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"f55fefe3", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"74776f0000000000000000000000000000000000000000000000000000000000" +// g() -> FAILURE, hex"44a06798", hex"0000000000000000000000000000000000000000000000000000000000000004", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"0000000000000000000000000000000000000000000000000000000000000006", hex"0000000000000000000000000000000000000000000000000000000000000004", hex"6669766500000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/errors/require_error_function_pointer_parameter.sol b/test/libsolidity/semanticTests/errors/require_error_function_pointer_parameter.sol new file mode 100644 index 000000000000..2e1dcdd5888a --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_error_function_pointer_parameter.sol @@ -0,0 +1,20 @@ +error CustomError(function(uint256) external pure returns (uint256)); + +contract C +{ + function e(uint256 x) external pure returns (uint256) + { + return x; + } + + function f() external view + { + // more than one stack slot + require(false, CustomError(this.e)); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"271b1dfa", hex"c06afe3a8444fc0004668591e8306bfb9968e79ef37cdc8e0000000000000000" diff --git a/test/libsolidity/semanticTests/errors/require_error_multiple_arguments.sol b/test/libsolidity/semanticTests/errors/require_error_multiple_arguments.sol new file mode 100644 index 000000000000..6c8521f9d2de --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_error_multiple_arguments.sol @@ -0,0 +1,20 @@ +error CustomError(uint256, string, uint256); + +contract C +{ + function f() external pure + { + require(false, CustomError(1, "two", 3)); + } + + function g() external pure + { + require(false, CustomError(4, "five", 6)); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"11a1077e", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"74776f0000000000000000000000000000000000000000000000000000000000" +// g() -> FAILURE, hex"11a1077e", hex"0000000000000000000000000000000000000000000000000000000000000004", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"0000000000000000000000000000000000000000000000000000000000000006", hex"0000000000000000000000000000000000000000000000000000000000000004", hex"6669766500000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/errors/require_error_string_literal.sol b/test/libsolidity/semanticTests/errors/require_error_string_literal.sol new file mode 100644 index 000000000000..5a3a140d0b23 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_error_string_literal.sol @@ -0,0 +1,20 @@ +error CustomError(string); + +contract C +{ + function f() external pure + { + require(false, CustomError("errorReason")); + } + + function g() external pure + { + require(false, CustomError("anotherReason")); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"8d6ea8be", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"000000000000000000000000000000000000000000000000000000000000000b", hex"6572726f72526561736f6e000000000000000000000000000000000000000000" +// g() -> FAILURE, hex"8d6ea8be", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"000000000000000000000000000000000000000000000000000000000000000d", hex"616e6f74686572526561736f6e00000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/errors/require_error_string_memory.sol b/test/libsolidity/semanticTests/errors/require_error_string_memory.sol new file mode 100644 index 000000000000..13947d399036 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_error_string_memory.sol @@ -0,0 +1,22 @@ +error CustomError(string); + +contract C +{ + function f() external pure + { + string memory reason = "errorReason"; + require(false, CustomError(reason)); + } + + function g() external pure + { + string memory reason = "anotherReason"; + require(false, CustomError(reason)); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"8d6ea8be", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"000000000000000000000000000000000000000000000000000000000000000b", hex"6572726f72526561736f6e000000000000000000000000000000000000000000" +// g() -> FAILURE, hex"8d6ea8be", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"000000000000000000000000000000000000000000000000000000000000000d", hex"616e6f74686572526561736f6e00000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/errors/require_error_uint256.sol b/test/libsolidity/semanticTests/errors/require_error_uint256.sol new file mode 100644 index 000000000000..d400e5fa7c23 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_error_uint256.sol @@ -0,0 +1,20 @@ +error CustomError(uint256); + +contract C +{ + function f() external pure + { + require(false, CustomError(1)); + } + + function g() external pure + { + require(false, CustomError(2)); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"110b3655", hex"0000000000000000000000000000000000000000000000000000000000000001" +// g() -> FAILURE, hex"110b3655", hex"0000000000000000000000000000000000000000000000000000000000000002" diff --git a/test/libsolidity/semanticTests/errors/require_evaluation_order.sol b/test/libsolidity/semanticTests/errors/require_evaluation_order.sol new file mode 100644 index 000000000000..4733b3aee73b --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_evaluation_order.sol @@ -0,0 +1,28 @@ +contract C +{ + error E(uint); + + function r() internal returns (uint) + { + assembly { mstore(0, 7) return (0, 32) } + return 42; + } + + function f() public returns (uint) + { + require(false, E(r())); + return 42; + } + + function g() public returns (uint) + { + require(true, E(r())); + return 42; + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> 7 +// g() -> 7 diff --git a/test/libsolidity/semanticTests/errors/require_inherited_error.sol b/test/libsolidity/semanticTests/errors/require_inherited_error.sol new file mode 100644 index 000000000000..24b544b73cf9 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/require_inherited_error.sol @@ -0,0 +1,17 @@ +contract Base +{ + error CustomError(uint256, string, uint256); +} + +contract C is Base +{ + function f() external pure + { + require(false, CustomError(1, "two", 3)); + } +} + +// ==== +// compileViaYul: true +// ---- +// f() -> FAILURE, hex"11a1077e", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"74776f0000000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/errors/small_error_optimization.sol b/test/libsolidity/semanticTests/errors/small_error_optimization.sol new file mode 100644 index 000000000000..0c9cd750aa32 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/small_error_optimization.sol @@ -0,0 +1,22 @@ +error E(); +contract A { + uint8[] x; + function f() public { + for (uint i = 0; i < 100; ++i) + x.push(uint8(i)); + revert E(); + } +} +contract B { + function f() public { + (new A()).f(); + } +} +// ---- +// f() -> FAILURE, hex"92bbf6e8" +// gas irOptimized: 221918 +// gas irOptimized code: 42800 +// gas legacy: 233746 +// gas legacy code: 37400 +// gas legacyOptimized: 224864 +// gas legacyOptimized code: 34200 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol index fec281c59a01..76acd4a0b23f 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol @@ -13,6 +13,6 @@ contract C { // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c -// gas irOptimized: 113485 +// gas irOptimized: 114231 // gas legacy: 116314 -// gas legacyOptimized: 114407 +// gas legacyOptimized: 114408 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol index 2b5a7114d99b..bdcda3a09370 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol @@ -14,6 +14,6 @@ contract C { // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c -// gas irOptimized: 113485 +// gas irOptimized: 114231 // gas legacy: 116314 -// gas legacyOptimized: 114407 +// gas legacyOptimized: 114408 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol index d6cfb68beff9..324f456f6794 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol @@ -15,6 +15,6 @@ contract C { // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[][]): 0x20, 0x02, 0x40, 0xa0, 0x02, 0x2a, 0x2b, 0x02, 0x2c, 0x2d -// gas irOptimized: 185033 +// gas irOptimized: 185148 // gas legacy: 187495 -// gas legacyOptimized: 184525 +// gas legacyOptimized: 184550 diff --git a/test/libsolidity/semanticTests/events/event_indexed_string.sol b/test/libsolidity/semanticTests/events/event_indexed_string.sol index 739619066a43..0ad2affe377a 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_string.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_string.sol @@ -17,6 +17,6 @@ contract C { // ---- // deposit() -> // ~ emit E(string,uint256[4]): #0xa7fb06bb999a5eb9aff9e0779953f4e1e4ce58044936c2f51c7fb879b85c08bd, #0xe755d8cc1a8cde16a2a31160dcd8017ac32d7e2f13215b29a23cdae40a78aa81 -// gas irOptimized: 328856 +// gas irOptimized: 332789 // gas legacy: 365828 -// gas legacyOptimized: 362251 +// gas legacyOptimized: 362250 diff --git a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol index 925ed54e6dc3..47feaf5258bb 100644 --- a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol +++ b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol @@ -74,12 +74,12 @@ contract FixedFeeRegistrar is Registrar { } // ---- // constructor() -// gas irOptimized: 77654 -// gas irOptimized code: 302200 +// gas irOptimized: 78076 +// gas irOptimized code: 307400 // gas legacy: 115395 // gas legacy code: 792400 -// gas legacyOptimized: 84566 -// gas legacyOptimized code: 387600 +// gas legacyOptimized: 84598 +// gas legacyOptimized code: 388000 // reserve(string), 69 ether: 0x20, 3, "abc" -> // ~ emit Changed(string): #0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 // gas irOptimized: 45967 diff --git a/test/libsolidity/semanticTests/externalContracts/base64.sol b/test/libsolidity/semanticTests/externalContracts/base64.sol index aed2a11df22c..a986be149b50 100644 --- a/test/libsolidity/semanticTests/externalContracts/base64.sol +++ b/test/libsolidity/semanticTests/externalContracts/base64.sol @@ -33,11 +33,11 @@ contract test { // EVMVersion: >=constantinople // ---- // constructor() -// gas irOptimized: 78952 -// gas irOptimized code: 320600 +// gas irOptimized: 79076 +// gas irOptimized code: 322000 // gas legacy: 102034 // gas legacy code: 627400 -// gas legacyOptimized: 87950 +// gas legacyOptimized: 87926 // gas legacyOptimized code: 429800 // encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0 // encode_inline_asm(bytes): 0x20, 1, "f" -> 0x20, 4, "Zg==" @@ -54,10 +54,10 @@ contract test { // encode_no_asm(bytes): 0x20, 5, "fooba" -> 0x20, 8, "Zm9vYmE=" // encode_no_asm(bytes): 0x20, 6, "foobar" -> 0x20, 8, "Zm9vYmFy" // encode_inline_asm_large() -// gas irOptimized: 1322025 +// gas irOptimized: 1406025 // gas legacy: 1554031 // gas legacyOptimized: 1132031 // encode_no_asm_large() -// gas irOptimized: 3206081 +// gas irOptimized: 3512081 // gas legacy: 4587075 -// gas legacyOptimized: 2823075 +// gas legacyOptimized: 2813075 diff --git a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol index ce77683aab73..9bfa3a340e5f 100644 --- a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol +++ b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol @@ -176,38 +176,38 @@ contract DepositContract is IDepositContract, ERC165 { } // ---- // constructor() -// gas irOptimized: 809248 +// gas irOptimized: 809602 // gas irOptimized code: 558000 // gas legacy: 919945 // gas legacy code: 1437600 -// gas legacyOptimized: 848464 -// gas legacyOptimized code: 875200 +// gas legacyOptimized: 848699 +// gas legacyOptimized code: 878200 // supportsInterface(bytes4): 0x0 -> 0 // supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 # // supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id # // supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// gas irOptimized: 109009 +// gas irOptimized: 109178 // gas legacy: 142735 // gas legacyOptimized: 117558 // get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit # // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// gas irOptimized: 109009 +// gas irOptimized: 109178 // gas legacy: 142735 // gas legacyOptimized: 117558 // get_deposit_count() -> 0x20, 8, 0 // deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 # // ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0xf50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x08, 0xca9a3b00000000000000000000000000000000000000000000000000000000, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8, 0x08, 0x00 // get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438 -// gas irOptimized: 108994 +// gas irOptimized: 109174 // gas legacy: 142744 // gas legacyOptimized: 117570 // get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000 // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac # // ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x08, 0x40597307000000000000000000000000000000000000000000000000000000, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d, 0x08, 0x0100000000000000000000000000000000000000000000000000000000000000 // get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee -// gas irOptimized: 108994 +// gas irOptimized: 109174 // gas legacy: 142744 // gas legacyOptimized: 117570 // get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol index ddd63971836c..4990d24e9a7e 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol @@ -48,8 +48,8 @@ contract test { } // ---- // constructor() -// gas irOptimized: 177336 -// gas irOptimized code: 1664400 +// gas irOptimized: 177903 +// gas irOptimized code: 1674400 // gas legacy: 209687 // gas legacy code: 2204400 // gas legacyOptimized: 178012 diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol index deacfd05641b..5d95c7a75c84 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol @@ -48,8 +48,8 @@ contract test { } // ---- // constructor() -// gas irOptimized: 168523 -// gas irOptimized code: 1547800 +// gas irOptimized: 170626 +// gas irOptimized code: 1577400 // gas legacy: 195146 // gas legacy code: 1998400 // gas legacyOptimized: 168857 diff --git a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol index cdaec8797eb7..1aa72b897b97 100644 --- a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol +++ b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol @@ -33,8 +33,8 @@ contract test { } // ---- // constructor() -// gas irOptimized: 79503 -// gas irOptimized code: 328000 +// gas irOptimized: 77816 +// gas irOptimized code: 307600 // gas legacy: 92086 // gas legacy code: 523000 // gas legacyOptimized: 82667 diff --git a/test/libsolidity/semanticTests/externalContracts/snark.sol b/test/libsolidity/semanticTests/externalContracts/snark.sol index d3492a5c6b06..97d15183a19b 100644 --- a/test/libsolidity/semanticTests/externalContracts/snark.sol +++ b/test/libsolidity/semanticTests/externalContracts/snark.sol @@ -294,11 +294,11 @@ contract Test { // f() -> true // g() -> true // pair() -> true -// gas irOptimized: 269697 +// gas irOptimized: 270424 // gas legacy: 275206 // gas legacyOptimized: 266925 // verifyTx() -> true // ~ emit Verified(string): 0x20, 0x16, "Successfully verified." -// gas irOptimized: 782210 +// gas irOptimized: 785783 // gas legacy: 801868 // gas legacyOptimized: 770942 diff --git a/test/libsolidity/semanticTests/externalContracts/strings.sol b/test/libsolidity/semanticTests/externalContracts/strings.sol index 102c85ae0fa8..773d7156afa3 100644 --- a/test/libsolidity/semanticTests/externalContracts/strings.sol +++ b/test/libsolidity/semanticTests/externalContracts/strings.sol @@ -49,12 +49,12 @@ contract test { } // ---- // constructor() -// gas irOptimized: 95949 -// gas irOptimized code: 528000 +// gas irOptimized: 95303 +// gas irOptimized code: 520000 // gas legacy: 126106 // gas legacy code: 930200 -// gas legacyOptimized: 102559 -// gas legacyOptimized code: 611400 +// gas legacyOptimized: 102639 +// gas legacyOptimized code: 612400 // toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0 // gas irOptimized: 22660 // gas legacy: 23190 @@ -72,6 +72,6 @@ contract test { // gas legacy: 31621 // gas legacyOptimized: 27914 // benchmark(string,bytes32): 0x40, 0x0842021, 8, "solidity" -> 0x2020 -// gas irOptimized: 1980944 +// gas irOptimized: 1976778 // gas legacy: 4233999 -// gas legacyOptimized: 2318684 +// gas legacyOptimized: 2318670 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol index 1133dc2be300..f7c05c10c4d6 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol @@ -15,7 +15,7 @@ contract D { } // ---- // constructor(): 2 -> -// gas irOptimized: 138863 +// gas irOptimized: 138930 // gas irOptimized code: 53800 // gas legacy: 145570 // gas legacy code: 95600 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol index ba90a8ecd5a6..9742a1d2f373 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol @@ -17,7 +17,7 @@ contract D { // EVMVersion: >=constantinople // ---- // constructor(): 2 -> -// gas irOptimized: 139026 +// gas irOptimized: 139112 // gas irOptimized code: 53800 // gas legacy: 145936 // gas legacy code: 95600 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol index 5b254a9f6c2d..87f7cbebb0d5 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol @@ -22,12 +22,12 @@ contract C { } // ---- // constructor(), 1 ether -> -// gas irOptimized: 89155 -// gas irOptimized code: 167800 +// gas irOptimized: 88853 +// gas irOptimized code: 164400 // gas legacy: 102626 // gas legacy code: 333200 -// gas legacyOptimized: 91471 -// gas legacyOptimized code: 196200 +// gas legacyOptimized: 91599 +// gas legacyOptimized code: 197800 // f(uint256): 0 -> FAILURE // f(uint256): 1 -> FAILURE // f(uint256): 2 -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol index 8bf182a89ee8..9da010e9bc21 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol @@ -25,12 +25,12 @@ contract C { // revertStrings: debug // ---- // constructor(), 1 ether -> -// gas irOptimized: 98842 -// gas irOptimized code: 286000 +// gas irOptimized: 98698 +// gas irOptimized code: 284200 // gas legacy: 123163 // gas legacy code: 681200 -// gas legacyOptimized: 106957 -// gas legacyOptimized code: 386400 +// gas legacyOptimized: 107069 +// gas legacyOptimized code: 387800 // f(uint256): 0 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" // f(uint256): 1 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" // f(uint256): 2 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol index 806c8eb41b9d..bf6f2c4baf4d 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol @@ -38,8 +38,8 @@ contract test { } // ---- // constructor(), 20 wei -> -// gas irOptimized: 120226 -// gas irOptimized code: 132400 +// gas irOptimized: 120218 +// gas irOptimized code: 132000 // gas legacy: 130568 // gas legacy code: 261000 // gas legacyOptimized: 121069 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol index c186fc40b22c..ebc78a437f69 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol @@ -37,8 +37,8 @@ contract test { } // ---- // constructor(), 20 wei -> -// gas irOptimized: 120226 -// gas irOptimized code: 132400 +// gas irOptimized: 120218 +// gas irOptimized code: 132000 // gas legacy: 130568 // gas legacy code: 261000 // gas legacyOptimized: 121069 diff --git a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol index 28c1822d77b7..7a9bf6014bad 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol @@ -18,7 +18,7 @@ contract test { } // ---- // set(uint8,uint8,uint8,uint8,uint8): 1, 21, 22, 42, 43 -> 0, 0, 0, 0 -// gas irOptimized: 111628 +// gas irOptimized: 111237 // gas legacy: 113748 // gas legacyOptimized: 111772 // get(uint8): 1 -> 21, 22, 42, 43 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index c8806c50d060..e1eb0621a611 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -27,7 +27,7 @@ contract C { } // ---- // f() -> 3, 7, 5 -// gas irOptimized: 86821 +// gas irOptimized: 86796 // gas irOptimized code: 37200 // gas legacy: 87728 // gas legacy code: 60800 diff --git a/test/libsolidity/semanticTests/immutable/use_scratch.sol b/test/libsolidity/semanticTests/immutable/use_scratch.sol index dc07086c29c3..2ee05af918c7 100644 --- a/test/libsolidity/semanticTests/immutable/use_scratch.sol +++ b/test/libsolidity/semanticTests/immutable/use_scratch.sol @@ -15,7 +15,7 @@ contract C { } // ---- // constructor(): 3 -> -// gas irOptimized: 81126 +// gas irOptimized: 81194 // gas irOptimized code: 42400 // gas legacy: 88245 // gas legacy code: 109400 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol index d5ff54b68a16..5234c27adf12 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -25,5 +25,5 @@ contract B { // gas irOptimized: 100282 // gas legacy: 56840 // gas legacy code: 123600 -// gas legacyOptimized: 54996 -// gas legacyOptimized code: 57600 +// gas legacyOptimized: 55002 +// gas legacyOptimized code: 60600 diff --git a/test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol b/test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol index f4975cd4c790..a375207252dc 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol @@ -40,8 +40,8 @@ contract D { // EVMVersion: >=cancun // ---- // constructor() -> -// gas irOptimized: 127944 -// gas irOptimized code: 225200 +// gas irOptimized: 127596 +// gas irOptimized code: 221000 // gas legacy: 149357 // gas legacy code: 499800 // gas legacyOptimized: 125830 diff --git a/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol b/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol index 0ad55b5ddff1..8ec19fffa573 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol @@ -16,8 +16,8 @@ contract ClientReceipt { } // ---- // constructor(), 2000 wei -> -// gas irOptimized: 114107 -// gas irOptimized code: 55800 +// gas irOptimized: 114353 +// gas irOptimized code: 58800 // gas legacy: 118618 // gas legacy code: 111400 // gas legacyOptimized: 114067 diff --git a/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol b/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol index 79d53273ba7e..817118473107 100644 --- a/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol +++ b/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol @@ -22,6 +22,6 @@ contract Test { // ---- // library: Lib // f() -> 4, 0x11 -// gas irOptimized: 111560 +// gas irOptimized: 111419 // gas legacy: 132935 // gas legacyOptimized: 118023 diff --git a/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol b/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol index b3e06c5bcfb8..bbdc920471bc 100644 --- a/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol +++ b/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol @@ -19,6 +19,6 @@ contract Test { // ---- // library: Lib // f() -> 1, 0, 0x2a, 0x17, 0, 0x63 -// gas irOptimized: 119635 +// gas irOptimized: 119837 // gas legacy: 124674 // gas legacyOptimized: 119669 diff --git a/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol b/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol index e9d855969afd..98cdf4fd18cd 100644 --- a/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol +++ b/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol @@ -17,6 +17,6 @@ contract Test { // ---- // library: Lib // f() -> 1, 0, 0x2a, 0x17, 0, 0x63 -// gas irOptimized: 120194 +// gas irOptimized: 119568 // gas legacy: 125109 // gas legacyOptimized: 120128 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 735731c8abf7..083c9a5e4838 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -21,8 +21,8 @@ contract A { // EVMVersion: >=constantinople // ---- // f(), 10 ether -> 3007, 3008, 3009 -// gas irOptimized: 187005 -// gas irOptimized code: 66000 +// gas irOptimized: 187022 +// gas irOptimized code: 67200 // gas legacy: 190863 // gas legacy code: 190200 // gas legacyOptimized: 187258 diff --git a/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol b/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol index 5f32421657cd..0c2f54b9e759 100644 --- a/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol +++ b/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol @@ -22,9 +22,9 @@ contract Test { // set(bytes): 0x20, 0 // storageEmpty -> 1 // set(bytes): 0x20, 66, "12345678901234567890123456789012", "12345678901234567890123456789012", "12" -// gas irOptimized: 111886 +// gas irOptimized: 111852 // gas legacy: 112734 -// gas legacyOptimized: 112115 +// gas legacyOptimized: 112084 // storageEmpty -> 0 // set(bytes): 0x20, 3, "abc" // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol index 2c29abc79bb0..75edb1c9e0fe 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol @@ -42,6 +42,6 @@ contract C { } // ---- // test() -> true -// gas irOptimized: 132493 +// gas irOptimized: 132633 // gas legacy: 136009 // gas legacyOptimized: 133478 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol index add42a8f3b18..ebf546fe2803 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol @@ -16,6 +16,6 @@ contract C { } // ---- // f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 77, 1, 2, 88 -// gas irOptimized: 202843 +// gas irOptimized: 202902 // gas legacy: 207384 -// gas legacyOptimized: 203584 +// gas legacyOptimized: 203588 diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol index 699836179be2..4465b1a3eece 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol @@ -23,6 +23,6 @@ contract CopyTest { } // ---- // run() -> 2, 23, 42 -// gas irOptimized: 193677 +// gas irOptimized: 192828 // gas legacy: 185731 // gas legacyOptimized: 184458 diff --git a/test/libsolidity/semanticTests/structs/copy_from_mapping.sol b/test/libsolidity/semanticTests/structs/copy_from_mapping.sol index 8ee19a278a23..a072fb0576b7 100644 --- a/test/libsolidity/semanticTests/structs/copy_from_mapping.sol +++ b/test/libsolidity/semanticTests/structs/copy_from_mapping.sol @@ -36,8 +36,8 @@ contract C { } // ---- // to_state() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 121394 +// gas irOptimized: 121282 // gas legacy: 122978 -// gas legacyOptimized: 121648 +// gas legacyOptimized: 121652 // to_storage() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 // to_memory() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 diff --git a/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol b/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol index 937eeeaf437e..29e7afca361a 100644 --- a/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol +++ b/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol @@ -87,7 +87,7 @@ contract Test { // EVMVersion: >homestead // ---- // test1() -> true -// gas irOptimized: 152882 +// gas irOptimized: 152965 // gas legacy: 153012 // gas legacyOptimized: 152637 // test2() -> true diff --git a/test/libsolidity/semanticTests/structs/copy_substructures_from_mapping.sol b/test/libsolidity/semanticTests/structs/copy_substructures_from_mapping.sol index 9b0fa9207a8c..61d2d68aada7 100644 --- a/test/libsolidity/semanticTests/structs/copy_substructures_from_mapping.sol +++ b/test/libsolidity/semanticTests/structs/copy_substructures_from_mapping.sol @@ -44,8 +44,8 @@ contract C { } // ---- // to_state() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 121511 +// gas irOptimized: 121454 // gas legacy: 123117 -// gas legacyOptimized: 121655 +// gas legacyOptimized: 121659 // to_storage() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 // to_memory() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 diff --git a/test/libsolidity/semanticTests/structs/copy_substructures_to_mapping.sol b/test/libsolidity/semanticTests/structs/copy_substructures_to_mapping.sol index a0834ca5bf5b..7d458ca29397 100644 --- a/test/libsolidity/semanticTests/structs/copy_substructures_to_mapping.sol +++ b/test/libsolidity/semanticTests/structs/copy_substructures_to_mapping.sol @@ -52,14 +52,14 @@ contract C { } // ---- // from_memory() -> 0x20, 0x60, 0xa0, 0x15, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 122952 +// gas irOptimized: 122720 // gas legacy: 130136 -// gas legacyOptimized: 128650 +// gas legacyOptimized: 128649 // from_state() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 121622 +// gas irOptimized: 121424 // gas legacy: 123191 -// gas legacyOptimized: 121760 +// gas legacyOptimized: 121764 // from_calldata((bytes,uint16[],uint16)): 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -> 0x20, 0x60, 0xa0, 0x15, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 115043 +// gas irOptimized: 114852 // gas legacy: 122425 -// gas legacyOptimized: 120696 +// gas legacyOptimized: 120700 diff --git a/test/libsolidity/semanticTests/structs/copy_to_mapping.sol b/test/libsolidity/semanticTests/structs/copy_to_mapping.sol index 033f0f518c12..068dc3d8c682 100644 --- a/test/libsolidity/semanticTests/structs/copy_to_mapping.sol +++ b/test/libsolidity/semanticTests/structs/copy_to_mapping.sol @@ -45,18 +45,18 @@ contract C { } // ---- // from_state() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 121599 +// gas irOptimized: 121515 // gas legacy: 123053 -// gas legacyOptimized: 121700 +// gas legacyOptimized: 121704 // from_storage() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 121644 +// gas irOptimized: 121559 // gas legacy: 123102 -// gas legacyOptimized: 121752 +// gas legacyOptimized: 121756 // from_memory() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 122860 +// gas irOptimized: 122740 // gas legacy: 129997 -// gas legacyOptimized: 128646 +// gas legacyOptimized: 128645 // from_calldata((bytes,uint16[],uint16)): 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -> 0x20, 0x60, 0xa0, 21, 3, 0x666f6f0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -// gas irOptimized: 114958 +// gas irOptimized: 114824 // gas legacy: 118210 -// gas legacyOptimized: 115324 +// gas legacyOptimized: 115329 diff --git a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol index e5b139d5c3c7..5ba9765415d9 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol @@ -66,7 +66,7 @@ contract Test { } // ---- // load() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 -// gas irOptimized: 110317 +// gas irOptimized: 110772 // gas legacy: 112964 // gas legacyOptimized: 110876 // store() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 diff --git a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol index 856edc27be48..955e082b72ae 100644 --- a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol +++ b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol @@ -23,17 +23,17 @@ contract c { // ---- // storageEmpty -> 1 // set(uint256,bytes,uint256): 12, 0x60, 13, 33, "12345678901234567890123456789012", "3" -> true -// gas irOptimized: 133592 +// gas irOptimized: 133560 // gas legacy: 134628 -// gas legacyOptimized: 133871 +// gas legacyOptimized: 133858 // test(uint256): 32 -> "3" // storageEmpty -> 0 // copy() -> true // storageEmpty -> 1 // set(uint256,bytes,uint256): 12, 0x60, 13, 33, "12345678901234567890123456789012", "3" -> true -// gas irOptimized: 133592 +// gas irOptimized: 133560 // gas legacy: 134628 -// gas legacyOptimized: 133871 +// gas legacyOptimized: 133858 // storageEmpty -> 0 // del() -> true // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/structs/struct_copy.sol b/test/libsolidity/semanticTests/structs/struct_copy.sol index a321f0686897..1fb9ef2168f6 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy.sol @@ -35,12 +35,12 @@ contract c { } // ---- // set(uint256): 7 -> true -// gas irOptimized: 109893 +// gas irOptimized: 109932 // gas legacy: 110597 // gas legacyOptimized: 110003 // retrieve(uint256): 7 -> 1, 3, 4, 2 // copy(uint256,uint256): 7, 8 -> true -// gas irOptimized: 118582 +// gas irOptimized: 118581 // gas legacy: 119147 // gas legacyOptimized: 118619 // retrieve(uint256): 7 -> 1, 3, 4, 2 diff --git a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol index 71b40acc80f6..6b8788d2c09d 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol @@ -17,6 +17,6 @@ contract c { } // ---- // test() -> true -// gas irOptimized: 109706 +// gas irOptimized: 109921 // gas legacy: 110615 // gas legacyOptimized: 109705 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol index d76618bbc9fc..28998df448dd 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol @@ -42,10 +42,10 @@ contract C { } // ---- // f() -> -// gas irOptimized: 113210 +// gas irOptimized: 113477 // gas legacy: 113591 // gas legacyOptimized: 113103 // g() -> -// gas irOptimized: 118580 +// gas irOptimized: 118843 // gas legacy: 118764 // gas legacyOptimized: 118172 diff --git a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol index 9af3774692a9..bd9fcf3e2303 100644 --- a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol +++ b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol @@ -28,6 +28,6 @@ contract C { } // ---- // f() -> 42, 23, 34, 42, 42 -// gas irOptimized: 110382 +// gas irOptimized: 110682 // gas legacy: 111993 // gas legacyOptimized: 110546 diff --git a/test/libsolidity/semanticTests/structs/structs.sol b/test/libsolidity/semanticTests/structs/structs.sol index b5e9d10bb844..190387051349 100644 --- a/test/libsolidity/semanticTests/structs/structs.sol +++ b/test/libsolidity/semanticTests/structs/structs.sol @@ -30,7 +30,7 @@ contract test { // ---- // check() -> false // set() -> -// gas irOptimized: 134417 +// gas irOptimized: 134073 // gas legacy: 135246 // gas legacyOptimized: 134062 // check() -> true diff --git a/test/libsolidity/semanticTests/types/mapping/copy_from_mapping_to_mapping.sol b/test/libsolidity/semanticTests/types/mapping/copy_from_mapping_to_mapping.sol index b17ba6d9160b..19c31f288011 100644 --- a/test/libsolidity/semanticTests/types/mapping/copy_from_mapping_to_mapping.sol +++ b/test/libsolidity/semanticTests/types/mapping/copy_from_mapping_to_mapping.sol @@ -29,6 +29,6 @@ contract C { } // ---- // f() -> 0x20, 7, 8, 9, 0xa0, 13, 2, 0x40, 0xa0, 2, 3, 4, 2, 3, 4 -// gas irOptimized: 197082 +// gas irOptimized: 197102 // gas legacy: 199891 -// gas legacyOptimized: 196817 +// gas legacyOptimized: 196845 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol b/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol index 9ed64be08bcf..1433386e5a24 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol @@ -49,13 +49,13 @@ contract C { } // ---- // test_f() -> true -// gas irOptimized: 122078 +// gas irOptimized: 122212 // gas legacy: 125322 -// gas legacyOptimized: 122709 +// gas legacyOptimized: 122694 // test_g() -> true -// gas irOptimized: 106215 +// gas irOptimized: 106428 // gas legacy: 111120 -// gas legacyOptimized: 106964 +// gas legacyOptimized: 106925 // addresses(uint256): 0 -> 0x18 // addresses(uint256): 1 -> 0x19 // addresses(uint256): 3 -> 0x1b diff --git a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol index 8976cf3c52cc..30aa590d6fa3 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol @@ -113,12 +113,12 @@ contract ERC20 { // ---- // constructor() // ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14 -// gas irOptimized: 121082 -// gas irOptimized code: 231600 +// gas irOptimized: 121322 +// gas irOptimized code: 234600 // gas legacy: 163352 // gas legacy code: 671400 -// gas legacyOptimized: 127448 -// gas legacyOptimized code: 285200 +// gas legacyOptimized: 127464 +// gas legacyOptimized code: 285400 // totalSupply() -> 20 // gas irOptimized: 23415 // gas legacy: 23653 diff --git a/test/libsolidity/semanticTests/various/address_code.sol b/test/libsolidity/semanticTests/various/address_code.sol index f283aaeaa3de..8b601ca8c14c 100644 --- a/test/libsolidity/semanticTests/various/address_code.sol +++ b/test/libsolidity/semanticTests/various/address_code.sol @@ -14,11 +14,11 @@ contract C { } // ---- // constructor() -> -// gas irOptimized: 70351 -// gas irOptimized code: 95800 +// gas irOptimized: 70760 +// gas irOptimized code: 94600 // gas legacy: 82380 // gas legacy code: 153800 -// gas legacyOptimized: 69496 +// gas legacyOptimized: 69400 // gas legacyOptimized code: 79200 // initCode() -> 0x20, 0 // f() -> true diff --git a/test/libsolidity/semanticTests/various/create_calldata.sol b/test/libsolidity/semanticTests/various/create_calldata.sol index b8ec252095c8..3ca50db13661 100644 --- a/test/libsolidity/semanticTests/various/create_calldata.sol +++ b/test/libsolidity/semanticTests/various/create_calldata.sol @@ -8,8 +8,8 @@ contract C { } // ---- // constructor(): 42 -> -// gas irOptimized: 67834 -// gas irOptimized code: 70400 +// gas irOptimized: 68239 +// gas irOptimized code: 69000 // gas legacy: 78029 // gas legacy code: 90200 // gas legacyOptimized: 68321 diff --git a/test/libsolidity/semanticTests/various/destructuring_assignment.sol b/test/libsolidity/semanticTests/various/destructuring_assignment.sol index b8236e2cd5ff..82183a112139 100644 --- a/test/libsolidity/semanticTests/various/destructuring_assignment.sol +++ b/test/libsolidity/semanticTests/various/destructuring_assignment.sol @@ -33,6 +33,6 @@ contract C { } // ---- // f(bytes): 0x20, 0x5, "abcde" -> 0 -// gas irOptimized: 241837 +// gas irOptimized: 242027 // gas legacy: 243284 -// gas legacyOptimized: 242420 +// gas legacyOptimized: 242395 diff --git a/test/libsolidity/semanticTests/various/erc20.sol b/test/libsolidity/semanticTests/various/erc20.sol index f7956c4c50eb..1a7718f6834f 100644 --- a/test/libsolidity/semanticTests/various/erc20.sol +++ b/test/libsolidity/semanticTests/various/erc20.sol @@ -96,12 +96,12 @@ contract ERC20 { // ---- // constructor() // ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14 -// gas irOptimized: 121248 -// gas irOptimized code: 232000 +// gas irOptimized: 121632 +// gas irOptimized code: 236800 // gas legacy: 159959 // gas legacy code: 647600 -// gas legacyOptimized: 126918 -// gas legacyOptimized code: 281800 +// gas legacyOptimized: 126934 +// gas legacyOptimized code: 282000 // totalSupply() -> 20 // gas irOptimized: 23415 // gas legacy: 23524 diff --git a/test/libsolidity/semanticTests/various/many_subassemblies.sol b/test/libsolidity/semanticTests/various/many_subassemblies.sol index 67a576da7889..b270c7006694 100644 --- a/test/libsolidity/semanticTests/various/many_subassemblies.sol +++ b/test/libsolidity/semanticTests/various/many_subassemblies.sol @@ -30,7 +30,7 @@ contract D { } // ---- // run() -> -// gas irOptimized: 375015 +// gas irOptimized: 374934 // gas irOptimized code: 6600 // gas legacy: 375119 // gas legacy code: 17600 diff --git a/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_multiple_beneficiaries.sol b/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_multiple_beneficiaries.sol index 16797ee4c0fd..690bff8d5588 100644 --- a/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_multiple_beneficiaries.sol +++ b/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_multiple_beneficiaries.sol @@ -35,8 +35,8 @@ contract D { // EVMVersion: >=cancun // ---- // constructor(), 2 ether -> -// gas irOptimized: 107718 -// gas irOptimized code: 116200 +// gas irOptimized: 108104 +// gas irOptimized code: 119200 // gas legacy: 120424 // gas legacy code: 253600 // gas legacyOptimized: 109015 @@ -46,7 +46,7 @@ contract D { // balance -> 2000000000000000000 // exists() -> false // test_deploy_and_terminate_twice() -> -// gas irOptimized: 121350 +// gas irOptimized: 121395 // gas irOptimized code: 14000 // gas legacy: 122384 // gas legacy code: 43200 diff --git a/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_redeploy.sol b/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_redeploy.sol index 1b3022efedf0..1ae89a558e70 100644 --- a/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_redeploy.sol +++ b/test/libsolidity/semanticTests/various/selfdestruct_post_cancun_redeploy.sol @@ -82,8 +82,8 @@ contract D { // EVMVersion: >=cancun // ---- // constructor(), 1 ether -> -// gas irOptimized: 132874 -// gas irOptimized code: 292400 +// gas irOptimized: 132974 +// gas irOptimized code: 293800 // gas legacy: 151217 // gas legacy code: 533400 // gas legacyOptimized: 131436 @@ -91,7 +91,7 @@ contract D { // exists() -> false // test_deploy_and_terminate() -> // ~ emit Deployed(address,bytes32) from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a: 0x7e6580007e709ac52945fae182c61131d42634e8, 0x1234000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 96394 +// gas irOptimized: 96528 // gas irOptimized code: 20800 // gas legacy: 97788 // gas legacy code: 20800 diff --git a/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_multiple_beneficiaries.sol b/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_multiple_beneficiaries.sol index a09a7cac68b1..dbe7109cbd9e 100644 --- a/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_multiple_beneficiaries.sol +++ b/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_multiple_beneficiaries.sol @@ -35,8 +35,8 @@ contract D { // EVMVersion: <=shanghai // ---- // constructor(), 2 ether -> -// gas irOptimized: 107718 -// gas irOptimized code: 116200 +// gas irOptimized: 108104 +// gas irOptimized code: 119200 // gas legacy: 120424 // gas legacy code: 253600 // gas legacyOptimized: 109015 @@ -46,7 +46,7 @@ contract D { // balance -> 2000000000000000000 // exists() -> false // test_deploy_and_terminate_twice() -> -// gas irOptimized: 121350 +// gas irOptimized: 121395 // gas irOptimized code: 14000 // gas legacy: 122384 // gas legacy code: 43200 diff --git a/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_redeploy.sol b/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_redeploy.sol index fc650ebba741..0d7f2334ebc0 100644 --- a/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_redeploy.sol +++ b/test/libsolidity/semanticTests/various/selfdestruct_pre_cancun_redeploy.sol @@ -79,8 +79,8 @@ contract D { // EVMVersion: =shanghai // ---- // constructor(), 1 ether -> -// gas irOptimized: 133253 -// gas irOptimized code: 297000 +// gas irOptimized: 133342 +// gas irOptimized code: 298400 // gas legacy: 151644 // gas legacy code: 538600 // gas legacyOptimized: 131799 @@ -88,7 +88,7 @@ contract D { // exists() -> false // test_deploy_and_terminate() -> // ~ emit Deployed(address,bytes32) from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a: 0x7e6580007e709ac52945fae182c61131d42634e8, 0x1234000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 96689 +// gas irOptimized: 96823 // gas irOptimized code: 20800 // gas legacy: 98095 // gas legacy code: 20800 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol index ef53a4e47848..9d078cfd698c 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -19,6 +19,6 @@ contract C { } // ---- // g() -> 2, 6 -// gas irOptimized: 178263 +// gas irOptimized: 178195 // gas legacy: 180657 -// gas legacyOptimized: 179156 +// gas legacyOptimized: 179146 diff --git a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol index 77a330f3cd54..2063fff7a571 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol @@ -45,7 +45,7 @@ contract D { // gas legacyOptimized: 98425380 // gas legacyOptimized code: 13200 // fpure() -> FAILURE -// gas irOptimized: 98425389 +// gas irOptimized: 98425388 // gas irOptimized code: 13200 // gas legacy: 98413174 // gas legacy code: 25600 diff --git a/test/libsolidity/semanticTests/various/value_complex.sol b/test/libsolidity/semanticTests/various/value_complex.sol index 427a006dc102..dc92e38df59b 100644 --- a/test/libsolidity/semanticTests/various/value_complex.sol +++ b/test/libsolidity/semanticTests/various/value_complex.sol @@ -19,8 +19,8 @@ contract test { } // ---- // constructor(), 20 wei -> -// gas irOptimized: 114399 -// gas irOptimized code: 58000 +// gas irOptimized: 114463 +// gas irOptimized code: 58800 // gas legacy: 120076 // gas legacy code: 132200 // gas legacyOptimized: 114536 diff --git a/test/libsolidity/semanticTests/various/value_insane.sol b/test/libsolidity/semanticTests/various/value_insane.sol index 97fbbab1e634..ad0e95701d07 100644 --- a/test/libsolidity/semanticTests/various/value_insane.sol +++ b/test/libsolidity/semanticTests/various/value_insane.sol @@ -18,8 +18,8 @@ contract test { } // ---- // constructor(), 20 wei -> -// gas irOptimized: 114463 -// gas irOptimized code: 58800 +// gas irOptimized: 114527 +// gas irOptimized code: 59600 // gas legacy: 120200 // gas legacy code: 133600 // gas legacyOptimized: 114568 diff --git a/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol b/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol index 5a85ba07591a..fbaa7789ea0e 100644 --- a/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol +++ b/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol @@ -21,6 +21,6 @@ contract C { } // ---- // f() -> -// gas irOptimized: 112969 +// gas irOptimized: 113118 // gas legacy: 112890 // gas legacyOptimized: 112580 diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal.sol index 08c48cbd99de..47b15369c04c 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal.sol @@ -2,18 +2,16 @@ contract C { function abiencodePackedStringLiteral() public pure { bytes memory b1 = abi.encodePacked(""); bytes memory b2 = abi.encodePacked(""); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b2.length); + assert(b1.length == b2.length); // should hold bytes memory b3 = abi.encodePacked(bytes("")); - assert(b1.length == b3.length); // should fail + assert(b1.length == b3.length); // should hold bytes memory b4 = abi.encodePacked(bytes24("")); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b4.length); + assert(b1.length == b4.length); // should fail bytes memory b5 = abi.encodePacked(string("")); - assert(b1.length == b5.length); // should fail + assert(b1.length == b5.length); // should hold, but currently fails due to abstraction bytes memory b6 = abi.encode(""); assert(b1.length == b6.length); // should fail @@ -21,10 +19,8 @@ contract C { } // ==== // SMTEngine: all -// SMTIgnoreOS: macos // ---- -// Warning 6328: (226-256): CHC: Assertion violation happens here.\nCounterexample:\n\nb1 = [0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42]\nb3 = []\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (310-340): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72]\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (483-513): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (568-598): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc]\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (654-684): CHC: Assertion violation happens here.\nCounterexample:\n\nb3 = [0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a]\nb6 = [0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117]\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Warning 6328: (354-384): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Warning 6328: (454-484): CHC: Assertion violation happens here.\nCounterexample:\n\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Warning 6328: (580-610): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal_no_unproved.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal_no_unproved.sol index f80027626102..581e649fcbbe 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal_no_unproved.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_string_literal_no_unproved.sol @@ -2,18 +2,16 @@ contract C { function abiencodePackedStringLiteral() public pure { bytes memory b1 = abi.encodePacked(""); bytes memory b2 = abi.encodePacked(""); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b2.length); + assert(b1.length == b2.length); // should hold bytes memory b3 = abi.encodePacked(bytes("")); - assert(b1.length == b3.length); // should fail + assert(b1.length == b3.length); // should hold bytes memory b4 = abi.encodePacked(bytes24("")); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b4.length); + assert(b1.length == b4.length); // should fail bytes memory b5 = abi.encodePacked(string("")); - assert(b1.length == b5.length); // should fail + assert(b1.length == b5.length); // should hold, but fails due to abstraction bytes memory b6 = abi.encode(""); assert(b1.length == b6.length); // should fail @@ -22,10 +20,8 @@ contract C { // ==== // SMTEngine: all // SMTShowUnproved: no -// SMTIgnoreOS: macos // ---- -// Warning 6328: (226-256): CHC: Assertion violation happens here.\nCounterexample:\n\nb1 = [0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42]\nb3 = []\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (310-340): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72]\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (483-513): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (568-598): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc]\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() -// Warning 6328: (654-684): CHC: Assertion violation happens here.\nCounterexample:\n\nb3 = [0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a, 0x011a]\nb6 = [0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117]\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Warning 6328: (354-384): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Warning 6328: (454-484): CHC: Assertion violation happens here.\nCounterexample:\n\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Warning 6328: (570-600): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedStringLiteral() +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_string_literal.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_string_literal.sol index b55952ee74f6..77d3cfb83be4 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_string_literal.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_string_literal.sol @@ -2,25 +2,22 @@ contract C { function abiEncodeStringLiteral() public pure { bytes memory b1 = abi.encode(""); bytes memory b2 = abi.encode(""); - // should hold, but currently fails due to string literal abstraction + // should hold assert(b1.length == b2.length); bytes memory b3 = abi.encode(bytes("")); - assert(b1.length == b3.length); // should fail + assert(b1.length == b3.length); // should hold bytes memory b4 = abi.encode(bytes24("")); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b4.length); + assert(b1.length == b4.length); // should fail bytes memory b5 = abi.encode(string("")); - assert(b1.length == b5.length); // should fail + assert(b1.length == b5.length); // should hold, but currently fails due to abstraction } } // ==== // SMTEngine: all -// SMTIgnoreOS: macos // ---- -// Warning 6328: (208-238): CHC: Assertion violation happens here.\nCounterexample:\n\nb3 = []\nb4 = []\nb5 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral() -// Warning 6328: (286-316): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d]\nb3 = [0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d]\nb4 = []\nb5 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral() -// Warning 6328: (453-483): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral() -// Warning 6328: (532-562): CHC: Assertion violation happens here.\nCounterexample:\n\nb3 = [0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca]\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral() +// Warning 6328: (326-356): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral() +// Warning 6328: (420-450): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral() +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_string_literal.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_string_literal.sol index 6d1ab3066c84..dd183263a42f 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_string_literal.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_string_literal.sol @@ -2,18 +2,17 @@ contract C { function abiEncodeStringLiteral(bytes4 sel) public pure { bytes memory b1 = abi.encodeWithSelector(sel, ""); bytes memory b2 = abi.encodeWithSelector(sel, ""); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b2.length); + + assert(b1.length == b2.length); // should hold bytes memory b3 = abi.encodeWithSelector(sel, bytes("")); - assert(b1.length == b3.length); // should fail + assert(b1.length == b3.length); // should hold bytes memory b4 = abi.encodeWithSelector(sel, bytes24("")); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b4.length); + assert(b1.length == b4.length); // should fail bytes memory b5 = abi.encodeWithSelector(sel, string("")); - assert(b1.length == b5.length); // should fail + assert(b1.length == b5.length); // should hold, but currently fails due to abstraction bytes memory b6 = abi.encodeWithSelector(0xcafecafe, bytes24("")); assert(b4.length == b6.length); // should fail @@ -21,10 +20,8 @@ contract C { } // ==== // SMTEngine: all -// SMTIgnoreOS: macos // ---- -// Warning 6328: (252-282): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb1 = [0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46]\nb3 = []\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) -// Warning 6328: (347-377): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb3 = [0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d]\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) -// Warning 6328: (531-561): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb1 = [0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90]\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) -// Warning 6328: (627-657): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb5 = [0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1]\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) -// Warning 6328: (746-776): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb2 = []\nb5 = [0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2]\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) +// Warning 6328: (403-433): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) +// Warning 6328: (514-544): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) +// Warning 6328: (673-703): CHC: Assertion violation happens here.\nCounterexample:\n\nsel = 0x0\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(0x0) +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice.sol index fad7437448f3..b2d1b4acc6d0 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice.sol @@ -24,10 +24,7 @@ contract C { } // ==== // SMTEngine: all -// SMTIgnoreOS: macos // ---- -// Warning 6328: (334-364): CHC: Assertion violation happens here. +// Warning 6328: (334-364): CHC: Assertion violation happens here.\nCounterexample:\n\ndata = [0x4f]\nb2 = [0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c]\nb3 = []\nb4 = []\nx = 0\ny = 0\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeSlice(sig, [0x4f]) -- counterexample incomplete; parameter name used instead of value // Warning 6328: (588-618): CHC: Assertion violation happens here. -// Warning 6328: (1086-1116): CHC: Assertion violation might happen here. -// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Warning 4661: (1086-1116): BMC: Assertion violation happens here. +// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice_2.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice_2.sol index 41e71ee5bf0e..4c21a02a6bbb 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice_2.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_array_slice_2.sol @@ -24,10 +24,7 @@ contract C { } // ==== // SMTEngine: all -// SMTIgnoreOS: macos // ---- -// Warning 6328: (335-365): CHC: Assertion violation happens here. +// Warning 6328: (335-365): CHC: Assertion violation happens here.\nCounterexample:\n\ndata = [36]\nb3 = []\nb4 = []\nx = 0\ny = 0\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeSlice(sig, [36]) -- counterexample incomplete; parameter name used instead of value // Warning 6328: (589-619): CHC: Assertion violation happens here. -// Warning 6328: (1087-1117): CHC: Assertion violation might happen here. -// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Warning 4661: (1087-1117): BMC: Assertion violation happens here. +// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_string_literal.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_string_literal.sol index de218cfaa6d6..ca782442b6f1 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_string_literal.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_string_literal.sol @@ -2,18 +2,16 @@ contract C { function abiEncodeStringLiteral(string memory sig) public pure { bytes memory b1 = abi.encodeWithSignature(sig, ""); bytes memory b2 = abi.encodeWithSignature(sig, ""); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b2.length); + assert(b1.length == b2.length); // should hold bytes memory b3 = abi.encodeWithSignature(sig, bytes("")); - assert(b1.length == b3.length); // should fail + assert(b1.length == b3.length); // should hold bytes memory b4 = abi.encodeWithSignature(sig, bytes24("")); - // should hold, but currently fails due to string literal abstraction - assert(b1.length == b4.length); + assert(b1.length == b4.length); // should fail bytes memory b5 = abi.encodeWithSignature(sig, string("")); - assert(b1.length == b5.length); // should fail + assert(b1.length == b5.length); // should hold, but currently fails due to abstraction bytes memory b6 = abi.encodeWithSelector("f()", bytes24("")); assert(b4.length == b6.length); // should fail @@ -21,10 +19,8 @@ contract C { } // ==== // SMTEngine: all -// SMTIgnoreOS: macos // ---- -// Warning 6328: (261-291): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a]\nb3 = []\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -// Warning 6328: (357-387): CHC: Assertion violation happens here.\nCounterexample:\n\nb3 = [0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90]\nb4 = []\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -// Warning 6328: (542-572): CHC: Assertion violation happens here.\nCounterexample:\n\nb3 = [0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa]\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -// Warning 6328: (639-669): CHC: Assertion violation happens here.\nCounterexample:\n\nb4 = [0x22, 0x22, 0x22, 0x22, 0x22, 0x0d, 0x22, 0x22, 0x22, 0x22, 0x09, 0x22, 0x0b, 0x22, 0x22, 0x0e, 0x22, 0x10, 0x22, 0x12, 0x22, 0x14, 0x22, 0x16, 0x22, 0x18, 0x22, 0x1a, 0x22, 0x1c, 0x22, 0x1e, 0x22, 0x20, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22]\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -// Warning 6328: (753-783): CHC: Assertion violation happens here.\nCounterexample:\n\nb2 = [0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117, 0x0117]\nb4 = []\nb5 = [0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118]\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) +// Warning 6328: (413-443): CHC: Assertion violation happens here.\nCounterexample:\n\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -- counterexample incomplete; parameter name used instead of value +// Warning 6328: (525-555): CHC: Assertion violation happens here.\nCounterexample:\n\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -- counterexample incomplete; parameter name used instead of value +// Warning 6328: (679-709): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.abiEncodeStringLiteral(sig) -- counterexample incomplete; parameter name used instead of value +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol index 387e45bb9f46..720ab5695029 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend.sol @@ -19,5 +19,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (280-314): CHC: Assertion violation happens here. -// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Warning 1236: (175-190): BMC: Insufficient funds happens here. +// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol index 5df0b99956f2..3ceac964f111 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/balance_spend_2.sol @@ -15,9 +15,9 @@ contract C { // ==== // SMTEngine: all // SMTIgnoreCex: yes +// SMTIgnoreOS: macos // ---- -// Warning 6328: (193-226): CHC: Assertion violation might happen here. +// Warning 8656: (141-156): CHC: Insufficient funds happens here. +// Warning 6328: (193-226): CHC: Assertion violation happens here. // Warning 6328: (245-279): CHC: Assertion violation happens here. // Warning 6328: (298-332): CHC: Assertion violation happens here. -// Warning 1236: (141-156): BMC: Insufficient funds happens here. -// Warning 4661: (193-226): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/decreasing_balance.sol b/test/libsolidity/smtCheckerTests/blockchain_state/decreasing_balance.sol index 76455060d8d5..df35a2785824 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/decreasing_balance.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/decreasing_balance.sol @@ -18,4 +18,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. +// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/free_function_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/free_function_2.sol index e2e187038ca1..3b7c0f9dce34 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/free_function_2.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/free_function_2.sol @@ -20,5 +20,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (258-274): CHC: Assertion violation happens here. -// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Warning 1236: (33-46): BMC: Insufficient funds happens here. +// Info 1391: CHC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/library_internal_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/library_internal_2.sol index f16a57acf68f..826af0bf867d 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/library_internal_2.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/library_internal_2.sol @@ -23,5 +23,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (315-331): CHC: Assertion violation happens here. -// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Warning 1236: (87-100): BMC: Insufficient funds happens here. +// Info 1391: CHC: 4 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/library_public_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/library_public_2.sol index 4b500581d323..02e29be8de9c 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/library_public_2.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/library_public_2.sol @@ -21,6 +21,6 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 4588: (238-243): Assertion checker does not yet implement this type of function call. +// Warning 8656: (54-67): CHC: Insufficient funds happens here. // Warning 6328: (282-298): CHC: Assertion violation happens here. // Warning 6328: (317-331): CHC: Assertion violation happens here. -// Warning 1236: (54-67): BMC: Insufficient funds happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/transfer.sol b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_1.sol similarity index 66% rename from test/libsolidity/smtCheckerTests/blockchain_state/transfer.sol rename to test/libsolidity/smtCheckerTests/blockchain_state/transfer_1.sol index c099ffb2e5c9..3118086b921a 100644 --- a/test/libsolidity/smtCheckerTests/blockchain_state/transfer.sol +++ b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_1.sol @@ -12,5 +12,4 @@ contract C { // SMTIgnoreCex: yes // ---- // Warning 6328: (166-201): CHC: Assertion violation happens here. -// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. \ No newline at end of file diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/transfer_2.sol b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_2.sol new file mode 100644 index 000000000000..ed5b4c90f2cf --- /dev/null +++ b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_2.sol @@ -0,0 +1,14 @@ +contract C { + address payable recipient; + uint amount; + + function shouldHold() public { + uint tempAmount = address(this).balance; + recipient.transfer(tempAmount); + recipient.transfer(amount); + } +} +// ==== +// SMTEngine: chc +// ---- +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/transfer_3.sol b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_3.sol new file mode 100644 index 000000000000..4b3318b6bece --- /dev/null +++ b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_3.sol @@ -0,0 +1,11 @@ +contract C { + address payable recipient; + + function shouldFail() public { + recipient.transfer(1); + } +} +// ==== +// SMTEngine: all +// ---- +// Warning 8656: (76-97): CHC: Insufficient funds happens here. diff --git a/test/libsolidity/smtCheckerTests/blockchain_state/transfer_4.sol b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_4.sol new file mode 100644 index 000000000000..ab0c4a81efeb --- /dev/null +++ b/test/libsolidity/smtCheckerTests/blockchain_state/transfer_4.sol @@ -0,0 +1,12 @@ +contract C { + address payable recipient; + + function f() public payable { + require(msg.value > 1); + recipient.transfer(1); + } +} +// ==== +// SMTEngine: all +// ---- +// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_array.sol b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_array.sol new file mode 100644 index 000000000000..b0e3b9565aab --- /dev/null +++ b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_array.sol @@ -0,0 +1,23 @@ +contract C { + function c1() public pure { + bytes32 k1 = keccak256(abi.encode([1])); + bytes32 k2 = keccak256(abi.encode([1])); + assert(k1 == k2); + } + + function c2() public pure { + bytes32 s1 = sha256(abi.encode([1,2])); + bytes32 s2 = sha256(abi.encode([1,2])); + assert(s1 == s2); + } + + function c3() public pure { + bytes32 r1 = ripemd160(abi.encode([1,2,3])); + bytes32 r2 = ripemd160(abi.encode([1,2,3])); + assert(r1 == r2); + } +} +// ==== +// SMTEngine: chc +// ---- +// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_string_literal.sol b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_string_literal.sol new file mode 100644 index 000000000000..9e5123ab5bd5 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/crypto/crypto_functions_same_string_literal.sol @@ -0,0 +1,23 @@ +contract C { + function c1() public pure { + bytes32 k1 = keccak256("1"); + bytes32 k2 = keccak256("1"); + assert(k1 == k2); + } + + function c2() public pure { + bytes32 s1 = sha256("10"); + bytes32 s2 = sha256("10"); + assert(s1 == s2); + } + + function c3() public pure { + bytes32 r1 = ripemd160("100"); + bytes32 r2 = ripemd160("100"); + assert(r1 == r2); + } +} +// ==== +// SMTEngine: chc +// ---- +// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_mutex_unsafe.sol b/test/libsolidity/smtCheckerTests/external_calls/call_mutex_unsafe.sol index e8c17d3eb05f..d2fefcd5f743 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_mutex_unsafe.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_mutex_unsafe.sol @@ -21,7 +21,7 @@ contract C { } // ==== // SMTEngine: all -// SMTIgnoreCex: no +// SMTIgnoreCex: yes // ---- // Warning 9302: (212-228): Return value of low-level calls not used. -// Warning 6328: (232-246): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, lock = false\n_a = 0x0\ny = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0, lock = false\nC.set(1)\nState: x = 1, lock = false\nC.f(0x0)\n _a.call("aaaaa") -- untrusted external call, synthesized as:\n C.set(0) -- reentrant call +// Warning 6328: (232-246): CHC: Assertion violation happens here.\nCounterexample:\nx = 1, lock = false\n_a = 0x0\ny = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0, lock = false\nC.f(0x0)\n _a.call("aaaaa") -- untrusted external call, synthesized as:\n C.set(1) -- reentrant call diff --git a/test/libsolidity/smtCheckerTests/functions/functions_library_internal.sol b/test/libsolidity/smtCheckerTests/functions/functions_library_internal.sol index 405c3f71507e..d2f2d6923de1 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_library_internal.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_library_internal.sol @@ -7,7 +7,7 @@ contract C { function f() public { function()internal x; x.value(42); - } + } } // ==== // SMTEngine: all diff --git a/test/libsolidity/smtCheckerTests/functions/this_state.sol b/test/libsolidity/smtCheckerTests/functions/this_state.sol index dec101060d8c..d069bd90f8e1 100644 --- a/test/libsolidity/smtCheckerTests/functions/this_state.sol +++ b/test/libsolidity/smtCheckerTests/functions/this_state.sol @@ -1,14 +1,14 @@ contract C { - uint public x; - function g() public { + uint public x; + function g() public { x = 0; - this.h(); + this.h(); assert(x == 2); - } - function h() public { - x = 2; - } + } + function h() public { + x = 2; + } } // ==== // SMTEngine: all diff --git a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_6.sol b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_6.sol index d0a917fa915c..4880b3a0d5c3 100644 --- a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_6.sol +++ b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_6.sol @@ -4,7 +4,7 @@ contract C { do { ++x; if (x > 0) { - x = 2; + x = 2; break; } if (x > 1) { diff --git a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_7.sol b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_7.sol index 52c3270ba7ea..5b4d6579bff7 100644 --- a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_7.sol +++ b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_7.sol @@ -6,11 +6,11 @@ contract C { if (x > 1) { x = 3; break; - } + } if (x > 0) { x = 2; break; - } + } } while (x < 3); assert(x == 2); } diff --git a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_1.sol b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_1.sol index 53ce958fab1a..43a5f91f5ab5 100644 --- a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_1.sol +++ b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_1.sol @@ -4,11 +4,11 @@ contract C { do { if (x > 1) { break; - } + } if (x >= 0) { x = 10; continue; - } + } } while (x < 3); assert(x == 10); } diff --git a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_2.sol b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_2.sol index 12d6fff6f5a8..eed910118470 100644 --- a/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_2.sol +++ b/test/libsolidity/smtCheckerTests/loops/do_while_bmc_iterations_break_continue_2.sol @@ -5,11 +5,11 @@ contract C { if (x > 1) { x = 3; break; - } + } if (x >= 0) { x = 2; continue; - } + } } while (x < 4); assert(x == 3); } diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_2.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_2.sol index cada2d85195e..e7ff49daed1d 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_2.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_2.sol @@ -4,7 +4,7 @@ contract C uint x; for (uint i = 0; i < 3; ++i) { ++x; - break; + break; } assert(x == 1); } diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_8.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_8.sol index a88a031e75e1..1778e22d5aff 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_8.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_8.sol @@ -3,7 +3,7 @@ contract C function f() public pure { uint x; for (;;) { - break; + break; ++x; } assert(x == 0); @@ -14,5 +14,5 @@ contract C // SMTSolvers: z3 // BMCLoopIterations: 4 // ---- -// Warning 5740: (78-81): Unreachable code. +// Warning 5740: (77-80): Unreachable code. // Info 6002: BMC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_9.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_9.sol index 4ce3d9268e89..8106ba30f9f8 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_9.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_9.sol @@ -4,7 +4,7 @@ contract C uint x; for (;x < 2;) { ++x; - break; + break; } assert(x == 1); } diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_1.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_1.sol index b999f9cf6176..1dbe81a96929 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_1.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_1.sol @@ -5,11 +5,11 @@ contract C for (uint i = 0; i < 3; ++i) { if (i > 1) { break; - } + } if (i >= 0) { x = 10; continue; - } + } } assert(x == 10); } diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_2.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_2.sol index 0da0f5d9940f..1781f77ce7f4 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_2.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_2.sol @@ -6,7 +6,7 @@ contract C if (i > 0) { x = 1; break; - } + } if (i >= 0) { x = 2; continue; diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_3.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_3.sol index 9f762bb43674..9336127581b5 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_3.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_break_continue_3.sol @@ -6,7 +6,7 @@ contract C if (i > 0) { x = 1; break; - } else { + } else { x = 2; continue; } diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_continue_3.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_continue_3.sol index b74709e484fd..6f999a14cf7f 100644 --- a/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_continue_3.sol +++ b/test/libsolidity/smtCheckerTests/loops/for_loop_bmc_iterations_continue_3.sol @@ -7,7 +7,7 @@ contract C x = 10; continue; } - if (x > 0) { + if (x > 0) { x = 11; continue; } diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_8.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_8.sol index b7ad4e2ecb0b..69c49d8f8982 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_8.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_8.sol @@ -3,7 +3,7 @@ contract C uint256[] y; function f() public view { - uint256 x = 0; + uint256 x = 0; while (x < y.length) { x = 1; } diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_4.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_4.sol index d1939871bf39..989130a138ae 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_4.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_4.sol @@ -4,7 +4,7 @@ contract C { while (x < 3) { ++x; if (x > 0) { - ++x; + ++x; break; } } diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_6.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_6.sol index 0546e48c0ddb..9f2bdd1aa224 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_6.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_6.sol @@ -4,7 +4,7 @@ contract C { while (x < 3) { ++x; if (x > 0) { - x = 2; + x = 2; break; } if (x > 1) { diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_7.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_7.sol index 8e4d3b6261d0..c1aca1bcc328 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_7.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_7.sol @@ -6,11 +6,11 @@ contract C { if (x > 1) { x = 3; break; - } + } if (x > 0) { x = 2; break; - } + } } assert(x == 2); } diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_1.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_1.sol index bb9554523453..6332d20e3e29 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_1.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_1.sol @@ -4,11 +4,11 @@ contract C { while (x < 3) { if (x > 1) { break; - } + } if (x >= 0) { x = 10; continue; - } + } } assert(x == 10); } diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_2.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_2.sol index b65404e22f76..c4e47d528961 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_2.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_break_continue_2.sol @@ -5,11 +5,11 @@ contract C { if (x > 1) { x = 3; break; - } + } if (x >= 0) { x = 2; continue; - } + } } assert(x == 3); } diff --git a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_semantics_2.sol b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_semantics_2.sol index a50acf4d2b4e..157cc61b6569 100644 --- a/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_semantics_2.sol +++ b/test/libsolidity/smtCheckerTests/loops/while_bmc_iterations_semantics_2.sol @@ -7,7 +7,7 @@ contract C { y = 1; ++x; } - // BMC loop iteration setting is just enough to leave the loop + // BMC loop iteration setting is just enough to leave the loop assert(x == 3); assert(y == 1); // should fail assert(y == 0); @@ -18,5 +18,5 @@ contract C { // SMTSolvers: z3 // BMCLoopIterations: 3 // ---- -// Warning 4661: (220-234): BMC: Assertion violation happens here. +// Warning 4661: (219-233): BMC: Assertion violation happens here. // Info 6002: BMC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/operators/bitwise_and_array.sol b/test/libsolidity/smtCheckerTests/operators/bitwise_and_array.sol new file mode 100644 index 000000000000..96e143490926 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/bitwise_and_array.sol @@ -0,0 +1,17 @@ +contract C { + function bitwiseXor(int[10] memory p) public pure { + 1 ^ p[0]; + } + + function bitwiseAnd(int[10] memory p) public pure { + 1 & p[0]; + } + + function bitwiseOr(int[10] memory p) public pure { + 1 | p[0]; + } +} +// ==== +// SMTEngine: all +// ---- +// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/operators/delete_multid_array.sol b/test/libsolidity/smtCheckerTests/operators/delete_multid_array.sol index 53a1a253e00e..ea6eb3a9aa0a 100644 --- a/test/libsolidity/smtCheckerTests/operators/delete_multid_array.sol +++ b/test/libsolidity/smtCheckerTests/operators/delete_multid_array.sol @@ -9,21 +9,21 @@ contract C { delete a; assert(a.length == 0); } - function g(uint x, uint y, uint v) public { + function g(uint x, uint y, uint v) public { require(x < b.length); require(y < b[x].length); b[x][y] = v; delete b; assert(b.length == 0); } - function h(uint x, uint y, uint v) public { + function h(uint x, uint y, uint v) public { require(x < b.length); require(y < b[x].length); b[x][y] = v; delete b[x]; assert(b[x].length == 0); } - function i(uint x, uint y, uint v) public { + function i(uint x, uint y, uint v) public { require(x < b.length); require(y < b[x].length); b[x][y] = v; @@ -31,7 +31,7 @@ contract C { delete b[y]; assert(b[y].length == 0); } - function j(uint x, uint y, uint z, uint v) public { + function j(uint x, uint y, uint z, uint v) public { require(x < b.length); require(y < b[x].length); b[x][y] = v; diff --git a/test/libsolidity/smtCheckerTests/operators/ternary_operator_with_functions.sol b/test/libsolidity/smtCheckerTests/operators/ternary_operator_with_functions.sol new file mode 100644 index 000000000000..8214862e7c82 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/ternary_operator_with_functions.sol @@ -0,0 +1,11 @@ +contract C { + function f() public {} + function g() public {} + + function test() public { + true ? f() : g(); + } +} +// ==== +// SMTEngine: all +// ---- diff --git a/test/libsolidity/smtCheckerTests/operators/ternary_operator_with_tuple.sol b/test/libsolidity/smtCheckerTests/operators/ternary_operator_with_tuple.sol new file mode 100644 index 000000000000..d05d699c3373 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/operators/ternary_operator_with_tuple.sol @@ -0,0 +1,18 @@ +contract C { + function empty_tuple() public pure { + true ? () : (); // bug fix test, proper handling of empty tuples + } + + function non_empty_tuple() public pure { + true ? (1, 2) : (3, 4); + } + + function return_empty_tuple() public pure { + return true ? () : (); + } +} +// ==== +// SMTEngine: all +// ---- +// Warning 6133: (53-67): Statement has no effect. +// Warning 6133: (166-188): Statement has no effect. diff --git a/test/libsolidity/smtCheckerTests/types/address_transfer.sol b/test/libsolidity/smtCheckerTests/types/address_transfer.sol index 89e8ae10274e..1430e15cb8e7 100644 --- a/test/libsolidity/smtCheckerTests/types/address_transfer.sol +++ b/test/libsolidity/smtCheckerTests/types/address_transfer.sol @@ -11,5 +11,5 @@ contract C // ==== // SMTEngine: all // ---- +// Warning 8656: (98-113): CHC: Insufficient funds happens here. // Warning 6328: (162-186): CHC: Assertion violation happens here. -// Warning 1236: (98-113): BMC: Insufficient funds happens here. diff --git a/test/libsolidity/smtCheckerTests/types/address_transfer_2.sol b/test/libsolidity/smtCheckerTests/types/address_transfer_2.sol index 0a2c08d0caab..ce6492d9e57a 100644 --- a/test/libsolidity/smtCheckerTests/types/address_transfer_2.sol +++ b/test/libsolidity/smtCheckerTests/types/address_transfer_2.sol @@ -15,6 +15,6 @@ contract C // SMTEngine: all // SMTIgnoreCex: yes // ---- +// Warning 8656: (184-199): CHC: Insufficient funds happens here. +// Warning 8656: (203-218): CHC: Insufficient funds happens here. // Warning 6328: (262-291): CHC: Assertion violation happens here. -// Warning 1236: (184-199): BMC: Insufficient funds happens here. -// Warning 1236: (203-218): BMC: Insufficient funds happens here. diff --git a/test/libsolidity/smtCheckerTests/types/address_transfer_3.sol b/test/libsolidity/smtCheckerTests/types/address_transfer_3.sol index 02d20c4f5bc4..3f9cc22c7bd6 100644 --- a/test/libsolidity/smtCheckerTests/types/address_transfer_3.sol +++ b/test/libsolidity/smtCheckerTests/types/address_transfer_3.sol @@ -13,5 +13,4 @@ contract C // ==== // SMTEngine: all // ---- -// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. -// Info 6002: BMC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/types/address_transfer_insufficient.sol b/test/libsolidity/smtCheckerTests/types/address_transfer_insufficient.sol index 59568cb5be91..55a96026ee51 100644 --- a/test/libsolidity/smtCheckerTests/types/address_transfer_insufficient.sol +++ b/test/libsolidity/smtCheckerTests/types/address_transfer_insufficient.sol @@ -12,6 +12,6 @@ contract C // SMTEngine: all // SMTIgnoreCex: yes // ---- +// Warning 8656: (101-116): CHC: Insufficient funds happens here. +// Warning 8656: (120-136): CHC: Insufficient funds happens here. // Warning 6328: (180-204): CHC: Assertion violation happens here. -// Warning 1236: (101-116): BMC: Insufficient funds happens here. -// Warning 1236: (120-136): BMC: Insufficient funds happens here. diff --git a/test/libsolidity/smtCheckerTests/types/array_literal_3.sol b/test/libsolidity/smtCheckerTests/types/array_literal_3.sol index cdaff2bf44a4..b4655f394f83 100644 --- a/test/libsolidity/smtCheckerTests/types/array_literal_3.sol +++ b/test/libsolidity/smtCheckerTests/types/array_literal_3.sol @@ -11,5 +11,5 @@ contract C // SMTEngine: all // SMTIgnoreCex: no // ---- -// Warning 6328: (168-188): CHC: Assertion violation happens here. +// Warning 6328: (168-188): CHC: Assertion violation happens here.\nCounterexample:\n\na = [1, 2, 3]\nb = [1, 2, 4]\n\nTransaction trace:\nC.constructor()\nC.f() // Info 1391: CHC: 8 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/types/mapping_integer_signedness_compatibility.sol b/test/libsolidity/smtCheckerTests/types/mapping_integer_signedness_compatibility.sol new file mode 100644 index 000000000000..a05c8d3e1b3a --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/mapping_integer_signedness_compatibility.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-3.0 + + +// Regression for handling signedness, see issue #14792 +contract C { + mapping(int => int) v1; + mapping(int => uint) v2; + mapping(uint => int) v3; + mapping(uint => uint) v4; + mapping(bytes12 => int) v5; + uint[5] a1; + int[5] a2; + + function f() public { + delete v1[0]; + delete v2[0]; + delete v3[0]; + delete v4[0]; + delete v5[0]; + delete a1[0]; + delete a2[0]; + } +} +// ---- +// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol index c96b82909921..c309d4c22724 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol @@ -12,5 +12,5 @@ contract C { } // ---- // TypeError 9062: (138-142): Expected an inline tuple, not an expression of a tuple type. -// TypeError 9062: (177-181): Expected an inline tuple, not an expression of a tuple type. +// TypeError 7515: (153-182): Expected a tuple with 0 components instead of a single non-tuple parameter. // TypeError 9062: (216-224): Expected an inline tuple, not an expression of a tuple type. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol index f6035dd0af33..9646acf483f2 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol @@ -17,7 +17,7 @@ contract C { // ---- // TypeError 2271: (284-299): Built-in binary operator + cannot be applied to types tuple(int_const 1,int_const 1) and tuple(int_const 2,int_const 2). // TypeError 9062: (284-299): Expected an inline tuple, not an expression of a tuple type. -// TypeError 2271: (334-345): Built-in binary operator / cannot be applied to types tuple() and tuple(). +// TypeError 2271: (334-345): Built-in binary operator / cannot be applied to types tuple() and error. // TypeError 9062: (334-345): Expected an inline tuple, not an expression of a tuple type. // TypeError 4907: (380-383): Built-in unary operator ! cannot be applied to type tuple(). // TypeError 9062: (380-383): Expected an inline tuple, not an expression of a tuple type. diff --git a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol index 1ef21c8bdc23..6681710fec25 100644 --- a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol +++ b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol @@ -2,4 +2,4 @@ contract C { uint constant x = 0x01 sun; } // ---- -// TypeError 5145: (32-40): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead. +// TypeError 5145: (32-40): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 days" instead. diff --git a/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol b/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol index 8eec22dee3f0..7c1f1e270f08 100644 --- a/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol +++ b/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol @@ -2,4 +2,4 @@ contract C { address a = 0x11111122222333334444455555666667777788888 wei; } // ---- -// TypeError 5145: (26-73): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead. +// TypeError 5145: (26-73): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 days" instead. diff --git a/test/libsolidity/syntaxTests/errors/abi_decode_error_constructor.sol b/test/libsolidity/syntaxTests/errors/abi_decode_error_constructor.sol new file mode 100644 index 000000000000..d3d26e6ccbab --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/abi_decode_error_constructor.sol @@ -0,0 +1,9 @@ +error E(uint); +contract C { + function f() public pure returns (bytes memory) { + return abi.decode(msg.data, (E(1))); + } +} +// ---- +// TypeError 1039: (119-123): Argument has to be a type name. +// TypeError 5132: (90-125): Different number of arguments in return statement than in returns declaration. diff --git a/test/libsolidity/syntaxTests/errors/abi_encode_error_constructor.sol b/test/libsolidity/syntaxTests/errors/abi_encode_error_constructor.sol new file mode 100644 index 000000000000..e8a22b08e2e5 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/abi_encode_error_constructor.sol @@ -0,0 +1,8 @@ +error E(uint); +contract C { + function f() public pure returns (bytes memory) { + return abi.encode(E(1)); + } +} +// ---- +// TypeError 2056: (108-112): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/errors/assert_with_error.sol b/test/libsolidity/syntaxTests/errors/assert_with_error.sol index 90f79b40eeb7..16972baaffb9 100644 --- a/test/libsolidity/syntaxTests/errors/assert_with_error.sol +++ b/test/libsolidity/syntaxTests/errors/assert_with_error.sol @@ -3,4 +3,4 @@ function f() pure { assert(E()); } // ---- -// TypeError 9553: (42-45): Invalid type for argument in function call. Invalid implicit conversion from tuple() to bool requested. +// TypeError 9553: (42-45): Invalid type for argument in function call. Invalid implicit conversion from error to bool requested. diff --git a/test/libsolidity/syntaxTests/errors/require_custom.sol b/test/libsolidity/syntaxTests/errors/require_custom.sol index f139a4fe5a7c..f428390277fb 100644 --- a/test/libsolidity/syntaxTests/errors/require_custom.sol +++ b/test/libsolidity/syntaxTests/errors/require_custom.sol @@ -4,5 +4,6 @@ contract C { require(c, E(2, 7)); } } +// ==== +// compileViaYul: true // ---- -// TypeError 9322: (83-90): No matching declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/errors/require_custom_legacy.sol b/test/libsolidity/syntaxTests/errors/require_custom_legacy.sol new file mode 100644 index 000000000000..334b847393cb --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/require_custom_legacy.sol @@ -0,0 +1,8 @@ +error E(uint a, uint b); +contract C { + function f(bool c) public pure { + require(c, E(2, 7)); + } +} +// ---- +// UnimplementedFeatureError: Require with a custom error is only available using the via-ir pipeline. diff --git a/test/libsolidity/syntaxTests/errors/require_nested.sol b/test/libsolidity/syntaxTests/errors/require_nested.sol new file mode 100644 index 000000000000..c5dc018242df --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/require_nested.sol @@ -0,0 +1,15 @@ +error CustomError(uint256); + +contract C +{ + function f() public pure returns (uint256) + { + require(false, require(CustomError(1))); + return 2; + } +} + +// ==== +// compileViaYul: true +// ---- +// TypeError 9322: (118-125): No matching declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/errors/selector_on_instance.sol b/test/libsolidity/syntaxTests/errors/selector_on_instance.sol index 3eac5984f311..008a94c02789 100644 --- a/test/libsolidity/syntaxTests/errors/selector_on_instance.sol +++ b/test/libsolidity/syntaxTests/errors/selector_on_instance.sol @@ -4,4 +4,4 @@ contract C { bytes4 t = E().selector; } // ---- -// TypeError 9582: (40-52): Member "selector" not found or not visible after argument-dependent lookup in tuple(). +// TypeError 9582: (40-52): Member "selector" not found or not visible after argument-dependent lookup in error. diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex_compound.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex_compound.sol new file mode 100644 index 000000000000..c3a51cc29760 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex_compound.sol @@ -0,0 +1,5 @@ +contract A { + uint a; + constructor() { a /= (((2)*2)%4); } +} +// ---- diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero_compound.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_compound.sol new file mode 100644 index 000000000000..9404f0ce9711 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_compound.sol @@ -0,0 +1,5 @@ +contract A { + uint a = 5; + constructor() { a /= uint(0); } +} +// ---- diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero_nonliteral.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_nonliteral.sol new file mode 100644 index 000000000000..66540568f357 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_nonliteral.sol @@ -0,0 +1,4 @@ +contract A { + constructor() { uint a; a / 0; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex_compound.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex_compound.sol new file mode 100644 index 000000000000..1e9f1e1fa731 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex_compound.sol @@ -0,0 +1,5 @@ +contract A { + uint a = 5; + constructor() { a %= uint(((2)*2)%4); } +} +// ---- diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero_compound.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero_compound.sol new file mode 100644 index 000000000000..2fb6e1df09af --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero_compound.sol @@ -0,0 +1,5 @@ +contract A { + uint a; + constructor() { a = 5; a %= 0; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero_nonliteral.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero_nonliteral.sol new file mode 100644 index 000000000000..0722a096fc85 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero_nonliteral.sol @@ -0,0 +1,4 @@ +contract A { + constructor() { uint a; a % 0; } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol index 6cbeb217c771..279a67ade038 100644 --- a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_decimal_fail.sol @@ -8,6 +8,6 @@ contract C { } // ---- // SyntaxError 2090: (56-61): Invalid use of underscores in number literal. No trailing underscores allowed. -// SyntaxError 2990: (77-83): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed. +// SyntaxError 2990: (77-83): Invalid use of underscores in number literal. Only one consecutive underscore between digits is allowed. // SyntaxError 6415: (99-105): Invalid use of underscores in number literal. No underscore at the end of the mantissa allowed. // SyntaxError 6165: (121-127): Invalid use of underscores in number literal. No underscore in front of exponent allowed. diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol index 49bf042cdabe..43f0aa948285 100644 --- a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_fixed_fail.sol @@ -10,7 +10,7 @@ contract C { } // ---- // SyntaxError 2090: (57-64): Invalid use of underscores in number literal. No trailing underscores allowed. -// SyntaxError 2990: (81-91): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed. +// SyntaxError 2990: (81-91): Invalid use of underscores in number literal. Only one consecutive underscore between digits is allowed. // SyntaxError 1023: (108-112): Invalid use of underscores in number literal. No underscores in front of the fraction part allowed. // SyntaxError 3891: (129-133): Invalid use of underscores in number literal. No underscores in front of the fraction part allowed. // SyntaxError 6165: (150-157): Invalid use of underscores in number literal. No underscore in front of exponent allowed. diff --git a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol index 5a2e2f5c1f7e..50cfda8e29e0 100644 --- a/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol +++ b/test/libsolidity/syntaxTests/parsing/lexer_numbers_with_underscores_hex_fail.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// SyntaxError 2990: (56-79): Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed. +// SyntaxError 2990: (56-79): Invalid use of underscores in number literal. Only one consecutive underscore between digits is allowed. diff --git a/test/libsolidity/syntaxTests/revertStatement/error_used_elsewhere.sol b/test/libsolidity/syntaxTests/revertStatement/error_used_elsewhere.sol index 208a7326be14..bad026154d31 100644 --- a/test/libsolidity/syntaxTests/revertStatement/error_used_elsewhere.sol +++ b/test/libsolidity/syntaxTests/revertStatement/error_used_elsewhere.sol @@ -3,4 +3,4 @@ function f() pure { E(); } // ---- -// TypeError 7757: (35-38): Errors can only be used with revert statements: "revert MyError();". +// TypeError 7757: (35-38): Errors can only be used with revert statements: "revert MyError(args);", or require functions: "require(condition, MyError(args))". diff --git a/test/libsolidity/syntaxTests/revertStatement/require_nested.sol b/test/libsolidity/syntaxTests/revertStatement/require_nested.sol new file mode 100644 index 000000000000..721c37c254e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/revertStatement/require_nested.sol @@ -0,0 +1,13 @@ +error Error(uint256); + +contract C +{ + error OtherError(uint256); + + function f() external pure + { + revert Error(require(false, OtherError(1))); + } +} +// ---- +// TypeError 9553: (126-155): Invalid type for argument in function call. Invalid implicit conversion from tuple() to uint256 requested. diff --git a/test/libsolidity/syntaxTests/sizeLimits/bytecode_too_large_byzantium.sol b/test/libsolidity/syntaxTests/sizeLimits/bytecode_too_large_byzantium.sol index 67dee4cad6ea..4f3239c2272a 100644 --- a/test/libsolidity/syntaxTests/sizeLimits/bytecode_too_large_byzantium.sol +++ b/test/libsolidity/syntaxTests/sizeLimits/bytecode_too_large_byzantium.sol @@ -7,4 +7,4 @@ contract test { // ==== // EVMVersion: =byzantium // ---- -// Warning 5574: (0-27133): Contract code size is 27221 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (0-27133): Contract code size is 27220 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_paris.sol b/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_paris.sol index 0a97c87dfa9c..82a3415d0cbe 100644 --- a/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_paris.sol +++ b/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_paris.sol @@ -26,6 +26,6 @@ contract test { // ==== // EVMVersion: =paris // ---- -// Warning 5574: (0-27130): Contract code size is 27193 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. -// Warning 5574: (27132-27224): Contract code size is 27219 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. -// Warning 5574: (27226-27319): Contract code size is 27219 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (0-27130): Contract code size is 27192 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (27132-27224): Contract code size is 27218 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (27226-27319): Contract code size is 27218 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_shanghai.sol b/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_shanghai.sol index 32e8d9133be2..dd0122971d8e 100644 --- a/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_shanghai.sol +++ b/test/libsolidity/syntaxTests/sizeLimits/combined_too_large_shanghai.sol @@ -26,7 +26,7 @@ contract test { // ==== // EVMVersion: =shanghai // ---- -// Warning 5574: (0-27130): Contract code size is 27187 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. -// Warning 5574: (27132-27224): Contract code size is 27213 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. -// Warning 5574: (27226-27319): Contract code size is 27212 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. -// Warning 3860: (27321-27398): Contract initcode size is 54618 bytes and exceeds 49152 bytes (a limit introduced in Shanghai). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (0-27130): Contract code size is 27186 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (27132-27224): Contract code size is 27212 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (27226-27319): Contract code size is 27211 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 3860: (27321-27398): Contract initcode size is 54616 bytes and exceeds 49152 bytes (a limit introduced in Shanghai). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/sizeLimits/initcode_too_large_shanghai.sol b/test/libsolidity/syntaxTests/sizeLimits/initcode_too_large_shanghai.sol index d48693db05b1..15273c66a7c0 100644 --- a/test/libsolidity/syntaxTests/sizeLimits/initcode_too_large_shanghai.sol +++ b/test/libsolidity/syntaxTests/sizeLimits/initcode_too_large_shanghai.sol @@ -27,4 +27,4 @@ contract test { // ==== // EVMVersion: =shanghai // ---- -// Warning 3860: (20321-20415): Contract initcode size is 60882 bytes and exceeds 49152 bytes (a limit introduced in Shanghai). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 3860: (20321-20415): Contract initcode size is 60879 bytes and exceeds 49152 bytes (a limit introduced in Shanghai). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/stopAfterAnalysisError.sol b/test/libsolidity/syntaxTests/stopAfterAnalysisError.sol new file mode 100644 index 000000000000..ac74ecf3a3ce --- /dev/null +++ b/test/libsolidity/syntaxTests/stopAfterAnalysisError.sol @@ -0,0 +1,8 @@ +contract C { + function f(uint[] x) public pure { + } +} +// ==== +// stopAfter: analysis +// ---- +// TypeError 6651: (28-36): Data location must be "memory" or "calldata" for parameter in function, but none was given. diff --git a/test/libsolidity/syntaxTests/stopAfterParsingAnalysisErrorNotShowing.sol b/test/libsolidity/syntaxTests/stopAfterParsingAnalysisErrorNotShowing.sol new file mode 100644 index 000000000000..58efffea6fc4 --- /dev/null +++ b/test/libsolidity/syntaxTests/stopAfterParsingAnalysisErrorNotShowing.sol @@ -0,0 +1,6 @@ +contract C { + uint x = address(0xabc); +} +// ==== +// stopAfter: parsing +// ---- diff --git a/test/libsolidity/syntaxTests/stopAfterParsingError.sol b/test/libsolidity/syntaxTests/stopAfterParsingError.sol new file mode 100644 index 000000000000..911a28d77122 --- /dev/null +++ b/test/libsolidity/syntaxTests/stopAfterParsingError.sol @@ -0,0 +1,7 @@ +contract C { + uint storage x; +} +// ==== +// stopAfter:parsing +// ---- +// ParserError 2314: (22-29): Expected identifier but got 'storage' diff --git a/test/libsolidity/syntaxTests/tupleAssignments/assignments_to_tuple_and_non_tuple_expressions_of_tuple_types.sol b/test/libsolidity/syntaxTests/tupleAssignments/assignments_to_tuple_and_non_tuple_expressions_of_tuple_types.sol new file mode 100644 index 000000000000..e88d82b85c35 --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/assignments_to_tuple_and_non_tuple_expressions_of_tuple_types.sol @@ -0,0 +1,40 @@ +contract C { + uint[] public array; + + function f() public { + // (f()) is not a tuple expression, but its value is a tuple. + (f()) = (); + } + + function g() public { + // (revert()) is not a tuple expression, but its value is a tuple. + (revert()) = (); + } + + function h() internal returns (uint, uint) {} + + function i() public { + // (h()) is not a tuple expression, but its value is a tuple (uint, uint). + (h()) = (1, 1); + } + + function j() public returns (uint, uint) { + // (j()) is not a tuple expression, but its value is a tuple (uint, uint). + (j()) = (1, 1); + } + + function m() public { + // (uint x, uint y) is a tuple expression, and its value is a tuple (uint, uint). + (uint x, uint y) = (1, 1); + } + + function n() public { + // ((array.push(), array.push())) is not a tuple expression, but contains a tuple expression, and the value of both is a tuple (pointer uint, pointer uint). + ((array.push(), array.push())) = (1, 1); + } +} +// ---- +// TypeError 4247: (126-129): Expression has to be an lvalue. +// TypeError 4247: (236-244): Expression has to be an lvalue. +// TypeError 4247: (407-410): Expression has to be an lvalue. +// TypeError 4247: (550-553): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/types/hex_string_to_bytesNN_different_size_implicit.sol b/test/libsolidity/syntaxTests/types/hex_string_to_bytesNN_different_size_implicit.sol new file mode 100644 index 000000000000..177694af1ae1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/hex_string_to_bytesNN_different_size_implicit.sol @@ -0,0 +1,20 @@ +contract C { + function f() public pure { + bytes1 b1 = hex""; + bytes1 b2 = hex"1234"; + bytes2 b3 = hex"12"; + bytes2 b4 = hex"1234"; + bytes2 b5 = hex"123456"; + bytes3 b6 = hex"1234"; + bytes3 b7 = hex"123456"; + bytes3 b8 = hex"12345678"; + bytes4 b9 = hex"123456"; + bytes4 b10 = hex"12345678"; + bytes4 b11 = hex"1234567890"; + } +} +// ---- +// TypeError 9574: (72-93): Type literal_string hex"1234" is not implicitly convertible to expected type bytes1. Literal is larger than the type. +// TypeError 9574: (154-177): Type literal_string hex"123456" is not implicitly convertible to expected type bytes2. Literal is larger than the type. +// TypeError 9574: (242-267): Type literal_string hex"12345678" is not implicitly convertible to expected type bytes3. Literal is larger than the type. +// TypeError 9574: (337-365): Type literal_string hex"1234567890" is not implicitly convertible to expected type bytes4. Literal is larger than the type. diff --git a/test/libsolidity/util/ContractABIUtils.cpp b/test/libsolidity/util/ContractABIUtils.cpp index 641c9107d69b..fb2f4eb62679 100644 --- a/test/libsolidity/util/ContractABIUtils.cpp +++ b/test/libsolidity/util/ContractABIUtils.cpp @@ -140,16 +140,16 @@ std::optional isFixedPoint(std::string const& type) return fixedPointType; } -std::string functionSignatureFromABI(Json::Value const& _functionABI) +std::string functionSignatureFromABI(Json const& _functionABI) { auto inputs = _functionABI["inputs"]; - std::string signature = {_functionABI["name"].asString() + "("}; + std::string signature = {_functionABI["name"].get() + "("}; size_t parameterCount = 0; for (auto const& input: inputs) { parameterCount++; - signature += input["type"].asString(); + signature += input["type"].get(); if (parameterCount < inputs.size()) signature += ","; } @@ -161,11 +161,11 @@ std::string functionSignatureFromABI(Json::Value const& _functionABI) std::optional ContractABIUtils::parametersFromJsonOutputs( ErrorReporter& _errorReporter, - Json::Value const& _contractABI, + Json const& _contractABI, std::string const& _functionSignature ) { - if (!_contractABI) + if (_contractABI.empty()) return std::nullopt; for (auto const& function: _contractABI) @@ -177,7 +177,7 @@ std::optional ContractABIUtils::paramet for (auto const& output: function["outputs"]) { - std::string type = output["type"].asString(); + std::string type = output["type"].get(); ABITypes inplaceTypes; ABITypes dynamicTypes; @@ -209,13 +209,13 @@ std::optional ContractABIUtils::paramet } bool ContractABIUtils::appendTypesFromName( - Json::Value const& _functionOutput, + Json const& _functionOutput, ABITypes& _inplaceTypes, ABITypes& _dynamicTypes, bool _isCompoundType ) { - std::string type = _functionOutput["type"].asString(); + std::string type = _functionOutput["type"].get(); if (isBool(type)) _inplaceTypes.push_back(ABIType{ABIType::Boolean}); else if (isUint(type)) diff --git a/test/libsolidity/util/ContractABIUtils.h b/test/libsolidity/util/ContractABIUtils.h index 209eca4232ba..3f0b1b04e283 100644 --- a/test/libsolidity/util/ContractABIUtils.h +++ b/test/libsolidity/util/ContractABIUtils.h @@ -19,8 +19,7 @@ #include #include - -#include +#include namespace solidity::frontend::test { @@ -40,7 +39,7 @@ class ContractABIUtils /// auto-correction during interactive update routine. static std::optional parametersFromJsonOutputs( ErrorReporter& _errorReporter, - Json::Value const& _contractABI, + Json const& _contractABI, std::string const& _functionSignature ); @@ -86,7 +85,7 @@ class ContractABIUtils /// `bytes` -> [`Unsigned`, `Unsigned`, `HexString`] /// ... static bool appendTypesFromName( - Json::Value const& _functionOutput, + Json const& _functionOutput, ABITypes& _inplaceTypes, ABITypes& _dynamicTypes, bool _isCompoundType = false diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index dd74d4035c68..3e0d3e873708 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -413,7 +413,7 @@ void TestFunctionCall::reset() { m_rawBytes = bytes{}; m_failure = true; - m_contractABI = Json::Value{}; + m_contractABI = Json(); m_calledNonExistingFunction = false; } diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index 724cb8286c19..9a63262cc2eb 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -23,8 +23,6 @@ #include #include -#include - #include #include #include @@ -99,7 +97,7 @@ class TestFunctionCall void setRawBytes(const bytes _rawBytes) { m_rawBytes = _rawBytes; } void setGasCostExcludingCode(std::string const& _runType, u256 const& _gasCost) { m_gasCostsExcludingCode[_runType] = _gasCost; } void setCodeDepositGasCost(std::string const& _runType, u256 const& _gasCost) { m_codeDepositGasCosts[_runType] = _gasCost; } - void setContractABI(Json::Value _contractABI) { m_contractABI = std::move(_contractABI); } + void setContractABI(Json _contractABI) { m_contractABI = std::move(_contractABI); } void setSideEffects(std::vector _sideEffects) { m_call.actualSideEffects = _sideEffects; } private: @@ -154,7 +152,7 @@ class TestFunctionCall bool m_failure = true; /// JSON object which holds the contract ABI and that is used to set the output formatting /// in the interactive update routine. - Json::Value m_contractABI = Json::Value{}; + Json m_contractABI = Json{}; /// Flags that the test failed because the called function is not known to exist on the contract. bool m_calledNonExistingFunction = false; }; diff --git a/test/libsolidity/util/TestFunctionCallTests.cpp b/test/libsolidity/util/TestFunctionCallTests.cpp index 5741ccd0debe..72e5c7393f2a 100644 --- a/test/libsolidity/util/TestFunctionCallTests.cpp +++ b/test/libsolidity/util/TestFunctionCallTests.cpp @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_multiline) call.displayMode = FunctionCall::DisplayMode::MultiLine; TestFunctionCall test{call}; - BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8)\n// -> 1"); + BOOST_REQUIRE_EQUAL(test.format(), "// f(uint8)\n// -> 1"); } BOOST_AUTO_TEST_CASE(format_multiple_unsigned_singleline) diff --git a/test/libsolutil/JSON.cpp b/test/libsolutil/JSON.cpp index da10c0b3c6a9..7b5528fffefb 100644 --- a/test/libsolutil/JSON.cpp +++ b/test/libsolutil/JSON.cpp @@ -34,50 +34,50 @@ BOOST_AUTO_TEST_SUITE(JsonTest, *boost::unit_test::label("nooptions")) BOOST_AUTO_TEST_CASE(json_types) { - auto check = [](Json::Value value, std::string const& expectation) { + auto check = [](Json value, std::string const& expectation) { BOOST_CHECK(jsonCompactPrint(value) == expectation); }; - Json::Value value; + Json value; BOOST_CHECK(value.empty()); value = {}; BOOST_CHECK(value.empty()); - value = Json::Value(); + value = Json(); BOOST_CHECK(value.empty()); - value = Json::nullValue; + value = Json(); BOOST_CHECK(value.empty()); check(value, "null"); check({}, "null"); - check(Json::Value(), "null"); - check(Json::nullValue, "null"); - check(Json::objectValue, "{}"); - check(Json::arrayValue, "[]"); - check(Json::UInt(1), "1"); - check(Json::UInt(-1), "4294967295"); - check(Json::UInt64(1), "1"); - check(Json::UInt64(-1), "18446744073709551615"); - check(Json::LargestUInt(1), "1"); - check(Json::LargestUInt(-1), "18446744073709551615"); - check(Json::LargestUInt(0xffffffff), "4294967295"); - check(Json::Value("test"), "\"test\""); + check(Json(), "null"); + check(Json(), "null"); + check(Json::object(), "{}"); + check(Json::array(), "[]"); + check(1, "1"); + check(static_cast(-1), "4294967295"); + check(1, "1"); + check(static_cast(-1), "18446744073709551615"); + check(1, "1"); + check(static_cast(-1), "18446744073709551615"); + check(0xffffffff, "4294967295"); + check(Json("test"), "\"test\""); check("test", "\"test\""); check(true, "true"); - value = Json::objectValue; + value = Json::object(); value["key"] = "value"; check(value, "{\"key\":\"value\"}"); - value = Json::arrayValue; - value.append(1); - value.append(2); + value = Json::array(); + value.push_back(1); + value.push_back(2); check(value, "[1,2]"); } BOOST_AUTO_TEST_CASE(json_pretty_print) { - Json::Value json; - Json::Value jsonChild; + Json json; + Json jsonChild; jsonChild["3.1"] = "3.1"; jsonChild["3.2"] = 2; @@ -85,26 +85,25 @@ BOOST_AUTO_TEST_CASE(json_pretty_print) json["2"] = "2"; json["3"] = jsonChild; json["4"] = "ऑ ऒ ओ औ क ख"; - json["5"] = "\xff"; + json["5"] = "\\xff\\xfe"; BOOST_CHECK( "{\n" " \"1\": 1,\n" " \"2\": \"2\",\n" - " \"3\":\n" - " {\n" + " \"3\": {\n" " \"3.1\": \"3.1\",\n" " \"3.2\": 2\n" " },\n" " \"4\": \"\\u0911 \\u0912 \\u0913 \\u0914 \\u0915 \\u0916\",\n" - " \"5\": \"\\ufffd\"\n" + " \"5\": \"\\\\xff\\\\xfe\"\n" "}" == jsonPrettyPrint(json)); } BOOST_AUTO_TEST_CASE(json_compact_print) { - Json::Value json; - Json::Value jsonChild; + Json json; + Json jsonChild; jsonChild["3.1"] = "3.1"; jsonChild["3.2"] = 2; @@ -112,9 +111,10 @@ BOOST_AUTO_TEST_CASE(json_compact_print) json["2"] = "2"; json["3"] = jsonChild; json["4"] = "ऑ ऒ ओ औ क ख"; - json["5"] = "\xff"; + json["5"] = "\x10"; + json["6"] = "\u4e2d"; - BOOST_CHECK("{\"1\":1,\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":2},\"4\":\"\\u0911 \\u0912 \\u0913 \\u0914 \\u0915 \\u0916\",\"5\":\"\\ufffd\"}" == jsonCompactPrint(json)); + BOOST_CHECK(R"({"1":1,"2":"2","3":{"3.1":"3.1","3.2":2},"4":"\u0911 \u0912 \u0913 \u0914 \u0915 \u0916","5":"\u0010","6":"\u4e2d"})" == jsonCompactPrint(json)); } BOOST_AUTO_TEST_CASE(parse_json_strict) @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(parse_json_strict) // In this test we check conformance against JSON.parse (https://tc39.es/ecma262/multipage/structured-data.html#sec-json.parse) // and ECMA-404 (https://www.ecma-international.org/publications-and-standards/standards/ecma-404/) - Json::Value json; + Json json; std::string errors; // Just parse a valid json input @@ -135,179 +135,202 @@ BOOST_AUTO_TEST_CASE(parse_json_strict) // Trailing garbage is not allowed in ECMA-262 BOOST_CHECK(!jsonParseStrict("{\"1\":2,\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":3}}}}}}}}}}", json, &errors)); - // Comments are not allowed in ECMA-262 - // ... but JSONCPP allows them - BOOST_CHECK(jsonParseStrict( - "{\"1\":3, // awesome comment\n\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":5}}", json, &errors - )); - BOOST_CHECK(json["1"] == 3); - BOOST_CHECK(json["2"] == "2"); - BOOST_CHECK(json["3"]["3.1"] == "3.1"); - BOOST_CHECK(json["3"]["3.2"] == 5); - // According to ECMA-404 object, array, number, string, true, false, null are allowed // ... but JSONCPP disallows value types BOOST_CHECK(jsonParseStrict("[]", json, &errors)); - BOOST_CHECK(json.isArray()); + BOOST_CHECK(json.is_array()); BOOST_CHECK(jsonParseStrict("{}", json, &errors)); - BOOST_CHECK(json.isObject()); - BOOST_CHECK(!jsonParseStrict("1", json, &errors)); - // BOOST_CHECK(json.isNumeric()); - BOOST_CHECK(!jsonParseStrict("\"hello\"", json, &errors)); - // BOOST_CHECK(json.isString()); - BOOST_CHECK(!jsonParseStrict("true", json, &errors)); - // BOOST_CHECK(json.isBool()); - BOOST_CHECK(!jsonParseStrict("null", json, &errors)); - // BOOST_CHECK(json.isNull()); + BOOST_CHECK(json.is_object()); + BOOST_CHECK(jsonParseStrict("1", json, &errors)); + BOOST_CHECK(json.is_number()); + BOOST_CHECK(jsonParseStrict("\"hello\"", json, &errors)); + BOOST_CHECK(json.is_string()); + BOOST_CHECK(jsonParseStrict("true", json, &errors)); + BOOST_CHECK(json.is_boolean()); + BOOST_CHECK(jsonParseStrict("null", json, &errors)); + BOOST_CHECK(json.is_null()); // Single quotes are also disallowed by ECMA-404 BOOST_CHECK(!jsonParseStrict("'hello'", json, &errors)); - // BOOST_CHECK(json.isString()); + // BOOST_CHECK(json.is_string()); // Only string keys in objects are allowed in ECMA-404 BOOST_CHECK(!jsonParseStrict("{ 42: \"hello\" }", json, &errors)); // According to ECMA-404 hex escape sequences are not allowed, only unicode (\uNNNN) and // a few control characters (\b, \f, \n, \r, \t) - // - // More lenient parsers allow hex escapes as long as they translate to a valid UTF-8 encoding. - // - // ... but JSONCPP allows any hex escapes - BOOST_CHECK(jsonParseStrict("[ \"\x80\xec\x80\" ]", json, &errors)); - BOOST_CHECK(json.isArray()); - BOOST_CHECK(json[0] == "\x80\xec\x80"); - - // This would be valid more lenient parsers. + BOOST_CHECK(jsonParseStrict("[ \"\xF0\x9F\x98\x8A\" ]", json, &errors)); - BOOST_CHECK(json.isArray()); + BOOST_CHECK(json.is_array()); BOOST_CHECK(json[0] == "😊"); + BOOST_CHECK(json[0] == "\xF0\x9F\x98\x8A"); } BOOST_AUTO_TEST_CASE(json_isOfType) { - Json::Value json; + Json json; json["float"] = 3.1f; json["double"] = 3.1; json["int"] = 2; - json["int64"] = Json::Int64{0x4000000000000000}; + json["int64"] = 0x4000000000000000; json["string"] = "Hello World!"; BOOST_CHECK(isOfType(json["float"])); BOOST_CHECK(isOfType(json["double"])); BOOST_CHECK(isOfType(json["int"])); - BOOST_CHECK(isOfType(json["int"])); - BOOST_CHECK(isOfType(json["int"])); - BOOST_CHECK(isOfType(json["int"])); - BOOST_CHECK(isOfType(json["int64"])); - BOOST_CHECK(isOfType(json["int64"])); + BOOST_CHECK(isOfType(json["int"])); + BOOST_CHECK(isOfType(json["int"])); + BOOST_CHECK(isOfType(json["int"])); + BOOST_CHECK(isOfType(json["int"])); + BOOST_CHECK(isOfType(json["int64"])); + BOOST_CHECK(isOfType(json["int64"])); + BOOST_CHECK(isOfType(json["int64"])); BOOST_CHECK(isOfType(json["string"])); - BOOST_CHECK(!isOfType(json["int64"])); + BOOST_CHECK(!isOfType(json["int64"])); BOOST_CHECK(!isOfType(json["double"])); BOOST_CHECK(!isOfType(json["string"])); BOOST_CHECK(!isOfType(json["string"])); - BOOST_CHECK(!isOfType(json["string"])); - BOOST_CHECK(!isOfType(json["string"])); - BOOST_CHECK(!isOfType(json["string"])); - BOOST_CHECK(!isOfType(json["string"])); + BOOST_CHECK(!isOfType(json["string"])); + BOOST_CHECK(!isOfType(json["string"])); + BOOST_CHECK(!isOfType(json["string"])); + BOOST_CHECK(!isOfType(json["string"])); } BOOST_AUTO_TEST_CASE(json_isisOfTypeIfExists) { - Json::Value json; + Json json; json["float"] = 3.1f; json["double"] = 3.1; json["int"] = 2; - json["int64"] = Json::Int64{0x4000000000000000}; + json["uint"] = 2u; + json["int64"] = 0x4000000000000000; + json["uint64"] = 0x4000000000000000u; json["string"] = "Hello World!"; BOOST_CHECK(isOfTypeIfExists(json, "float")); BOOST_CHECK(isOfTypeIfExists(json, "double")); BOOST_CHECK(isOfTypeIfExists(json, "int")); - BOOST_CHECK(isOfTypeIfExists(json, "int")); - BOOST_CHECK(isOfTypeIfExists(json, "int")); - BOOST_CHECK(isOfTypeIfExists(json, "int")); - BOOST_CHECK(isOfTypeIfExists(json, "int64")); - BOOST_CHECK(isOfTypeIfExists(json, "int64")); + BOOST_CHECK(isOfTypeIfExists(json, "int")); + BOOST_CHECK(isOfTypeIfExists(json, "uint")); + BOOST_CHECK(isOfTypeIfExists(json, "int")); + BOOST_CHECK(isOfTypeIfExists(json, "int64")); + BOOST_CHECK(isOfTypeIfExists(json, "uint64")); BOOST_CHECK(isOfTypeIfExists(json, "string")); - BOOST_CHECK(!isOfTypeIfExists(json, "int64")); + BOOST_CHECK(!isOfTypeIfExists(json, "int64")); BOOST_CHECK(!isOfTypeIfExists(json, "double")); BOOST_CHECK(!isOfTypeIfExists(json, "string")); BOOST_CHECK(!isOfTypeIfExists(json, "string")); - BOOST_CHECK(!isOfTypeIfExists(json, "string")); - BOOST_CHECK(!isOfTypeIfExists(json, "string")); - BOOST_CHECK(!isOfTypeIfExists(json, "string")); - BOOST_CHECK(!isOfTypeIfExists(json, "string")); - BOOST_CHECK(isOfTypeIfExists(json, "NOT_EXISTING")); + BOOST_CHECK(!isOfTypeIfExists(json, "string")); + BOOST_CHECK(!isOfTypeIfExists(json, "string")); + BOOST_CHECK(!isOfTypeIfExists(json, "string")); + BOOST_CHECK(!isOfTypeIfExists(json, "string")); + BOOST_CHECK(isOfTypeIfExists(json, "NOT_EXISTING")); } BOOST_AUTO_TEST_CASE(json_getOrDefault) { - Json::Value json; + Json json; json["float"] = 3.1f; json["double"] = 3.1; json["int"] = 2; - json["int64"] = Json::Int64{0x4000000000000000}; - json["uint64"] = Json::UInt64{0x5000000000000000}; + json["int64"] = 0x4000000000000000; + json["uint64"] = 0x5000000000000000; json["string"] = "Hello World!"; - BOOST_CHECK(getOrDefault(json["float"]) == 3.1f); - BOOST_CHECK(getOrDefault(json["float"], -1.1f) == 3.1f); - BOOST_CHECK(getOrDefault(json["no_float"], -1.1f) == -1.1f); - BOOST_CHECK(getOrDefault(json["double"]) == 3.1); - BOOST_CHECK(getOrDefault(json["double"], -1) == 3.1); - BOOST_CHECK(getOrDefault(json["no_double"], -1.1) == -1.1); - BOOST_CHECK(getOrDefault(json["int"]) == 2); - BOOST_CHECK(getOrDefault(json["int"], -1) == 2); - BOOST_CHECK(getOrDefault(json["no_int"], -1) == -1); - BOOST_CHECK(getOrDefault(json["int"]) == 2); - BOOST_CHECK(getOrDefault(json["int"], -1) == 2); - BOOST_CHECK(getOrDefault(json["no_int"], -1) == -1); - BOOST_CHECK(getOrDefault(json["int"]) == 2); - BOOST_CHECK(getOrDefault(json["int"], 1) == 2); - BOOST_CHECK(getOrDefault(json["no_int"], 1) == 1); - BOOST_CHECK(getOrDefault(json["int"]) == 2); - BOOST_CHECK(getOrDefault(json["int"], -1) == 2); - BOOST_CHECK(getOrDefault(json["no_int"], -1) == -1); - BOOST_CHECK(getOrDefault(json["int64"]) == 0x4000000000000000); - BOOST_CHECK(getOrDefault(json["int64"], -1) == 0x4000000000000000); - BOOST_CHECK(getOrDefault(json["no_int64"], -1) == -1); - BOOST_CHECK(getOrDefault(json["int64"]) == 0x4000000000000000); - BOOST_CHECK(getOrDefault(json["int64"], 1) == 0x4000000000000000); - BOOST_CHECK(getOrDefault(json["no_int64"], 1) == 1); - BOOST_CHECK(getOrDefault(json["uint64"]) == 0x5000000000000000); - BOOST_CHECK(getOrDefault(json["uint64"], 1) == 0x5000000000000000); - BOOST_CHECK(getOrDefault(json["no_uint64"], 1) == 1); - BOOST_CHECK(getOrDefault(json["string"], "ERROR") == "Hello World!"); - BOOST_CHECK(getOrDefault(json["no_string"]).empty()); - BOOST_CHECK(getOrDefault(json["no_string"], "ERROR") == "ERROR"); + BOOST_CHECK(getOrDefault(json, "float") == 3.1f); + BOOST_CHECK(getOrDefault(json, "float", -1.1f) == 3.1f); + BOOST_CHECK(getOrDefault(json, "no_float", -1.1f) == -1.1f); + BOOST_CHECK(getOrDefault(json, "double") == 3.1); + BOOST_CHECK(getOrDefault(json, "double", -1) == 3.1); + BOOST_CHECK(getOrDefault(json, "no_double", -1.1) == -1.1); + BOOST_CHECK(getOrDefault(json, "int") == 2); + BOOST_CHECK(getOrDefault(json, "int", -1) == 2); + BOOST_CHECK(getOrDefault(json, "no_int", -1) == -1); + BOOST_CHECK(getOrDefault(json, "int") == 2); + BOOST_CHECK(getOrDefault(json, "int", -1) == 2); + BOOST_CHECK(getOrDefault(json, "no_int", -1) == -1); + BOOST_CHECK(getOrDefault(json, "int") == 2); + BOOST_CHECK(getOrDefault(json, "int", 1) == 2); + BOOST_CHECK(getOrDefault(json, "no_int", 1) == 1); + BOOST_CHECK(getOrDefault(json, "int") == 2); + BOOST_CHECK(getOrDefault(json, "int", -1) == 2); + BOOST_CHECK(getOrDefault(json, "no_int", -1) == -1); + BOOST_CHECK(getOrDefault(json, "int64") == 0x4000000000000000); + BOOST_CHECK(getOrDefault(json, "int64", -1) == 0x4000000000000000); + BOOST_CHECK(getOrDefault(json, "no_int64", -1) == -1); + BOOST_CHECK(getOrDefault(json, "int64") == 0x4000000000000000); + BOOST_CHECK(getOrDefault(json, "int64", 1) == 0x4000000000000000); + BOOST_CHECK(getOrDefault(json, "no_int64", 1) == 1); + BOOST_CHECK(getOrDefault(json, "uint64") == 0x5000000000000000); + BOOST_CHECK(getOrDefault(json, "uint64", 1) == 0x5000000000000000); + BOOST_CHECK(getOrDefault(json, "no_uint64", 1) == 1); + BOOST_CHECK(getOrDefault(json, "string", "ERROR") == "Hello World!"); + BOOST_CHECK(getOrDefault(json, "no_string").empty()); + BOOST_CHECK(getOrDefault(json, "no_string", "ERROR") == "ERROR"); } BOOST_AUTO_TEST_CASE(json_get) { - Json::Value json; + Json json; json["float"] = 3.1f; json["double"] = 3.1; json["int"] = 2; - json["int64"] = Json::Int64{0x4000000000000000}; - json["uint64"] = Json::UInt64{0x5000000000000000}; + json["int64"] = 0x4000000000000000; + json["uint64"] = 0x5000000000000000; json["string"] = "Hello World!"; BOOST_CHECK(get(json["float"]) == 3.1f); BOOST_CHECK(get(json["double"]) == 3.1); BOOST_CHECK(get(json["int"]) == 2); - BOOST_CHECK(get(json["int"]) == 2); - BOOST_CHECK(get(json["int"]) == 2); - BOOST_CHECK(get(json["int"]) == 2); - BOOST_CHECK(get(json["int64"]) == 0x4000000000000000); - BOOST_CHECK(get(json["int64"]) == 0x4000000000000000); - BOOST_CHECK(get(json["uint64"]) == 0x5000000000000000); + BOOST_CHECK(get(json["int"]) == 2); + BOOST_CHECK(get(json["int"]) == 2); + BOOST_CHECK(get(json["int"]) == 2); + BOOST_CHECK(get(json["int64"]) == 0x4000000000000000); + BOOST_CHECK(get(json["int64"]) == 0x4000000000000000); + BOOST_CHECK(get(json["uint64"]) == 0x5000000000000000); BOOST_CHECK(get(json["string"]) == "Hello World!"); } +template +void json_test_int_range() +{ + Json max = {{"v", std::numeric_limits::max()}}; + Json min = {{"v", std::numeric_limits::min()}}; + Json overflow = {{"v", static_cast(std::numeric_limits::max()) + 1}}; + Json underflow = {{"v", static_cast(std::numeric_limits::min()) - 1}}; + BOOST_CHECK(getOrDefault(max, "v", 0) == std::numeric_limits::max()); + BOOST_CHECK(getOrDefault(min, "v", 0) == std::numeric_limits::min()); + BOOST_CHECK(getOrDefault(overflow, "v", 0) == 0); + BOOST_CHECK(getOrDefault(underflow, "v", 0) == 0); + BOOST_CHECK(get(max["v"]) == std::numeric_limits::max()); + BOOST_CHECK(get(min["v"]) == std::numeric_limits::min()); + BOOST_CHECK_THROW(get(overflow["v"]), InvalidType); + BOOST_CHECK_THROW(get(underflow["v"]), InvalidType); +} + +BOOST_AUTO_TEST_CASE(json_range_checks) +{ + json_test_int_range(); + json_test_int_range(); + json_test_int_range(); + json_test_int_range(); + json_test_int_range(); + json_test_int_range(); + + Json overflow = {{"v", static_cast(std::numeric_limits::max()) * 2}}; + Json underflow = {{"v", static_cast(std::numeric_limits::min()) / 2}}; + BOOST_CHECK(getOrDefault({{"v", std::numeric_limits::max()}}, "v", 0) == std::numeric_limits::max()); + BOOST_CHECK(getOrDefault({{"v", std::numeric_limits::min()}}, "v", 0) == std::numeric_limits::min()); + BOOST_CHECK(getOrDefault(overflow, "v", 0) == 0); + BOOST_CHECK(getOrDefault(underflow, "v", 0) == 0); + BOOST_CHECK_THROW(get(overflow["v"]), InvalidType); + BOOST_CHECK_THROW(get(underflow["v"]), InvalidType); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index c9b9ec0727f7..69314abee136 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -450,12 +450,12 @@ BOOST_AUTO_TEST_CASE(customSourceLocations_mixed_locations_3) ErrorReporter reporter(errorList); auto const sourceText = R"( /// @src 1:23:45 - { // Block - { // Block - sstore(0, 1) // FunctionCall + { // Block + { // Block + sstore(0, 1) // FunctionCall /// @src 0:420:680 } - mstore(1, 2) // FunctionCall + mstore(1, 2) // FunctionCall } )"; EVMDialectTyped const& dialect = EVMDialectTyped::instance(EVMVersion{}); diff --git a/test/libyul/StackShufflingTest.cpp b/test/libyul/StackShufflingTest.cpp index 7c85a931e2c8..e53eeafbb03c 100644 --- a/test/libyul/StackShufflingTest.cpp +++ b/test/libyul/StackShufflingTest.cpp @@ -56,12 +56,12 @@ bool StackShufflingTest::parse(std::string const& _source) scanner.next(); std::string functionName = scanner.currentLiteral(); auto call = yul::FunctionCall{ - {}, yul::Identifier{{}, YulString(functionName)}, {} + {}, yul::Identifier{{}, YulString(functionName)}, {} }; stack.emplace_back(FunctionCallReturnLabelSlot{ - m_functions.insert( - make_pair(functionName, call) - ).first->second + m_functions.insert( + make_pair(functionName, call) + ).first->second }); expectToken(Token::RBrack); } @@ -78,14 +78,14 @@ bool StackShufflingTest::parse(std::string const& _source) scanner.next(); std::string functionName = scanner.currentLiteral(); auto call = yul::FunctionCall{ - {}, yul::Identifier{{}, YulString(functionName)}, {} - }; + {}, yul::Identifier{{}, YulString(functionName)}, {} + }; expectToken(Token::Comma); scanner.next(); size_t index = size_t(atoi(scanner.currentLiteral().c_str())); stack.emplace_back(TemporarySlot{ - m_functions.insert(make_pair(functionName, call)).first->second, - index + m_functions.insert(make_pair(functionName, call)).first->second, + index }); expectToken(Token::RBrack); } @@ -104,7 +104,7 @@ bool StackShufflingTest::parse(std::string const& _source) std::string ghostVariableId = scanner.currentLiteral(); Scope::Variable ghostVar = Scope::Variable{""_yulstring, YulString(literal + "[" + ghostVariableId + "]")}; stack.emplace_back(VariableSlot{ - m_variables.insert(std::make_pair(ghostVar.name, ghostVar)).first->second + m_variables.insert(std::make_pair(ghostVar.name, ghostVar)).first->second }); expectToken(Token::RBrack); } @@ -112,9 +112,9 @@ bool StackShufflingTest::parse(std::string const& _source) { Scope::Variable var = Scope::Variable{""_yulstring, YulString(literal)}; stack.emplace_back(VariableSlot{ - m_variables.insert( - make_pair(literal, var) - ).first->second + m_variables.insert( + make_pair(literal, var) + ).first->second }); } scanner.next(); diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 9fc6712db330..82e2549809e2 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -81,8 +81,7 @@ TestCase::TestResult YulOptimizerTest::run(std::ostream& _stream, std::string co auto const printed = (m_object->subObjects.empty() ? AsmPrinter{ *m_dialect }(*m_object->code) : m_object->toString(m_dialect)); // Re-parse new code for compilability - // TODO: support for wordSizeTransform which needs different input and output dialects - if (m_optimizerStep != "wordSizeTransform" && !std::get<0>(parse(_stream, _linePrefix, _formatted, printed))) + if (!std::get<0>(parse(_stream, _linePrefix, _formatted, printed))) { util::AnsiColorized(_stream, _formatted, {util::formatting::BOLD, util::formatting::CYAN}) << _linePrefix << "Result after the optimiser:" << std::endl; diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index e529f1d95d32..091a9a0b6cff 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -417,13 +417,12 @@ std::string YulOptimizerTestCommon::randomOptimiserStep(unsigned _seed) if (count == idx) { std::string optimiserStep = step.first; - // Do not fuzz mainFunction and wordSizeTransform - // because they do not preserve yul code semantics. + // Do not fuzz mainFunction + // because it does not preserve yul code semantics. // Do not fuzz reasoning based simplifier because // it can sometimes drain memory. if ( - optimiserStep == "mainFunction" || - optimiserStep == "wordSizeTransform" + optimiserStep == "mainFunction" ) // "Fullsuite" is fuzzed roughly four times more frequently than // other steps because of the filtering in place above. diff --git a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul index f78b9fb99234..2cde783c1a59 100644 --- a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul +++ b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_different_names.yul @@ -1,11 +1,11 @@ { { - function a() -> x { x := b() } - function b() -> y { y := a() } + function a() -> x { x := b() } + function b() -> y { y := a() } } { - function c() -> z { z := d() } - function d() -> w { w := c() } + function c() -> z { z := d() } + function d() -> w { w := c() } } } // ---- diff --git a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul index 858a48d85baa..112f9fdccdde 100644 --- a/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul +++ b/test/libyul/yulOptimizerTests/circularReferencesPruner/nested_same_name.yul @@ -1,11 +1,11 @@ { { - function z() -> x { x := y() } - function y() -> x { x := z() } + function z() -> x { x := y() } + function y() -> x { x := z() } } { - function z() -> x { x := y() } - function y() -> x { x := z() } + function z() -> x { x := y() } + function y() -> x { x := z() } } } // ---- diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul index 73a79410dfeb..f9191afb6bbc 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/return_vars_zero.yul @@ -1,7 +1,7 @@ // return variables are assumed to be zero initially. { function f() -> c, d { - let y := add(d, add(c, 7)) + let y := add(d, add(c, 7)) sstore(0, y) } let t, v := f() diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi2.yul b/test/libyul/yulOptimizerTests/fullSuite/abi2.yul index d8c8e90558ef..2f2e060be089 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi2.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi2.yul @@ -1093,25 +1093,21 @@ // value0 := and(calldataload(headStart), sub(shl(160, 1), 1)) // value1 := calldataload(add(headStart, 32)) // let offset := calldataload(add(headStart, 64)) -// let _1 := 0xffffffffffffffff -// if gt(offset, _1) { revert(0, 0) } -// let _2 := add(headStart, offset) -// if iszero(slt(add(_2, 0x1f), dataEnd)) { revert(0, 0) } -// let length := calldataload(_2) -// if gt(length, _1) { revert(0, 0) } -// if gt(add(add(_2, length), 32), dataEnd) { revert(0, 0) } -// value2 := add(_2, 32) +// if gt(offset, 0xffffffffffffffff) { revert(0, 0) } +// let _1 := add(headStart, offset) +// if iszero(slt(add(_1, 0x1f), dataEnd)) { revert(0, 0) } +// let length := calldataload(_1) +// if gt(length, 0xffffffffffffffff) { revert(0, 0) } +// if gt(add(add(_1, length), 32), dataEnd) { revert(0, 0) } +// value2 := add(_1, 32) // value3 := length -// let _3 := calldataload(add(headStart, 96)) -// if iszero(lt(_3, 3)) { revert(0, 0) } -// value4 := _3 +// value4 := cleanup_revert_enum_Operation(calldataload(add(headStart, 96))) // } // function abi_encode_bytes32_address_uint256_bytes32_enum_Operation_uint256_uint256_uint256_address_address_uint256(headStart, value10, value9, value8, value7, value6, value5, value4, value3, value2, value1, value0) -> tail // { // tail := add(headStart, 352) // mstore(headStart, value0) -// let _1 := sub(shl(160, 1), 1) -// mstore(add(headStart, 32), and(value1, _1)) +// mstore(add(headStart, 32), and(value1, sub(shl(160, 1), 1))) // mstore(add(headStart, 64), value2) // mstore(add(headStart, 96), value3) // if iszero(lt(value4, 3)) { invalid() } @@ -1119,8 +1115,13 @@ // mstore(add(headStart, 160), value5) // mstore(add(headStart, 192), value6) // mstore(add(headStart, 224), value7) -// mstore(add(headStart, 256), and(value8, _1)) -// mstore(add(headStart, 288), and(value9, _1)) +// mstore(add(headStart, 256), and(value8, sub(shl(160, 1), 1))) +// mstore(add(headStart, 288), and(value9, sub(shl(160, 1), 1))) // mstore(add(headStart, 320), value10) // } +// function cleanup_revert_enum_Operation(value) -> cleaned +// { +// if iszero(lt(value, 3)) { revert(0, 0) } +// cleaned := value +// } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul index 2abdf6d9c283..dbb87439f637 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul @@ -492,68 +492,64 @@ // } // function abi_decode_array_array_uint256_memory_dyn(offset, end) -> array // { -// let _1 := 0x1f // if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) } // let length := calldataload(offset) // array := allocateMemory(array_allocation_size_array_address_dyn_memory(length)) // let dst := array // mstore(array, length) -// let _2 := 0x20 -// dst := add(array, _2) -// let src := add(offset, _2) -// if gt(add(add(offset, shl(6, length)), _2), end) { revert(0, 0) } +// dst := add(array, 0x20) +// let src := add(offset, 0x20) +// if gt(add(add(offset, shl(6, length)), 0x20), end) { revert(0, 0) } // let i := 0 // for { } lt(i, length) { i := add(i, 1) } // { -// if iszero(slt(add(src, _1), end)) { revert(0, 0) } -// let dst_1 := allocateMemory_967() -// let dst_2 := dst_1 +// if iszero(slt(add(src, 0x1f), end)) { revert(0, 0) } +// let dst_1 := allocateMemory_823() +// let array_1 := dst_1 // let src_1 := src -// let _3 := add(src, 64) -// if gt(_3, end) { revert(0, 0) } +// let _1 := add(src, 64) +// if gt(_1, end) { revert(0, 0) } // let i_1 := 0 // for { } lt(i_1, 0x2) { i_1 := add(i_1, 1) } // { // mstore(dst_1, calldataload(src_1)) -// dst_1 := add(dst_1, _2) -// src_1 := add(src_1, _2) +// dst_1 := add(dst_1, 0x20) +// src_1 := add(src_1, 0x20) // } -// mstore(dst, dst_2) -// dst := add(dst, _2) -// src := _3 +// mstore(dst, array_1) +// dst := add(dst, 0x20) +// src := _1 // } // } // function abi_decode_uint256t_uint256t_array_uint256_dynt_array_array_uint256_memory_dyn(headStart, dataEnd) -> value0, value1, value2, value3 // { // if slt(sub(dataEnd, headStart), 128) { revert(0, 0) } // value0 := calldataload(headStart) -// let _1 := 32 -// value1 := calldataload(add(headStart, _1)) +// value1 := calldataload(add(headStart, 32)) // let offset := calldataload(add(headStart, 64)) -// let _2 := 0xffffffffffffffff -// if gt(offset, _2) { revert(0, 0) } -// let _3 := add(headStart, offset) -// if iszero(slt(add(_3, 0x1f), dataEnd)) { revert(0, 0) } -// let length := calldataload(_3) +// if gt(offset, 0xffffffffffffffff) { revert(0, 0) } +// let _1 := add(headStart, offset) +// if iszero(slt(add(_1, 0x1f), dataEnd)) { revert(0, 0) } +// let length := calldataload(_1) // let dst := allocateMemory(array_allocation_size_array_address_dyn_memory(length)) -// let dst_1 := dst +// let array := dst // mstore(dst, length) -// dst := add(dst, _1) -// let src := add(_3, _1) -// if gt(add(add(_3, shl(5, length)), _1), dataEnd) { revert(0, 0) } +// dst := add(dst, 32) +// let src := add(_1, 32) +// if gt(add(add(_1, shl(5, length)), 32), dataEnd) { revert(0, 0) } // let i := 0 // for { } lt(i, length) { i := add(i, 1) } // { // mstore(dst, calldataload(src)) -// dst := add(dst, _1) -// src := add(src, _1) +// dst := add(dst, 32) +// src := add(src, 32) // } -// value2 := dst_1 +// value2 := array // let offset_1 := calldataload(add(headStart, 96)) -// if gt(offset_1, _2) { revert(0, 0) } +// if gt(offset_1, 0xffffffffffffffff) { revert(0, 0) } // value3 := abi_decode_array_array_uint256_memory_dyn(add(headStart, offset_1), dataEnd) // } -// function allocateMemory_967() -> memPtr +// function allocateMemory_823() -> memPtr // { // memPtr := mload(64) // let newFreePtr := add(memPtr, 64) diff --git a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul index dd5facaf0315..bf419017bf15 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul @@ -36,8 +36,7 @@ // switch n // case 0 { ret := A(add(m, not(0)), 1) } // default { -// let _1 := not(0) -// ret := A(add(m, _1), A(m, add(n, _1))) +// ret := A(add(m, not(0)), A(m, add(n, not(0)))) // } // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul index 005c58778b87..edf1a086faaa 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul @@ -45,7 +45,6 @@ // ret := A(add(m, not(0)), 1) // leave // } -// let _1 := not(0) -// ret := A(add(m, _1), A(m, add(n, _1))) +// ret := A(add(m, not(0)), A(m, add(n, not(0)))) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul index 2b22055794c6..8b26a7ba3723 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul @@ -237,53 +237,56 @@ // { // mstore(0x80, 7673901602397024137095011250362199966051872585513276903826533215767972925880) // mstore(0xa0, 8489654445897228341090914135473290831551238522473825886865492707826370766375) -// let notes := add(0x04, calldataload(0x04)) +// let _1 := calldataload(0x04) +// let notes := add(0x04, _1) +// let m := calldataload(0x24) // let n := calldataload(notes) -// if gt(calldataload(0x24), n) +// let challenge := mod(calldataload(0x44), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// if gt(m, n) // { // mstore(0x00, 404) // revert(0x00, 0x20) // } // let kn := calldataload(add(calldatasize(), not(191))) -// let _1 := 0x2a0 -// mstore(_1, caller()) +// mstore(0x2a0, caller()) // mstore(0x2c0, kn) -// mstore(0x2e0, calldataload(0x24)) -// kn := mulmod(sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, kn), mod(calldataload(0x44), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// mstore(0x2e0, m) +// kn := mulmod(sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, kn), challenge, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // hashCommitments(notes, n) // let b := add(0x300, shl(7, n)) // let i := 0 // for { } lt(i, n) { i := add(i, 0x01) } // { -// let noteIndex := add(add(calldataload(0x04), mul(i, 0xc0)), 0x24) +// let _2 := add(_1, mul(i, 0xc0)) +// let noteIndex := add(_2, 0x24) // let k := 0 -// let a := calldataload(add(add(calldataload(0x04), mul(i, 0xc0)), 0x44)) -// let c := mod(calldataload(0x44), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) -// let _2 := add(i, 0x01) -// switch eq(_2, n) +// let a := calldataload(add(_2, 0x44)) +// let c := challenge +// let _3 := add(i, 0x01) +// switch eq(_3, n) // case 1 { // k := kn -// if eq(calldataload(0x24), n) +// if eq(m, n) // { // k := sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, kn) // } // } // case 0 { k := calldataload(noteIndex) } // validateCommitment(noteIndex, k, a) -// switch gt(_2, calldataload(0x24)) +// switch gt(_3, m) // case 1 { // kn := addmod(kn, sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, k), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // let x := mod(mload(0), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // k := mulmod(k, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // a := mulmod(a, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) -// c := mulmod(mod(calldataload(0x44), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) +// c := mulmod(challenge, x, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // mstore(0, keccak256(0, 0x20)) // } // case 0 { // kn := addmod(kn, k, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001) // } -// calldatacopy(0xe0, add(add(calldataload(0x04), mul(i, 0xc0)), 164), 0x40) -// calldatacopy(0x20, add(add(calldataload(0x04), mul(i, 0xc0)), 100), 0x40) +// calldatacopy(0xe0, add(_2, 164), 0x40) +// calldatacopy(0x20, add(_2, 100), 0x40) // mstore(0x120, sub(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001, c)) // mstore(0x60, k) // mstore(0xc0, a) @@ -292,19 +295,18 @@ // let result_2 := and(result_1, call(gas(), 7, 0, 0x80, 0x60, 0x160, 0x40)) // let result_3 := and(result_2, call(gas(), 6, 0, 0x120, 0x80, 0x160, 0x40)) // result := and(result_3, call(gas(), 6, 0, 0x160, 0x80, b, 0x40)) -// if eq(i, calldataload(0x24)) +// if eq(i, m) // { // mstore(0x260, mload(0x20)) // mstore(0x280, mload(0x40)) // mstore(0x1e0, mload(0xe0)) // mstore(0x200, sub(0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47, mload(0x100))) // } -// if gt(i, calldataload(0x24)) +// if gt(i, m) // { // mstore(0x60, c) -// let _3 := 0x220 -// let result_4 := and(result, call(gas(), 7, 0, 0x20, 0x60, _3, 0x40)) -// let result_5 := and(result_4, call(gas(), 6, 0, _3, 0x80, 0x260, 0x40)) +// let result_4 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x220, 0x40)) +// let result_5 := and(result_4, call(gas(), 6, 0, 0x220, 0x80, 0x260, 0x40)) // result := and(result_5, call(gas(), 6, 0, 0x1a0, 0x80, 0x1e0, 0x40)) // } // if iszero(result) @@ -314,8 +316,8 @@ // } // b := add(b, 0x40) // } -// if lt(calldataload(0x24), n) { validatePairing() } -// if iszero(eq(mod(keccak256(_1, add(b, not(671))), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), mod(calldataload(0x44), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001))) +// if lt(m, n) { validatePairing() } +// if iszero(eq(mod(keccak256(0x2a0, add(b, not(671))), 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), challenge)) // { // mstore(0, 404) // revert(0, 0x20) @@ -329,35 +331,28 @@ // let t2_x_1 := calldataload(132) // let t2_y := calldataload(164) // let t2_y_1 := calldataload(196) -// let _1 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b -// let _2 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa -// let _3 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2 -// let _4 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed -// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, _4)), eq(t2_x_1, _3)), eq(t2_y, _2)), eq(t2_y_1, _1)) +// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed)), eq(t2_x_1, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2)), eq(t2_y, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa)), eq(t2_y_1, 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b)) // { // mstore(0x00, 400) // revert(0x00, 0x20) // } -// let _5 := mload(0x1e0) -// let _6 := 0x20 -// mstore(_6, _5) +// mstore(0x20, mload(0x1e0)) // mstore(0x40, mload(0x200)) -// mstore(0x80, _4) -// mstore(0x60, _3) -// mstore(0xc0, _2) -// mstore(0xa0, _1) +// mstore(0x80, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed) +// mstore(0x60, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2) +// mstore(0xc0, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa) +// mstore(0xa0, 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b) // mstore(0xe0, mload(0x260)) // mstore(0x100, mload(0x280)) // mstore(0x140, t2_x) // mstore(0x120, t2_x_1) -// let _7 := 0x180 -// mstore(_7, t2_y) +// mstore(0x180, t2_y) // mstore(0x160, t2_y_1) -// let success := call(gas(), 8, 0, _6, _7, _6, _6) -// if or(iszero(success), iszero(mload(_6))) +// let success := call(gas(), 8, 0, 0x20, 0x180, 0x20, 0x20) +// if or(iszero(success), iszero(mload(0x20))) // { // mstore(0, 400) -// revert(0, _6) +// revert(0, 0x20) // } // } // function validateCommitment(note, k, a) @@ -366,9 +361,7 @@ // let gammaY := calldataload(add(note, 0x60)) // let sigmaX := calldataload(add(note, 0x80)) // let sigmaY := calldataload(add(note, 0xa0)) -// let _1 := 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 -// let _2 := 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 -// if iszero(and(and(and(eq(mod(a, _2), a), gt(a, 1)), and(eq(mod(k, _2), k), gt(k, 1))), and(eq(addmod(mulmod(mulmod(sigmaX, sigmaX, _1), sigmaX, _1), 3, _1), mulmod(sigmaY, sigmaY, _1)), eq(addmod(mulmod(mulmod(gammaX, gammaX, _1), gammaX, _1), 3, _1), mulmod(gammaY, gammaY, _1))))) +// if iszero(and(and(and(eq(mod(a, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), a), gt(a, 1)), and(eq(mod(k, 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001), k), gt(k, 1))), and(eq(addmod(mulmod(mulmod(sigmaX, sigmaX, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47), sigmaX, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47), 3, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47), mulmod(sigmaY, sigmaY, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47)), eq(addmod(mulmod(mulmod(gammaX, gammaX, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47), gammaX, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47), 3, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47), mulmod(gammaY, gammaY, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47))))) // { // mstore(0x00, 400) // revert(0x00, 0x20) diff --git a/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul b/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul index fc36bdfa37a0..5f42470f65a4 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul @@ -28,21 +28,20 @@ // // { // { -// let _1 := 1 -// mstore(_1, _1) -// mstore(2, _1) -// mstore(3, _1) -// mstore(4, _1) -// mstore(5, _1) -// mstore(6, _1) -// let _2 := sload(8) -// mstore(mload(7), _1) -// mstore(_2, _1) -// mstore(calldataload(9), _1) -// let _3 := mload(13) -// mstore(11, _1) -// mstore(12, _1) -// mstore(_3, _1) +// mstore(1, 1) +// mstore(2, 1) +// mstore(3, 1) +// mstore(4, 1) +// mstore(5, 1) +// mstore(6, 1) +// let _1 := sload(8) +// mstore(mload(7), 1) +// mstore(_1, 1) +// mstore(calldataload(9), 1) +// let _2 := mload(13) +// mstore(11, 1) +// mstore(12, 1) +// mstore(_2, 1) // return(0, 32) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul b/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul index f9d248e2feeb..6ebca20f5bbb 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul @@ -13,8 +13,7 @@ // // { // { -// let _1 := sub(shl(160, 1), 1) -// let a := and(create2(0, 0, 0x20, 0), _1) -// sstore(a, and(_1, create2(0, 0, 0x20, 0))) +// let a := and(create2(0, 0, 0x20, 0), sub(shl(160, 1), 1)) +// sstore(a, and(sub(shl(160, 1), 1), create2(0, 0, 0x20, 0))) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul b/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul index c89c620bb52d..078616bb3b7e 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul @@ -13,8 +13,7 @@ // // { // { -// let _1 := sub(shl(160, 1), 1) -// let a := and(create(0, 0, 0x20), _1) -// sstore(a, and(_1, create(0, 0, 0x20))) +// let a := and(create(0, 0, 0x20), sub(shl(160, 1), 1)) +// sstore(a, and(sub(shl(160, 1), 1), create(0, 0, 0x20))) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul index fe06f1629bc3..fca4a6366bdf 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul @@ -25,8 +25,11 @@ // let sum := 0 // let length := calldataload(_1) // let i := 0 -// for { } lt(i, length) { i := add(i, 1) } +// for { } true { i := add(i, 1) } // { +// let _2 := iszero(lt(i, length)) +// if _2 { break } +// _2 := 0 // sum := add(sum, calldataload(add(add(_1, shl(5, i)), 0x20))) // } // sstore(0, sum) diff --git a/test/libyul/yulOptimizerTests/fullSuite/extcodelength.yul b/test/libyul/yulOptimizerTests/fullSuite/extcodelength.yul index 436f5d5fafc4..dd6cdc0e44c4 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/extcodelength.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/extcodelength.yul @@ -26,12 +26,10 @@ // let value := calldataload(4) // if iszero(eq(value, and(value, sub(shl(160, 1), 1)))) { revert(0, 0) } // let length := extcodesize(value) -// let _1 := 0xffffffffffffffff -// if gt(length, _1) { revert(0, 0) } +// if gt(length, 0xffffffffffffffff) { revert(0, 0) } // let memPtr := mload(64) -// let _2 := not(31) -// let newFreePtr := add(memPtr, and(add(and(add(length, 31), _2), 63), _2)) -// if or(gt(newFreePtr, _1), lt(newFreePtr, memPtr)) { revert(0, 0) } +// let newFreePtr := add(memPtr, and(add(and(add(length, 31), not(31)), 63), not(31))) +// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } // mstore(64, newFreePtr) // mstore(memPtr, length) // extcodecopy(value, add(memPtr, 32), 0, length) diff --git a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul index 86329c3275f0..76d671bfc3e2 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul @@ -29,8 +29,11 @@ // let length := calldataload(_1) // let i := 0 // let _2 := calldataload(7) -// for { } lt(i, length) { i := add(i, 1) } +// for { } true { i := add(i, 1) } // { +// let _3 := iszero(lt(i, length)) +// if _3 { break } +// _3 := 0 // sum := add(sum, add(calldataload(add(add(_1, shl(5, i)), 0x20)), _2)) // } // sstore(0, sum) diff --git a/test/libyul/yulOptimizerTests/fullSuite/medium.yul b/test/libyul/yulOptimizerTests/fullSuite/medium.yul index 9a6381d79913..911504071661 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/medium.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/medium.yul @@ -12,9 +12,7 @@ if 0 { mstore(0x40, 0x20) } - if sub(2,1) { - for { switch mul(1,2) case 2 { mstore(0x40, 0x20) } } sub(1,1) {} { mstore(0x80, 0x40) } - } + mstore(0x40, 0x20) sstore(0, array_index_access(x, 3)) sstore(1, mload(0x40)) } diff --git a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_1_pre_shanghai.yul b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_1_pre_shanghai.yul index d041cff1041f..4d3ed471b4e1 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_1_pre_shanghai.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_1_pre_shanghai.yul @@ -33,14 +33,13 @@ // { // { // let a := 0 -// let a_1 := 0 -// for { } a_1 { } +// for { } a { } // { -// let _1 := add(a_1, a_1) +// let _1 := add(a, a) // let var := add(_1, _1) -// switch a_1 -// case 0 { a_1 := var } -// default { sstore(a, var) } +// switch a +// case 0 { a := var } +// default { sstore(0, var) } // } // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul index 06965e3ca695..3161dc2efac4 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/name_dependent_cse_bug_part_2_pre_shanghai.yul @@ -33,14 +33,13 @@ // { // { // let a := 0 -// let a_1 := 0 -// for { } a_1 { } +// for { } a { } // { -// let _1 := add(a_1, a_1) +// let _1 := add(a, a) // let var := add(_1, _1) -// switch a_1 -// case 0 { a_1 := var } -// default { sstore(a, var) } +// switch a +// case 0 { a := var } +// default { sstore(0, var) } // } // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul b/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul index 75e2ff4c2010..5fbe8d22e615 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul @@ -40,22 +40,18 @@ // // { // { -// let _1 := 1 -// let _2 := 15 -// let _3 := 10 -// let _4 := gt(not(gcd(_3, _2)), _1) -// let _5 := gcd(_3, _2) -// let _6 := not(0) -// let _7 := lt(or(_1, add(gcd(_3, _2), _6)), _1) -// let _8 := gcd(_3, _2) -// let _9 := gcd(_3, _2) -// pop(keccak256(gcd(_3, _2), or(gt(not(gcd(_3, _2)), _1), _1))) -// mstore(lt(or(gt(_1, or(or(gt(or(or(or(gt(or(gt(_6, _9), _1), _8), _7), _5), _1), _1), _4), _1)), _1), _1), _1) -// sstore(not(gcd(_3, _2)), _1) -// sstore(2, _1) -// extcodecopy(_1, msize(), _1, _1) +// let _1 := gt(not(gcd(10, 15)), 1) +// let _2 := gcd(10, 15) +// let _3 := lt(or(1, add(gcd(10, 15), not(0))), 1) +// let _4 := gcd(10, 15) +// let _5 := gcd(10, 15) +// pop(keccak256(gcd(10, 15), or(gt(not(gcd(10, 15)), 1), 1))) +// mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(not(0), _5), 1), _4), _3), _2), 1), 1), _1), 1)), 1), 1), 1) +// sstore(not(gcd(10, 15)), 1) +// sstore(2, 1) +// foo_singlereturn() // sstore(0, 0) -// sstore(3, _1) +// sstore(3, 1) // } // function gcd(_a, _b) -> out // { @@ -63,4 +59,6 @@ // case 0 { out := _a } // default { out := gcd(_b, mod(_a, _b)) } // } +// function foo_singlereturn() +// { extcodecopy(1, msize(), 1, 1) } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/static_array_slot_computation.yul b/test/libyul/yulOptimizerTests/fullSuite/static_array_slot_computation.yul index bf74af6f4713..6dc1d8c94b7c 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/static_array_slot_computation.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/static_array_slot_computation.yul @@ -1,8 +1,8 @@ // The yul code for the following contract -// contract C { -// uint256[] x; -// function f() public { x[10] = 5; } -// } +// contract C { +// uint256[] x; +// function f() public { x[10] = 5; } +// } { let _1 := 0 diff --git a/test/libyul/yulOptimizerTests/fullSuite/structural_simplification.yul b/test/libyul/yulOptimizerTests/fullSuite/structural_simplification.yul new file mode 100644 index 000000000000..aabc14f15106 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/structural_simplification.yul @@ -0,0 +1,18 @@ +{ + if sub(2, 1) { + mstore(0x40, 0x20) + for {} sub(1, 1) {} {} + } + sstore(1, mload(0x40)) +} +// ---- +// step: fullSuite +// +// { +// { +// mstore(0x40, 0x20) +// for { } iszero(1) { } +// { } +// sstore(1, mload(0x40)) +// } +// } diff --git a/test/libyul/yulOptimizerTests/ssaTransform/function.yul b/test/libyul/yulOptimizerTests/ssaTransform/function.yul index d41c18b04c60..341d18cc12ce 100644 --- a/test/libyul/yulOptimizerTests/ssaTransform/function.yul +++ b/test/libyul/yulOptimizerTests/ssaTransform/function.yul @@ -12,15 +12,15 @@ // { // function f(a, b) -> c, d // { -// let b_5 := b -// let a_6 := a -// let b_1 := add(b_5, a_6) +// let a_5 := a +// let b_6 := b +// let b_1 := add(b_6, a_5) // b := b_1 // let c_2 := add(c, b_1) // c := c_2 // let d_3 := add(d, c_2) // d := d_3 -// let a_4 := add(a_6, d_3) +// let a_4 := add(a_5, d_3) // a := a_4 // } // } diff --git a/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul index d3cfb0d84b0b..213ebcaea45b 100644 --- a/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul +++ b/test/libyul/yulOptimizerTests/unusedAssignEliminator/for_continue.yul @@ -7,7 +7,7 @@ x := 2 // Will not be removed as if-condition can be false. if callvalue() { // This can be removed because x is overwritten both after the - // loop at at the start of the next iteration. + // loop at the start of the next iteration. x := 3 continue } diff --git a/test/solc/CommandLineInterface.cpp b/test/solc/CommandLineInterface.cpp index 7a4f625c1570..b3b93cb3aa11 100644 --- a/test/solc/CommandLineInterface.cpp +++ b/test/solc/CommandLineInterface.cpp @@ -241,6 +241,29 @@ BOOST_AUTO_TEST_CASE(cli_input) BOOST_CHECK_EQUAL(result.reader.allowedDirectories(), expectedAllowedPaths); } +BOOST_AUTO_TEST_CASE(cli_optimizer_disabled_yul_optimization_input_whitespaces_or_empty) +{ + TemporaryDirectory tempDir(TEST_CASE_NAME); + createFilesWithParentDirs({tempDir.path() / "input.sol"}); + createFilesWithParentDirs({tempDir.path() / "input.yul"}); + + std::string const expectedMessage = + "--yul-optimizations is invalid with a non-empty sequence if Yul optimizer is disabled." + " Note that the empty optimizer sequence is properly denoted by \":\"."; + std::vector> const commandVariations = { + {"solc", "--strict-assembly", "--yul-optimizations", "", (tempDir.path() / "input.yul").string()}, + {"solc", "--strict-assembly", "--yul-optimizations", " ", (tempDir.path() / "input.yul").string()}, + {"solc", "--yul-optimizations", "", (tempDir.path() / "input.sol").string()}, + {"solc", "--yul-optimizations", " ", (tempDir.path() / "input.sol").string()}, + }; + for (auto const& command: commandVariations) + BOOST_CHECK_EXCEPTION( + parseCommandLineAndReadInputFiles(command), + CommandLineValidationError, + [&](auto const& _exception) { BOOST_TEST(_exception.what() == expectedMessage); return true; } + ); +} + BOOST_AUTO_TEST_CASE(cli_ignore_missing_some_files_exist) { TemporaryDirectory tempDir1(TEST_CASE_NAME); @@ -1157,15 +1180,20 @@ BOOST_AUTO_TEST_CASE(standard_json_include_paths) OptionsReaderAndMessages result = runCLI(commandLine, standardJsonInput); - Json::Value parsedStdout; + Json parsedStdout; std::string jsonParsingErrors; BOOST_TEST(util::jsonParseStrict(result.stdoutContent, parsedStdout, &jsonParsingErrors)); BOOST_TEST(jsonParsingErrors == ""); - for (Json::Value const& errorDict: parsedStdout["errors"]) + for (Json const& errorDict: parsedStdout["errors"]) // The error list might contain pre-release compiler warning BOOST_TEST(errorDict["severity"] != "error"); + // we might be able to use ranges again, but the nlohmann::json support is not yet fully there. + // (parsedStdout["sources"].items() | ranges::views::keys | ranges::to) + std::set sources; + for (auto const& [key, _]: parsedStdout["sources"].items()) + sources.insert(key); BOOST_TEST( - (parsedStdout["sources"].getMemberNames() | ranges::to) == + sources == (expectedSources | ranges::views::keys | ranges::to) + std::set{"main.sol"} ); diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index e0592da5d174..9fe24bcc662f 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -498,6 +498,9 @@ BOOST_AUTO_TEST_CASE(valid_optimiser_sequences) { std::vector validSequenceInputs { ":", // Empty optimization sequence and empty cleanup sequence + " : ", // whitespaces only optimization sequence and whitespaces only cleanup sequence + ": ", // Empty optimization sequence and whitespaces only cleanup sequence + " :", // whitespaces only optimization sequence and empty cleanup sequence ":fDn", // Empty optimization sequence and specified cleanup sequence "dhfoDgvulfnTUtnIf:", // Specified optimization sequence and empty cleanup sequence "dhfoDgvulfnTUtnIf:fDn", // Specified optimization sequence and cleanup sequence @@ -509,6 +512,9 @@ BOOST_AUTO_TEST_CASE(valid_optimiser_sequences) std::vector> const expectedParsedSequences { {"", ""}, + {" ", " "}, + {"", " "}, + {" ", ""}, {"", "fDn"}, {"dhfoDgvulfnTUtnIf", ""}, {"dhfoDgvulfnTUtnIf", "fDn"}, @@ -600,11 +606,26 @@ BOOST_AUTO_TEST_CASE(valid_empty_optimizer_sequences_without_optimize) BOOST_AUTO_TEST_CASE(invalid_optimizer_sequence_without_optimize) { - std::string const invalidSequence{"u: "}; - std::string const expectedErrorMessage{"--yul-optimizations is invalid with a non-empty sequence if Yul optimizer is disabled."}; - std::vector commandLineOptions{"solc", "contract.sol", "--yul-optimizations=" + invalidSequence}; + std::vector const invalidSequenceInputs { + {" "}, + {"u: "}, + {"u:"}, + {":f"}, + {" :f"} + }; + + std::string const expectedErrorMessage{ + "--yul-optimizations is invalid with a non-empty sequence if Yul optimizer is disabled." + " Note that the empty optimizer sequence is properly denoted by \":\"." + }; + auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedErrorMessage; }; - BOOST_CHECK_EXCEPTION(parseCommandLine(commandLineOptions), CommandLineValidationError, hasCorrectMessage); + + for (auto const& invalidSequence: invalidSequenceInputs) + { + std::vector commandLineOptions{"solc", "contract.sol", "--yul-optimizations=" + invalidSequence}; + BOOST_CHECK_EXCEPTION(parseCommandLine(commandLineOptions), CommandLineValidationError, hasCorrectMessage); + } } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/tools/afl_fuzzer.cpp b/test/tools/afl_fuzzer.cpp index af0939c2bd2c..bac98d76bf9b 100644 --- a/test/tools/afl_fuzzer.cpp +++ b/test/tools/afl_fuzzer.cpp @@ -28,7 +28,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::util; @@ -60,11 +59,11 @@ Allowed options)", ) ( "input-file", - po::value(), + po::value(), "input file" )( "input-files", - po::value>()->multitoken(), + po::value>()->multitoken(), "input files" ) ( @@ -86,7 +85,7 @@ Allowed options)", } catch (po::error const& _exception) { - cerr << _exception.what() << endl; + std::cerr << _exception.what() << std::endl; return 1; } @@ -95,26 +94,26 @@ Allowed options)", if (arguments.count("help")) { - cout << options; + std::cout << options; return 0; } - vector inputs; + std::vector inputs; if (arguments.count("input-file")) - inputs.push_back(arguments["input-file"].as()); + inputs.push_back(arguments["input-file"].as()); else if (arguments.count("input-files")) - inputs = arguments["input-files"].as>(); + inputs = arguments["input-files"].as>(); else inputs.emplace_back(""); bool optimize = !arguments.count("without-optimizer"); int retResult = 0; - for (string const& inputFile: inputs) + for (std::string const& inputFile: inputs) { - string input; + std::string input; if (inputFile.size() == 0) - input = readUntilEnd(cin); + input = readUntilEnd(std::cin); else input = readFileAsString(inputFile); @@ -134,7 +133,7 @@ Allowed options)", if (inputFile.size() == 0) throw; - cerr << "Fuzzer " + std::cerr << "Fuzzer " << (optimize ? "" : "(without optimizer) ") << "failed on " << inputFile; diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index 1bb04bf66aad..b054883820fc 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -33,14 +33,13 @@ #include -using namespace std; using namespace solidity; using namespace solidity::evmasm; using namespace solidity::frontend; using namespace solidity::langutil; using namespace solidity::util; -static vector s_evmVersions = { +static std::vector s_evmVersions = { EVMVersion::homestead(), EVMVersion::tangerineWhistle(), EVMVersion::spuriousDragon(), @@ -53,18 +52,18 @@ static vector s_evmVersions = { EVMVersion::paris() }; -void FuzzerUtil::testCompilerJsonInterface(string const& _input, bool _optimize, bool _quiet) +void FuzzerUtil::testCompilerJsonInterface(std::string const& _input, bool _optimize, bool _quiet) { if (!_quiet) - cout << "Testing compiler " << (_optimize ? "with" : "without") << " optimizer." << endl; + std::cout << "Testing compiler " << (_optimize ? "with" : "without") << " optimizer." << std::endl; - Json::Value config = Json::objectValue; + Json config; config["language"] = "Solidity"; - config["sources"] = Json::objectValue; - config["sources"][""] = Json::objectValue; + config["sources"] = Json::object(); + config["sources"][""] = Json::object(); config["sources"][""]["content"] = _input; - config["settings"] = Json::objectValue; - config["settings"]["optimizer"] = Json::objectValue; + config["settings"] = Json::object(); + config["settings"]["optimizer"] = Json::object(); config["settings"]["optimizer"]["enabled"] = _optimize; config["settings"]["optimizer"]["runs"] = static_cast(OptimiserSettings{}.expectedExecutionsPerDeployment); config["settings"]["evmVersion"] = "berlin"; @@ -82,7 +81,7 @@ void FuzzerUtil::forceSMT(StringMap& _input) // Add SMT checker pragma if not already present in source static auto constexpr smtPragma = "pragma experimental SMTChecker;"; for (auto &sourceUnit: _input) - if (sourceUnit.second.find(smtPragma) == string::npos) + if (sourceUnit.second.find(smtPragma) == std::string::npos) sourceUnit.second += smtPragma; } @@ -144,46 +143,46 @@ void FuzzerUtil::testCompiler( } } -void FuzzerUtil::runCompiler(string const& _input, bool _quiet) +void FuzzerUtil::runCompiler(std::string const& _input, bool _quiet) { if (!_quiet) - cout << "Input JSON: " << _input << endl; - string outputString(solidity_compile(_input.c_str(), nullptr, nullptr)); + std::cout << "Input JSON: " << _input << std::endl; + std::string outputString(solidity_compile(_input.c_str(), nullptr, nullptr)); if (!_quiet) - cout << "Output JSON: " << outputString << endl; + std::cout << "Output JSON: " << outputString << std::endl; // This should be safe given the above copies the output. solidity_reset(); - Json::Value output; + Json output; if (!jsonParseStrict(outputString, output)) { - string msg{"Compiler produced invalid JSON output."}; - cout << msg << endl; + std::string msg{"Compiler produced invalid JSON output."}; + std::cout << msg << std::endl; BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg))); } - if (output.isMember("errors")) + if (output.contains("errors")) for (auto const& error: output["errors"]) { - string invalid = findAnyOf(error["type"].asString(), vector{ + std::string invalid = findAnyOf(error["type"].get(), std::vector{ "Exception", "InternalCompilerError" }); if (!invalid.empty()) { - string msg = "Invalid error: \"" + error["type"].asString() + "\""; - cout << msg << endl; + std::string msg = "Invalid error: \"" + error["type"].get() + "\""; + std::cout << msg << std::endl; BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg))); } } } -void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet) +void FuzzerUtil::testConstantOptimizer(std::string const& _input, bool _quiet) { if (!_quiet) - cout << "Testing constant optimizer" << endl; - vector numbers; - stringstream sin(_input); + std::cout << "Testing constant optimizer" << std::endl; + std::vector numbers; + std::stringstream sin(_input); while (!sin.eof()) { @@ -192,7 +191,7 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet) numbers.push_back(u256(data)); } if (!_quiet) - cout << "Got " << numbers.size() << " inputs:" << endl; + std::cout << "Got " << numbers.size() << " inputs:" << std::endl; for (bool isCreation: {false, true}) { @@ -200,7 +199,7 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet) for (u256 const& n: numbers) { if (!_quiet) - cout << n << endl; + std::cout << n << std::endl; assembly.append(n); } for (unsigned runs: {1u, 2u, 3u, 20u, 40u, 100u, 200u, 400u, 1000u}) @@ -217,10 +216,10 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet) } } -void FuzzerUtil::testStandardCompiler(string const& _input, bool _quiet) +void FuzzerUtil::testStandardCompiler(std::string const& _input, bool _quiet) { if (!_quiet) - cout << "Testing compiler via JSON interface." << endl; + std::cout << "Testing compiler via JSON interface." << std::endl; runCompiler(_input, _quiet); } diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 9d20f1059fb3..fa56b35d7dc2 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -38,7 +38,6 @@ #include #endif -using namespace std; using namespace solidity; using namespace solidity::util; using namespace solidity::frontend; @@ -69,24 +68,24 @@ struct TestStats class TestFilter { public: - explicit TestFilter(string _filter): m_filter(std::move(_filter)) + explicit TestFilter(std::string _filter): m_filter(std::move(_filter)) { - string filter{m_filter}; + std::string filter{m_filter}; boost::replace_all(filter, "/", "\\/"); boost::replace_all(filter, "*", ".*"); - m_filterExpression = regex{"(" + filter + "(\\.sol|\\.yul|\\.stack))"}; + m_filterExpression = std::regex{"(" + filter + "(\\.sol|\\.yul|\\.stack))"}; } - bool matches(fs::path const& _path, string const& _name) const + bool matches(fs::path const& _path, std::string const& _name) const { - return regex_match(_name, m_filterExpression) && solidity::test::isValidSemanticTestPath(_path); + return std::regex_match(_name, m_filterExpression) && solidity::test::isValidSemanticTestPath(_path); } private: - string m_filter; - regex m_filterExpression; + std::string m_filter; + std::regex m_filterExpression; }; class TestTool @@ -96,7 +95,7 @@ class TestTool TestCreator _testCaseCreator, TestOptions const& _options, fs::path _path, - string _name + std::string _name ): m_testCaseCreator(_testCaseCreator), m_options(_options), @@ -137,9 +136,9 @@ class TestTool TestOptions const& m_options; TestFilter m_filter; fs::path const m_path; - string const m_name; + std::string const m_name; - unique_ptr m_test; + std::unique_ptr m_test; static bool m_exitRequested; }; @@ -154,7 +153,7 @@ TestTool::Result TestTool::process() { if (m_filter.matches(m_path, m_name)) { - (AnsiColorized(cout, formatted, {BOLD}) << m_name << ": ").flush(); + (AnsiColorized(std::cout, formatted, {BOLD}) << m_name << ": ").flush(); m_test = m_testCaseCreator(TestCase::Config{ m_path.string(), @@ -170,22 +169,22 @@ TestTool::Result TestTool::process() switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted)) { case TestCase::TestResult::Success: - AnsiColorized(cout, formatted, {BOLD, GREEN}) << "OK" << endl; + AnsiColorized(std::cout, formatted, {BOLD, GREEN}) << "OK" << std::endl; return Result::Success; default: - AnsiColorized(cout, formatted, {BOLD, RED}) << "FAIL" << endl; + AnsiColorized(std::cout, formatted, {BOLD, RED}) << "FAIL" << std::endl; - AnsiColorized(cout, formatted, {BOLD, CYAN}) << " Contract:" << endl; - m_test->printSource(cout, " ", formatted); - m_test->printSettings(cout, " ", formatted); + AnsiColorized(std::cout, formatted, {BOLD, CYAN}) << " Contract:" << std::endl; + m_test->printSource(std::cout, " ", formatted); + m_test->printSettings(std::cout, " ", formatted); - cout << endl << outputMessages.str() << endl; + std::cout << std::endl << outputMessages.str() << std::endl; return result == TestCase::TestResult::FatalError ? Result::Exception : Result::Failure; } } else { - AnsiColorized(cout, formatted, {BOLD, YELLOW}) << "NOT RUN" << endl; + AnsiColorized(std::cout, formatted, {BOLD, YELLOW}) << "NOT RUN" << std::endl; return Result::Skipped; } } @@ -194,30 +193,30 @@ TestTool::Result TestTool::process() } catch (boost::exception const& _e) { - AnsiColorized(cout, formatted, {BOLD, RED}) << - "Exception during test: " << boost::diagnostic_information(_e) << endl; + AnsiColorized(std::cout, formatted, {BOLD, RED}) << + "Exception during test: " << boost::diagnostic_information(_e) << std::endl; return Result::Exception; } catch (std::exception const& _e) { - AnsiColorized(cout, formatted, {BOLD, RED}) << - "Exception during test: " << boost::diagnostic_information(_e) << endl; + AnsiColorized(std::cout, formatted, {BOLD, RED}) << + "Exception during test: " << boost::diagnostic_information(_e) << std::endl; return Result::Exception; } catch (...) { - AnsiColorized(cout, formatted, {BOLD, RED}) << - "Unknown exception during test: " << boost::current_exception_diagnostic_information() << endl; + AnsiColorized(std::cout, formatted, {BOLD, RED}) << + "Unknown exception during test: " << boost::current_exception_diagnostic_information() << std::endl; return Result::Exception; } } void TestTool::updateTestCase() { - ofstream file(m_path.string(), ios::trunc); + std::ofstream file(m_path.string(), std::ios::trunc); m_test->printSource(file); m_test->printUpdatedSettings(file); - file << "// ----" << endl; + file << "// ----" << std::endl; m_test->printUpdatedExpectations(file, "// "); } @@ -230,34 +229,34 @@ TestTool::Request TestTool::handleResponse(bool _exception) } if (_exception) - cout << "(e)dit/(s)kip/(q)uit? "; + std::cout << "(e)dit/(s)kip/(q)uit? "; else - cout << "(e)dit/(u)pdate expectations/(s)kip/(q)uit? "; - cout.flush(); + std::cout << "(e)dit/(u)pdate expectations/(s)kip/(q)uit? "; + std::cout.flush(); while (true) { switch(readStandardInputChar()) { case 's': - cout << endl; + std::cout << std::endl; return Request::Skip; case 'u': if (_exception) break; else { - cout << endl; + std::cout << std::endl; updateTestCase(); return Request::Rerun; } case 'e': - cout << endl << endl; + std::cout << std::endl << std::endl; if (system((m_options.editor + " \"" + m_path.string() + "\"").c_str())) - cerr << "Error running editor command." << endl << endl; + std::cerr << "Error running editor command." << std::endl << std::endl; return Request::Rerun; case 'q': - cout << endl; + std::cout << std::endl; return Request::Quit; default: break; @@ -326,7 +325,7 @@ TestStats TestTool::processPath( m_exitRequested = true; break; case Request::Rerun: - cout << "Re-running test case..." << endl; + std::cout << "Re-running test case..." << std::endl; --testCount; break; case Request::Skip: @@ -379,7 +378,7 @@ std::optional runTestSuite( TestOptions const& _options, fs::path const& _basePath, fs::path const& _subdirectory, - string const& _name, + std::string const& _name, solidity::test::Batcher& _batcher ) { @@ -388,7 +387,7 @@ std::optional runTestSuite( if (!fs::exists(testPath) || !fs::is_directory(testPath)) { - cerr << _name << " tests not found. Use the --testpath argument." << endl; + std::cerr << _name << " tests not found. Use the --testpath argument." << std::endl; return std::nullopt; } @@ -402,19 +401,19 @@ std::optional runTestSuite( if (stats.skippedCount != stats.testCount) { - cout << endl << _name << " Test Summary: "; - AnsiColorized(cout, formatted, {BOLD, stats ? GREEN : RED}) << + std::cout << std::endl << _name << " Test Summary: "; + AnsiColorized(std::cout, formatted, {BOLD, stats ? GREEN : RED}) << stats.successCount << "/" << stats.testCount; - cout << " tests successful"; + std::cout << " tests successful"; if (stats.skippedCount > 0) { - cout << " ("; - AnsiColorized(cout, formatted, {BOLD, YELLOW}) << stats.skippedCount; - cout<< " tests skipped)"; + std::cout << " ("; + AnsiColorized(std::cout, formatted, {BOLD, YELLOW}) << stats.skippedCount; + std::cout<< " tests skipped)"; } - cout << "." << endl << endl; + std::cout << "." << std::endl << std::endl; } return stats; } @@ -446,14 +445,14 @@ int main(int argc, char const *argv[]) return EXIT_FAILURE; if (options.disableSemanticTests) - cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl; + std::cout << std::endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << std::endl << std::endl; TestStats global_stats{0, 0}; - cout << "Running tests..." << endl << endl; + std::cout << "Running tests..." << std::endl << std::endl; Batcher batcher(CommonOptions::get().selectedBatch, CommonOptions::get().batches); if (CommonOptions::get().batches > 1) - cout << "Batch " << CommonOptions::get().selectedBatch << " out of " << CommonOptions::get().batches << endl; + std::cout << "Batch " << CommonOptions::get().selectedBatch << " out of " << CommonOptions::get().batches << std::endl; // Actually run the tests. // Interactive tests are added in InteractiveTests.h @@ -479,42 +478,42 @@ int main(int argc, char const *argv[]) return EXIT_FAILURE; } - cout << endl << "Summary: "; - AnsiColorized(cout, !options.noColor, {BOLD, global_stats ? GREEN : RED}) << + std::cout << std::endl << "Summary: "; + AnsiColorized(std::cout, !options.noColor, {BOLD, global_stats ? GREEN : RED}) << global_stats.successCount << "/" << global_stats.testCount; - cout << " tests successful"; + std::cout << " tests successful"; if (global_stats.skippedCount > 0) { - cout << " ("; - AnsiColorized(cout, !options.noColor, {BOLD, YELLOW}) << global_stats.skippedCount; - cout << " tests skipped)"; + std::cout << " ("; + AnsiColorized(std::cout, !options.noColor, {BOLD, YELLOW}) << global_stats.skippedCount; + std::cout << " tests skipped)"; } - cout << "." << endl; + std::cout << "." << std::endl; if (options.disableSemanticTests) - cout << "\nNOTE: Skipped semantics tests.\n" << endl; + std::cout << "\nNOTE: Skipped semantics tests.\n" << std::endl; return global_stats ? EXIT_SUCCESS : EXIT_FAILURE; } catch (boost::program_options::error const& exception) { - cerr << exception.what() << endl; + std::cerr << exception.what() << std::endl; return 2; } catch (std::runtime_error const& exception) { - cerr << exception.what() << endl; + std::cerr << exception.what() << std::endl; return 2; } catch (solidity::test::ConfigException const& exception) { - cerr << exception.what() << endl; + std::cerr << exception.what() << std::endl; return 2; } catch (...) { - cerr << "Unhandled exception caught." << endl; - cerr << boost::current_exception_diagnostic_information() << endl; + std::cerr << "Unhandled exception caught." << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; return 2; } } diff --git a/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp b/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp index 78697a9ddd10..e10979ee13e2 100644 --- a/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp +++ b/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp @@ -29,7 +29,6 @@ using namespace solidity::test::abiv2fuzzer; using namespace solidity::test; using namespace solidity::util; using namespace solidity; -using namespace std; static constexpr size_t abiCoderHeapSize = 1024 * 512; static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; @@ -37,18 +36,18 @@ static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; DEFINE_PROTO_FUZZER(Contract const& _contract) { ProtoConverter converter(_contract.seed()); - string contractSource = converter.contractToString(_contract); + std::string contractSource = converter.contractToString(_contract); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { // With libFuzzer binary run this to generate the solidity source file x.sol from a proto input: // PROTO_FUZZER_DUMP_PATH=x.sol ./a.out proto-input - ofstream of(dump_path); + std::ofstream of(dump_path); of << contractSource; } - string typeString = converter.isabelleTypeString(); - string valueString = converter.isabelleValueString(); + std::string typeString = converter.isabelleTypeString(); + std::string valueString = converter.isabelleValueString(); abicoder::ABICoder coder(abiCoderHeapSize); if (!typeString.empty() && converter.coderFunction()) { @@ -58,7 +57,7 @@ DEFINE_PROTO_FUZZER(Contract const& _contract) // We target the default EVM which is the latest langutil::EVMVersion version; EVMHost hostContext(version, evmone); - string contractName = "C"; + std::string contractName = "C"; StringMap source({{"test.sol", contractSource}}); CompilerInput cInput(version, source, contractName, OptimiserSettings::minimal(), {}); EvmoneUtility evmoneUtil( diff --git a/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp b/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp index ea5fa20ce4a7..738d69b8c0af 100644 --- a/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp +++ b/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp @@ -21,7 +21,6 @@ #include -using namespace std; using namespace solidity::test::fuzzer::mutator; // Prototype as we can't use the FuzzerInterface.h header. @@ -54,17 +53,17 @@ SolidityCustomMutatorInterface::SolidityCustomMutatorInterface( data(_data), size(_size), maxMutantSize(_maxSize), - generator(make_shared(_seed)) + generator(std::make_shared(_seed)) {} size_t SolidityCustomMutatorInterface::generate() { - string testCase = generator->generateTestProgram(); + std::string testCase = generator->generateTestProgram(); solAssert( !testCase.empty() && data, "Solc custom mutator: Invalid mutant or memory pointer" ); - size_t mutantSize = min(testCase.size(), maxMutantSize - 1); + size_t mutantSize = std::min(testCase.size(), maxMutantSize - 1); mempcpy(data, testCase.data(), mutantSize); return mutantSize; } diff --git a/test/tools/ossfuzz/SolidityEvmoneInterface.cpp b/test/tools/ossfuzz/SolidityEvmoneInterface.cpp index 34147090882c..425239808be7 100644 --- a/test/tools/ossfuzz/SolidityEvmoneInterface.cpp +++ b/test/tools/ossfuzz/SolidityEvmoneInterface.cpp @@ -28,9 +28,8 @@ using namespace solidity::test::fuzzer; using namespace solidity::frontend; using namespace solidity::langutil; using namespace solidity::util; -using namespace std; -optional SolidityCompilationFramework::compileContract() +std::optional SolidityCompilationFramework::compileContract() { m_compiler.setSources(m_compilerInput.sourceCode); m_compiler.setLibraries(m_compilerInput.libraryAddresses); @@ -41,8 +40,8 @@ optional SolidityCompilationFramework::compileContract() { if (m_compilerInput.debugFailure) { - cerr << "Compiling contract failed" << endl; - cerr << SourceReferenceFormatter::formatErrorInformation( + std::cerr << "Compiling contract failed" << std::endl; + std::cerr << SourceReferenceFormatter::formatErrorInformation( m_compiler.errors(), m_compiler ); @@ -51,13 +50,13 @@ optional SolidityCompilationFramework::compileContract() } else { - string contractName; + std::string contractName; if (m_compilerInput.contractName.empty()) contractName = m_compiler.lastContractName(); else contractName = m_compilerInput.contractName; evmasm::LinkerObject obj = m_compiler.object(contractName); - Json::Value methodIdentifiers = m_compiler.interfaceSymbols(contractName)["methods"]; + Json methodIdentifiers = m_compiler.interfaceSymbols(contractName)["methods"]; return CompilerOutput{obj.bytecode, methodIdentifiers}; } } @@ -103,7 +102,7 @@ evmc::Result EvmoneUtility::deployContract(bytes const& _code) evmc::Result EvmoneUtility::deployAndExecute( bytes const& _byteCode, - string const& _hexEncodedInput + std::string const& _hexEncodedInput ) { // Deploy contract and signal failure if deploy failed @@ -128,9 +127,9 @@ evmc::Result EvmoneUtility::deployAndExecute( return callResult; } -evmc::Result EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) +evmc::Result EvmoneUtility::compileDeployAndExecute(std::string _fuzzIsabelle) { - map libraryAddressMap; + std::map libraryAddressMap; // Stage 1: Compile and deploy library if present. if (!m_libraryName.empty()) { @@ -158,16 +157,16 @@ evmc::Result EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) "SolidityEvmoneInterface: Invalid compilation output." ); - string methodName; + std::string methodName; if (!_fuzzIsabelle.empty()) // TODO: Remove this once a cleaner solution is found for querying // isabelle test entry point. At the moment, we are sure that the // entry point is the second method in the contract (hence the ++) // but not its name. - methodName = (++cOutput->methodIdentifiersInContract.begin())->asString() + + methodName = (++cOutput->methodIdentifiersInContract.begin())->get() + _fuzzIsabelle.substr(2, _fuzzIsabelle.size()); else - methodName = cOutput->methodIdentifiersInContract[m_methodName].asString(); + methodName = cOutput->methodIdentifiersInContract[m_methodName].get(); return deployAndExecute( cOutput->byteCode, @@ -175,7 +174,7 @@ evmc::Result EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) ); } -optional EvmoneUtility::compileContract() +std::optional EvmoneUtility::compileContract() { try { diff --git a/test/tools/ossfuzz/SolidityEvmoneInterface.h b/test/tools/ossfuzz/SolidityEvmoneInterface.h index ea684ea72332..00582c681e62 100644 --- a/test/tools/ossfuzz/SolidityEvmoneInterface.h +++ b/test/tools/ossfuzz/SolidityEvmoneInterface.h @@ -35,7 +35,7 @@ struct CompilerOutput /// EVM bytecode returned by compiler solidity::bytes byteCode; /// Method identifiers in a contract - Json::Value methodIdentifiersInContract; + Json methodIdentifiersInContract; }; struct CompilerInput @@ -89,7 +89,7 @@ class SolidityCompilationFramework m_compilerInput.libraryAddresses = std::move(_libraryAddresses); } /// @returns method identifiers in contract called @param _contractName. - Json::Value methodIdentifiers(std::string const& _contractName) + Json methodIdentifiers(std::string const& _contractName) { return m_compiler.interfaceSymbols(_contractName)["methods"]; } diff --git a/test/tools/ossfuzz/SolidityGenerator.cpp b/test/tools/ossfuzz/SolidityGenerator.cpp index 1d836a4aee36..1897de6f1209 100644 --- a/test/tools/ossfuzz/SolidityGenerator.cpp +++ b/test/tools/ossfuzz/SolidityGenerator.cpp @@ -23,7 +23,6 @@ using namespace solidity::test::fuzzer::mutator; using namespace solidity::util; -using namespace std; GeneratorBase::GeneratorBase(std::shared_ptr _mutator) { @@ -32,11 +31,11 @@ GeneratorBase::GeneratorBase(std::shared_ptr _mutator) uRandDist = mutator->uniformRandomDist(); } -string GeneratorBase::visitChildren() +std::string GeneratorBase::visitChildren() { - ostringstream os; + std::ostringstream os; // Randomise visit order - vector randomisedChildren; + std::vector randomisedChildren; for (auto const& child: generators) randomisedChildren.push_back(child); shuffle(randomisedChildren.begin(), randomisedChildren.end(), *uRandDist->randomEngine); @@ -47,7 +46,7 @@ string GeneratorBase::visitChildren() return os.str(); } -string TestState::randomPath(set const& _sourceUnitPaths) const +std::string TestState::randomPath(std::set const& _sourceUnitPaths) const { auto it = _sourceUnitPaths.begin(); /// Advance iterator by n where 0 <= n <= sourceUnitPaths.size() - 1 @@ -60,7 +59,7 @@ string TestState::randomPath(set const& _sourceUnitPaths) const return *it; } -string TestState::randomPath() const +std::string TestState::randomPath() const { solAssert(!empty(), "Solc custom mutator: Null test state"); return randomPath(sourceUnitPaths); @@ -73,20 +72,20 @@ void TestState::print(std::ostream& _os) const _os << "Source path: " << item << std::endl; } -string TestState::randomNonCurrentPath() const +std::string TestState::randomNonCurrentPath() const { /// To obtain a source path that is not the currently visited /// source unit itself, we require at least one other source /// unit to be previously visited. solAssert(size() >= 2, "Solc custom mutator: Invalid test state"); - set filteredSourcePaths; - string currentPath = currentSourceUnitPath; - copy_if( + std::set filteredSourcePaths; + std::string currentPath = currentSourceUnitPath; + std::copy_if( sourceUnitPaths.begin(), sourceUnitPaths.end(), inserter(filteredSourcePaths, filteredSourcePaths.begin()), - [currentPath](string const& _item) { + [currentPath](std::string const& _item) { return _item != currentPath; } ); @@ -100,12 +99,12 @@ void TestCaseGenerator::setup() }); } -string TestCaseGenerator::visit() +std::string TestCaseGenerator::visit() { - ostringstream os; + std::ostringstream os; for (unsigned i = 0; i < uRandDist->distributionOneToN(s_maxSourceUnits); i++) { - string sourcePath = path(); + std::string sourcePath = path(); os << "\n" << "==== Source: " << sourcePath @@ -126,32 +125,32 @@ void SourceUnitGenerator::setup() }); } -string SourceUnitGenerator::visit() +std::string SourceUnitGenerator::visit() { return visitChildren(); } -string PragmaGenerator::visit() +std::string PragmaGenerator::visit() { static constexpr const char* preamble = R"( pragma solidity >= 0.0.0; pragma experimental SMTChecker; )"; // Choose equally at random from coder v1 and v2 - string abiPragma = "pragma abicoder v" + - to_string(uRandDist->distributionOneToN(2)) + + std::string abiPragma = "pragma abicoder v" + + std::to_string(uRandDist->distributionOneToN(2)) + ";\n"; return preamble + abiPragma; } -string ImportGenerator::visit() +std::string ImportGenerator::visit() { /* * Case 1: No source units defined * Case 2: One source unit defined * Case 3: At least two source units defined */ - ostringstream os; + std::ostringstream os; // Self import with a small probability only if // there is one source unit present in test. if (state->size() == 1) @@ -175,19 +174,19 @@ string ImportGenerator::visit() } template -shared_ptr SolidityGenerator::generator() +std::shared_ptr SolidityGenerator::generator() { for (auto& g: m_generators) - if (holds_alternative>(g)) - return get>(g); + if (std::holds_alternative>(g)) + return std::get>(g); solAssert(false, ""); } SolidityGenerator::SolidityGenerator(unsigned _seed) { m_generators = {}; - m_urd = make_shared(make_unique(_seed)); - m_state = make_shared(m_urd); + m_urd = std::make_shared(std::make_unique(_seed)); + m_state = std::make_shared(m_urd); } template @@ -200,14 +199,14 @@ void SolidityGenerator::createGenerators() } } -string SolidityGenerator::generateTestProgram() +std::string SolidityGenerator::generateTestProgram() { createGenerators(); for (auto& g: m_generators) std::visit(GenericVisitor{ [&](auto const& _item) { return _item->setup(); } }, g); - string program = generator()->generate(); + std::string program = generator()->generate(); destroyGenerators(); return program; } diff --git a/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp b/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp index fb502af52778..25559bc66f27 100644 --- a/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp +++ b/test/tools/ossfuzz/StackReuseCodegenFuzzer.cpp @@ -46,7 +46,6 @@ using namespace solidity::test::fuzzer; using namespace solidity::yul; using namespace solidity::yul::test::yul_fuzzer; using namespace solidity::langutil; -using namespace std; static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; @@ -80,7 +79,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) filterStatefulInstructions, filterUnboundedLoops ); - string yul_source = converter.programToString(_input); + std::string yul_source = converter.programToString(_input); // Do not fuzz the EVM Version field. // See https://github.com/ethereum/solidity/issues/12590 langutil::EVMVersion version; @@ -89,8 +88,8 @@ DEFINE_PROTO_FUZZER(Program const& _input) if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { - ofstream of(dump_path); - of.write(yul_source.data(), static_cast(yul_source.size())); + std::ofstream of(dump_path); + of.write(yul_source.data(), static_cast(yul_source.size())); } YulStringRepository::reset(); @@ -103,7 +102,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) bool unoptimizedStackTooDeep = false; try { - YulAssembler assembler{version, nullopt, settings, yul_source}; + YulAssembler assembler{version, std::nullopt, settings, yul_source}; unoptimisedByteCode = assembler.assemble(); auto yulObject = assembler.object(); recursiveFunction = recursiveFunctionExists( @@ -116,7 +115,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) unoptimizedStackTooDeep = true; } - ostringstream unoptimizedState; + std::ostringstream unoptimizedState; bool noRevertInSource = true; bool noInvalidInSource = true; if (!unoptimizedStackTooDeep) @@ -128,8 +127,8 @@ DEFINE_PROTO_FUZZER(Program const& _input) evmc::Result callResult = hostContext.call(callMessage); // If the fuzzer synthesized input does not contain the revert opcode which // we lazily check by string find, the EVM call should not revert. - noRevertInSource = yul_source.find("revert") == string::npos; - noInvalidInSource = yul_source.find("invalid") == string::npos; + noRevertInSource = yul_source.find("revert") == std::string::npos; + noInvalidInSource = yul_source.find("invalid") == std::string::npos; if (noInvalidInSource) solAssert( callResult.status_code != EVMC_INVALID_INSTRUCTION, @@ -157,7 +156,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) bytes optimisedByteCode; try { - optimisedByteCode = YulAssembler{version, nullopt, settings, yul_source}.assemble(); + optimisedByteCode = YulAssembler{version, std::nullopt, settings, yul_source}.assemble(); } catch (solidity::yul::StackTooDeepError const&) { @@ -194,13 +193,13 @@ DEFINE_PROTO_FUZZER(Program const& _input) (!noInvalidInSource && callResultOpt.status_code == EVMC_INVALID_INSTRUCTION)), "Optimised call failed." ); - ostringstream optimizedState; + std::ostringstream optimizedState; optimizedState << EVMHostPrinter{hostContext, deployResultOpt.create_address}.state(); if (unoptimizedState.str() != optimizedState.str()) { - cout << unoptimizedState.str() << endl; - cout << optimizedState.str() << endl; + std::cout << unoptimizedState.str() << std::endl; + std::cout << optimizedState.str() << std::endl; solAssert( false, "State of unoptimised and optimised stack reused code do not match." diff --git a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp index 6d792a70c56f..bdfe4e48c61b 100644 --- a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp +++ b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp @@ -29,27 +29,26 @@ using namespace solidity::test::abiv2fuzzer; using namespace solidity::test; using namespace solidity::util; using namespace solidity; -using namespace std; static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; DEFINE_PROTO_FUZZER(Contract const& _input) { - string contract_source = ProtoConverter{_input.seed()}.contractToString(_input); + std::string contract_source = ProtoConverter{_input.seed()}.contractToString(_input); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { // With libFuzzer binary run this to generate the solidity source file x.sol from a proto input: // PROTO_FUZZER_DUMP_PATH=x.sol ./a.out proto-input - ofstream of(dump_path); + std::ofstream of(dump_path); of << contract_source; } // We target the default EVM which is the latest langutil::EVMVersion version; EVMHost hostContext(version, evmone); - string contractName = "C"; - string methodName = "test()"; + std::string contractName = "C"; + std::string methodName = "test()"; StringMap source({{"test.sol", contract_source}}); CompilerInput cInput(version, source, contractName, OptimiserSettings::minimal(), {}); EvmoneUtility evmoneUtil( @@ -67,9 +66,9 @@ DEFINE_PROTO_FUZZER(Contract const& _input) if (!EvmoneUtility::zeroWord(result.output_data, result.output_size)) { solidity::bytes res; - for (size_t i = 0; i < result.output_size; i++) + for (std::size_t i = 0; i < result.output_size; i++) res.push_back(result.output_data[i]); - cout << solidity::util::toHex(res) << endl; + std::cout << solidity::util::toHex(res) << std::endl; solAssert( false, "Proto ABIv2 fuzzer: ABIv2 coding failure found" diff --git a/test/tools/ossfuzz/const_opt_ossfuzz.cpp b/test/tools/ossfuzz/const_opt_ossfuzz.cpp index 0b799c956e6e..84ad87e7f8e8 100644 --- a/test/tools/ossfuzz/const_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/const_opt_ossfuzz.cpp @@ -18,8 +18,6 @@ #include -using namespace std; - // Prototype as we can't use the FuzzerInterface.h header. extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size); @@ -27,7 +25,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) { if (_size <= 250) { - string input(reinterpret_cast(_data), _size); + std::string input(reinterpret_cast(_data), _size); FuzzerUtil::testConstantOptimizer(input, /*quiet=*/true); } return 0; diff --git a/test/tools/ossfuzz/protoToAbiV2.cpp b/test/tools/ossfuzz/protoToAbiV2.cpp index 98de7dd359ba..1511390ebb35 100644 --- a/test/tools/ossfuzz/protoToAbiV2.cpp +++ b/test/tools/ossfuzz/protoToAbiV2.cpp @@ -50,14 +50,13 @@ BOOST_PP_REPEAT(32, USINGDECL, 0) /// Switch implementation that instantiates case statements for (un)signed /// Solidity integer types. #define SWITCHIMPL(sign) \ - ostringstream stream; \ + std::ostringstream stream; \ switch (_intWidth) \ { \ - BOOST_PP_REPEAT(32, CASEIMPL, sign) \ - } \ + BOOST_PP_REPEAT(32, CASEIMPL, sign) \ + } \ return stream.str(); -using namespace std; using namespace solidity::util; using namespace solidity::test::abiv2fuzzer; @@ -75,17 +74,17 @@ static V integerValue(unsigned _counter) return value; } -static string signedIntegerValue(unsigned _counter, unsigned _intWidth) +static std::string signedIntegerValue(unsigned _counter, unsigned _intWidth) { SWITCHIMPL(1) } -static string unsignedIntegerValue(unsigned _counter, unsigned _intWidth) +static std::string unsignedIntegerValue(unsigned _counter, unsigned _intWidth) { SWITCHIMPL(0) } -static string integerValue(unsigned _counter, unsigned _intWidth, bool _signed) +static std::string integerValue(unsigned _counter, unsigned _intWidth, bool _signed) { if (_signed) return signedIntegerValue(_counter, _intWidth); @@ -94,16 +93,16 @@ static string integerValue(unsigned _counter, unsigned _intWidth, bool _signed) } } -string ProtoConverter::getVarDecl( - string const& _type, - string const& _varName, - string const& _qualifier +std::string ProtoConverter::getVarDecl( + std::string const& _type, + std::string const& _varName, + std::string const& _qualifier ) { // One level of indentation for state variable declarations // Two levels of indentation for local variable declarations return Whiskers(R"( - ;)" + ;)" ) ("isLocalVar", !m_isStateVar) ("type", _type) @@ -114,7 +113,7 @@ string ProtoConverter::getVarDecl( "\n"; } -pair ProtoConverter::visit(Type const& _type) +std::pair ProtoConverter::visit(Type const& _type) { switch (_type.type_oneof_case()) { @@ -123,11 +122,11 @@ pair ProtoConverter::visit(Type const& _type) case Type::kNvtype: return visit(_type.nvtype()); case Type::TYPE_ONEOF_NOT_SET: - return make_pair("", ""); + return std::make_pair("", ""); } } -pair ProtoConverter::visit(ValueType const& _type) +std::pair ProtoConverter::visit(ValueType const& _type) { switch (_type.value_type_oneof_case()) { @@ -140,11 +139,11 @@ pair ProtoConverter::visit(ValueType const& _type) case ValueType::kAdty: return visit(_type.adty()); case ValueType::VALUE_TYPE_ONEOF_NOT_SET: - return make_pair("", ""); + return std::make_pair("", ""); } } -pair ProtoConverter::visit(NonValueType const& _type) +std::pair ProtoConverter::visit(NonValueType const& _type) { switch (_type.nonvalue_type_oneof_case()) { @@ -154,56 +153,56 @@ pair ProtoConverter::visit(NonValueType const& _type) if (ValidityVisitor().visit(_type.arrtype())) return visit(_type.arrtype()); else - return make_pair("", ""); + return std::make_pair("", ""); case NonValueType::kStype: if (ValidityVisitor().visit(_type.stype())) return visit(_type.stype()); else - return make_pair("", ""); + return std::make_pair("", ""); case NonValueType::NONVALUE_TYPE_ONEOF_NOT_SET: - return make_pair("", ""); + return std::make_pair("", ""); } } -pair ProtoConverter::visit(BoolType const& _type) +std::pair ProtoConverter::visit(BoolType const& _type) { return processType(_type, true); } -pair ProtoConverter::visit(IntegerType const& _type) +std::pair ProtoConverter::visit(IntegerType const& _type) { return processType(_type, true); } -pair ProtoConverter::visit(FixedByteType const& _type) +std::pair ProtoConverter::visit(FixedByteType const& _type) { return processType(_type, true); } -pair ProtoConverter::visit(AddressType const& _type) +std::pair ProtoConverter::visit(AddressType const& _type) { return processType(_type, true); } -pair ProtoConverter::visit(DynamicByteArrayType const& _type) +std::pair ProtoConverter::visit(DynamicByteArrayType const& _type) { return processType(_type, false); } -pair ProtoConverter::visit(ArrayType const& _type) +std::pair ProtoConverter::visit(ArrayType const& _type) { return processType(_type, false); } -pair ProtoConverter::visit(StructType const& _type) +std::pair ProtoConverter::visit(StructType const& _type) { return processType(_type, false); } template -pair ProtoConverter::processType(T const& _type, bool _isValueType) +std::pair ProtoConverter::processType(T const& _type, bool _isValueType) { - ostringstream local, global; + std::ostringstream local, global; auto [varName, paramName] = newVarNames(getNextVarCounter(), m_isStateVar); // Add variable name to the argument list of coder function call @@ -212,7 +211,7 @@ pair ProtoConverter::processType(T const& _type, bool _isValueTy else m_argsCoder << ", " << varName; - string location{}; + std::string location{}; if (!m_isStateVar && !_isValueType) location = "memory"; @@ -230,24 +229,24 @@ pair ProtoConverter::processType(T const& _type, bool _isValueTy local << assignCheckBuffers.second; m_structCounter += m_numStructsAdded; - return make_pair(global.str(), local.str()); + return std::make_pair(global.str(), local.str()); } template -pair ProtoConverter::varDecl( - string const& _varName, - string const& _paramName, +std::pair ProtoConverter::varDecl( + std::string const& _varName, + std::string const& _paramName, T _type, bool _isValueType, - string const& _location + std::string const& _location ) { - ostringstream local, global; + std::ostringstream local, global; TypeVisitor tVisitor(m_structCounter); - string typeStr = tVisitor.visit(_type); + std::string typeStr = tVisitor.visit(_type); if (typeStr.empty()) - return make_pair("", ""); + return std::make_pair("", ""); // Append struct defs global << tVisitor.structDef(); @@ -292,17 +291,17 @@ pair ProtoConverter::varDecl( if (tVisitor.isLastDynParamRightPadded()) m_isLastDynParamRightPadded = true; - return make_pair(global.str(), local.str()); + return std::make_pair(global.str(), local.str()); } template -pair ProtoConverter::assignChecker( - string const& _varName, - string const& _paramName, +std::pair ProtoConverter::assignChecker( + std::string const& _varName, + std::string const& _paramName, T _type ) { - ostringstream local; + std::ostringstream local; AssignCheckVisitor acVisitor( _varName, _paramName, @@ -311,7 +310,7 @@ pair ProtoConverter::assignChecker( m_counter, m_structCounter ); - pair assignCheckStrPair = acVisitor.visit(_type); + std::pair assignCheckStrPair = acVisitor.visit(_type); m_returnValue += acVisitor.errorStmts(); m_counter += acVisitor.counted(); @@ -325,10 +324,10 @@ pair ProtoConverter::assignChecker( // Therefore, we buffer their assignments and // render them in function scope later. local << assignCheckStrPair.first; - return make_pair("", local.str()); + return std::make_pair("", local.str()); } -pair ProtoConverter::visit(VarDecl const& _x) +std::pair ProtoConverter::visit(VarDecl const& _x) { return visit(_x.type()); } @@ -375,11 +374,11 @@ void ProtoConverter::appendTypedParams( void ProtoConverter::appendTypes( bool _isValueType, - string const& _typeString, + std::string const& _typeString, Delimiter _delimiter ) { - string qualifiedTypeString = ( + std::string qualifiedTypeString = ( _isValueType ? _typeString : _typeString + " memory" @@ -392,11 +391,11 @@ void ProtoConverter::appendTypes( void ProtoConverter::appendTypedReturn( bool _isValueType, - string const& _typeString, + std::string const& _typeString, Delimiter _delimiter ) { - string qualifiedTypeString = ( + std::string qualifiedTypeString = ( _isValueType ? _typeString : _typeString + " memory" @@ -404,7 +403,7 @@ void ProtoConverter::appendTypedReturn( m_typedReturn << Whiskers(R"( )") ("delimiter", delimiterToString(_delimiter)) ("type", qualifiedTypeString) - ("varName", "lv_" + to_string(m_varCounter - 1)) + ("varName", "lv_" + std::to_string(m_varCounter - 1)) .render(); } @@ -467,16 +466,16 @@ std::string ProtoConverter::typedParametersAsString(CalleeType _calleeType) return m_typedParamsPublic.str(); case CalleeType::EXTERNAL: { - ostringstream typedParamsExternal; + std::ostringstream typedParamsExternal; for (auto const& i: m_externalParamsRep) { - Delimiter del = get<0>(i); - bool valueType = get<1>(i); - string typeString = get<2>(i); - string varName = get<3>(i); + Delimiter del = std::get<0>(i); + bool valueType = std::get<1>(i); + std::string typeString = std::get<2>(i); + std::string varName = std::get<3>(i); bool isCalldata = randomBool(/*probability=*/0.5); - string location = (isCalldata ? "calldata" : "memory"); - string qualifiedTypeString = (valueType ? typeString : typeString + " " + location); + std::string location = (isCalldata ? "calldata" : "memory"); + std::string qualifiedTypeString = (valueType ? typeString : typeString + " " + location); typedParamsExternal << Whiskers(R"( )") ("delimiter", delimiterToString(del)) ("type", qualifiedTypeString) @@ -488,17 +487,17 @@ std::string ProtoConverter::typedParametersAsString(CalleeType _calleeType) } } -string ProtoConverter::visit(TestFunction const& _x, string const& _storageVarDefs) +std::string ProtoConverter::visit(TestFunction const& _x, std::string const& _storageVarDefs) { // TODO: Support more than one but less than N local variables auto localVarBuffers = visit(_x.local_vars()); - string structTypeDecl = localVarBuffers.first; - string localVarDefs = localVarBuffers.second; + std::string structTypeDecl = localVarBuffers.first; + std::string localVarDefs = localVarBuffers.second; - ostringstream testBuffer; + std::ostringstream testBuffer; - string testFunction = Whiskers(R"( + std::string testFunction = Whiskers(R"( function test() public returns (uint) { return test_calldata_coding(); return test_returndata_coding(); @@ -507,8 +506,8 @@ string ProtoConverter::visit(TestFunction const& _x, string const& _storageVarDe ("returndata", m_test == Contract_Test::Contract_Test_RETURNDATA_CODER) .render(); - string functionDeclCalldata = "function test_calldata_coding() internal returns (uint)"; - string functionDeclReturndata = "function test_returndata_coding() internal returns (uint)"; + std::string functionDeclCalldata = "function test_calldata_coding() internal returns (uint)"; + std::string functionDeclReturndata = "function test_returndata_coding() internal returns (uint)"; testBuffer << Whiskers(R"( @@ -551,7 +550,7 @@ string ProtoConverter::visit(TestFunction const& _x, string const& _storageVarDe return testBuffer.str(); } -string ProtoConverter::testCallDataFunction(unsigned _invalidLength) +std::string ProtoConverter::testCallDataFunction(unsigned _invalidLength) { return Whiskers(R"( uint returnVal = this.coder_calldata_public(); @@ -592,7 +591,7 @@ string ProtoConverter::testCallDataFunction(unsigned _invalidLength) .render(); } -string ProtoConverter::testReturnDataFunction() +std::string ProtoConverter::testReturnDataFunction() { return Whiskers(R"( @@ -607,9 +606,9 @@ string ProtoConverter::testReturnDataFunction() .render(); } -string ProtoConverter::calldataHelperFunctions() +std::string ProtoConverter::calldataHelperFunctions() { - stringstream calldataHelperFuncs; + std::stringstream calldataHelperFuncs; calldataHelperFuncs << R"( /// Accepts function selector, correct argument encoding, and length of /// invalid encoding and returns the correct and incorrect abi encoding @@ -676,12 +675,12 @@ string ProtoConverter::calldataHelperFunctions() })"; /// These are indirections to test memory-calldata codings more robustly. - stringstream indirections; + std::stringstream indirections; unsigned numIndirections = randomNumberOneToN(s_maxIndirections); for (unsigned i = 1; i <= numIndirections; i++) { bool finalIndirection = i == numIndirections; - string mutability = (finalIndirection ? "pure" : "view"); + std::string mutability = (finalIndirection ? "pure" : "view"); indirections << Whiskers(R"( function coder_calldata_external_i() external returns (uint) { @@ -692,12 +691,12 @@ string ProtoConverter::calldataHelperFunctions() } )") - ("N", to_string(i)) + ("N", std::to_string(i)) ("parameters", typedParametersAsString(CalleeType::EXTERNAL)) ("mutability", mutability) ("finalIndirection", finalIndirection) ("equality_checks", equalityChecksAsString()) - ("NPlusOne", to_string(i + 1)) + ("NPlusOne", std::to_string(i + 1)) ("untyped_parameters", m_untypedParamsExternal.str()) .render(); } @@ -726,9 +725,9 @@ string ProtoConverter::calldataHelperFunctions() return calldataHelperFuncs.str(); } -string ProtoConverter::commonHelperFunctions() +std::string ProtoConverter::commonHelperFunctions() { - stringstream helperFuncs; + std::stringstream helperFuncs; helperFuncs << R"( /// Compares bytes, returning true if they are equal and false otherwise. function bytesCompare(bytes memory a, bytes memory b) internal pure returns (bool) { @@ -746,7 +745,7 @@ string ProtoConverter::commonHelperFunctions() void ProtoConverter::visit(Contract const& _x) { - string pragmas = R"(pragma solidity >=0.0; + std::string pragmas = R"(pragma solidity >=0.0; pragma experimental ABIEncoderV2;)"; // Record test spec @@ -754,10 +753,10 @@ pragma experimental ABIEncoderV2;)"; // TODO: Support more than one but less than N state variables auto storageBuffers = visit(_x.state_vars()); - string storageVarDecls = storageBuffers.first; - string storageVarDefs = storageBuffers.second; + std::string storageVarDecls = storageBuffers.first; + std::string storageVarDefs = storageBuffers.second; m_isStateVar = false; - string testFunction = visit(_x.testfunction(), storageVarDefs); + std::string testFunction = visit(_x.testfunction(), storageVarDefs); /* Structure of contract body * - Storage variable declarations * - Struct definitions @@ -767,7 +766,7 @@ pragma experimental ABIEncoderV2;)"; * - Test code proper (calls public and external functions) * - Helper functions */ - ostringstream contractBody; + std::ostringstream contractBody; contractBody << storageVarDecls << testFunction << commonHelperFunctions(); @@ -782,32 +781,32 @@ pragma experimental ABIEncoderV2;)"; .render(); } -string ProtoConverter::isabelleTypeString() const +std::string ProtoConverter::isabelleTypeString() const { - string typeString = m_isabelleTypeString.str(); + std::string typeString = m_isabelleTypeString.str(); if (!typeString.empty()) return "(" + typeString + ")"; else return typeString; } -string ProtoConverter::isabelleValueString() const +std::string ProtoConverter::isabelleValueString() const { - string valueString = m_isabelleValueString.str(); + std::string valueString = m_isabelleValueString.str(); if (!valueString.empty()) return "(" + valueString + ")"; else return valueString; } -string ProtoConverter::contractToString(Contract const& _input) +std::string ProtoConverter::contractToString(Contract const& _input) { visit(_input); return m_output.str(); } /// Type visitor -void TypeVisitor::StructTupleString::addTypeStringToTuple(string& _typeString) +void TypeVisitor::StructTupleString::addTypeStringToTuple(std::string& _typeString) { index++; if (index > 1) @@ -815,51 +814,51 @@ void TypeVisitor::StructTupleString::addTypeStringToTuple(string& _typeString) stream << _typeString; } -void TypeVisitor::StructTupleString::addArrayBracketToType(string& _arrayBracket) +void TypeVisitor::StructTupleString::addArrayBracketToType(std::string& _arrayBracket) { stream << _arrayBracket; } -string TypeVisitor::visit(BoolType const&) +std::string TypeVisitor::visit(BoolType const&) { m_baseType = "bool"; m_structTupleString.addTypeStringToTuple(m_baseType); return m_baseType; } -string TypeVisitor::visit(IntegerType const& _type) +std::string TypeVisitor::visit(IntegerType const& _type) { m_baseType = getIntTypeAsString(_type); m_structTupleString.addTypeStringToTuple(m_baseType); return m_baseType; } -string TypeVisitor::visit(FixedByteType const& _type) +std::string TypeVisitor::visit(FixedByteType const& _type) { m_baseType = getFixedByteTypeAsString(_type); m_structTupleString.addTypeStringToTuple(m_baseType); return m_baseType; } -string TypeVisitor::visit(AddressType const&) +std::string TypeVisitor::visit(AddressType const&) { m_baseType = "address"; m_structTupleString.addTypeStringToTuple(m_baseType); return m_baseType; } -string TypeVisitor::visit(ArrayType const& _type) +std::string TypeVisitor::visit(ArrayType const& _type) { if (!ValidityVisitor().visit(_type)) return ""; - string baseType = visit(_type.t()); + std::string baseType = visit(_type.t()); solAssert(!baseType.empty(), ""); - string arrayBracket = _type.is_static() ? - string("[") + - to_string(getStaticArrayLengthFromFuzz(_type.length())) + - string("]") : - string("[]"); + std::string arrayBracket = _type.is_static() ? + std::string("[") + + std::to_string(getStaticArrayLengthFromFuzz(_type.length())) + + std::string("]") : + std::string("[]"); m_baseType += arrayBracket; m_structTupleString.addArrayBracketToType(arrayBracket); @@ -872,7 +871,7 @@ string TypeVisitor::visit(ArrayType const& _type) return baseType + arrayBracket; } -string TypeVisitor::visit(DynamicByteArrayType const&) +std::string TypeVisitor::visit(DynamicByteArrayType const&) { m_isLastDynParamRightPadded = true; m_baseType = "bytes"; @@ -893,10 +892,10 @@ void TypeVisitor::structDefinition(StructType const& _type) m_structFieldCounter = 0; // Commence struct declaration - string structDef = lineString( + std::string structDef = lineString( "struct " + - string(s_structNamePrefix) + - to_string(m_structCounter) + + std::string(s_structNamePrefix) + + std::to_string(m_structCounter) + " {" ); // Start tuple of types with parenthesis @@ -905,7 +904,7 @@ void TypeVisitor::structDefinition(StructType const& _type) m_indentation++; for (auto const& t: _type.t()) { - string type{}; + std::string type{}; if (!ValidityVisitor().visit(t)) continue; @@ -920,10 +919,10 @@ void TypeVisitor::structDefinition(StructType const& _type) structDef += lineString( Whiskers(R"( ;)") ("type", type) - ("member", "m" + to_string(m_structFieldCounter++)) + ("member", "m" + std::to_string(m_structFieldCounter++)) .render() ); - string isabelleTypeStr = tVisitor.isabelleTypeString(); + std::string isabelleTypeStr = tVisitor.isabelleTypeString(); m_structTupleString.addTypeStringToTuple(isabelleTypeStr); } m_indentation--; @@ -936,7 +935,7 @@ void TypeVisitor::structDefinition(StructType const& _type) m_structFieldCounter = wasFieldCounter; } -string TypeVisitor::visit(StructType const& _type) +std::string TypeVisitor::visit(StructType const& _type) { if (ValidityVisitor().visit(_type)) { @@ -945,7 +944,7 @@ string TypeVisitor::visit(StructType const& _type) // Set last dyn param if struct contains a dyn param e.g., bytes, array etc. m_isLastDynParamRightPadded = DynParamVisitor().visit(_type); // If top-level struct is a non-empty struct, assign the name S - m_baseType = s_structTypeName + to_string(m_structStartCounter); + m_baseType = s_structTypeName + std::to_string(m_structStartCounter); } else m_baseType = {}; @@ -954,7 +953,7 @@ string TypeVisitor::visit(StructType const& _type) } /// AssignCheckVisitor implementation -void AssignCheckVisitor::ValueStream::appendValue(string& _value) +void AssignCheckVisitor::ValueStream::appendValue(std::string& _value) { solAssert(!_value.empty(), "Abiv2 fuzzer: Empty value"); index++; @@ -963,77 +962,77 @@ void AssignCheckVisitor::ValueStream::appendValue(string& _value) stream << _value; } -pair AssignCheckVisitor::visit(BoolType const& _type) +std::pair AssignCheckVisitor::visit(BoolType const& _type) { - string value = ValueGetterVisitor(counter()).visit(_type); + std::string value = ValueGetterVisitor(counter()).visit(_type); if (!m_forcedVisit) m_valueStream.appendValue(value); return assignAndCheckStringPair(m_varName, m_paramName, value, value, DataType::VALUE); } -pair AssignCheckVisitor::visit(IntegerType const& _type) +std::pair AssignCheckVisitor::visit(IntegerType const& _type) { - string value = ValueGetterVisitor(counter()).visit(_type); + std::string value = ValueGetterVisitor(counter()).visit(_type); if (!m_forcedVisit) m_valueStream.appendValue(value); return assignAndCheckStringPair(m_varName, m_paramName, value, value, DataType::VALUE); } -pair AssignCheckVisitor::visit(FixedByteType const& _type) +std::pair AssignCheckVisitor::visit(FixedByteType const& _type) { - string value = ValueGetterVisitor(counter()).visit(_type); + std::string value = ValueGetterVisitor(counter()).visit(_type); if (!m_forcedVisit) { - string isabelleValue = ValueGetterVisitor{}.isabelleBytesValueAsString(value); + std::string isabelleValue = ValueGetterVisitor{}.isabelleBytesValueAsString(value); m_valueStream.appendValue(isabelleValue); } return assignAndCheckStringPair(m_varName, m_paramName, value, value, DataType::VALUE); } -pair AssignCheckVisitor::visit(AddressType const& _type) +std::pair AssignCheckVisitor::visit(AddressType const& _type) { - string value = ValueGetterVisitor(counter()).visit(_type); + std::string value = ValueGetterVisitor(counter()).visit(_type); if (!m_forcedVisit) { - string isabelleValue = ValueGetterVisitor{}.isabelleAddressValueAsString(value); + std::string isabelleValue = ValueGetterVisitor{}.isabelleAddressValueAsString(value); m_valueStream.appendValue(isabelleValue); } return assignAndCheckStringPair(m_varName, m_paramName, value, value, DataType::VALUE); } -pair AssignCheckVisitor::visit(DynamicByteArrayType const& _type) +std::pair AssignCheckVisitor::visit(DynamicByteArrayType const& _type) { - string value = ValueGetterVisitor(counter()).visit(_type); + std::string value = ValueGetterVisitor(counter()).visit(_type); if (!m_forcedVisit) { - string isabelleValue = ValueGetterVisitor{}.isabelleBytesValueAsString(value); + std::string isabelleValue = ValueGetterVisitor{}.isabelleBytesValueAsString(value); m_valueStream.appendValue(isabelleValue); } DataType dataType = DataType::BYTES; return assignAndCheckStringPair(m_varName, m_paramName, value, value, dataType); } -pair AssignCheckVisitor::visit(ArrayType const& _type) +std::pair AssignCheckVisitor::visit(ArrayType const& _type) { if (!ValidityVisitor().visit(_type)) - return make_pair("", ""); + return std::make_pair("", ""); // Obtain type of array to be resized and initialized - string typeStr{}; + std::string typeStr{}; unsigned wasStructCounter = m_structCounter; TypeVisitor tVisitor(m_structCounter); typeStr = tVisitor.visit(_type); - pair resizeBuffer; - string lengthStr; + std::pair resizeBuffer; + std::string lengthStr; unsigned length; // Resize dynamic arrays if (!_type.is_static()) { length = getDynArrayLengthFromFuzz(_type.length(), counter()); - lengthStr = to_string(length); + lengthStr = std::to_string(length); if (m_stateVar) { // Dynamic storage arrays are resized via the empty push() operation @@ -1048,7 +1047,7 @@ pair AssignCheckVisitor::visit(ArrayType const& _type) else { // Resizing memory arrays via the new operator - string resizeOp = Whiskers(R"(new ())") + std::string resizeOp = Whiskers(R"(new ())") ("fullTypeStr", typeStr) ("length", lengthStr) .render(); @@ -1064,22 +1063,22 @@ pair AssignCheckVisitor::visit(ArrayType const& _type) else { length = getStaticArrayLengthFromFuzz(_type.length()); - lengthStr = to_string(length); + lengthStr = std::to_string(length); // Add check on length resizeBuffer.second = checkString(m_paramName + ".length", lengthStr, DataType::VALUE); } // Add assignCheckBuffer and check statements - pair assignCheckBuffer; - string wasVarName = m_varName; - string wasParamName = m_paramName; + std::pair assignCheckBuffer; + std::string wasVarName = m_varName; + std::string wasParamName = m_paramName; if (!m_forcedVisit) m_valueStream.startArray(); for (unsigned i = 0; i < length; i++) { - m_varName = wasVarName + "[" + to_string(i) + "]"; - m_paramName = wasParamName + "[" + to_string(i) + "]"; - pair assign = visit(_type.t()); + m_varName = wasVarName + "[" + std::to_string(i) + "]"; + m_paramName = wasParamName + "[" + std::to_string(i) + "]"; + std::pair assign = visit(_type.t()); assignCheckBuffer.first += assign.first; assignCheckBuffer.second += assign.second; if (i < length - 1) @@ -1102,33 +1101,33 @@ pair AssignCheckVisitor::visit(ArrayType const& _type) m_paramName = wasParamName; // Compose resize and initialization assignment and check - return make_pair( + return std::make_pair( resizeBuffer.first + assignCheckBuffer.first, resizeBuffer.second + assignCheckBuffer.second ); } -pair AssignCheckVisitor::visit(StructType const& _type) +std::pair AssignCheckVisitor::visit(StructType const& _type) { if (!ValidityVisitor().visit(_type)) - return make_pair("", ""); + return std::make_pair("", ""); - pair assignCheckBuffer; + std::pair assignCheckBuffer; unsigned i = 0; // Increment struct counter m_structCounter++; - string wasVarName = m_varName; - string wasParamName = m_paramName; + std::string wasVarName = m_varName; + std::string wasParamName = m_paramName; if (!m_forcedVisit) m_valueStream.startStruct(); for (auto const& t: _type.t()) { - m_varName = wasVarName + ".m" + to_string(i); - m_paramName = wasParamName + ".m" + to_string(i); - pair assign = visit(t); + m_varName = wasVarName + ".m" + std::to_string(i); + m_paramName = wasParamName + ".m" + std::to_string(i); + std::pair assign = visit(t); // If type is not well formed continue without // updating state. if (assign.first.empty() && assign.second.empty()) @@ -1144,29 +1143,29 @@ pair AssignCheckVisitor::visit(StructType const& _type) return assignCheckBuffer; } -pair AssignCheckVisitor::assignAndCheckStringPair( - string const& _varRef, - string const& _checkRef, - string const& _assignValue, - string const& _checkValue, +std::pair AssignCheckVisitor::assignAndCheckStringPair( + std::string const& _varRef, + std::string const& _checkRef, + std::string const& _assignValue, + std::string const& _checkValue, DataType _type ) { - return make_pair(assignString(_varRef, _assignValue), checkString(_checkRef, _checkValue, _type)); + return std::make_pair(assignString(_varRef, _assignValue), checkString(_checkRef, _checkValue, _type)); } -string AssignCheckVisitor::assignString(string const& _ref, string const& _value) +std::string AssignCheckVisitor::assignString(std::string const& _ref, std::string const& _value) { - string assignStmt = Whiskers(R"( = ;)") + std::string assignStmt = Whiskers(R"( = ;)") ("ref", _ref) ("value", _value) .render(); return indentation() + assignStmt + "\n"; } -string AssignCheckVisitor::checkString(string const& _ref, string const& _value, DataType _type) +std::string AssignCheckVisitor::checkString(std::string const& _ref, std::string const& _value, DataType _type) { - string checkPred; + std::string checkPred; switch (_type) { case DataType::BYTES: @@ -1184,25 +1183,25 @@ string AssignCheckVisitor::checkString(string const& _ref, string const& _value, case DataType::ARRAY: solUnimplemented("Proto ABIv2 fuzzer: Invalid data type."); } - string checkStmt = Whiskers(R"(if () return ;)") + std::string checkStmt = Whiskers(R"(if () return ;)") ("checkPred", checkPred) - ("errCode", to_string(m_errorCode++)) + ("errCode", std::to_string(m_errorCode++)) .render(); return indentation() + checkStmt + "\n"; } /// ValueGetterVisitor -string ValueGetterVisitor::visit(BoolType const&) +std::string ValueGetterVisitor::visit(BoolType const&) { return counter() % 2 ? "true" : "false"; } -string ValueGetterVisitor::visit(IntegerType const& _type) +std::string ValueGetterVisitor::visit(IntegerType const& _type) { return integerValue(counter(), getIntWidth(_type), _type.is_signed()); } -string ValueGetterVisitor::visit(FixedByteType const& _type) +std::string ValueGetterVisitor::visit(FixedByteType const& _type) { return fixedByteValueAsString( getFixedByteWidth(_type), @@ -1210,12 +1209,12 @@ string ValueGetterVisitor::visit(FixedByteType const& _type) ); } -string ValueGetterVisitor::visit(AddressType const&) +std::string ValueGetterVisitor::visit(AddressType const&) { return addressValueAsString(counter()); } -string ValueGetterVisitor::visit(DynamicByteArrayType const&) +std::string ValueGetterVisitor::visit(DynamicByteArrayType const&) { return bytesArrayValueAsString( counter(), @@ -1331,7 +1330,7 @@ std::string ValueGetterVisitor::variableLengthValueAsString( unsigned numBytesRemaining = _numBytes; // Stores the literal - string output{}; + std::string output{}; // If requested value is shorter than or exactly 32 bytes, // the literal is the return value of hexValueAsString. if (numBytesRemaining <= 32) @@ -1350,7 +1349,7 @@ std::string ValueGetterVisitor::variableLengthValueAsString( // update number of bytes to be appended. // Stores the cached literal that saves us // (expensive) calls to keccak256. - string cachedString = hexValueAsString( + std::string cachedString = hexValueAsString( /*numBytes=*/32, _counter, _isHexLiteral, @@ -1398,7 +1397,7 @@ std::string ValueGetterVisitor::variableLengthValueAsString( .render(); } -string ValueGetterVisitor::bytesArrayValueAsString(unsigned _counter, bool _isHexLiteral) +std::string ValueGetterVisitor::bytesArrayValueAsString(unsigned _counter, bool _isHexLiteral) { return variableLengthValueAsString( getVarLength(_counter), diff --git a/test/tools/ossfuzz/protoToAbiV2.h b/test/tools/ossfuzz/protoToAbiV2.h index be583d49711c..803c0e7b3461 100644 --- a/test/tools/ossfuzz/protoToAbiV2.h +++ b/test/tools/ossfuzz/protoToAbiV2.h @@ -19,116 +19,116 @@ /** * Template of the solidity test program generated by this converter is as follows: * - * pragma solidity >=0.0; - * pragma experimental ABIEncoderV2; + * pragma solidity >=0.0; + * pragma experimental ABIEncoderV2; * - * contract C { - * // State variable - * string sv_0; - * // Test function that is called by the VM. - * // There are 2 variations of this function: one returns - * // the output of test_calldata_coding() and the other - * // returns the output of test_returndata_coding(). The - * // proto field called Test decides which one of the two - * // are chosen for creating a test case. - * function test() public returns (uint) { - * // The protobuf field "Contract.test" decides which of - * // the two internal functions "test_calldata_coding()" - * // and "test_returndata_coding()" are called. Here, - * // we assume that the protobuf field equals "CALLDATA_CODER" - * return this.test_calldata_coding() - * } + * contract C { + * // State variable + * string sv_0; + * // Test function that is called by the VM. + * // There are 2 variations of this function: one returns + * // the output of test_calldata_coding() and the other + * // returns the output of test_returndata_coding(). The + * // proto field called Test decides which one of the two + * // are chosen for creating a test case. + * function test() public returns (uint) { + * // The protobuf field "Contract.test" decides which of + * // the two internal functions "test_calldata_coding()" + * // and "test_returndata_coding()" are called. Here, + * // we assume that the protobuf field equals "CALLDATA_CODER" + * return this.test_calldata_coding() + * } * - * // The following function is generated if the protobuf field - * // "Contract.test" is equal to "RETURNDATA_CODER". - * function test_returndata_coding() internal returns (uint) { - * string memory lv_0, bytes memory lv_1 = test_returndata_external(); - * if (lv_0 != 044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d) - * return 1; - * if (lv_1 != "1") - * return 2; - * return 0; - * } + * // The following function is generated if the protobuf field + * // "Contract.test" is equal to "RETURNDATA_CODER". + * function test_returndata_coding() internal returns (uint) { + * string memory lv_0, bytes memory lv_1 = test_returndata_external(); + * if (lv_0 != 044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d) + * return 1; + * if (lv_1 != "1") + * return 2; + * return 0; + * } * - * // The following function is generated if the protobuf field - * // "Contract.test" is equal to "RETURNDATA_CODER". - * function test_returndata_external() external returns (string memory, bytes memory) - * { - * sv_0 = "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"; - * bytes memory lv_0 = "1"; - * return (sv_0, lv_0); - * } + * // The following function is generated if the protobuf field + * // "Contract.test" is equal to "RETURNDATA_CODER". + * function test_returndata_external() external returns (string memory, bytes memory) + * { + * sv_0 = "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"; + * bytes memory lv_0 = "1"; + * return (sv_0, lv_0); + * } * - * // The following function is generated if the protobuf field - * // "Contract.test" is equal to "CALLDATA_CODER". - * function test_calldata_coding() internal returns (uint) { - * // Local variable - * bytes lv_1 = "1"; - * sv_0 = "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"; - * uint returnVal = this.coder_public(sv_0, lv_1); - * if (returnVal != 0) - * return returnVal; - * // Since the return codes in the public and external coder functions are identical - * // we offset error code by a fixed amount (200000) for differentiation. - * returnVal = this.coder_external(sv_0, lv_1); - * if (returnVal != 0) - * return 200000 + returnVal; - * // Encode parameters - * bytes memory argumentEncoding = abi.encode(); - * returnVal = checkEncodedCall(this.coder_public.selector, argumentEncoding, ); - * // Check if calls to coder_public meet expectations for correctly/incorrectly encoded data. - * if (returnVal != 0) - * return returnVal; + * // The following function is generated if the protobuf field + * // "Contract.test" is equal to "CALLDATA_CODER". + * function test_calldata_coding() internal returns (uint) { + * // Local variable + * bytes lv_1 = "1"; + * sv_0 = "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d"; + * uint returnVal = this.coder_public(sv_0, lv_1); + * if (returnVal != 0) + * return returnVal; + * // Since the return codes in the public and external coder functions are identical + * // we offset error code by a fixed amount (200000) for differentiation. + * returnVal = this.coder_external(sv_0, lv_1); + * if (returnVal != 0) + * return 200000 + returnVal; + * // Encode parameters + * bytes memory argumentEncoding = abi.encode(); + * returnVal = checkEncodedCall(this.coder_public.selector, argumentEncoding, ); + * // Check if calls to coder_public meet expectations for correctly/incorrectly encoded data. + * if (returnVal != 0) + * return returnVal; * - * returnVal = checkEncodedCall(this.coder_external.selector, argumentEncoding, ); - * // Check if calls to coder_external meet expectations for correctly/incorrectly encoded data. - * // Offset return value to distinguish between failures originating from coder_public and coder_external. - * if (returnVal != 0) - * return uint(200000) + returnVal; - * // Return zero if all checks pass. - * return 0; - * } + * returnVal = checkEncodedCall(this.coder_external.selector, argumentEncoding, ); + * // Check if calls to coder_external meet expectations for correctly/incorrectly encoded data. + * // Offset return value to distinguish between failures originating from coder_public and coder_external. + * if (returnVal != 0) + * return uint(200000) + returnVal; + * // Return zero if all checks pass. + * return 0; + * } * - * /// Accepts function selector, correct argument encoding, and an invalid encoding length as input. - * /// Returns a non-zero value if either call with correct encoding fails or call with incorrect encoding - * /// succeeds. Returns zero if both calls meet expectation. - * function checkEncodedCall(bytes4 funcSelector, bytes memory argumentEncoding, uint invalidLengthFuzz) - * public returns (uint) { - * ... - * } + * /// Accepts function selector, correct argument encoding, and an invalid encoding length as input. + * /// Returns a non-zero value if either call with correct encoding fails or call with incorrect encoding + * /// succeeds. Returns zero if both calls meet expectation. + * function checkEncodedCall(bytes4 funcSelector, bytes memory argumentEncoding, uint invalidLengthFuzz) + * public returns (uint) { + * ... + * } * - * /// Accepts function selector, correct argument encoding, and length of invalid encoding and returns - * /// the correct and incorrect abi encoding for calling the function specified by the function selector. - * function createEncoding(bytes4 funcSelector, bytes memory argumentEncoding, uint invalidLengthFuzz) - * internal pure returns (bytes memory, bytes memory) { - * ... - * } + * /// Accepts function selector, correct argument encoding, and length of invalid encoding and returns + * /// the correct and incorrect abi encoding for calling the function specified by the function selector. + * function createEncoding(bytes4 funcSelector, bytes memory argumentEncoding, uint invalidLengthFuzz) + * internal pure returns (bytes memory, bytes memory) { + * ... + * } * - * /// Compares two dynamically sized bytes arrays for equality. - * function bytesCompare(bytes memory a, bytes memory b) internal pure returns (bool) { - * ... - * } + * /// Compares two dynamically sized bytes arrays for equality. + * function bytesCompare(bytes memory a, bytes memory b) internal pure returns (bool) { + * ... + * } * - * // Public function that is called by test() function. Accepts one or more arguments and returns - * // a uint value (zero if abi en/decoding was successful, non-zero otherwise) - * function coder_public(string memory c_0, bytes memory c_1) public pure returns (uint) { - * if (!bytesCompare(bytes(c_0), "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d")) - * return 1; - * if (!bytesCompare(c_1, "1")) - * return 2; - * return 0; - * } + * // Public function that is called by test() function. Accepts one or more arguments and returns + * // a uint value (zero if abi en/decoding was successful, non-zero otherwise) + * function coder_public(string memory c_0, bytes memory c_1) public pure returns (uint) { + * if (!bytesCompare(bytes(c_0), "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d")) + * return 1; + * if (!bytesCompare(c_1, "1")) + * return 2; + * return 0; + * } * - * // External function that is called by test() function. Accepts one or more arguments and returns - * // a uint value (zero if abi en/decoding was successful, non-zero otherwise) - * function coder_external(string calldata c_0, bytes calldata c_1) external pure returns (uint) { - * if (!bytesCompare(bytes(c_0), "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d")) - * return 1; - * if (!bytesCompare(c_1, "1")) - * return 2; - * return 0; - * } - * } + * // External function that is called by test() function. Accepts one or more arguments and returns + * // a uint value (zero if abi en/decoding was successful, non-zero otherwise) + * function coder_external(string calldata c_0, bytes calldata c_1) external pure returns (uint) { + * if (!bytesCompare(bytes(c_0), "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d")) + * return 1; + * if (!bytesCompare(c_1, "1")) + * return 2; + * return 0; + * } + * } */ namespace solidity::test::abiv2fuzzer diff --git a/test/tools/ossfuzz/protoToSol.cpp b/test/tools/ossfuzz/protoToSol.cpp index 73ed34b0d352..f8a60c4a0040 100644 --- a/test/tools/ossfuzz/protoToSol.cpp +++ b/test/tools/ossfuzz/protoToSol.cpp @@ -26,30 +26,29 @@ using namespace solidity::test::solprotofuzzer; using namespace solidity::util; -using namespace std; -string ProtoConverter::protoToSolidity(Program const& _p) +std::string ProtoConverter::protoToSolidity(Program const& _p) { // Create random number generator with fuzzer supplied // seed. - m_randomGen = make_shared(_p.seed()); + m_randomGen = std::make_shared(_p.seed()); return visit(_p); } -pair ProtoConverter::generateTestCase(TestContract const& _testContract) +std::pair ProtoConverter::generateTestCase(TestContract const& _testContract) { - ostringstream testCode; - string usingLibDecl; + std::ostringstream testCode; + std::string usingLibDecl; switch (_testContract.type()) { case TestContract::LIBRARY: { m_libraryTest = true; auto testTuple = pseudoRandomLibraryTest(); - m_libraryName = get<0>(testTuple); + m_libraryName = std::get<0>(testTuple); Whiskers u(R"(using for uint;)"); u("ind", "\t"); - u("libraryName", get<0>(testTuple)); + u("libraryName", std::get<0>(testTuple)); usingLibDecl = u.render(); Whiskers test(R"()"); test("endl", "\n"); @@ -57,8 +56,8 @@ pair ProtoConverter::generateTestCase(TestContract const& _testC test("varDecl", "uint x;"); Whiskers ifStmt(R"(if ()return 1;)"); Whiskers ifCond(R"(x.() != )"); - ifCond("testFunction", get<1>(testTuple)); - ifCond("expectedOutput", get<2>(testTuple)); + ifCond("testFunction", std::get<1>(testTuple)); + ifCond("expectedOutput", std::get<2>(testTuple)); ifStmt("cond", ifCond.render()); ifStmt("endl", "\n"); ifStmt("ind", "\t\t\t"); @@ -77,8 +76,8 @@ pair ProtoConverter::generateTestCase(TestContract const& _testC // running into stack too deep errors if (contractVarIndex >= s_maxVars) break; - string contractName = testTuple.first; - string contractVarName = "tc" + to_string(contractVarIndex); + std::string contractName = testTuple.first; + std::string contractVarName = "tc" + std::to_string(contractVarIndex); Whiskers init(R"( = new ();)"); init("endl", "\n"); init("ind", "\t\t"); @@ -98,7 +97,7 @@ pair ProtoConverter::generateTestCase(TestContract const& _testC ifStmt("endl", "\n"); ifStmt("cond", ifCond.render()); ifStmt("ind", "\t\t\t"); - ifStmt("errorCode", to_string(errorCode)); + ifStmt("errorCode", std::to_string(errorCode)); tc("ifStmt", ifStmt.render()); testCode << tc.render(); errorCode++; @@ -113,10 +112,10 @@ pair ProtoConverter::generateTestCase(TestContract const& _testC return {usingLibDecl, testCode.str()}; } -string ProtoConverter::visit(TestContract const& _testContract) +std::string ProtoConverter::visit(TestContract const& _testContract) { - string testCode; - string usingLibDecl; + std::string testCode; + std::string usingLibDecl; m_libraryTest = false; // Simply return valid uint (zero) if there are @@ -143,15 +142,15 @@ bool ProtoConverter::libraryTest() const return m_libraryTest; } -string ProtoConverter::libraryName() const +std::string ProtoConverter::libraryName() const { return m_libraryName; } -string ProtoConverter::visit(Program const& _p) +std::string ProtoConverter::visit(Program const& _p) { - ostringstream program; - ostringstream contracts; + std::ostringstream program; + std::ostringstream contracts; for (auto &contract: _p.contracts()) contracts << visit(contract); @@ -163,7 +162,7 @@ string ProtoConverter::visit(Program const& _p) return p.render(); } -string ProtoConverter::visit(ContractType const& _contractType) +std::string ProtoConverter::visit(ContractType const& _contractType) { switch (_contractType.contract_type_oneof_case()) { @@ -178,25 +177,25 @@ string ProtoConverter::visit(ContractType const& _contractType) } } -string ProtoConverter::visit(Contract const& _contract) +std::string ProtoConverter::visit(Contract const& _contract) { openProgramScope(&_contract); return ""; } -string ProtoConverter::visit(Interface const& _interface) +std::string ProtoConverter::visit(Interface const& _interface) { openProgramScope(&_interface); return ""; } -string ProtoConverter::visit(Library const& _library) +std::string ProtoConverter::visit(Library const& _library) { openProgramScope(&_library); return ""; } -tuple ProtoConverter::pseudoRandomLibraryTest() +std::tuple ProtoConverter::pseudoRandomLibraryTest() { solAssert(m_libraryTests.size() > 0, "Sol proto fuzzer: No library tests found"); unsigned index = randomNumber() % m_libraryTests.size(); @@ -205,18 +204,18 @@ tuple ProtoConverter::pseudoRandomLibraryTest() void ProtoConverter::openProgramScope(CIL _program) { - string programNamePrefix; - if (holds_alternative(_program)) + std::string programNamePrefix; + if (std::holds_alternative(_program)) programNamePrefix = "C"; - else if (holds_alternative(_program)) + else if (std::holds_alternative(_program)) programNamePrefix = "I"; else programNamePrefix = "L"; - string programName = programNamePrefix + to_string(m_programNumericSuffix++); + std::string programName = programNamePrefix + std::to_string(m_programNumericSuffix++); m_programNameMap.emplace(_program, programName); } -string ProtoConverter::programName(CIL _program) +std::string ProtoConverter::programName(CIL _program) { solAssert(m_programNameMap.count(_program), "Sol proto fuzzer: Unregistered program"); return m_programNameMap[_program]; diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 1ba0d599d4b7..8822666c8b02 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -32,14 +32,13 @@ #include -using namespace std; using namespace solidity::yul::test::yul_fuzzer; using namespace solidity::yul::test; using namespace solidity::langutil; using namespace solidity::util; using namespace solidity; -string ProtoConverter::dictionaryToken(HexPrefix _p) +std::string ProtoConverter::dictionaryToken(HexPrefix _p) { std::string token; // If dictionary constant is requested while converting @@ -57,9 +56,9 @@ string ProtoConverter::dictionaryToken(HexPrefix _p) return _p == HexPrefix::Add ? "0x" + token : token; } -string ProtoConverter::createHex(string const& _hexBytes) +std::string ProtoConverter::createHex(std::string const& _hexBytes) { - string tmp{_hexBytes}; + std::string tmp{_hexBytes}; if (!tmp.empty()) { ranges::actions::remove_if(tmp, [=](char c) -> bool { @@ -79,9 +78,9 @@ string ProtoConverter::createHex(string const& _hexBytes) return tmp; } -string ProtoConverter::createAlphaNum(string const& _strBytes) +std::string ProtoConverter::createAlphaNum(std::string const& _strBytes) { - string tmp{_strBytes}; + std::string tmp{_strBytes}; if (!tmp.empty()) { ranges::actions::remove_if(tmp, [=](char c) -> bool { @@ -123,12 +122,12 @@ EVMVersion ProtoConverter::evmVersionMapping(Program_Version const& _ver) } } -string ProtoConverter::visit(Literal const& _x) +std::string ProtoConverter::visit(Literal const& _x) { switch (_x.literal_oneof_case()) { case Literal::kIntval: - return to_string(_x.intval()); + return std::to_string(_x.intval()); case Literal::kHexval: return "0x" + createHex(_x.hexval()); case Literal::kStrval: @@ -238,7 +237,7 @@ void ProtoConverter::visit(Expression const& _x) case Expression::kFuncExpr: if (auto v = functionExists(NumFunctionReturns::Single); v.has_value()) { - string functionName = v.value(); + std::string functionName = v.value(); visit(_x.func_expr(), functionName, true); } else @@ -359,11 +358,11 @@ void ProtoConverter::visit(BinaryOp const& _x) { m_output << "mod("; visit(_x.left()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ","; m_output << "mod("; visit(_x.right()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; } else { @@ -374,7 +373,7 @@ void ProtoConverter::visit(BinaryOp const& _x) m_output << ")"; } -void ProtoConverter::scopeVariables(vector const& _varNames) +void ProtoConverter::scopeVariables(std::vector const& _varNames) { // If we are inside a for-init block, there are two places // where the visited vardecl may have been defined: @@ -443,7 +442,7 @@ void ProtoConverter::scopeVariables(vector const& _varNames) void ProtoConverter::visit(VarDecl const& _x) { - string varName = newVarName(); + std::string varName = newVarName(); m_output << "let " << varName << " := "; visit(_x.expr()); m_output << "\n"; @@ -453,14 +452,14 @@ void ProtoConverter::visit(VarDecl const& _x) void ProtoConverter::visit(MultiVarDecl const& _x) { m_output << "let "; - vector varNames; + std::vector varNames; // We support up to 4 variables in a single // declaration statement. unsigned numVars = _x.num_vars() % 3 + 2; - string delimiter; + std::string delimiter; for (unsigned i = 0; i < numVars; i++) { - string varName = newVarName(); + std::string varName = newVarName(); varNames.push_back(varName); m_output << delimiter << varName; if (i == 0) @@ -472,7 +471,7 @@ void ProtoConverter::visit(MultiVarDecl const& _x) void ProtoConverter::visit(TypedVarDecl const& _x) { - string varName = newVarName(); + std::string varName = newVarName(); m_output << "let " << varName; switch (_x.type()) { @@ -662,7 +661,7 @@ void ProtoConverter::visit(UnaryOp const& _x) { m_output << "mod("; visit(_x.operand()); - m_output << ", " << to_string(s_maxMemory - 32) << ")"; + m_output << ", " << std::to_string(s_maxMemory - 32) << ")"; } else visit(_x.operand()); @@ -844,20 +843,20 @@ void ProtoConverter::visit(CopyFunc const& _x) m_output << "("; m_output << "mod("; visit(_x.target()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; if (type == CopyFunc::MEMORY) { m_output << "mod("; visit(_x.source()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; } else visit(_x.source()); m_output << ", "; m_output << "mod("; visit(_x.size()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; m_output << ")\n"; } @@ -869,13 +868,13 @@ void ProtoConverter::visit(ExtCodeCopy const& _x) m_output << ", "; m_output << "mod("; visit(_x.target()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; visit(_x.source()); m_output << ", "; m_output << "mod("; visit(_x.size()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; m_output << ")\n"; } @@ -884,11 +883,11 @@ void ProtoConverter::visit(LogFunc const& _x) auto visitPosAndSize = [&](LogFunc const& _y) { m_output << "mod("; visit(_y.pos()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; m_output << "mod("; visit(_y.size()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; }; switch (_x.num_topics()) @@ -984,7 +983,7 @@ void ProtoConverter::visitFunctionInputParams(FunctionCall const& _x, unsigned _ void ProtoConverter::convertFunctionCall( FunctionCall const& _x, - string const& _name, + std::string const& _name, unsigned _numInParams, bool _newLine ) @@ -996,10 +995,10 @@ void ProtoConverter::convertFunctionCall( m_output << "\n"; } -vector ProtoConverter::createVarDecls(unsigned _start, unsigned _end, bool _isAssignment) +std::vector ProtoConverter::createVarDecls(unsigned _start, unsigned _end, bool _isAssignment) { m_output << "let "; - vector varsVec = createVars(_start, _end); + std::vector varsVec = createVars(_start, _end); if (_isAssignment) m_output << " := "; else @@ -1007,7 +1006,7 @@ vector ProtoConverter::createVarDecls(unsigned _start, unsigned _end, bo return varsVec; } -optional ProtoConverter::functionExists(NumFunctionReturns _numReturns) +std::optional ProtoConverter::functionExists(NumFunctionReturns _numReturns) { for (auto const& item: m_functionSigMap) if (_numReturns == NumFunctionReturns::None || _numReturns == NumFunctionReturns::Single) @@ -1020,10 +1019,10 @@ optional ProtoConverter::functionExists(NumFunctionReturns _numReturns) if (item.second.second >= static_cast(_numReturns)) return item.first; } - return nullopt; + return std::nullopt; } -void ProtoConverter::visit(FunctionCall const& _x, string const& _functionName, bool _expression) +void ProtoConverter::visit(FunctionCall const& _x, std::string const& _functionName, bool _expression) { yulAssert(m_functionSigMap.count(_functionName), "Proto fuzzer: Invalid function."); auto ret = m_functionSigMap.at(_functionName); @@ -1038,7 +1037,7 @@ void ProtoConverter::visit(FunctionCall const& _x, string const& _functionName, else { yulAssert(numOutParams > 0, ""); - vector varsVec; + std::vector varsVec; if (!_expression) { // Obtain variable name suffix @@ -1096,19 +1095,19 @@ void ProtoConverter::visit(LowLevelCall const& _x) } m_output << "mod("; visit(_x.in()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; m_output << "mod("; visit(_x.insize()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; m_output << ", "; m_output << "mod("; visit(_x.out()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; m_output << "mod("; visit(_x.outsize()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; m_output << ")"; } @@ -1137,11 +1136,11 @@ void ProtoConverter::visit(Create const& _x) m_output << ", "; m_output << "mod("; visit(_x.position()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; m_output << "mod("; visit(_x.size()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; if (type == Create::CREATE2) { m_output << ", "; @@ -1183,7 +1182,7 @@ void ProtoConverter::visit(StoreFunc const& _x) { m_output << "mod("; visit(_x.loc()); - m_output << ", " << to_string(s_maxMemory) << ")"; + m_output << ", " << std::to_string(s_maxMemory) << ")"; } else if (storeType == StoreFunc::MSTORE) { @@ -1191,7 +1190,7 @@ void ProtoConverter::visit(StoreFunc const& _x) // upper bound on memory. m_output << "mod("; visit(_x.loc()); - m_output << ", " << to_string(s_maxMemory - 32) << ")"; + m_output << ", " << std::to_string(s_maxMemory - 32) << ")"; } m_output << ", "; @@ -1261,7 +1260,7 @@ void ProtoConverter::visit(BoundedForStmt const& _x) void ProtoConverter::visit(CaseStmt const& _x) { - string literal = visit(_x.case_lit()); + std::string literal = visit(_x.case_lit()); // u256 value of literal u256 literalVal; @@ -1278,7 +1277,7 @@ void ProtoConverter::visit(CaseStmt const& _x) // a case statement containing a case literal that has already been used in a // previous case statement. If the hash (u256 value) matches a previous hash, // then we simply don't create a new case statement. - string noDoubleQuoteStr; + std::string noDoubleQuoteStr; if (literal.size() > 2) { // Ensure that all characters in the string literal except the first @@ -1376,11 +1375,11 @@ void ProtoConverter::visit(RetRevStmt const& _x) m_output << "("; m_output << "mod("; visit(_x.pos()); - m_output << ", " << to_string(s_maxMemory - s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxMemory - s_maxSize) << ")"; m_output << ", "; m_output << "mod("; visit(_x.size()); - m_output << ", " << to_string(s_maxSize) << ")"; + m_output << ", " << std::to_string(s_maxSize) << ")"; m_output << ")\n"; } @@ -1527,14 +1526,14 @@ void ProtoConverter::openBlockScope() !m_funcVars.empty(), "Proto fuzzer: Invalid data structure" ); - m_funcVars.back().push_back(vector{}); + m_funcVars.back().push_back(std::vector{}); if (m_inForInitScope && m_forInitScopeExtEnabled) { yulAssert( !m_funcForLoopInitVars.empty(), "Proto fuzzer: Invalid data structure" ); - m_funcForLoopInitVars.back().push_back(vector{}); + m_funcForLoopInitVars.back().push_back(std::vector{}); } } else @@ -1545,13 +1544,13 @@ void ProtoConverter::openBlockScope() } } -void ProtoConverter::openFunctionScope(vector const& _funcParams) +void ProtoConverter::openFunctionScope(std::vector const& _funcParams) { - m_funcVars.push_back(vector>({_funcParams})); - m_funcForLoopInitVars.push_back(vector>({})); + m_funcVars.push_back(std::vector>({_funcParams})); + m_funcForLoopInitVars.push_back(std::vector>({})); } -void ProtoConverter::updateFunctionMaps(string const& _var) +void ProtoConverter::updateFunctionMaps(std::string const& _var) { size_t erased = m_functionSigMap.erase(_var); @@ -1609,7 +1608,7 @@ void ProtoConverter::closeFunctionScope() m_funcForLoopInitVars.pop_back(); } -void ProtoConverter::addVarsToScope(vector const& _vars) +void ProtoConverter::addVarsToScope(std::vector const& _vars) { // If we are in function definition, add the new vars to current function scope if (m_inFunctionDef) @@ -1706,12 +1705,12 @@ void ProtoConverter::visit(Block const& _x) closeBlockScope(); } -vector ProtoConverter::createVars(unsigned _startIdx, unsigned _endIdx) +std::vector ProtoConverter::createVars(unsigned _startIdx, unsigned _endIdx) { yulAssert(_endIdx > _startIdx, "Proto fuzzer: Variable indices not in range"); - string varsStr = suffixedVariableNameList("x_", _startIdx, _endIdx); + std::string varsStr = suffixedVariableNameList("x_", _startIdx, _endIdx); m_output << varsStr; - vector varsVec; + std::vector varsVec; boost::split( varsVec, varsStr, @@ -1740,14 +1739,14 @@ void ProtoConverter::registerFunction(FunctionDef const* _x) numReturns = NumFunctionReturns::Multiple; // Generate function name - string funcName = functionName(numReturns); + std::string funcName = functionName(numReturns); // Register function - auto ret = m_functionSigMap.emplace(make_pair(funcName, make_pair(numInParams, numOutParams))); + auto ret = m_functionSigMap.emplace(std::make_pair(funcName, std::make_pair(numInParams, numOutParams))); yulAssert(ret.second, "Proto fuzzer: Function already exists."); m_functions.push_back(funcName); m_scopeFuncs.back().push_back(funcName); - m_functionDefMap.emplace(make_pair(_x, funcName)); + m_functionDefMap.emplace(std::make_pair(_x, funcName)); } void ProtoConverter::fillFunctionCallInput(unsigned _numInParams) @@ -1760,7 +1759,7 @@ void ProtoConverter::fillFunctionCallInput(unsigned _numInParams) unsigned diceValue = counter() % 4; // Pseudo-randomly choose one of the first ten 32-byte // aligned slots. - string slot = to_string((counter() % 10) * 32); + std::string slot = std::to_string((counter() % 10) * 32); switch (diceValue) { case 0: @@ -1769,7 +1768,7 @@ void ProtoConverter::fillFunctionCallInput(unsigned _numInParams) case 1: { // Access memory within stipulated bounds - slot = "mod(" + dictionaryToken() + ", " + to_string(s_maxMemory - 32) + ")"; + slot = "mod(" + dictionaryToken() + ", " + std::to_string(s_maxMemory - 32) + ")"; m_output << "mload(" << slot << ")"; break; } @@ -1787,19 +1786,19 @@ void ProtoConverter::fillFunctionCallInput(unsigned _numInParams) } } -void ProtoConverter::saveFunctionCallOutput(vector const& _varsVec) +void ProtoConverter::saveFunctionCallOutput(std::vector const& _varsVec) { constexpr auto numSlots = 10; constexpr auto slotSize = 32; - for (string const& var: _varsVec) + for (std::string const& var: _varsVec) { // Flip a dice to choose whether to save output values // in storage or memory. unsigned diceThrow = counter() % (m_evmVersion.supportsTransientStorage() ? 3 : 2); // Pseudo-randomly choose one of the first ten 32-byte // aligned slots. - string slot = std::to_string((counter() % numSlots) * slotSize); + std::string slot = std::to_string((counter() % numSlots) * slotSize); if (diceThrow == 0) m_output << "sstore(" << slot << ", " << var << ")\n"; else if (diceThrow == 1) @@ -1816,12 +1815,12 @@ void ProtoConverter::saveFunctionCallOutput(vector const& _varsVec) } void ProtoConverter::createFunctionCall( - string const& _funcName, + std::string const& _funcName, unsigned _numInParams, unsigned _numOutParams ) { - vector varsVec{}; + std::vector varsVec{}; if (_numOutParams > 0) { unsigned startIdx = counter(); @@ -1864,16 +1863,16 @@ void ProtoConverter::createFunctionDefAndCall( // Obtain function name yulAssert(m_functionDefMap.count(&_x), "Proto fuzzer: Unregistered function"); - string funcName = m_functionDefMap.at(&_x); + std::string funcName = m_functionDefMap.at(&_x); - vector varsVec = {}; + std::vector varsVec = {}; m_output << "function " << funcName << "("; unsigned startIdx = counter(); if (_numInParams > 0) varsVec = createVars(startIdx, startIdx + _numInParams); m_output << ")"; - vector outVarsVec = {}; + std::vector outVarsVec = {}; // This creates -> x_n+1,...,x_r if (_numOutParams > 0) { @@ -1937,15 +1936,15 @@ void ProtoConverter::visit(LeaveStmt const&) m_output << "leave\n"; } -string ProtoConverter::getObjectIdentifier(unsigned _x) +std::string ProtoConverter::getObjectIdentifier(unsigned _x) { unsigned currentId = currentObjectId(); - string currentObjName = "object" + to_string(currentId); + std::string currentObjName = "object" + std::to_string(currentId); yulAssert( m_objectScope.count(currentObjName) && !m_objectScope.at(currentObjName).empty(), "Yul proto fuzzer: Error referencing object" ); - vector objectIdsInScope = m_objectScope.at(currentObjName); + std::vector objectIdsInScope = m_objectScope.at(currentObjName); return objectIdsInScope[_x % objectIdsInScope.size()]; } @@ -1979,8 +1978,8 @@ void ProtoConverter::visit(Object const& _x) void ProtoConverter::buildObjectScopeTree(Object const& _x) { // Identifies object being visited - string objectName = newObjectId(false); - vector node{objectName}; + std::string objectName = newObjectId(false); + std::vector node{objectName}; if (_x.has_data()) node.emplace_back(s_dataIdentifier); for (auto const& subObj: _x.sub_obj()) @@ -1988,12 +1987,12 @@ void ProtoConverter::buildObjectScopeTree(Object const& _x) // Identifies sub object whose numeric suffix is // m_objectId unsigned subObjectId = m_objectId; - string subObjectName = "object" + to_string(subObjectId); + std::string subObjectName = "object" + std::to_string(subObjectId); node.push_back(subObjectName); buildObjectScopeTree(subObj); // Add sub-object to object's ancestors yulAssert(m_objectScope.count(subObjectName), "Yul proto fuzzer: Invalid object hierarchy"); - for (string const& item: m_objectScope.at(subObjectName)) + for (std::string const& item: m_objectScope.at(subObjectName)) if (item != subObjectName) node.emplace_back(subObjectName + "." + item); } @@ -2033,13 +2032,13 @@ void ProtoConverter::visit(Program const& _x) } } -string ProtoConverter::programToString(Program const& _input) +std::string ProtoConverter::programToString(Program const& _input) { visit(_input); return m_output.str(); } -string ProtoConverter::functionTypeToString(NumFunctionReturns _type) +std::string ProtoConverter::functionTypeToString(NumFunctionReturns _type) { switch (_type) { diff --git a/test/tools/ossfuzz/protoToYul.h b/test/tools/ossfuzz/protoToYul.h index c264dd51af13..2ae54f68a0b1 100644 --- a/test/tools/ossfuzz/protoToYul.h +++ b/test/tools/ossfuzz/protoToYul.h @@ -199,9 +199,9 @@ class ProtoConverter /// Prints a Yul formatted variable declaration statement to the output /// stream. /// Example 1: createVarDecls(0, 1, true) returns {"x_0"} and prints - /// let x_0 := + /// let x_0 := /// Example 2: createVarDecls(0, 2, false) returns {"x_0", "x_1"} and prints - /// let x_0, x_1 + /// let x_0, x_1 /// @param _start Start index of variable (inclusive) /// @param _end End index of variable (exclusive) /// @param _isAssignment Flag indicating if variable declaration is also @@ -215,7 +215,7 @@ class ProtoConverter /// Prints comma separated variable names to output stream and /// returns a vector containing the printed variable names. /// Example: createVars(0, 2) returns {"x_0", "x_1"} and prints - /// x_0, x_1 + /// x_0, x_1 /// @param _startIdx Start index of variable (inclusive) /// @param _endIdx End index of variable (exclusive) /// @return A vector of strings containing the printed variable names. @@ -264,7 +264,7 @@ class ProtoConverter /// @param _p Enum that decides if the returned token is hex prefixed ("0x") or not /// @return Dictionary token at the index computed using a /// monotonically increasing counter as follows: - /// index = (m_inputSize * m_inputSize + counter) % dictionarySize + /// index = (m_inputSize * m_inputSize + counter) % dictionarySize /// where m_inputSize is the size of the protobuf input and /// dictionarySize is the total number of entries in the dictionary. std::string dictionaryToken(util::HexPrefix _p = util::HexPrefix::Add); diff --git a/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp b/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp index 9b0c97a22df0..bf370dd37851 100644 --- a/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp +++ b/test/tools/ossfuzz/protomutators/YulProtoMutator.cpp @@ -6,11 +6,10 @@ using namespace solidity::yul::test::yul_fuzzer; using namespace protobuf_mutator; -using namespace std; using YPM = YulProtoMutator; -MutationInfo::MutationInfo(ProtobufMessage const* _message, string const& _info): +MutationInfo::MutationInfo(ProtobufMessage const* _message, std::string const& _info): ScopeGuard([&]{ exitInfo(); }), m_protobufMsg(_message) { @@ -60,7 +59,7 @@ struct addControlFlow /// Unused variable registers callback. LPMPostProcessor callback(function); } - function function; + std::function function; }; } @@ -182,7 +181,7 @@ void YPM::addControlFlow(T* _msg, unsigned _seed) Leave, Termination }; - uniform_int_distribution d( + std::uniform_int_distribution d( static_cast(ControlFlowStmt::For), static_cast(ControlFlowStmt::Termination) ); @@ -229,7 +228,7 @@ Block* YPM::randomBlock(ForStmt* _stmt, unsigned _seed) Post = 1, Body = 2 }; - uniform_int_distribution d( + std::uniform_int_distribution d( static_cast(ForBlocks::Init), static_cast(ForBlocks::Body) ); diff --git a/test/tools/ossfuzz/solProtoFuzzer.cpp b/test/tools/ossfuzz/solProtoFuzzer.cpp index f7acc6c10de7..06edd3e99ae8 100644 --- a/test/tools/ossfuzz/solProtoFuzzer.cpp +++ b/test/tools/ossfuzz/solProtoFuzzer.cpp @@ -35,19 +35,18 @@ using namespace solidity; using namespace solidity::frontend; using namespace solidity::test; using namespace solidity::util; -using namespace std; DEFINE_PROTO_FUZZER(Program const& _input) { ProtoConverter converter; - string sol_source = converter.protoToSolidity(_input); + std::string sol_source = converter.protoToSolidity(_input); if (char const* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_DUMP_PATH=x.yul ./a.out proto-input - ofstream of(dump_path); - of.write(sol_source.data(), static_cast(sol_source.size())); + std::ofstream of(dump_path); + of.write(sol_source.data(), static_cast(sol_source.size())); } if (char const* dump_path = getenv("SOL_DEBUG_FILE")) @@ -55,7 +54,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) sol_source.clear(); // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_LOAD_PATH=x.yul ./a.out proto-input - ifstream ifstr(dump_path); + std::ifstream ifstr(dump_path); sol_source = { std::istreambuf_iterator(ifstr), std::istreambuf_iterator() @@ -66,9 +65,9 @@ DEFINE_PROTO_FUZZER(Program const& _input) // We target the default EVM which is the latest langutil::EVMVersion version; EVMHost hostContext(version, evmone); - string contractName = "C"; - string libraryName = converter.libraryTest() ? converter.libraryName() : ""; - string methodName = "test()"; + std::string contractName = "C"; + std::string libraryName = converter.libraryTest() ? converter.libraryName() : ""; + std::string methodName = "test()"; StringMap source({{"test.sol", sol_source}}); CompilerInput cInput(version, source, contractName, OptimiserSettings::minimal(), {}); EvmoneUtility evmoneUtil( diff --git a/test/tools/ossfuzz/solc_ossfuzz.cpp b/test/tools/ossfuzz/solc_ossfuzz.cpp index 620ef332b976..dc7e26a2aeae 100644 --- a/test/tools/ossfuzz/solc_ossfuzz.cpp +++ b/test/tools/ossfuzz/solc_ossfuzz.cpp @@ -23,7 +23,6 @@ #include using namespace solidity::frontend::test; -using namespace std; // Prototype as we can't use the FuzzerInterface.h header. extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size); @@ -32,13 +31,13 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) { if (_size <= 600) { - string input(reinterpret_cast(_data), _size); - map sourceCode; + std::string input(reinterpret_cast(_data), _size); + std::map sourceCode; try { TestCaseReader t = TestCaseReader(std::istringstream(input)); sourceCode = t.sources().sources; - map settings = t.settings(); + std::map settings = t.settings(); bool compileViaYul = settings.count("compileViaYul") && (settings.at("compileViaYul") == "also" || settings.at("compileViaYul") == "true"); @@ -51,7 +50,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) compileViaYul ); } - catch (runtime_error const&) + catch (std::runtime_error const&) { return 0; } diff --git a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp index c7ffd3d417a3..595aecdca3f4 100644 --- a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp @@ -24,7 +24,6 @@ using namespace solidity; using namespace solidity::yul; -using namespace std; // Prototype as we can't use the FuzzerInterface.h header. extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size); @@ -36,10 +35,10 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) YulStringRepository::reset(); - string input(reinterpret_cast(_data), _size); + std::string input(reinterpret_cast(_data), _size); YulStack stack( langutil::EVMVersion(), - nullopt, + std::nullopt, YulStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::minimal(), langutil::DebugInfoSelection::All() diff --git a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp index 5c923a3ea718..e31391b0e15b 100644 --- a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp @@ -36,7 +36,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::yul; using namespace solidity::util; @@ -51,7 +50,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) if (_size > 600) return 0; - string input(reinterpret_cast(_data), _size); + std::string input(reinterpret_cast(_data), _size); if (std::any_of(input.begin(), input.end(), [](char c) { return ((static_cast(c) > 127) || !(isPrint(c) || (c == '\n') || (c == '\t'))); @@ -62,7 +61,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) YulStack stack( langutil::EVMVersion(), - nullopt, + std::nullopt, YulStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::full(), DebugInfoSelection::All() @@ -81,8 +80,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) return 0; } - ostringstream os1; - ostringstream os2; + std::ostringstream os1; + std::ostringstream os2; // Disable memory tracing to avoid false positive reports // such as unused write to memory e.g., // { mstore(0, 1) } diff --git a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp index db35cc865241..7553c81c0f44 100644 --- a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp @@ -25,7 +25,6 @@ using namespace solidity; using namespace solidity::langutil; using namespace solidity::util; using namespace solidity::yul; -using namespace std; // Prototype as we can't use the FuzzerInterface.h header. extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size); @@ -37,10 +36,10 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) YulStringRepository::reset(); - string input(reinterpret_cast(_data), _size); + std::string input(reinterpret_cast(_data), _size); YulStack stack( langutil::EVMVersion(), - nullopt, + std::nullopt, YulStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::full(), DebugInfoSelection::All() diff --git a/test/tools/ossfuzz/yulFuzzerCommon.cpp b/test/tools/ossfuzz/yulFuzzerCommon.cpp index 57f930cfe1e1..4f7a871ac8bf 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.cpp +++ b/test/tools/ossfuzz/yulFuzzerCommon.cpp @@ -17,14 +17,13 @@ // SPDX-License-Identifier: GPL-3.0 #include -using namespace std; using namespace solidity; using namespace solidity::yul; using namespace solidity::yul::test::yul_fuzzer; yulFuzzerUtil::TerminationReason yulFuzzerUtil::interpret( - ostream& _os, - shared_ptr _ast, + std::ostream& _os, + std::shared_ptr _ast, Dialect const& _dialect, bool _disableMemoryTracing, bool _outputStorageOnly, diff --git a/test/tools/ossfuzz/yulProtoFuzzer.cpp b/test/tools/ossfuzz/yulProtoFuzzer.cpp index c2ac680934e5..b27d879d5606 100644 --- a/test/tools/ossfuzz/yulProtoFuzzer.cpp +++ b/test/tools/ossfuzz/yulProtoFuzzer.cpp @@ -40,20 +40,19 @@ using namespace solidity::langutil; using namespace solidity::yul; using namespace solidity::yul::test; using namespace solidity::yul::test::yul_fuzzer; -using namespace std; DEFINE_PROTO_FUZZER(Program const& _input) { ProtoConverter converter; - string yul_source = converter.programToString(_input); + std::string yul_source = converter.programToString(_input); EVMVersion version = converter.version(); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_DUMP_PATH=x.yul ./a.out proto-input - ofstream of(dump_path); - of.write(yul_source.data(), static_cast(yul_source.size())); + std::ofstream of(dump_path); + of.write(yul_source.data(), static_cast(yul_source.size())); } if (yul_source.size() > 1200) @@ -64,7 +63,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) // YulStack entry point YulStack stack( version, - nullopt, + std::nullopt, YulStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::full(), DebugInfoSelection::All() @@ -85,6 +84,6 @@ DEFINE_PROTO_FUZZER(Program const& _input) EVMDialect::strictAssemblyForEVMObjects(version) ); optimizerTest.setStep(optimizerTest.randomOptimiserStep(_input.step())); - shared_ptr astBlock = optimizerTest.run(); + std::shared_ptr astBlock = optimizerTest.run(); yulAssert(astBlock != nullptr, "Optimiser error."); } diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index d1717a159a5e..49470f719820 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -36,7 +36,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::util; using namespace solidity::langutil; @@ -47,15 +46,15 @@ using namespace solidity::yul::test::yul_fuzzer; DEFINE_PROTO_FUZZER(Program const& _input) { ProtoConverter converter; - string yul_source = converter.programToString(_input); + std::string yul_source = converter.programToString(_input); EVMVersion version = converter.version(); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { // With libFuzzer binary run this to generate a YUL source file x.yul: // PROTO_FUZZER_DUMP_PATH=x.yul ./a.out proto-input - ofstream of(dump_path); - of.write(yul_source.data(), static_cast(yul_source.size())); + std::ofstream of(dump_path); + of.write(yul_source.data(), static_cast(yul_source.size())); } YulStringRepository::reset(); @@ -63,7 +62,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) // YulStack entry point YulStack stack( version, - nullopt, + std::nullopt, YulStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::full(), DebugInfoSelection::All() @@ -81,8 +80,8 @@ DEFINE_PROTO_FUZZER(Program const& _input) yulAssert(false, "Proto fuzzer generated malformed program"); } - ostringstream os1; - ostringstream os2; + std::ostringstream os1; + std::ostringstream os2; // Disable memory tracing to avoid false positive reports // such as unused write to memory e.g., // { mstore(0, 1) } @@ -102,7 +101,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) EVMDialect::strictAssemblyForEVMObjects(version) ); optimizerTest.setStep(optimizerTest.randomOptimiserStep(_input.step())); - shared_ptr astBlock = optimizerTest.run(); + std::shared_ptr astBlock = optimizerTest.run(); yulAssert(astBlock != nullptr, "Optimiser error."); termReason = yulFuzzerUtil::interpret( os2, @@ -116,8 +115,8 @@ DEFINE_PROTO_FUZZER(Program const& _input) bool isTraceEq = (os1.str() == os2.str()); if (!isTraceEq) { - cout << os1.str() << endl; - cout << os2.str() << endl; + std::cout << os1.str() << std::endl; + std::cout << os2.str() << std::endl; yulAssert(false, "Interpreted traces for optimized and unoptimized code differ."); } return; diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index 20491afe1657..d16b1da1969b 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -64,7 +64,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::util; using namespace solidity::langutil; @@ -79,14 +78,14 @@ class YulOpti static void printErrors(CharStream const& _charStream, ErrorList const& _errors) { SourceReferenceFormatter{ - cerr, + std::cerr, SingletonCharStreamProvider(_charStream), true, false }.printErrorInformation(_errors); } - void parse(string const& _input) + void parse(std::string const& _input) { ErrorList errors; ErrorReporter errorReporter(errors); @@ -96,11 +95,11 @@ class YulOpti m_ast = yul::Parser(errorReporter, m_dialect).parse(_charStream); if (!m_ast || !errorReporter.errors().empty()) { - cerr << "Error parsing source." << endl; + std::cerr << "Error parsing source." << std::endl; printErrors(_charStream, errors); throw std::runtime_error("Could not parse source."); } - m_analysisInfo = make_unique(); + m_analysisInfo = std::make_unique(); AsmAnalyzer analyzer( *m_analysisInfo, errorReporter, @@ -108,21 +107,21 @@ class YulOpti ); if (!analyzer.analyze(*m_ast) || !errorReporter.errors().empty()) { - cerr << "Error analyzing source." << endl; + std::cerr << "Error analyzing source." << std::endl; printErrors(_charStream, errors); throw std::runtime_error("Could not analyze source."); } } catch(...) { - cerr << "Fatal error during parsing: " << endl; + std::cerr << "Fatal error during parsing: " << std::endl; printErrors(_charStream, errors); throw; } } void printUsageBanner( - map const& _extraOptions, + std::map const& _extraOptions, size_t _columns ) { @@ -134,10 +133,10 @@ class YulOpti max_element(_extraOptions.begin(), _extraOptions.end(), hasShorterString)->second.size() ); - vector overlappingAbbreviations = + std::vector overlappingAbbreviations = ranges::views::set_intersection(_extraOptions | ranges::views::keys, optimiserSteps | ranges::views::keys) | - ranges::views::transform([](char _abbreviation){ return string(1, _abbreviation); }) | - ranges::to(); + ranges::views::transform([](char _abbreviation){ return std::string(1, _abbreviation); }) | + ranges::to(); yulAssert( overlappingAbbreviations.empty(), @@ -148,10 +147,10 @@ class YulOpti "Please update the code to use a different character and recompile yulopti." ); - vector> sortedOptions = + std::vector> sortedOptions = ranges::views::concat(optimiserSteps, _extraOptions) | - ranges::to>>() | - ranges::actions::sort([](tuple const& _a, tuple const& _b) { + ranges::to>>() | + ranges::actions::sort([](std::tuple const& _a, std::tuple const& _b) { return ( !boost::algorithm::iequals(get<1>(_a), get<1>(_b)) ? boost::algorithm::lexicographical_compare(get<1>(_a), get<1>(_b), boost::algorithm::is_iless()) : @@ -164,9 +163,9 @@ class YulOpti for (size_t row = 0; row < rows; ++row) { for (auto const& [key, name]: sortedOptions | ranges::views::drop(row) | ranges::views::stride(rows)) - cout << key << ": " << setw(static_cast(longestDescriptionLength)) << setiosflags(ios::left) << name << " "; + std::cout << key << ": " << std::setw(static_cast(longestDescriptionLength)) << std::setiosflags(std::ios::left) << name << " "; - cout << endl; + std::cout << std::endl; } } @@ -177,22 +176,22 @@ class YulOpti m_nameDispenser.reset(*m_ast); } - void runSteps(string _source, string _steps) + void runSteps(std::string _source, std::string _steps) { parse(_source); disambiguate(); OptimiserSuite{m_context}.runSequence(_steps, *m_ast); - cout << AsmPrinter{m_dialect}(*m_ast) << endl; + std::cout << AsmPrinter{m_dialect}(*m_ast) << std::endl; } - void runInteractive(string _source, bool _disambiguated = false) + void runInteractive(std::string _source, bool _disambiguated = false) { bool disambiguated = _disambiguated; while (true) { parse(_source); disambiguated = disambiguated || (disambiguate(), true); - map const& extraOptions = { + std::map const& extraOptions = { // QUIT starts with a non-letter character on purpose to get it to show up on top of the list {'#', ">>> QUIT <<<"}, {',', "VarNameCleaner"}, @@ -200,10 +199,10 @@ class YulOpti }; printUsageBanner(extraOptions, 4); - cout << "? "; - cout.flush(); + std::cout << "? "; + std::cout.flush(); char option = static_cast(readStandardInputChar()); - cout << ' ' << option << endl; + std::cout << ' ' << option << std::endl; try { @@ -234,19 +233,19 @@ class YulOpti } catch (...) { - cerr << endl << "Exception during optimiser step:" << endl; - cerr << boost::current_exception_diagnostic_information() << endl; + std::cerr << std::endl << "Exception during optimiser step:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; } - cout << "----------------------" << endl; - cout << _source << endl; + std::cout << "----------------------" << std::endl; + std::cout << _source << std::endl; } } private: - shared_ptr m_ast; + std::shared_ptr m_ast; Dialect const& m_dialect{EVMDialect::strictAssemblyForEVMObjects(EVMVersion{})}; - unique_ptr m_analysisInfo; - set const m_reservedIdentifiers = {}; + std::unique_ptr m_analysisInfo; + std::set const m_reservedIdentifiers = {}; NameDispenser m_nameDispenser{m_dialect, m_reservedIdentifiers}; OptimiserStepContext m_context{ m_dialect, @@ -275,12 +274,12 @@ int main(int argc, char** argv) options.add_options() ( "input-file", - po::value(), + po::value(), "input file" ) ( "steps", - po::value(), + po::value(), "steps to execute non-interactively" ) ( @@ -302,43 +301,43 @@ int main(int argc, char** argv) if (arguments.count("help")) { - cout << options; + std::cout << options; return 0; } - string input; + std::string input; if (arguments.count("input-file")) { - string filename = arguments["input-file"].as(); + std::string filename = arguments["input-file"].as(); if (filename == "-") { nonInteractive = true; - input = readUntilEnd(cin); + input = readUntilEnd(std::cin); } else - input = readFileAsString(arguments["input-file"].as()); + input = readFileAsString(arguments["input-file"].as()); } else { - cout << options; + std::cout << options; return 1; } if (nonInteractive && !arguments.count("steps")) { - cout << options; + std::cout << options; return 1; } YulOpti yulOpti; bool disambiguated = false; if (!nonInteractive) - cout << input << endl; + std::cout << input << std::endl; if (arguments.count("steps")) { - string sequence = arguments["steps"].as(); + std::string sequence = arguments["steps"].as(); if (!nonInteractive) - cout << "----------------------" << endl; + std::cout << "----------------------" << std::endl; yulOpti.runSteps(input, sequence); disambiguated = true; } @@ -349,23 +348,23 @@ int main(int argc, char** argv) } catch (po::error const& _exception) { - cerr << _exception.what() << endl; + std::cerr << _exception.what() << std::endl; return 1; } catch (FileNotFound const& _exception) { - cerr << "File not found:" << _exception.comment() << endl; + std::cerr << "File not found:" << _exception.comment() << std::endl; return 1; } catch (NotAFile const& _exception) { - cerr << "Not a regular file:" << _exception.comment() << endl; + std::cerr << "Not a regular file:" << _exception.comment() << std::endl; return 1; } catch(...) { - cerr << endl << "Exception:" << endl; - cerr << boost::current_exception_diagnostic_information() << endl; + std::cerr << std::endl << "Exception:" << std::endl; + std::cerr << boost::current_exception_diagnostic_information() << std::endl; return 1; } } diff --git a/test/tools/yulrun.cpp b/test/tools/yulrun.cpp index 2e1bcc013e45..fb18b4e598ee 100644 --- a/test/tools/yulrun.cpp +++ b/test/tools/yulrun.cpp @@ -43,7 +43,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::util; using namespace solidity::langutil; @@ -55,11 +54,11 @@ namespace po = boost::program_options; namespace { -pair, shared_ptr> parse(string const& _source) +std::pair, std::shared_ptr> parse(std::string const& _source) { YulStack stack( langutil::EVMVersion(), - nullopt, + std::nullopt, YulStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::none(), DebugInfoSelection::Default() @@ -71,15 +70,15 @@ pair, shared_ptr> parse(string const& _source } else { - SourceReferenceFormatter(cout, stack, true, false).printErrorInformation(stack.errors()); + SourceReferenceFormatter(std::cout, stack, true, false).printErrorInformation(stack.errors()); return {}; } } -void interpret(string const& _source, bool _inspect, bool _disableExternalCalls) +void interpret(std::string const& _source, bool _inspect, bool _disableExternalCalls) { - shared_ptr ast; - shared_ptr analysisInfo; + std::shared_ptr ast; + std::shared_ptr analysisInfo; tie(ast, analysisInfo) = parse(_source); if (!ast || !analysisInfo) return; @@ -100,7 +99,7 @@ void interpret(string const& _source, bool _inspect, bool _disableExternalCalls) { } - state.dumpTraceAndState(cout, /*disableMemoryTracing=*/false); + state.dumpTraceAndState(std::cout, /*disableMemoryTracing=*/false); } } @@ -119,7 +118,7 @@ Allowed options)", ("help", "Show this help screen.") ("enable-external-calls", "Enable external calls") ("interactive", "Run interactive") - ("input-file", po::value>(), "input file"); + ("input-file", po::value>(), "input file"); po::positional_options_description filesPositions; filesPositions.add("input-file", -1); @@ -132,17 +131,17 @@ Allowed options)", } catch (po::error const& _exception) { - cerr << _exception.what() << endl; + std::cerr << _exception.what() << std::endl; return 1; } if (arguments.count("help")) - cout << options; + std::cout << options; else { - string input; + std::string input; if (arguments.count("input-file")) - for (string path: arguments["input-file"].as>()) + for (std::string path: arguments["input-file"].as>()) { try { @@ -150,17 +149,17 @@ Allowed options)", } catch (FileNotFound const&) { - cerr << "File not found: " << path << endl; + std::cerr << "File not found: " << path << std::endl; return 1; } catch (NotAFile const&) { - cerr << "Not a regular file: " << path << endl; + std::cerr << "Not a regular file: " << path << std::endl; return 1; } } else - input = readUntilEnd(cin); + input = readUntilEnd(std::cin); interpret(input, arguments.count("interactive"), !arguments.count("enable-external-calls")); } diff --git a/test/yulPhaser/AlgorithmRunner.cpp b/test/yulPhaser/AlgorithmRunner.cpp index 56868f1ce76e..f89a0d70f57e 100644 --- a/test/yulPhaser/AlgorithmRunner.cpp +++ b/test/yulPhaser/AlgorithmRunner.cpp @@ -434,6 +434,10 @@ BOOST_FIXTURE_TEST_CASE(run_should_overwrite_existing_file_if_autosave_file_spec BOOST_TEST(readLinesFromFile(m_autosavePath) != originalContent); } +// Disabled due to a fairly obscure bug in GCC 13+ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109561 +// The issue is on line 444, and more specifically the Options struct std::optional +/* BOOST_FIXTURE_TEST_CASE(run_should_not_save_population_to_file_if_autosave_file_not_specified, AlgorithmRunnerAutosaveFixture) { m_options.maxRounds = 5; @@ -445,6 +449,7 @@ BOOST_FIXTURE_TEST_CASE(run_should_not_save_population_to_file_if_autosave_file_ BOOST_TEST(!fs::exists(m_autosavePath)); } +*/ BOOST_FIXTURE_TEST_CASE(run_should_randomise_duplicate_chromosomes_if_requested, AlgorithmRunnerFixture) { diff --git a/test/yulPhaser/Program.cpp b/test/yulPhaser/Program.cpp index a54bf09af146..018de32ee2e7 100644 --- a/test/yulPhaser/Program.cpp +++ b/test/yulPhaser/Program.cpp @@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE(toJson) CharStream sourceStream(sourceCode, current_test_case().p_name); Program program = get(Program::load(sourceStream)); - Json::Value parsingResult; + Json parsingResult; std::string errors; BOOST_TEST(jsonParseStrict(program.toJson(), parsingResult, &errors)); BOOST_TEST(errors.empty()); diff --git a/tools/yulPhaser/AlgorithmRunner.cpp b/tools/yulPhaser/AlgorithmRunner.cpp index d5ad75575c54..827261dc0822 100644 --- a/tools/yulPhaser/AlgorithmRunner.cpp +++ b/tools/yulPhaser/AlgorithmRunner.cpp @@ -26,7 +26,6 @@ #include #include -using namespace std; using namespace solidity::phaser; void AlgorithmRunner::run(GeneticAlgorithm& _algorithm) @@ -65,12 +64,12 @@ void AlgorithmRunner::printRoundSummary( if (m_options.showRoundInfo) { m_outputStream << "---------- ROUND " << _round + 1; - m_outputStream << " [round: " << fixed << setprecision(1) << roundTime << " s,"; - m_outputStream << " total: " << fixed << setprecision(1) << totalTime << " s]"; - m_outputStream << " ----------" << endl; + m_outputStream << " [round: " << std::fixed << std::setprecision(1) << roundTime << " s,"; + m_outputStream << " total: " << std::fixed << std::setprecision(1) << totalTime << " s]"; + m_outputStream << " ----------" << std::endl; } else if (m_population.individuals().size() > 0) - m_outputStream << endl; + m_outputStream << std::endl; m_outputStream << m_population; } @@ -78,11 +77,11 @@ void AlgorithmRunner::printRoundSummary( { if (m_options.showRoundInfo) { - m_outputStream << setw(5) << _round + 1 << " | "; - m_outputStream << setw(5) << fixed << setprecision(1) << totalTime << " | "; + m_outputStream << std::setw(5) << _round + 1 << " | "; + m_outputStream << std::setw(5) << std::fixed << std::setprecision(1) << totalTime << " | "; } - m_outputStream << m_population.individuals()[0] << endl; + m_outputStream << m_population.individuals()[0] << std::endl; } } @@ -91,7 +90,7 @@ void AlgorithmRunner::printInitialPopulation() const if (!m_options.showInitialPopulation) return; - m_outputStream << "---------- INITIAL POPULATION ----------" << endl; + m_outputStream << "---------- INITIAL POPULATION ----------" << std::endl; m_outputStream << m_population; } @@ -108,23 +107,23 @@ void AlgorithmRunner::printCacheStats() const else ++disabledCacheCount; - m_outputStream << "---------- CACHE STATS ----------" << endl; + m_outputStream << "---------- CACHE STATS ----------" << std::endl; if (disabledCacheCount < m_programCaches.size()) { for (auto& [round, count]: totalStats.roundEntryCounts) - m_outputStream << "Round " << round << ": " << count << " entries" << endl; - m_outputStream << "Total hits: " << totalStats.hits << endl; - m_outputStream << "Total misses: " << totalStats.misses << endl; - m_outputStream << "Size of cached code: " << totalStats.totalCodeSize << endl; + m_outputStream << "Round " << round << ": " << count << " entries" << std::endl; + m_outputStream << "Total hits: " << totalStats.hits << std::endl; + m_outputStream << "Total misses: " << totalStats.misses << std::endl; + m_outputStream << "Size of cached code: " << totalStats.totalCodeSize << std::endl; } if (disabledCacheCount == m_programCaches.size()) - m_outputStream << "Program cache disabled" << endl; + m_outputStream << "Program cache disabled" << std::endl; else if (disabledCacheCount > 0) { m_outputStream << "Program cache disabled for " << disabledCacheCount << " out of "; - m_outputStream << m_programCaches.size() << " programs" << endl; + m_outputStream << m_programCaches.size() << " programs" << std::endl; } } @@ -133,20 +132,20 @@ void AlgorithmRunner::populationAutosave() const if (!m_options.populationAutosaveFile.has_value()) return; - ofstream outputStream(m_options.populationAutosaveFile.value(), ios::out | ios::trunc); + std::ofstream outputStream(m_options.populationAutosaveFile.value(), std::ios::out | std::ios::trunc); assertThrow( outputStream.is_open(), FileOpenError, - "Could not open file '" + m_options.populationAutosaveFile.value() + "': " + strerror(errno) + "Could not open file '" + m_options.populationAutosaveFile.value() + "': " + std::strerror(errno) ); for (auto& individual: m_population.individuals()) - outputStream << individual.chromosome << endl; + outputStream << individual.chromosome << std::endl; assertThrow( !outputStream.bad(), FileWriteError, - "Error while writing to file '" + m_options.populationAutosaveFile.value() + "': " + strerror(errno) + "Error while writing to file '" + m_options.populationAutosaveFile.value() + "': " + std::strerror(errno) ); } @@ -188,7 +187,7 @@ Population AlgorithmRunner::randomiseDuplicates( if (_population.individuals().size() == 0) return _population; - vector individuals{_population.individuals()[0]}; + std::vector individuals{_population.individuals()[0]}; size_t duplicateCount = 0; for (size_t i = 1; i < _population.individuals().size(); ++i) if (_population.individuals()[i].chromosome == _population.individuals()[i - 1].chromosome) diff --git a/tools/yulPhaser/Chromosome.cpp b/tools/yulPhaser/Chromosome.cpp index 6e8d3544e136..85a97a781c3f 100644 --- a/tools/yulPhaser/Chromosome.cpp +++ b/tools/yulPhaser/Chromosome.cpp @@ -25,7 +25,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::yul; using namespace solidity::phaser; @@ -33,36 +32,36 @@ using namespace solidity::phaser; namespace solidity::phaser { -ostream& operator<<(ostream& _stream, Chromosome const& _chromosome); +std::ostream& operator<<(std::ostream& _stream, Chromosome const& _chromosome); } Chromosome Chromosome::makeRandom(size_t _length) { - vector steps; + std::vector steps; for (size_t i = 0; i < _length; ++i) steps.push_back(randomOptimisationStep()); return Chromosome(std::move(steps)); } -ostream& phaser::operator<<(ostream& _stream, Chromosome const& _chromosome) +std::ostream& phaser::operator<<(std::ostream& _stream, Chromosome const& _chromosome) { return _stream << _chromosome.m_genes; } -vector Chromosome::allStepNames() +std::vector Chromosome::allStepNames() { - vector stepNames; + std::vector stepNames; for (auto const& step: OptimiserSuite::allSteps()) stepNames.push_back(step.first); return stepNames; } -string const& Chromosome::randomOptimisationStep() +std::string const& Chromosome::randomOptimisationStep() { - static vector stepNames = allStepNames(); + static std::vector stepNames = allStepNames(); return stepNames[SimulationRNG::uniformInt(0, stepNames.size() - 1)]; } @@ -72,18 +71,18 @@ char Chromosome::randomGene() return OptimiserSuite::stepNameToAbbreviationMap().at(randomOptimisationStep()); } -string Chromosome::stepsToGenes(vector const& _optimisationSteps) +std::string Chromosome::stepsToGenes(std::vector const& _optimisationSteps) { - string genes; - for (string const& stepName: _optimisationSteps) + std::string genes; + for (std::string const& stepName: _optimisationSteps) genes.push_back(OptimiserSuite::stepNameToAbbreviationMap().at(stepName)); return genes; } -vector Chromosome::genesToSteps(string const& _genes) +std::vector Chromosome::genesToSteps(std::string const& _genes) { - vector steps; + std::vector steps; for (char abbreviation: _genes) steps.push_back(OptimiserSuite::stepAbbreviationToNameMap().at(abbreviation)); diff --git a/tools/yulPhaser/Common.cpp b/tools/yulPhaser/Common.cpp index a23210172d49..ca5197b7d1c6 100644 --- a/tools/yulPhaser/Common.cpp +++ b/tools/yulPhaser/Common.cpp @@ -26,21 +26,20 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::phaser; -vector phaser::readLinesFromFile(string const& _path) +std::vector phaser::readLinesFromFile(std::string const& _path) { - ifstream inputStream(_path); - assertThrow(inputStream.is_open(), FileOpenError, "Could not open file '" + _path + "': " + strerror(errno)); + std::ifstream inputStream(_path); + assertThrow(inputStream.is_open(), FileOpenError, "Could not open file '" + _path + "': " + std::strerror(errno)); - string line; - vector lines; - while (!getline(inputStream, line).fail()) + std::string line; + std::vector lines; + while (!std::getline(inputStream, line).fail()) lines.push_back(line); - assertThrow(!inputStream.bad(), FileReadError, "Error while reading from file '" + _path + "': " + strerror(errno)); + assertThrow(!inputStream.bad(), FileReadError, "Error while reading from file '" + _path + "': " + std::strerror(errno)); return lines; } diff --git a/tools/yulPhaser/FitnessMetrics.cpp b/tools/yulPhaser/FitnessMetrics.cpp index e0b719e25555..43ad3aa64183 100644 --- a/tools/yulPhaser/FitnessMetrics.cpp +++ b/tools/yulPhaser/FitnessMetrics.cpp @@ -22,7 +22,6 @@ #include -using namespace std; using namespace solidity::util; using namespace solidity::yul; using namespace solidity::phaser; @@ -62,7 +61,7 @@ size_t ProgramSize::evaluate(Chromosome const& _chromosome) size_t RelativeProgramSize::evaluate(Chromosome const& _chromosome) { - double const scalingFactor = pow(10, m_fixedPointPrecision); + double const scalingFactor = std::pow(10, m_fixedPointPrecision); size_t unoptimisedSize = optimisedProgram(Chromosome("")).codeSize(codeWeights()); if (unoptimisedSize == 0) @@ -70,7 +69,7 @@ size_t RelativeProgramSize::evaluate(Chromosome const& _chromosome) size_t optimisedSize = optimisedProgram(_chromosome).codeSize(codeWeights()); - return static_cast(round( + return static_cast(std::round( double(optimisedSize) / double(unoptimisedSize) * scalingFactor )); } @@ -103,7 +102,7 @@ size_t FitnessMetricMaximum::evaluate(Chromosome const& _chromosome) size_t maximum = m_metrics[0]->evaluate(_chromosome); for (size_t i = 1; i < m_metrics.size(); ++i) - maximum = max(maximum, m_metrics[i]->evaluate(_chromosome)); + maximum = std::max(maximum, m_metrics[i]->evaluate(_chromosome)); return maximum; } @@ -114,7 +113,7 @@ size_t FitnessMetricMinimum::evaluate(Chromosome const& _chromosome) size_t minimum = m_metrics[0]->evaluate(_chromosome); for (size_t i = 1; i < m_metrics.size(); ++i) - minimum = min(minimum, m_metrics[i]->evaluate(_chromosome)); + minimum = std::min(minimum, m_metrics[i]->evaluate(_chromosome)); return minimum; } diff --git a/tools/yulPhaser/GeneticAlgorithms.cpp b/tools/yulPhaser/GeneticAlgorithms.cpp index ff40d222a786..9345fda4f9b0 100644 --- a/tools/yulPhaser/GeneticAlgorithms.cpp +++ b/tools/yulPhaser/GeneticAlgorithms.cpp @@ -21,13 +21,12 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::phaser; -function phaser::buildCrossoverOperator( +std::function phaser::buildCrossoverOperator( CrossoverChoice _choice, - optional _uniformCrossoverSwapChance + std::optional _uniformCrossoverSwapChance ) { switch (_choice) @@ -44,9 +43,9 @@ function phaser::buildCrossoverOperator( }; } -function phaser::buildSymmetricCrossoverOperator( +std::function phaser::buildSymmetricCrossoverOperator( CrossoverChoice _choice, - optional _uniformCrossoverSwapChance + std::optional _uniformCrossoverSwapChance ) { switch (_choice) @@ -146,14 +145,14 @@ Population ClassicGeneticAlgorithm::select(Population _population, size_t _selec size_t maxFitness = 0; for (auto const& individual: _population.individuals()) - maxFitness = max(maxFitness, individual.fitness); + maxFitness = std::max(maxFitness, individual.fitness); size_t rouletteRange = 0; for (auto const& individual: _population.individuals()) // Add 1 to make sure that every chromosome has non-zero probability of being chosen rouletteRange += maxFitness + 1 - individual.fitness; - vector selectedIndividuals; + std::vector selectedIndividuals; for (size_t i = 0; i < _selectionSize; ++i) { size_t ball = SimulationRNG::uniformInt(0, rouletteRange - 1); diff --git a/tools/yulPhaser/Mutations.cpp b/tools/yulPhaser/Mutations.cpp index 873fbbb9ba65..ac55ae9d4eaa 100644 --- a/tools/yulPhaser/Mutations.cpp +++ b/tools/yulPhaser/Mutations.cpp @@ -28,15 +28,14 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::phaser; -function phaser::geneRandomisation(double _chance) +std::function phaser::geneRandomisation(double _chance) { return [=](Chromosome const& _chromosome) { - string genes; + std::string genes; for (char gene: _chromosome.genes()) genes.push_back( SimulationRNG::bernoulliTrial(_chance) ? @@ -48,11 +47,11 @@ function phaser::geneRandomisation(double _chance) }; } -function phaser::geneDeletion(double _chance) +std::function phaser::geneDeletion(double _chance) { return [=](Chromosome const& _chromosome) { - string genes; + std::string genes; for (char gene: _chromosome.genes()) if (!SimulationRNG::bernoulliTrial(_chance)) genes.push_back(gene); @@ -61,11 +60,11 @@ function phaser::geneDeletion(double _chance) }; } -function phaser::geneAddition(double _chance) +std::function phaser::geneAddition(double _chance) { return [=](Chromosome const& _chromosome) { - string genes; + std::string genes; if (SimulationRNG::bernoulliTrial(_chance)) genes.push_back(Chromosome::randomGene()); @@ -81,10 +80,10 @@ function phaser::geneAddition(double _chance) }; } -function phaser::alternativeMutations( +std::function phaser::alternativeMutations( double _firstMutationChance, - function _mutation1, - function _mutation2 + std::function _mutation1, + std::function _mutation2 ) { return [=](Chromosome const& _chromosome) @@ -96,7 +95,7 @@ function phaser::alternativeMutations( }; } -function phaser::mutationSequence(vector> _mutations) +std::function phaser::mutationSequence(std::vector> _mutations) { return [=](Chromosome const& _chromosome) { @@ -134,26 +133,26 @@ ChromosomePair fixedPointSwap( } -function phaser::randomPointCrossover() +std::function phaser::randomPointCrossover() { return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { - size_t minLength = min(_chromosome1.length(), _chromosome2.length()); + size_t minLength = std::min(_chromosome1.length(), _chromosome2.length()); // Don't use position 0 (because this just swaps the values) unless it's the only choice. size_t minPoint = (minLength > 0 ? 1 : 0); assert(minPoint <= minLength); size_t randomPoint = SimulationRNG::uniformInt(minPoint, minLength); - return get<0>(fixedPointSwap(_chromosome1, _chromosome2, randomPoint)); + return std::get<0>(fixedPointSwap(_chromosome1, _chromosome2, randomPoint)); }; } -function phaser::symmetricRandomPointCrossover() +std::function phaser::symmetricRandomPointCrossover() { return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { - size_t minLength = min(_chromosome1.length(), _chromosome2.length()); + size_t minLength = std::min(_chromosome1.length(), _chromosome2.length()); // Don't use position 0 (because this just swaps the values) unless it's the only choice. size_t minPoint = (minLength > 0 ? 1 : 0); @@ -164,16 +163,16 @@ function phaser::symmetricRandomPointCrossover() }; } -function phaser::fixedPointCrossover(double _crossoverPoint) +std::function phaser::fixedPointCrossover(double _crossoverPoint) { assert(0.0 <= _crossoverPoint && _crossoverPoint <= 1.0); return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { - size_t minLength = min(_chromosome1.length(), _chromosome2.length()); - size_t concretePoint = static_cast(round(double(minLength) * _crossoverPoint)); + size_t minLength = std::min(_chromosome1.length(), _chromosome2.length()); + size_t concretePoint = static_cast(std::round(double(minLength) * _crossoverPoint)); - return get<0>(fixedPointSwap(_chromosome1, _chromosome2, concretePoint)); + return std::get<0>(fixedPointSwap(_chromosome1, _chromosome2, concretePoint)); }; } @@ -192,8 +191,8 @@ ChromosomePair fixedTwoPointSwap( assert(_crossoverPoint2 <= _chromosome1.length()); assert(_crossoverPoint2 <= _chromosome2.length()); - size_t lowPoint = min(_crossoverPoint1, _crossoverPoint2); - size_t highPoint = max(_crossoverPoint1, _crossoverPoint2); + size_t lowPoint = std::min(_crossoverPoint1, _crossoverPoint2); + size_t highPoint = std::max(_crossoverPoint1, _crossoverPoint2); return { Chromosome( @@ -211,11 +210,11 @@ ChromosomePair fixedTwoPointSwap( } -function phaser::randomTwoPointCrossover() +std::function phaser::randomTwoPointCrossover() { return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { - size_t minLength = min(_chromosome1.length(), _chromosome2.length()); + size_t minLength = std::min(_chromosome1.length(), _chromosome2.length()); // Don't use position 0 (because this just swaps the values) unless it's the only choice. size_t minPoint = (minLength > 0 ? 1 : 0); @@ -223,15 +222,15 @@ function phaser::randomTwoPointCrossover() size_t randomPoint1 = SimulationRNG::uniformInt(minPoint, minLength); size_t randomPoint2 = SimulationRNG::uniformInt(randomPoint1, minLength); - return get<0>(fixedTwoPointSwap(_chromosome1, _chromosome2, randomPoint1, randomPoint2)); + return std::get<0>(fixedTwoPointSwap(_chromosome1, _chromosome2, randomPoint1, randomPoint2)); }; } -function phaser::symmetricRandomTwoPointCrossover() +std::function phaser::symmetricRandomTwoPointCrossover() { return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { - size_t minLength = min(_chromosome1.length(), _chromosome2.length()); + size_t minLength = std::min(_chromosome1.length(), _chromosome2.length()); // Don't use position 0 (because this just swaps the values) unless it's the only choice. size_t minPoint = (minLength > 0 ? 1 : 0); @@ -248,10 +247,10 @@ namespace ChromosomePair uniformSwap(Chromosome const& _chromosome1, Chromosome const& _chromosome2, double _swapChance) { - string steps1; - string steps2; + std::string steps1; + std::string steps2; - size_t minLength = min(_chromosome1.length(), _chromosome2.length()); + size_t minLength = std::min(_chromosome1.length(), _chromosome2.length()); for (size_t i = 0; i < minLength; ++i) if (SimulationRNG::bernoulliTrial(_swapChance)) { @@ -286,15 +285,15 @@ ChromosomePair uniformSwap(Chromosome const& _chromosome1, Chromosome const& _ch } -function phaser::uniformCrossover(double _swapChance) +std::function phaser::uniformCrossover(double _swapChance) { return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { - return get<0>(uniformSwap(_chromosome1, _chromosome2, _swapChance)); + return std::get<0>(uniformSwap(_chromosome1, _chromosome2, _swapChance)); }; } -function phaser::symmetricUniformCrossover(double _swapChance) +std::function phaser::symmetricUniformCrossover(double _swapChance) { return [=](Chromosome const& _chromosome1, Chromosome const& _chromosome2) { diff --git a/tools/yulPhaser/PairSelections.cpp b/tools/yulPhaser/PairSelections.cpp index 4c9d4ee5f961..deff94863039 100644 --- a/tools/yulPhaser/PairSelections.cpp +++ b/tools/yulPhaser/PairSelections.cpp @@ -23,17 +23,16 @@ #include -using namespace std; using namespace solidity::phaser; -vector> RandomPairSelection::materialise(size_t _poolSize) const +std::vector> RandomPairSelection::materialise(size_t _poolSize) const { if (_poolSize < 2) return {}; - auto count = static_cast(round(double(_poolSize) * m_selectionSize)); + auto count = static_cast(std::round(double(_poolSize) * m_selectionSize)); - vector> selection; + std::vector> selection; for (size_t i = 0; i < count; ++i) { size_t index1 = SimulationRNG::uniformInt(0, _poolSize - 1); @@ -49,9 +48,9 @@ vector> RandomPairSelection::materialise(size_t _poolSize) return selection; } -vector> PairsFromRandomSubset::materialise(size_t _poolSize) const +std::vector> PairsFromRandomSubset::materialise(size_t _poolSize) const { - vector selectedIndices = RandomSubset(m_selectionChance).materialise(_poolSize); + std::vector selectedIndices = RandomSubset(m_selectionChance).materialise(_poolSize); if (selectedIndices.size() % 2 != 0) { @@ -72,7 +71,7 @@ vector> PairsFromRandomSubset::materialise(size_t _poolSiz } assert(selectedIndices.size() % 2 == 0); - vector> selectedPairs; + std::vector> selectedPairs; for (size_t i = selectedIndices.size() / 2; i > 0; --i) { size_t position1 = SimulationRNG::uniformInt(0, selectedIndices.size() - 1); @@ -89,18 +88,18 @@ vector> PairsFromRandomSubset::materialise(size_t _poolSiz return selectedPairs; } -vector> PairMosaicSelection::materialise(size_t _poolSize) const +std::vector> PairMosaicSelection::materialise(size_t _poolSize) const { if (_poolSize < 2) return {}; - size_t count = static_cast(round(double(_poolSize) * m_selectionSize)); + size_t count = static_cast(std::round(double(_poolSize) * m_selectionSize)); - vector> selection; + std::vector> selection; for (size_t i = 0; i < count; ++i) { - tuple pair = m_pattern[i % m_pattern.size()]; - selection.emplace_back(min(get<0>(pair), _poolSize - 1), min(get<1>(pair), _poolSize - 1)); + std::tuple pair = m_pattern[i % m_pattern.size()]; + selection.emplace_back(std::min(std::get<0>(pair), _poolSize - 1), std::min(std::get<1>(pair), _poolSize - 1)); } return selection; diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index db5ec35cedfa..6bddf39fc050 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -37,7 +37,6 @@ #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::util; @@ -49,58 +48,58 @@ namespace po = boost::program_options; namespace { -map const PhaserModeToStringMap = +std::map const PhaserModeToStringMap = { {PhaserMode::RunAlgorithm, "run-algorithm"}, {PhaserMode::PrintOptimisedPrograms, "print-optimised-programs"}, {PhaserMode::PrintOptimisedASTs, "print-optimised-asts"}, }; -map const StringToPhaserModeMap = invertMap(PhaserModeToStringMap); +std::map const StringToPhaserModeMap = invertMap(PhaserModeToStringMap); -map const AlgorithmToStringMap = +std::map const AlgorithmToStringMap = { {Algorithm::Random, "random"}, {Algorithm::GEWEP, "GEWEP"}, {Algorithm::Classic, "classic"}, }; -map const StringToAlgorithmMap = invertMap(AlgorithmToStringMap); +std::map const StringToAlgorithmMap = invertMap(AlgorithmToStringMap); -map MetricChoiceToStringMap = +std::map MetricChoiceToStringMap = { {MetricChoice::CodeSize, "code-size"}, {MetricChoice::RelativeCodeSize, "relative-code-size"}, }; -map const StringToMetricChoiceMap = invertMap(MetricChoiceToStringMap); +std::map const StringToMetricChoiceMap = invertMap(MetricChoiceToStringMap); -map const MetricAggregatorChoiceToStringMap = +std::map const MetricAggregatorChoiceToStringMap = { {MetricAggregatorChoice::Average, "average"}, {MetricAggregatorChoice::Sum, "sum"}, {MetricAggregatorChoice::Maximum, "maximum"}, {MetricAggregatorChoice::Minimum, "minimum"}, }; -map const StringToMetricAggregatorChoiceMap = invertMap(MetricAggregatorChoiceToStringMap); +std::map const StringToMetricAggregatorChoiceMap = invertMap(MetricAggregatorChoiceToStringMap); -map const CrossoverChoiceToStringMap = +std::map const CrossoverChoiceToStringMap = { {CrossoverChoice::SinglePoint, "single-point"}, {CrossoverChoice::TwoPoint, "two-point"}, {CrossoverChoice::Uniform, "uniform"}, }; -map const StringToCrossoverChoiceMap = invertMap(CrossoverChoiceToStringMap); +std::map const StringToCrossoverChoiceMap = invertMap(CrossoverChoiceToStringMap); } -istream& phaser::operator>>(istream& _inputStream, PhaserMode& _phaserMode) { return deserializeChoice(_inputStream, _phaserMode, StringToPhaserModeMap); } -ostream& phaser::operator<<(ostream& _outputStream, PhaserMode _phaserMode) { return serializeChoice(_outputStream, _phaserMode, PhaserModeToStringMap); } -istream& phaser::operator>>(istream& _inputStream, Algorithm& _algorithm) { return deserializeChoice(_inputStream, _algorithm, StringToAlgorithmMap); } -ostream& phaser::operator<<(ostream& _outputStream, Algorithm _algorithm) { return serializeChoice(_outputStream, _algorithm, AlgorithmToStringMap); } -istream& phaser::operator>>(istream& _inputStream, MetricChoice& _metric) { return deserializeChoice(_inputStream, _metric, StringToMetricChoiceMap); } -ostream& phaser::operator<<(ostream& _outputStream, MetricChoice _metric) { return serializeChoice(_outputStream, _metric, MetricChoiceToStringMap); } -istream& phaser::operator>>(istream& _inputStream, MetricAggregatorChoice& _aggregator) { return deserializeChoice(_inputStream, _aggregator, StringToMetricAggregatorChoiceMap); } -ostream& phaser::operator<<(ostream& _outputStream, MetricAggregatorChoice _aggregator) { return serializeChoice(_outputStream, _aggregator, MetricAggregatorChoiceToStringMap); } -istream& phaser::operator>>(istream& _inputStream, CrossoverChoice& _crossover) { return deserializeChoice(_inputStream, _crossover, StringToCrossoverChoiceMap); } -ostream& phaser::operator<<(ostream& _outputStream, CrossoverChoice _crossover) { return serializeChoice(_outputStream, _crossover, CrossoverChoiceToStringMap); } +std::istream& phaser::operator>>(std::istream& _inputStream, PhaserMode& _phaserMode) { return deserializeChoice(_inputStream, _phaserMode, StringToPhaserModeMap); } +std::ostream& phaser::operator<<(std::ostream& _outputStream, PhaserMode _phaserMode) { return serializeChoice(_outputStream, _phaserMode, PhaserModeToStringMap); } +std::istream& phaser::operator>>(std::istream& _inputStream, Algorithm& _algorithm) { return deserializeChoice(_inputStream, _algorithm, StringToAlgorithmMap); } +std::ostream& phaser::operator<<(std::ostream& _outputStream, Algorithm _algorithm) { return serializeChoice(_outputStream, _algorithm, AlgorithmToStringMap); } +std::istream& phaser::operator>>(std::istream& _inputStream, MetricChoice& _metric) { return deserializeChoice(_inputStream, _metric, StringToMetricChoiceMap); } +std::ostream& phaser::operator<<(std::ostream& _outputStream, MetricChoice _metric) { return serializeChoice(_outputStream, _metric, MetricChoiceToStringMap); } +std::istream& phaser::operator>>(std::istream& _inputStream, MetricAggregatorChoice& _aggregator) { return deserializeChoice(_inputStream, _aggregator, StringToMetricAggregatorChoiceMap); } +std::ostream& phaser::operator<<(std::ostream& _outputStream, MetricAggregatorChoice _aggregator) { return serializeChoice(_outputStream, _aggregator, MetricAggregatorChoiceToStringMap); } +std::istream& phaser::operator>>(std::istream& _inputStream, CrossoverChoice& _crossover) { return deserializeChoice(_inputStream, _crossover, StringToCrossoverChoiceMap); } +std::ostream& phaser::operator<<(std::ostream& _outputStream, CrossoverChoice _crossover) { return serializeChoice(_outputStream, _crossover, CrossoverChoiceToStringMap); } GeneticAlgorithmFactory::Options GeneticAlgorithmFactory::Options::fromCommandLine(po::variables_map const& _arguments) { @@ -112,17 +111,17 @@ GeneticAlgorithmFactory::Options GeneticAlgorithmFactory::Options::fromCommandLi _arguments["uniform-crossover-swap-chance"].as(), _arguments.count("random-elite-pool-size") > 0 ? _arguments["random-elite-pool-size"].as() : - optional{}, + std::optional{}, _arguments["gewep-mutation-pool-size"].as(), _arguments["gewep-crossover-pool-size"].as(), _arguments["gewep-randomisation-chance"].as(), _arguments["gewep-deletion-vs-addition-chance"].as(), _arguments.count("gewep-genes-to-randomise") > 0 ? _arguments["gewep-genes-to-randomise"].as() : - optional{}, + std::optional{}, _arguments.count("gewep-genes-to-add-or-delete") > 0 ? _arguments["gewep-genes-to-add-or-delete"].as() : - optional{}, + std::optional{}, _arguments["classic-elite-pool-size"].as(), _arguments["classic-crossover-chance"].as(), _arguments["classic-mutation-chance"].as(), @@ -131,7 +130,7 @@ GeneticAlgorithmFactory::Options GeneticAlgorithmFactory::Options::fromCommandLi }; } -unique_ptr GeneticAlgorithmFactory::build( +std::unique_ptr GeneticAlgorithmFactory::build( Options const& _options, size_t _populationSize ) @@ -147,7 +146,7 @@ unique_ptr GeneticAlgorithmFactory::build( if (_options.randomElitePoolSize.has_value()) elitePoolSize = _options.randomElitePoolSize.value(); - return make_unique(RandomAlgorithm::Options{ + return std::make_unique(RandomAlgorithm::Options{ /* elitePoolSize = */ elitePoolSize, /* minChromosomeLength = */ _options.minChromosomeLength, /* maxChromosomeLength = */ _options.maxChromosomeLength, @@ -163,7 +162,7 @@ unique_ptr GeneticAlgorithmFactory::build( if (_options.gewepGenesToAddOrDelete.has_value()) percentGenesToAddOrDelete = _options.gewepGenesToAddOrDelete.value(); - return make_unique(GenerationalElitistWithExclusivePools::Options{ + return std::make_unique(GenerationalElitistWithExclusivePools::Options{ /* mutationPoolSize = */ _options.gewepMutationPoolSize, /* crossoverPoolSize = */ _options.gewepCrossoverPoolSize, /* randomisationChance = */ _options.gewepRandomisationChance, @@ -176,7 +175,7 @@ unique_ptr GeneticAlgorithmFactory::build( } case Algorithm::Classic: { - return make_unique(ClassicGeneticAlgorithm::Options{ + return std::make_unique(ClassicGeneticAlgorithm::Options{ /* elitePoolSize = */ _options.classicElitePoolSize, /* crossoverChance = */ _options.classicCrossoverChance, /* mutationChance = */ _options.classicMutationChance, @@ -222,24 +221,24 @@ FitnessMetricFactory::Options FitnessMetricFactory::Options::fromCommandLine(po: }; } -unique_ptr FitnessMetricFactory::build( +std::unique_ptr FitnessMetricFactory::build( Options const& _options, - vector _programs, - vector> _programCaches, + std::vector _programs, + std::vector> _programCaches, CodeWeights const& _weights ) { assert(_programCaches.size() == _programs.size()); assert(_programs.size() > 0 && "Validations should prevent this from being executed with zero files."); - vector> metrics; + std::vector> metrics; switch (_options.metric) { case MetricChoice::CodeSize: { for (size_t i = 0; i < _programs.size(); ++i) - metrics.push_back(make_unique( - _programCaches[i] != nullptr ? optional{} : std::move(_programs[i]), + metrics.push_back(std::make_unique( + _programCaches[i] != nullptr ? std::optional{} : std::move(_programs[i]), std::move(_programCaches[i]), _weights, _options.chromosomeRepetitions @@ -250,8 +249,8 @@ unique_ptr FitnessMetricFactory::build( case MetricChoice::RelativeCodeSize: { for (size_t i = 0; i < _programs.size(); ++i) - metrics.push_back(make_unique( - _programCaches[i] != nullptr ? optional{} : std::move(_programs[i]), + metrics.push_back(std::make_unique( + _programCaches[i] != nullptr ? std::optional{} : std::move(_programs[i]), std::move(_programCaches[i]), _options.relativeMetricScale, _weights, @@ -266,13 +265,13 @@ unique_ptr FitnessMetricFactory::build( switch (_options.metricAggregator) { case MetricAggregatorChoice::Average: - return make_unique(std::move(metrics)); + return std::make_unique(std::move(metrics)); case MetricAggregatorChoice::Sum: - return make_unique(std::move(metrics)); + return std::make_unique(std::move(metrics)); case MetricAggregatorChoice::Maximum: - return make_unique(std::move(metrics)); + return std::make_unique(std::move(metrics)); case MetricAggregatorChoice::Minimum: - return make_unique(std::move(metrics)); + return std::make_unique(std::move(metrics)); default: assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value."); } @@ -287,20 +286,20 @@ PopulationFactory::Options PopulationFactory::Options::fromCommandLine(po::varia _arguments["min-chromosome-length"].as(), _arguments["max-chromosome-length"].as(), _arguments.count("population") > 0 ? - _arguments["population"].as>() : - vector{}, + _arguments["population"].as>() : + std::vector{}, _arguments.count("random-population") > 0 ? - _arguments["random-population"].as>() : - vector{}, + _arguments["random-population"].as>() : + std::vector{}, _arguments.count("population-from-file") > 0 ? - _arguments["population-from-file"].as>() : - vector{}, + _arguments["population-from-file"].as>() : + std::vector{}, }; } Population PopulationFactory::build( Options const& _options, - shared_ptr _fitnessMetric + std::shared_ptr _fitnessMetric ) { Population population = buildFromStrings(_options.population, _fitnessMetric); @@ -316,19 +315,19 @@ Population PopulationFactory::build( _fitnessMetric ); - for (string const& populationFilePath: _options.populationFromFile) + for (std::string const& populationFilePath: _options.populationFromFile) population = std::move(population) + buildFromFile(populationFilePath, _fitnessMetric); return population; } Population PopulationFactory::buildFromStrings( - vector const& _geneSequences, - shared_ptr _fitnessMetric + std::vector const& _geneSequences, + std::shared_ptr _fitnessMetric ) { - vector chromosomes; - for (string const& geneSequence: _geneSequences) + std::vector chromosomes; + for (std::string const& geneSequence: _geneSequences) chromosomes.emplace_back(geneSequence); return Population(std::move(_fitnessMetric), std::move(chromosomes)); @@ -338,7 +337,7 @@ Population PopulationFactory::buildRandom( size_t _populationSize, size_t _minChromosomeLength, size_t _maxChromosomeLength, - shared_ptr _fitnessMetric + std::shared_ptr _fitnessMetric ) { return Population::makeRandom( @@ -350,8 +349,8 @@ Population PopulationFactory::buildRandom( } Population PopulationFactory::buildFromFile( - string const& _filePath, - shared_ptr _fitnessMetric + std::string const& _filePath, + std::shared_ptr _fitnessMetric ) { return buildFromStrings(readLinesFromFile(_filePath), std::move(_fitnessMetric)); @@ -364,14 +363,14 @@ ProgramCacheFactory::Options ProgramCacheFactory::Options::fromCommandLine(po::v }; } -vector> ProgramCacheFactory::build( +std::vector> ProgramCacheFactory::build( Options const& _options, - vector _programs + std::vector _programs ) { - vector> programCaches; + std::vector> programCaches; for (Program& program: _programs) - programCaches.push_back(_options.programCacheEnabled ? make_shared(std::move(program)) : nullptr); + programCaches.push_back(_options.programCacheEnabled ? std::make_shared(std::move(program)) : nullptr); return programCaches; } @@ -379,28 +378,28 @@ vector> ProgramCacheFactory::build( ProgramFactory::Options ProgramFactory::Options::fromCommandLine(po::variables_map const& _arguments) { return { - _arguments["input-files"].as>(), - _arguments["prefix"].as(), + _arguments["input-files"].as>(), + _arguments["prefix"].as(), }; } -vector ProgramFactory::build(Options const& _options) +std::vector ProgramFactory::build(Options const& _options) { - vector inputPrograms; + std::vector inputPrograms; for (auto& path: _options.inputFiles) { CharStream sourceCode = loadSource(path); - variant programOrErrors = Program::load(sourceCode); - if (holds_alternative(programOrErrors)) + std::variant programOrErrors = Program::load(sourceCode); + if (std::holds_alternative(programOrErrors)) { - SourceReferenceFormatter{cerr, SingletonCharStreamProvider(sourceCode), true, false} - .printErrorInformation(get(programOrErrors)); - cerr << endl; + SourceReferenceFormatter{std::cerr, SingletonCharStreamProvider(sourceCode), true, false} + .printErrorInformation(std::get(programOrErrors)); + std::cerr << std::endl; assertThrow(false, InvalidProgram, "Failed to load program " + path); } - get(programOrErrors).optimise(Chromosome(_options.prefix).optimisationSteps()); - inputPrograms.push_back(std::move(get(programOrErrors))); + std::get(programOrErrors).optimise(Chromosome(_options.prefix).optimisationSteps()); + inputPrograms.push_back(std::move(std::get(programOrErrors))); } return inputPrograms; @@ -410,13 +409,13 @@ CharStream ProgramFactory::loadSource(boost::filesystem::path const& _sourcePath { assertThrow(boost::filesystem::exists(_sourcePath), MissingFile, "Source file does not exist: " + _sourcePath.string()); - string sourceCode = readFileAsString(_sourcePath); + std::string sourceCode = readFileAsString(_sourcePath); return CharStream(sourceCode, _sourcePath.string()); } void Phaser::main(int _argc, char** _argv) { - optional arguments = parseCommandLine(_argc, _argv); + std::optional arguments = parseCommandLine(_argc, _argv); if (!arguments.has_value()) return; @@ -447,10 +446,10 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription() po::options_description generalDescription("GENERAL", lineLength, minDescriptionLength); generalDescription.add_options() ("help", "Show help message and exit.") - ("input-files", po::value>()->required()->value_name(""), "Input files.") + ("input-files", po::value>()->required()->value_name(""), "Input files.") ( "prefix", - po::value()->value_name("")->default_value(""), + po::value()->value_name("")->default_value(""), "Initial optimisation steps automatically applied to every input program.\n" "The result is treated as if it was the actual input, i.e. the steps are not considered " "a part of the chromosomes and cannot be mutated. The values of relative metric values " @@ -615,24 +614,24 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription() populationDescription.add_options() ( "population", - po::value>()->multitoken()->value_name(""), + po::value>()->multitoken()->value_name(""), "List of chromosomes to be included in the initial population. " "You can specify multiple values separated with spaces or invoke the option multiple times " "and all the values will be included." ) ( "random-population", - po::value>()->value_name(""), + po::value>()->value_name(""), "The number of randomly generated chromosomes to be included in the initial population." ) ( "population-from-file", - po::value>()->value_name(""), + po::value>()->value_name(""), "A text file with a list of chromosomes (one per line) to be included in the initial population." ) ( "population-autosave", - po::value()->value_name(""), + po::value()->value_name(""), "If specified, the population is saved in the specified file after each round. (default=autosave disabled)" ) ; @@ -756,7 +755,7 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription() return {keywordDescription, positionalDescription}; } -optional Phaser::parseCommandLine(int _argc, char** _argv) +std::optional Phaser::parseCommandLine(int _argc, char** _argv) { auto [keywordDescription, positionalDescription] = buildCommandLineDescription(); @@ -769,8 +768,8 @@ optional Phaser::parseCommandLine(int _argc, char** _argv) if (arguments.count("help") > 0) { - cout << keywordDescription << endl; - return nullopt; + std::cout << keywordDescription << std::endl; + return std::nullopt; } if (arguments.count("input-files") == 0) @@ -789,14 +788,14 @@ void Phaser::initialiseRNG(po::variables_map const& _arguments) SimulationRNG::reset(seed); if (_arguments["show-seed"].as()) - cout << "Random seed: " << seed << endl; + std::cout << "Random seed: " << seed << std::endl; } AlgorithmRunner::Options Phaser::buildAlgorithmRunnerOptions(po::variables_map const& _arguments) { return { - _arguments.count("rounds") > 0 ? static_cast>(_arguments["rounds"].as()) : nullopt, - _arguments.count("population-autosave") > 0 ? static_cast>(_arguments["population-autosave"].as()) : nullopt, + _arguments.count("rounds") > 0 ? static_cast>(_arguments["rounds"].as()) : std::nullopt, + _arguments.count("population-autosave") > 0 ? static_cast>(_arguments["population-autosave"].as()) : std::nullopt, !_arguments["no-randomise-duplicates"].as(), _arguments["min-chromosome-length"].as(), _arguments["max-chromosome-length"].as(), @@ -814,10 +813,10 @@ void Phaser::runPhaser(po::variables_map const& _arguments) auto metricOptions = FitnessMetricFactory::Options::fromCommandLine(_arguments); auto populationOptions = PopulationFactory::Options::fromCommandLine(_arguments); - vector programs = ProgramFactory::build(programOptions); - vector> programCaches = ProgramCacheFactory::build(cacheOptions, programs); + std::vector programs = ProgramFactory::build(programOptions); + std::vector> programCaches = ProgramCacheFactory::build(cacheOptions, programs); CodeWeights codeWeights = CodeWeightFactory::buildFromCommandLine(_arguments); - unique_ptr fitnessMetric = FitnessMetricFactory::build( + std::unique_ptr fitnessMetric = FitnessMetricFactory::build( metricOptions, programs, programCaches, @@ -834,51 +833,51 @@ void Phaser::runPhaser(po::variables_map const& _arguments) void Phaser::runAlgorithm( po::variables_map const& _arguments, Population _population, - vector> _programCaches + std::vector> _programCaches ) { auto algorithmOptions = GeneticAlgorithmFactory::Options::fromCommandLine(_arguments); - unique_ptr geneticAlgorithm = GeneticAlgorithmFactory::build( + std::unique_ptr geneticAlgorithm = GeneticAlgorithmFactory::build( algorithmOptions, _population.individuals().size() ); - AlgorithmRunner algorithmRunner(std::move(_population), std::move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout); + AlgorithmRunner algorithmRunner(std::move(_population), std::move(_programCaches), buildAlgorithmRunnerOptions(_arguments), std::cout); algorithmRunner.run(*geneticAlgorithm); } void Phaser::printOptimisedProgramsOrASTs( po::variables_map const& _arguments, Population const& _population, - vector _programs, + std::vector _programs, PhaserMode phaserMode ) { assert(phaserMode == PhaserMode::PrintOptimisedPrograms || phaserMode == PhaserMode::PrintOptimisedASTs); - assert(_programs.size() == _arguments["input-files"].as>().size()); + assert(_programs.size() == _arguments["input-files"].as>().size()); if (_population.individuals().size() == 0) { - cout << "" << endl; + std::cout << "" << std::endl; return; } - vector const& paths = _arguments["input-files"].as>(); + std::vector const& paths = _arguments["input-files"].as>(); for (auto& individual: _population.individuals()) { - cout << "Chromosome: " << individual.chromosome << endl; + std::cout << "Chromosome: " << individual.chromosome << std::endl; for (size_t i = 0; i < _programs.size(); ++i) { for (size_t j = 0; j < _arguments["chromosome-repetitions"].as(); ++j) _programs[i].optimise(individual.chromosome.optimisationSteps()); - cout << "Program: " << paths[i] << endl; + std::cout << "Program: " << paths[i] << std::endl; if (phaserMode == PhaserMode::PrintOptimisedPrograms) - cout << _programs[i] << endl; + std::cout << _programs[i] << std::endl; else - cout << _programs[i].toJson() << endl; + std::cout << _programs[i].toJson() << std::endl; } } } diff --git a/tools/yulPhaser/Population.cpp b/tools/yulPhaser/Population.cpp index d4fe1f0bd046..e669dafe56c6 100644 --- a/tools/yulPhaser/Population.cpp +++ b/tools/yulPhaser/Population.cpp @@ -28,7 +28,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::util; @@ -37,12 +36,12 @@ using namespace solidity::phaser; namespace solidity::phaser { -ostream& operator<<(ostream& _stream, Individual const& _individual); -ostream& operator<<(ostream& _stream, Population const& _population); +std::ostream& operator<<(std::ostream& _stream, Individual const& _individual); +std::ostream& operator<<(std::ostream& _stream, Population const& _population); } -ostream& phaser::operator<<(ostream& _stream, Individual const& _individual) +std::ostream& phaser::operator<<(std::ostream& _stream, Individual const& _individual) { _stream << _individual.fitness << " " << _individual.chromosome; @@ -59,12 +58,12 @@ bool phaser::isFitter(Individual const& a, Individual const& b) } Population Population::makeRandom( - shared_ptr _fitnessMetric, + std::shared_ptr _fitnessMetric, size_t _size, - function _chromosomeLengthGenerator + std::function _chromosomeLengthGenerator ) { - vector chromosomes; + std::vector chromosomes; for (size_t i = 0; i < _size; ++i) chromosomes.push_back(Chromosome::makeRandom(_chromosomeLengthGenerator())); @@ -72,7 +71,7 @@ Population Population::makeRandom( } Population Population::makeRandom( - shared_ptr _fitnessMetric, + std::shared_ptr _fitnessMetric, size_t _size, size_t _minChromosomeLength, size_t _maxChromosomeLength @@ -87,25 +86,25 @@ Population Population::makeRandom( Population Population::select(Selection const& _selection) const { - vector selectedIndividuals; + std::vector selectedIndividuals; for (size_t i: _selection.materialise(m_individuals.size())) selectedIndividuals.emplace_back(m_individuals[i]); return Population(m_fitnessMetric, selectedIndividuals); } -Population Population::mutate(Selection const& _selection, function _mutation) const +Population Population::mutate(Selection const& _selection, std::function _mutation) const { - vector mutatedIndividuals; + std::vector mutatedIndividuals; for (size_t i: _selection.materialise(m_individuals.size())) mutatedIndividuals.emplace_back(_mutation(m_individuals[i].chromosome), *m_fitnessMetric); return Population(m_fitnessMetric, mutatedIndividuals); } -Population Population::crossover(PairSelection const& _selection, function _crossover) const +Population Population::crossover(PairSelection const& _selection, std::function _crossover) const { - vector crossedIndividuals; + std::vector crossedIndividuals; for (auto const& [i, j]: _selection.materialise(m_individuals.size())) { auto childChromosome = _crossover( @@ -118,27 +117,27 @@ Population Population::crossover(PairSelection const& _selection, function Population::symmetricCrossoverWithRemainder( +std::tuple Population::symmetricCrossoverWithRemainder( PairSelection const& _selection, - function _symmetricCrossover + std::function _symmetricCrossover ) const { - vector indexSelected(m_individuals.size(), false); + std::vector indexSelected(m_individuals.size(), false); - vector crossedIndividuals; + std::vector crossedIndividuals; for (auto const& [i, j]: _selection.materialise(m_individuals.size())) { auto children = _symmetricCrossover( m_individuals[i].chromosome, m_individuals[j].chromosome ); - crossedIndividuals.emplace_back(std::move(get<0>(children)), *m_fitnessMetric); - crossedIndividuals.emplace_back(std::move(get<1>(children)), *m_fitnessMetric); + crossedIndividuals.emplace_back(std::move(std::get<0>(children)), *m_fitnessMetric); + crossedIndividuals.emplace_back(std::move(std::get<1>(children)), *m_fitnessMetric); indexSelected[i] = true; indexSelected[j] = true; } - vector remainder; + std::vector remainder; for (size_t i = 0; i < indexSelected.size(); ++i) if (!indexSelected[i]) remainder.emplace_back(m_individuals[i]); @@ -166,7 +165,7 @@ Population operator+(Population _a, Population _b) Population Population::combine(std::tuple _populationPair) { - return get<0>(_populationPair) + get<1>(_populationPair); + return std::get<0>(_populationPair) + std::get<1>(_populationPair); } bool Population::operator==(Population const& _other) const @@ -177,28 +176,28 @@ bool Population::operator==(Population const& _other) const return m_individuals == _other.m_individuals && m_fitnessMetric == _other.m_fitnessMetric; } -ostream& phaser::operator<<(ostream& _stream, Population const& _population) +std::ostream& phaser::operator<<(std::ostream& _stream, Population const& _population) { auto individual = _population.m_individuals.begin(); for (; individual != _population.m_individuals.end(); ++individual) - _stream << *individual << endl; + _stream << *individual << std::endl; return _stream; } -vector Population::chromosomesToIndividuals( +std::vector Population::chromosomesToIndividuals( FitnessMetric& _fitnessMetric, - vector _chromosomes + std::vector _chromosomes ) { - vector individuals; + std::vector individuals; for (auto& chromosome: _chromosomes) individuals.emplace_back(std::move(chromosome), _fitnessMetric); return individuals; } -vector Population::sortedIndividuals(vector _individuals) +std::vector Population::sortedIndividuals(std::vector _individuals) { sort(_individuals.begin(), _individuals.end(), isFitter); return _individuals; diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index 3089591ed8ba..00abcc8e5c31 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -45,7 +45,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::langutil; using namespace solidity::yul; @@ -55,39 +54,39 @@ using namespace solidity::phaser; namespace solidity::phaser { -ostream& operator<<(ostream& _stream, Program const& _program); +std::ostream& operator<<(std::ostream& _stream, Program const& _program); } Program::Program(Program const& program): - m_ast(make_unique(get(ASTCopier{}(*program.m_ast)))), + m_ast(std::make_unique(std::get(ASTCopier{}(*program.m_ast)))), m_dialect{program.m_dialect}, m_nameDispenser(program.m_nameDispenser) { } -variant Program::load(CharStream& _sourceCode) +std::variant Program::load(CharStream& _sourceCode) { // ASSUMPTION: parseSource() rewinds the stream on its own Dialect const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{}); - variant, ErrorList> astOrErrors = parseObject(dialect, _sourceCode); - if (holds_alternative(astOrErrors)) - return get(astOrErrors); + std::variant, ErrorList> astOrErrors = parseObject(dialect, _sourceCode); + if (std::holds_alternative(astOrErrors)) + return std::get(astOrErrors); - variant, ErrorList> analysisInfoOrErrors = analyzeAST( + std::variant, ErrorList> analysisInfoOrErrors = analyzeAST( dialect, - *get>(astOrErrors) + *std::get>(astOrErrors) ); - if (holds_alternative(analysisInfoOrErrors)) - return get(analysisInfoOrErrors); + if (std::holds_alternative(analysisInfoOrErrors)) + return std::get(analysisInfoOrErrors); Program program( dialect, disambiguateAST( dialect, - *get>(astOrErrors), - *get>(analysisInfoOrErrors) + *std::get>(astOrErrors), + *std::get>(analysisInfoOrErrors) ) ); program.optimise({ @@ -99,30 +98,30 @@ variant Program::load(CharStream& _sourceCode) return program; } -void Program::optimise(vector const& _optimisationSteps) +void Program::optimise(std::vector const& _optimisationSteps) { m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, std::move(m_ast), _optimisationSteps); } -ostream& phaser::operator<<(ostream& _stream, Program const& _program) +std::ostream& phaser::operator<<(std::ostream& _stream, Program const& _program) { return _stream << AsmPrinter()(*_program.m_ast); } -string Program::toJson() const +std::string Program::toJson() const { - Json::Value serializedAst = AsmJsonConverter(0)(*m_ast); + Json serializedAst = AsmJsonConverter(0)(*m_ast); return jsonPrettyPrint(removeNullMembers(std::move(serializedAst))); } -variant, ErrorList> Program::parseObject(Dialect const& _dialect, CharStream _source) +std::variant, ErrorList> Program::parseObject(Dialect const& _dialect, CharStream _source) { ErrorList errors; ErrorReporter errorReporter(errors); - auto scanner = make_shared(_source); + auto scanner = std::make_shared(_source); ObjectParser parser(errorReporter, _dialect); - shared_ptr object = parser.parse(scanner, false); + std::shared_ptr object = parser.parse(scanner, false); if (object == nullptr || !errorReporter.errors().empty()) // NOTE: It's possible to get errors even if the returned object is non-null. // For example when there are errors in a nested object. @@ -150,16 +149,16 @@ variant, ErrorList> Program::parseObject(Dialect const& _diale // The public API of the class does not provide access to the smart pointer so it won't be hard // to switch to shared_ptr if the copying turns out to be an issue (though it would be better // to refactor ObjectParser and Object to use unique_ptr instead). - auto astCopy = make_unique(get(ASTCopier{}(*selectedObject->code))); + auto astCopy = std::make_unique(std::get(ASTCopier{}(*selectedObject->code))); - return variant, ErrorList>(std::move(astCopy)); + return std::variant, ErrorList>(std::move(astCopy)); } -variant, ErrorList> Program::analyzeAST(Dialect const& _dialect, Block const& _ast) +std::variant, ErrorList> Program::analyzeAST(Dialect const& _dialect, Block const& _ast) { ErrorList errors; ErrorReporter errorReporter(errors); - auto analysisInfo = make_unique(); + auto analysisInfo = std::make_unique(); AsmAnalyzer analyzer(*analysisInfo, errorReporter, _dialect); bool analysisSuccessful = analyzer.analyze(_ast); @@ -167,31 +166,31 @@ variant, ErrorList> Program::analyzeAST(Dialect cons return errors; assert(errorReporter.errors().empty()); - return variant, ErrorList>(std::move(analysisInfo)); + return std::variant, ErrorList>(std::move(analysisInfo)); } -unique_ptr Program::disambiguateAST( +std::unique_ptr Program::disambiguateAST( Dialect const& _dialect, Block const& _ast, AsmAnalysisInfo const& _analysisInfo ) { - set const externallyUsedIdentifiers = {}; + std::set const externallyUsedIdentifiers = {}; Disambiguator disambiguator(_dialect, _analysisInfo, externallyUsedIdentifiers); - return make_unique(get(disambiguator(_ast))); + return std::make_unique(std::get(disambiguator(_ast))); } -unique_ptr Program::applyOptimisationSteps( +std::unique_ptr Program::applyOptimisationSteps( Dialect const& _dialect, NameDispenser& _nameDispenser, - unique_ptr _ast, - vector const& _optimisationSteps + std::unique_ptr _ast, + std::vector const& _optimisationSteps ) { // An empty set of reserved identifiers. It could be a constructor parameter but I don't // think it would be useful in this tool. Other tools (like yulopti) have it empty too. - set const externallyUsedIdentifiers = {}; + std::set const externallyUsedIdentifiers = {}; OptimiserStepContext context{ _dialect, _nameDispenser, @@ -199,7 +198,7 @@ unique_ptr Program::applyOptimisationSteps( frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment }; - for (string const& step: _optimisationSteps) + for (std::string const& step: _optimisationSteps) OptimiserSuite::allSteps().at(step)->run(context, *_ast); return _ast; diff --git a/tools/yulPhaser/ProgramCache.cpp b/tools/yulPhaser/ProgramCache.cpp index 351532aa74fa..f8fae50faa16 100644 --- a/tools/yulPhaser/ProgramCache.cpp +++ b/tools/yulPhaser/ProgramCache.cpp @@ -22,7 +22,6 @@ #include -using namespace std; using namespace solidity::yul; using namespace solidity::phaser; @@ -51,16 +50,16 @@ bool CacheStats::operator==(CacheStats const& _other) const } Program ProgramCache::optimiseProgram( - string const& _abbreviatedOptimisationSteps, - size_t _repetitionCount + std::string const& _abbreviatedOptimisationSteps, + std::size_t _repetitionCount ) { - string targetOptimisations = _abbreviatedOptimisationSteps; - for (size_t i = 1; i < _repetitionCount; ++i) + std::string targetOptimisations = _abbreviatedOptimisationSteps; + for (std::size_t i = 1; i < _repetitionCount; ++i) targetOptimisations += _abbreviatedOptimisationSteps; - size_t prefixSize = 0; - for (size_t i = 1; i <= targetOptimisations.size(); ++i) + std::size_t prefixSize = 0; + for (std::size_t i = 1; i <= targetOptimisations.size(); ++i) { auto const& pair = m_entries.find(targetOptimisations.substr(0, i)); if (pair != m_entries.end()) @@ -79,9 +78,9 @@ Program ProgramCache::optimiseProgram( m_entries.at(targetOptimisations.substr(0, prefixSize)).program ); - for (size_t i = prefixSize + 1; i <= targetOptimisations.size(); ++i) + for (std::size_t i = prefixSize + 1; i <= targetOptimisations.size(); ++i) { - string stepName = OptimiserSuite::stepAbbreviationToNameMap().at(targetOptimisations[i - 1]); + std::string stepName = OptimiserSuite::stepAbbreviationToNameMap().at(targetOptimisations[i - 1]); intermediateProgram.optimise({stepName}); m_entries.insert({targetOptimisations.substr(0, i), {intermediateProgram, m_currentRound}}); @@ -91,7 +90,7 @@ Program ProgramCache::optimiseProgram( return intermediateProgram; } -void ProgramCache::startRound(size_t _roundNumber) +void ProgramCache::startRound(std::size_t _roundNumber) { assert(_roundNumber > m_currentRound); m_currentRound = _roundNumber; @@ -113,7 +112,7 @@ void ProgramCache::clear() m_currentRound = 0; } -Program const* ProgramCache::find(string const& _abbreviatedOptimisationSteps) const +Program const* ProgramCache::find(std::string const& _abbreviatedOptimisationSteps) const { auto const& pair = m_entries.find(_abbreviatedOptimisationSteps); if (pair == m_entries.end()) @@ -132,18 +131,18 @@ CacheStats ProgramCache::gatherStats() const }; } -size_t ProgramCache::calculateTotalCachedCodeSize() const +std::size_t ProgramCache::calculateTotalCachedCodeSize() const { - size_t size = 0; + std::size_t size = 0; for (auto const& pair: m_entries) size += pair.second.program.codeSize(CacheStats::StorageWeights); return size; } -map ProgramCache::countRoundEntries() const +std::map ProgramCache::countRoundEntries() const { - map counts; + std::map counts; for (auto& pair: m_entries) if (counts.find(pair.second.roundNumber) != counts.end()) ++counts.at(pair.second.roundNumber); diff --git a/tools/yulPhaser/Selections.cpp b/tools/yulPhaser/Selections.cpp index 5c55706454a9..ca2cefeb4a68 100644 --- a/tools/yulPhaser/Selections.cpp +++ b/tools/yulPhaser/Selections.cpp @@ -23,14 +23,13 @@ #include #include -using namespace std; using namespace solidity::phaser; -vector RangeSelection::materialise(size_t _poolSize) const +std::vector RangeSelection::materialise(size_t _poolSize) const { - size_t beginIndex = static_cast(round(double(_poolSize) * m_startPercent)); - size_t endIndex = static_cast(round(double(_poolSize) * m_endPercent)); - vector selection; + size_t beginIndex = static_cast(std::round(double(_poolSize) * m_startPercent)); + size_t endIndex = static_cast(std::round(double(_poolSize) * m_endPercent)); + std::vector selection; for (size_t i = beginIndex; i < endIndex; ++i) selection.push_back(i); @@ -38,31 +37,31 @@ vector RangeSelection::materialise(size_t _poolSize) const return selection; } -vector MosaicSelection::materialise(size_t _poolSize) const +std::vector MosaicSelection::materialise(size_t _poolSize) const { - size_t count = static_cast(round(double(_poolSize) * m_selectionSize)); + size_t count = static_cast(std::round(double(_poolSize) * m_selectionSize)); - vector selection; + std::vector selection; for (size_t i = 0; i < count; ++i) - selection.push_back(min(m_pattern[i % m_pattern.size()], _poolSize - 1)); + selection.push_back(std::min(m_pattern[i % m_pattern.size()], _poolSize - 1)); return selection; } -vector RandomSelection::materialise(size_t _poolSize) const +std::vector RandomSelection::materialise(size_t _poolSize) const { - size_t count = static_cast(round(double(_poolSize) * m_selectionSize)); + size_t count = static_cast(std::round(double(_poolSize) * m_selectionSize)); - vector selection; + std::vector selection; for (size_t i = 0; i < count; ++i) selection.push_back(SimulationRNG::uniformInt(0, _poolSize - 1)); return selection; } -vector RandomSubset::materialise(size_t _poolSize) const +std::vector RandomSubset::materialise(size_t _poolSize) const { - vector selection; + std::vector selection; for (size_t index = 0; index < _poolSize; ++index) if (SimulationRNG::bernoulliTrial(m_selectionChance)) selection.push_back(index); diff --git a/tools/yulPhaser/SimulationRNG.cpp b/tools/yulPhaser/SimulationRNG.cpp index 5fca4d99e5eb..2306db63a625 100644 --- a/tools/yulPhaser/SimulationRNG.cpp +++ b/tools/yulPhaser/SimulationRNG.cpp @@ -28,7 +28,6 @@ #include #include -using namespace std; using namespace solidity; using namespace solidity::phaser; @@ -51,7 +50,7 @@ size_t SimulationRNG::binomialInt(size_t _numTrials, double _successProbability) { // NOTE: binomial_distribution would not work because it internally tries to use abs() // and fails to compile due to ambiguous conversion. - assert(_numTrials <= static_cast(numeric_limits::max())); + assert(_numTrials <= static_cast(std::numeric_limits::max())); boost::random::binomial_distribution distribution(static_cast(_numTrials), _successProbability); return static_cast(distribution(s_generator)); @@ -62,5 +61,5 @@ uint32_t SimulationRNG::generateSeed() // This is not a secure way to seed the generator but it's good enough for simulation purposes. // The only thing that matters for us is that the sequence is different on each run and that // it fits the expected distribution. It does not have to be 100% unpredictable. - return static_cast(time(nullptr)); + return static_cast(std::time(nullptr)); }