Skip to content

Commit

Permalink
Implement Yul's datacopy
Browse files Browse the repository at this point in the history
  • Loading branch information
acuarica committed Jan 6, 2024
1 parent 4ff413e commit 9c8c911
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/yul.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ function yulExpr(expr: Expr): string {
case 'Fn':
return FNS[expr.mnemonic][0](yulExpr(expr.value));
case 'DataCopy':
throw new Error('Not implemented yet: "DataCopy" case');
switch (expr.kind) {
case 'calldatacopy':
return yul`calldatacopy(${expr.offset}, ${expr.size})`;
case 'codecopy':
return yul`codecopy(${expr.offset}, ${expr.size})`;
case 'extcodecopy':
return yul`extcodecopy(${expr.address}, ${expr.offset}, ${expr.size})`;
case 'returndatacopy':
return yul`returndatacopy(${expr.offset}, ${expr.size})`;
default:
throw new TypeError(`Unknown DataCopy kind: ${expr.kind}`);
}
case 'MLoad':
return yul`mload(${expr.loc})`;
case 'Sha3':
Expand Down

0 comments on commit 9c8c911

Please sign in to comment.