Skip to content

Commit

Permalink
Improve flow info tracking for curried dispatch application
Browse files Browse the repository at this point in the history
  • Loading branch information
krame505 committed Oct 1, 2024
1 parent bcc7f11 commit 22987cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions grammars/silver/compiler/definition/core/Expr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,16 @@ top::Expr ::= @e::Expr @es::AppExprs @anns::AnnoAppExprs
top.unparse = e.unparse ++ "(" ++ es.unparse ++ "," ++ anns.unparse ++ ")";

local t :: Type = performSubstitution(e.typerep, e.upSubst);
nondecorated local extraArgs :: AppExprs =
production extraArgs :: AppExprs =
foldl(snocAppExprs(_, ',', _), emptyAppExprs(),
map(presentAppExpr, drop(es.appExprSize - length(t.inputTypes), es.rawExprs)));
nondecorated local dispatchArgs :: AppExprs =
production dispatchArgs :: AppExprs =
foldl(snocAppExprs(_, ',', _), emptyAppExprs(),
map(presentAppExpr, take(es.appExprSize - length(t.inputTypes), es.rawExprs)));

forwards to application(
application(@e, '(', extraArgs, ',', emptyAnnoAppExprs(), ')'),
'(', dispatchArgs, ',', ^anns, ')');
application(@e, '(', @extraArgs, ',', emptyAnnoAppExprs(), ')'),
'(', @dispatchArgs, ',', ^anns, ')');
}

abstract production dispatchApplication implements Application
Expand Down
15 changes: 10 additions & 5 deletions grammars/silver/compiler/definition/flow/env/Expr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,20 @@ top::Expr ::= @e::Expr @es::AppExprs @anns::AnnoAppExprs
aspect production curriedDispatchApplication
top::Expr ::= @e::Expr @es::AppExprs @anns::AnnoAppExprs
{
es.appProd =
-- We override these attributes in what we forward to, as a special case to
-- be more precise about what production is being applied.
dispatchArgs.appProd =
case e of
| productionReference(q) -> just(q.lookupValue.dcl.namedSignature)
| _ -> nothing()
end;
es.appIndexOffset = 0;
e.decSiteVertexInfo = nothing();
es.decSiteVertexInfo = top.decSiteVertexInfo;
es.alwaysDecorated = top.alwaysDecorated;
dispatchArgs.appIndexOffset = 0;
dispatchArgs.decSiteVertexInfo = top.decSiteVertexInfo;
dispatchArgs.alwaysDecorated = top.alwaysDecorated;
extraArgs.appProd = dispatchArgs.appProd;
extraArgs.appIndexOffset = dispatchArgs.appExprSize;
extraArgs.decSiteVertexInfo = top.decSiteVertexInfo;
extraArgs.alwaysDecorated = top.alwaysDecorated;
}

aspect production dispatchApplication
Expand Down

0 comments on commit 22987cb

Please sign in to comment.