argotorg / argotorg/solcore

Allow calling high-level functions from Yul blocks

Open
#265 0 comments 0 reactions 1 assignee Claimed by @mbenke View on GitHub
Dominant language
Haskell
Stars
113
Forks
9
Avg merge
4d 9h
Merged PRs (30d)
1

Description

Simple example

```
function f() -> word { return 42; }

contract C {
function main() {
let res: word;
assembly {
res := f(42)
}
return res;
}
```
May be more complicated, e.g. `f(iszero(iszero(sub(x,1))))`

Concept art (see `mbenke/callHeaven` branch):

``` haskell
specStmt (Asm ys) = do
ys' <- mapM specYulStmt ys
pure (Asm ys')
-- specStmt (Asm ys) = Asm ys

specStmt stmt = errors ["specStmt not implemented for: ", show stmt]

specYulStmt :: Yul.YulStmt -> SM Yul.YulStmt
specYulStmt ys = everywhereM (mkM specYulExp) ys

specYulExp :: Yul.YulExp -> SM Yul.YulExp
{-
specYulExp (YCall name args)
| name `notElem` primYulOps = do
-- result type must be word or () (perhaps the latter only in YExp stmt)
-- arg types must be word (modify typechecker)
-- introduce some variables
-- assign them args (note: Yul probably has righ-to-left eval order)
-- pure (YCall name args')
-}
specYulExp e = pure e
```

Also need to do something about function renaming, e.g. only rename functions that clash with Yul primOps.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.