-
Notifications
You must be signed in to change notification settings - Fork 4
Open
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):
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 eAlso need to do something about function renaming, e.g. only rename functions that clash with Yul primOps.