ethereum / evmone

Fast Ethereum Virtual Machine implementation
Apache License 2.0
840 stars 280 forks source link

Bytecode DSL #772

Open chfast opened 9 months ago

chfast commented 9 months ago

Enhance the bytecode utility (from bytecode.hpp.

### Tasks
- [ ] Rethink syntax (see below)
- [ ] Use S-expressions?
- [ ] Add support for jump labels
- [ ] Add support for user-defined macros
- [ ] Add support for user-defined functions

Syntax

Concatenation (current)

mstore(0, add(mload(0), 1)) + revert(0, msize());

Dot

mstore(0, add(mload(0), 1)).revert(0, msize());

Inheritance

{
    mstore(0, add(mload(0), 1));
    revert(0, msize());
}

Aggregate initialization

bytecode{
    mstore(0, add(mload(0), 1)),
    revert(0, msize()),
};
chfast commented 8 months ago

Some inspirations: