-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve ability to output yul from internal AST representation (#316)
* removing unused imports * this will make the indentation a little better, but its not a real solution * hacking on the mustache file and AST translation for #310 * end of day scraps and comments to myself for where to start Monday * scraps and notes to myself * adding assert false and first cut at outputting a default return; removing dead comments and latenight code that didnt compile * default return, now not in AST form and at the bottom * adding asserts before more unit values * adding cases * hoisting to a function * type, adding a fully qualified name to satisfy the IDE * scraps, comments, code hygine * scraps, comments, code hygine * scraps, comments, code hygine * massaging whitespace * fussing with syntax * committing to overriding toString * overriding some toStrings * code hygine * less manual toString for function calls * new implementation of function strings seems good * combinator for integer literals * removing the code i pushed into the object structure * noting a bug to fix in the future * moving code around a little, working on comments * finessing output for switch * whitespace * i may have deprecated this code; check tomorrow * scraps, clean up before merging #315 * cleaning up todos and code quality for #315 * yulString object was dead code * lifting repeated code, adjusting comments * cleaning up assignment case * removing repeated code * removing repeated code * removing needless tostring * adding type annotations, removing needless parens, replacing iteration that misses cases with a map that works * braces and parens * a little more code clean up for #315 * string interpolation
- Loading branch information
Showing
7 changed files
with
218 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 71 additions & 138 deletions
209
src/main/scala/edu/cmu/cs/obsidian/codegen/CodeGenYul.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package edu.cmu.cs.obsidian.codegen | ||
|
||
/* utility functions shared between yulAST and CodeGenYul */ | ||
object Util { | ||
def brace(str: String): String = s"{$str}" | ||
def paren(str: String): String = s"($str)" | ||
def ilit(i: Int): Literal = Literal(LiteralKind.number,i.toString,"int") | ||
def blit(b : Boolean): Literal = Literal(LiteralKind.boolean,b.toString,"bool") | ||
val true_lit: Literal = blit(true) | ||
val false_lit: Literal = blit(false) | ||
|
||
// TODO unimplemented; hardcode to uint256 for now | ||
def mapObsTypeToABI(ntype: String): String = { | ||
"uint256" | ||
} | ||
|
||
// TODO unimplemented; hardcode for now; bouncycastle library may be helpful | ||
def keccak256(s: String): String = { | ||
"0x70a08231" | ||
} | ||
|
||
def hashFunction(f: FunctionDefinition): String = { | ||
// TODO/iev until the above todo gets resolved, the outer call makes this function | ||
// basically \_ => "0x70a08231". the original implementation didn't have a | ||
// seperator so i don't know what it should be but probably not " " | ||
keccak256(f.name + paren(f.parameters.map(p=>mapObsTypeToABI(p.ntype)).mkString(" "))) | ||
// TODO truncate and keep the first 4 bytes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/main/scala/edu/cmu/cs/obsidian/codegen/yulString.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.