-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add support for Huff #6470
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
Open
sambacha
wants to merge
11
commits into
github-linguist:main
Choose a base branch
from
manifoldfinance:feat-huff-lang
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add support for Huff #6470
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
597609e
feat(language): Huff
sambacha aac6db0
fix(language): add language_id
sambacha 68876fb
fix(samples): change Huff sample code reference
sambacha bc99f77
fix(huff): address pr feedback for language (#1)
sambacha ec5a4ea
fix(huff): goodbye sweet prince
sambacha 51ee3bb
fix(huff): Replace FixedPointMathLib.hf with Clones.huff
sambacha 52872ad
Merge branch 'master' into feat-huff-lang
sambacha 7319e14
fix(languages): Huff samples
sambacha 5817bbd
Merge branch 'master' into feat-huff-lang
sambacha 6c9dcd0
Merge branch 'master' into feat-huff-lang
sambacha 7d73ad2
Merge branch 'master' into feat-huff-lang
sambacha 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| /// @title Errors | ||
| /// @notice SPDX-License-Identifier: MIT | ||
| /// @author jtriley.eth | ||
| /// @author clabby <https://github.com/clabby> | ||
| /// @notice Custom error utilities. | ||
|
|
||
| // https://docs.soliditylang.org/en/latest/control-structures.html?highlight=panic#panic-via-assert-and-error-via-require | ||
|
|
||
| // Errors | ||
| #define error Error(string) | ||
| #define error Panic(uint256) | ||
|
|
||
| // Constants | ||
| // Solidity Panic Codes | ||
| #define constant COMPILER_PANIC = 0x00 | ||
| #define constant ASSERT_FALSE = 0x01 | ||
| #define constant ARITHMETIC_OVERFLOW = 0x11 | ||
| #define constant DIVIDE_BY_ZERO = 0x12 | ||
| #define constant INVALID_ENUM_VALUE = 0x21 | ||
| #define constant INVALID_STORAGE_BYTE_ARRAY = 0x22 | ||
| #define constant EMPTY_ARRAY_POP = 0x31 | ||
| #define constant ARRAY_OUT_OF_BOUNDS = 0x32 | ||
| #define constant MEMORY_TOO_LARGE = 0x41 | ||
| #define constant UNINITIALIZED_FUNCTION_POINTER = 0x51 | ||
|
|
||
| /* | ||
|
|
||
| Solidity Require. Error `string` MUST be no greater than 32 bytes. | ||
|
|
||
| MEMORY LAYOUT WHEN THROWN | ||
| | sig || message offset || message length || message "revert" | | ||
| 0x08c379a 0000000000000000000000000000000000000000000000000000000000000020 0000000000000000000000000000000000000000000000000000000000000006 7265766572740000000000000000000000000000000000000000000000000000 | ||
|
|
||
| */ | ||
| #define macro REQUIRE() = takes (3) returns (0) { | ||
| // takes: // [condition, message_length, message] | ||
| do_not_throw // [do_not_throw_jumpdest, condition, message_length, message] | ||
| jumpi // [message_length, message] | ||
| __ERROR(Error) // [error_sig, , message_length, message] | ||
| 0x00 // [mem_ptr, error_sig, message_length, message] | ||
| mstore // [message_length, message] | ||
| 0x20 // [message_offset, message_length, message] | ||
| 0x04 // [message_offset_ptr, message_offset, message_length, message] | ||
| mstore // [message_length, message] | ||
| 0x24 // [message_length_ptr, message_length, message] | ||
| mstore // [message] | ||
| 0x44 // [message_ptr, message] | ||
| mstore // [] | ||
| 0x80 // [size] | ||
| 0x00 // [offset, size] | ||
| revert // [] | ||
| do_not_throw: // [message_length, message] | ||
| pop // [message] | ||
| pop // [] | ||
| } | ||
|
|
||
| /* | ||
|
|
||
| Solidity Panic. | ||
|
|
||
| MEMORY LAYOUT WHEN THROWN | ||
| | sig || panic code | | ||
| 0x4e487b71 0000000000000000000000000000000000000000000000000000000000000001 | ||
|
|
||
| */ | ||
| #define macro PANIC() = takes (1) returns (0) { | ||
| // takes: // [panic_code] | ||
| __ERROR(Panic) // [panic_sig, panic_code] | ||
| 0x00 // [panic_sig_offset, panic_sig, panic_code] | ||
| mstore // [panic_code] | ||
| 0x04 // [panic_code_offset, panic_code] | ||
| mstore // [] | ||
| 0x24 // [revert_size] | ||
| 0x00 // [revert_offset, revert_size] | ||
| revert // [] | ||
| } | ||
|
|
||
| /* | ||
| Solidity Assert. | ||
|
|
||
| MEMORY LAYOUT WHEN THROWN | ||
| | sig || assert failed panic code | | ||
| 0x4e487b71 0000000000000000000000000000000000000000000000000000000000000001 | ||
|
|
||
| */ | ||
| #define macro ASSERT() = takes (1) returns (0) { | ||
| // takes: // [condition] | ||
| do_not_panic // [do_not_panic_jumpdest, condition] | ||
| jumpi // [] | ||
| [ASSERT_FALSE] // [assert_false] | ||
| PANIC() // [] | ||
| do_not_panic: // [] | ||
| } | ||
|
|
||
| // Assert that two stack elements are equal | ||
| #define macro ASSERT_EQ() = { | ||
| // takes: [a, b] | ||
| eq // [a == b] | ||
| ASSERT() // [] | ||
| } | ||
|
|
||
| // Assert that two stack elements are not equal | ||
| #define macro ASSERT_NOT_EQ() = { | ||
| // takes: [a, b] | ||
| eq iszero // [a != b] | ||
| ASSERT() // [] | ||
| } | ||
|
|
||
| // Assert that two memory offsets contain equal words | ||
| #define macro ASSERT_MEM_EQ(ptr_a, ptr_b) = { | ||
| // takes: [] | ||
| <ptr_b> mload // [b] | ||
| <ptr_a> mload // [a, b] | ||
| eq // [a == b] | ||
| ASSERT() // [] | ||
| } | ||
|
|
||
| // Assert that two memory offsets do not contain equal words | ||
| #define macro ASSERT_MEM_NOT_EQ(ptr_a, ptr_b) = { | ||
| // takes: [] | ||
| <ptr_b> mload // [b] | ||
| <ptr_a> mload // [a, b] | ||
| eq iszero // [a != b] | ||
| ASSERT() // [] | ||
| } | ||
|
|
||
| // Assert that two storage slots contain equal words | ||
| #define macro ASSERT_STORAGE_EQ(slot_a, slot_b) = { | ||
| // takes: [] | ||
| <slot_b> sload // [b] | ||
| <slot_a> sload // [a, b] | ||
| eq // [a == b] | ||
| ASSERT() // [] | ||
| } | ||
|
|
||
| // Assert that two storage slots do not contain equal words | ||
| #define macro ASSERT_STORAGE_NOT_EQ(slot_a, slot_b) = { | ||
| // takes: [] | ||
| <slot_b> sload // [b] | ||
| <slot_a> sload // [a, b] | ||
| eq iszero // [a != b] | ||
| ASSERT() // [] | ||
| } | ||
|
|
||
| /* Bubbles up revert data if call failed. Call directly after `call`, `staticcall`, `delegatecall`. */ | ||
| #define macro BUBBLE_UP_IF_FAILED() = takes (1) returns (0) { | ||
| // takes: // [call_succeeded] | ||
| call_succeeded // [call_succeeded_jumpdest, call_succeeded] | ||
| jumpi // [] | ||
| returndatasize // [returndatasize] | ||
| 0x00 // [memory_offset, returndatasize] | ||
| returndatasize // [returndatasize, memory_offset, returndatasize] | ||
| dup2 // [returndata_offset, returndatasize, memory_offset, returndatasize] | ||
| dup3 // [memory_offset, returndata_offset, returndatasize, memory_offset, returndatasize] | ||
| returndatacopy // [memory_offset, returndatasize] | ||
| revert // [] | ||
| call_succeeded: | ||
| } |
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
Submodule huff-ghlang
added at
b56c9a
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,19 @@ | ||
| --- | ||
| name: huff-ghlang | ||
| version: b56c9ad8dd512fc4cf09c116c07d5cf14d95a3a4 | ||
| type: git_submodule | ||
| homepage: https://github.com/sambacha/huff-ghlang.git | ||
| license: mit | ||
| licenses: | ||
| - sources: LICENSE.txt | ||
| text: |+ | ||
| Copyright 2022 Huff-Language | ||
|
|
||
| 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. | ||
|
|
||
| notices: [] | ||
| ... |
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.