Jump Labels
Jump Labels are a simple abstraction included into the language to make defining
and referring to JUMPDEST
s more simple for the developer.
Example
#define macro MAIN() = takes (0) returns (0) {
// Store "Hello, World!" in memory
0x48656c6c6f2c20576f726c6421
0x00 mstore // ["Hello, World!"]
// Jump to success label, skipping the revert statement
success // [success_label_pc, "Hello, World!"]
jump // ["Hello, World!"]
// Revert if this point is reached
0x00 0x00 revert
// Labels are defined within macros or functions, and are designated
// by a word followed by a colon. Note that while it may appear as if
// labels are scoped code blocks due to the indentation, they are simply
// destinations to jump to in the bytecode. If operations exist below a label,
// they will be executed unless the program counter is altered or execution is
// halted by a `revert`, `return`, `stop`, or `selfdestruct` opcode.
success:
0x00 mstore
0x20 0x00 return
}