From f8b52f8d4d7a512ac1efec763b69111c18d5f144 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 27 Jun 2022 00:51:14 +0200 Subject: [PATCH] Rename to solstdlib --- stdlib/CMakeLists.txt | 21 ------------------ stdlib/src/precompiles.sol | 44 -------------------------------------- stdlib/stdlib.h.in | 15 ------------- stdlib/stdlib.src.h.in | 13 ----------- 4 files changed, 93 deletions(-) delete mode 100644 stdlib/CMakeLists.txt delete mode 100644 stdlib/src/precompiles.sol delete mode 100644 stdlib/stdlib.h.in delete mode 100644 stdlib/stdlib.src.h.in diff --git a/stdlib/CMakeLists.txt b/stdlib/CMakeLists.txt deleted file mode 100644 index 742755f85..000000000 --- a/stdlib/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# This will re-generate the headers if any file within src was modified. -set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/stdlib/src/) - -set(STDLIB precompiles) -set(GENERATED_STDLIB_HEADERS) -foreach(src IN LISTS STDLIB) - set(STDLIB_FILE ${CMAKE_SOURCE_DIR}/stdlib/src/${src}.sol) - file(READ ${STDLIB_FILE} STDLIB_FILE_CONTENT HEX) - string(REGEX MATCHALL ".." STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}") - 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("${CMAKE_SOURCE_DIR}/stdlib/stdlib.src.h.in" ${CMAKE_BINARY_DIR}/include/stdlib/${src}.h @ONLY) - list(APPEND GENERATED_STDLIB_HEADERS ${CMAKE_BINARY_DIR}/include/stdlib/${src}.h) -endforeach() - -configure_file("${CMAKE_SOURCE_DIR}/stdlib/stdlib.h.in" ${CMAKE_BINARY_DIR}/include/stdlib.h @ONLY) - -#add_library(stdlib -# ${GENERATED_STDLIB_HEADERS} -#) diff --git a/stdlib/src/precompiles.sol b/stdlib/src/precompiles.sol deleted file mode 100644 index a1d6c5985..000000000 --- a/stdlib/src/precompiles.sol +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -function sha256(bytes memory input) returns (bytes32 ret) { - assembly { - let success := staticcall(gas(), 2, add(input, 32), mload(input), 0, 32) - if iszero(success) { revert(0, 0) } - ret := mload(0) - } -} - -function ripemd160(bytes memory input) returns (bytes20 ret) { - assembly { - let success := staticcall(gas(), 3, add(input, 32), mload(input), 0, 32) - if iszero(success) { revert(0, 0) } - // TODO: check byteorder - ret := mload(0) - } -} - -function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address addr) { - assembly { - // Prepare input - // We are using the free memory pointer. - let input := mload(0x40) - mstore(input, hash) - mstore(add(input, 32), v) - mstore(add(input, 64), r) - mstore(add(input, 96), s) - - // Prepare output - let output := add(input, 128) - mstore(output, 0) - - // Call the precompile - let ret := staticcall(gas(), 1, input, 128, output, 32) - switch ret - case 1 { // Success - addr := mload(output) - } - default { // Failure - // Need to do anything? - } - } -} diff --git a/stdlib/stdlib.h.in b/stdlib/stdlib.h.in deleted file mode 100644 index b1d243270..000000000 --- a/stdlib/stdlib.h.in +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include - -#include "stdlib/precompiles.h" - -namespace solidity::stdlib -{ - -static std::map sources = { - { "std/precompiles.sol", precompiles }, -}; - -} // namespace solidity::stdlib diff --git a/stdlib/stdlib.src.h.in b/stdlib/stdlib.src.h.in deleted file mode 100644 index 0407663d6..000000000 --- a/stdlib/stdlib.src.h.in +++ /dev/null @@ -1,13 +0,0 @@ -// The generation of this file is defined in stdlib/CMakeLists.txt. -// This file was generated by using the content of stdlib/src/@STDLIB_FILE_NAME@.sol. - -#pragma once - -namespace solidity::stdlib -{ - -static char const @STDLIB_FILE_NAME@[] = { - @STDLIB_FILE_CONTENT@, 0 -}; - -} // namespace solidity::stdlib