Skip to content

Commit

Permalink
📝 More examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Philogy committed Nov 6, 2024
1 parent d251d1f commit e3b33f4
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 1 deletion.
12 changes: 12 additions & 0 deletions examples/SimpleMacros.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define macro MAIN() = takes(0) returns(0) {
0x0
0b111
wow
wow:
INNER(0b11111001, wow)
}

#define macro INNER(a, dest) = takes(0) returns(0) {
<dest> jump
<a>
}
9 changes: 9 additions & 0 deletions examples/errors/ErrorInIncluded.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#define macro MAIN() = takes(0) returns(0) {
__codeoffset(VERY_NICE)
__codeoffset(MAIN)
skibidi
}

#define macro VERY_NICE() = {
skibidi
}
5 changes: 5 additions & 0 deletions examples/errors/Include.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "./Recursive.huff"

#define macro MAIN() = takes(0) returns(0) {
// wow
}
2 changes: 1 addition & 1 deletion examples/errors/MacroArgCountMismatch.huff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define macro MAIN(a, skbidi) = takes(0) returns(0) {
WOW(0x1, 0x2)
WOW(0x1)
WOW(0x1, 0x2, 0x3)
}

Expand Down
7 changes: 7 additions & 0 deletions examples/features/CodeIntrospection.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#define macro MAIN() = takes(0) returns(0) {
__codeoffset(NICE)
}

#define macro NICE() = {
stop
}
15 changes: 15 additions & 0 deletions examples/features/CustomConstructor.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#define macro CONSTRUCTOR() = {
__codesize(MAIN)
dup1
__codeoffset(MAIN)
0x0
codecopy
0x0
return
}

#define macro MAIN() = takes(0) returns(0) {
0x1 0x1 add
msize mstore
msize 0x0 return
}
14 changes: 14 additions & 0 deletions examples/features/LabelResolution.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#define macro MAIN() = takes(0) returns(0) {
INNER()
target:
}


#define macro INNER() = {
target

0x1 0x1
add
0x2
eq
}
6 changes: 6 additions & 0 deletions examples/features/Sig.huff
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define function hello((uint256 hello,string)[])

#define macro MAIN() = takes(0) returns(0) {
0x1

}

0 comments on commit e3b33f4

Please sign in to comment.