Brainstorm how to insert constants into code while constructing a contract #103
Labels
A-assembler
Area: assembler
C-enhance
Category: a request for an improvement
E-medium
Experience: of moderate difficulty
It'd be nice to make it easier to insert constants into code while constructing a contract.
These are pretty much off the top of my head, so bear with me.
I think I'm partial to Solution 1 because it seems the most general / least opinionated, but Solution 2 probably has less footguns.
Solution 1: Exported Labels
We modify
%include
to expose the labels of the included file.main.etk
ctor.etk
Solution 2:
%const(...)
We add a new built-in instruction macro
%const(n)
. It errors if compiled directly, but expands to apush32
with some sentinel value (0xdeadc0de...
) wheninclude
d.Then we modify
%include
to take extra parameters. Each parameter is the name of a label pointing to where the constant should be written.Then your initcode can reference those labels to write the constants:
main.etk
ctor.etk
The text was updated successfully, but these errors were encountered: