Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shafu0x/huff-stacker
The goal of this project is to automatically generate stack comments for huff macros
https://github.com/shafu0x/huff-stacker
Last synced: about 2 months ago
JSON representation
The goal of this project is to automatically generate stack comments for huff macros
- Host: GitHub
- URL: https://github.com/shafu0x/huff-stacker
- Owner: shafu0x
- Created: 2023-09-13T16:06:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-30T22:35:42.000Z (over 1 year ago)
- Last Synced: 2024-08-03T16:09:18.532Z (5 months ago)
- Language: Rust
- Size: 116 KB
- Stars: 50
- Watchers: 2
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-huff - huff-stacker
README
# huff-stack-generator
The goal of this project is to automatically generate the stack comments.
From this:
```huff
#define macro SET_VALUE2() = takes (2) returns (0) {
0x04
0x04
_XXX_YYY
0x04
0x55
lt
0x87
gt
}#define macro _XXX_YYY() = takes (1) returns (1) {
0x06
calldataload
[VALUE_LOCATION]
sstore
0x69
0x00
}
```To this:
```huff
#define macro SET_VALUE2() = takes (2) returns (0) {
0x04 // [$0, $1, 0x04]
0x04 // [$0, $1, 0x04, 0x04]
_XXX_YYY // [$0, $1, 0x04, _XXX_YYY: %0]
0x04 // [$0, $1, 0x04, _XXX_YYY: %0, 0x04]
0x55 // [$0, $1, 0x04, _XXX_YYY: %0, 0x04, 0x55]
lt // [$0, $1, 0x04, _XXX_YYY: %0, (0x55 < 0x04)]
0x87 // [$0, $1, 0x04, _XXX_YYY: %0, (0x55 < 0x04), 0x87]
gt // [$0, $1, 0x04, _XXX_YYY: %0, (0x87 > (0x55 < 0x04))]
}#define macro _XXX_YYY() = takes (1) returns (1) {
0x06 // [$0, 0x06]
calldataload // [$0, calldataload(0x06)]
[VALUE_LOCATION] // [$0, calldataload(0x06), [VALUE_LOCATION]]
sstore // [$0]
0x69 // [$0, 0x69]
0x00 // [$0, 0x69, 0x00]
}
```## How to use
```console
$ cargo run
```Optional
```console
stack-direction: [--(right/left)]
```#### Example
```console
$ cargo run /home/shafu/huff-stack-generator/macro.huff /home/shafu/huff-stack-generator/out.huff
```#### TODO
- add dup/swap
- use iterator
- support jumps
- huff lexer