This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains 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,23 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Install Huff | ||
run: node ./dist/index.js | ||
with: | ||
version: nightly | ||
|
||
- name: Install Dependencies | ||
run: huffc examples/test.huff |
This file contains 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 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,38 @@ | ||
/* Interface */ | ||
#define function setNumber(uint256) nonpayable returns () | ||
#define function getNumber() view returns (uint256) | ||
|
||
/* Storage Slots */ | ||
#define constant NUMBER_LOCATION = FREE_STORAGE_POINTER() | ||
|
||
/* Methods */ | ||
#define macro SET_NUMBER() = takes (0) returns (0) { | ||
0x04 calldataload // [number] | ||
[NUMBER_LOCATION] // [ptr, number] | ||
sstore // [] | ||
} | ||
|
||
#define macro GET_NUMBER() = takes (0) returns (0) { | ||
// Load number from storage. | ||
[NUMBER_LOCATION] // [ptr] | ||
sload // [number] | ||
|
||
// Store number in memory. | ||
0x00 mstore | ||
|
||
// Return number | ||
0x20 0x00 return | ||
} | ||
|
||
#define macro MAIN() = takes (0) returns (0) { | ||
// Identify which function is being called. | ||
0x00 calldataload 0xE0 shr | ||
dup1 0x3fb5c1cb eq set jumpi | ||
dup1 0xf2c9ecd8 eq get jumpi | ||
|
||
set: | ||
SET_NUMBER() | ||
get: | ||
GET_NUMBER() | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.