-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Experimental standard library #14249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # 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 stub) | ||
| set(GENERATED_STDLIB_HEADERS) | ||
| foreach(src IN LISTS STDLIB) | ||
| set(STDLIB_FILE ${CMAKE_SOURCE_DIR}/libstdlib/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("${CMAKE_SOURCE_DIR}/libstdlib/stdlib.src.h.in" ${CMAKE_BINARY_DIR}/include/libstdlib/${src}.h NEWLINE_STYLE LF @ONLY) | ||
| list(APPEND GENERATED_STDLIB_HEADERS ${CMAKE_BINARY_DIR}/include/libstdlib/${src}.h) | ||
| endforeach() | ||
|
|
||
| configure_file("${CMAKE_SOURCE_DIR}/libstdlib/stdlib.h.in" ${CMAKE_BINARY_DIR}/include/libstdlib/stdlib.h NEWLINE_STYLE LF @ONLY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity >=0.0; | ||
|
|
||
| pragma experimental solidity; | ||
|
|
||
| function identity(uint256 x) pure returns (uint256) | ||
| { | ||
| return x; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #pragma once | ||
|
|
||
| #include <map> | ||
| #include <string> | ||
|
|
||
| #include "libstdlib/stub.h" | ||
|
|
||
| namespace solidity::stdlib | ||
| { | ||
|
|
||
| static std::map<std::string, std::string> sources = { | ||
| { "std.stub", stub } | ||
| }; | ||
|
|
||
| } // namespace solidity::stdlib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_1.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pragma experimental solidity; | ||
|
|
||
| import std.stub; | ||
| // ==== | ||
| // EVMVersion: >=constantinople | ||
| // ---- | ||
| // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. | ||
| // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_2.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pragma experimental solidity; | ||
|
|
||
| import std.stub as stub; | ||
| // ==== | ||
| // EVMVersion: >=constantinople | ||
| // ---- | ||
| // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. | ||
| // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_3.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pragma experimental solidity; | ||
|
|
||
| import { identity } from std.stub; | ||
| // ==== | ||
| // EVMVersion: >=constantinople | ||
| // ---- | ||
| // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. | ||
| // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_4.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pragma experimental solidity; | ||
|
|
||
| import * as stub from std.stub; | ||
| // ==== | ||
| // EVMVersion: >=constantinople | ||
| // ---- | ||
| // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. | ||
| // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. | ||
3 changes: 3 additions & 0 deletions
3
test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_without_pragma_1.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import std.stub; | ||
| // ---- | ||
| // ParserError 9478: (7-10): Expected string literal (path), "*" or alias list. |
3 changes: 3 additions & 0 deletions
3
test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_without_pragma_2.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { identity } from std.stub; | ||
| // ---- | ||
| // ParserError 6845: (25-28): Expected import path. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.