Skip to content

Commit

Permalink
Yul codegen (#293)
Browse files Browse the repository at this point in the history
Progress toward generating Yul code.

* translate int state & field, and transaction that manipulates int state/field
* refactor helper functions to generate yul string from ast to a separate object

Some additional comments would be helpful, but I'm merging now to avoid bitrot.
  • Loading branch information
YinglanChen committed Sep 29, 2020
1 parent 500980d commit 640599d
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 48 deletions.
5 changes: 5 additions & 0 deletions Obsidian_Runtime/src/main/yul_templates/function.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function {{functionName}}({{arg0}}{{#params}},{{name}}{{/params}}){{#hasRetVal}}->{{retParams}}{{/hasRetVal}}{
{{#body}}
{{code}}
{{/body}}
}
24 changes: 19 additions & 5 deletions Obsidian_Runtime/src/main/yul_templates/object.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@ object "{{creationObject}}" {
{{#constructorHasParams}} let {{constructorParams}} := {{copyConstructorArguments}}() {{/constructorHasParams}}
{{implicitConstructor}}({{constructorParams}})
{{/notLibrary}}
{{deploy}}
{{functions}}
{{#deploy}}
{{call}}
{{/deploy}}
{{#deployFunctions}}
{{code}}
{{/deployFunctions}}
}
object "{{runtimeObject}}" {
code {
{{memoryInit}}
{{dispatch}}
{{runtimeFunctions}}
{{memoryInitRuntime}}
{{#dispatch}}
let selector := shift_right_unsigned(calldataload(0))
switch selector
{{#dispatchCase}}
case {{hash}} {
{{dispatchCall}}}
}
{{/dispatchCase}}
{{/dispatch}}
{{#runtimeFunctions}}
{{code}}
{{/runtimeFunctions}}
}
{{runtimeSubObjects}}
}
Expand Down

0 comments on commit 640599d

Please sign in to comment.