| @@ -217,10 +217,14 @@ elabImplementation {vars} fc vis opts_in pass env nest is cons iname ps impln nu · 216 unmodified lines |
| 217 | -- case of dependencies) | 217 | -- case of dependencies) |
| 218 | | 218 | |
| 219 | -- 5. Elaborate the method bodies | 219 | -- 5. Elaborate the method bodies |
| 220 | | 220 | let upds = map methNameUpdate fns |
| 221 | body' <- traverse (updateBody (map methNameUpdate fns)) body | 221 | body' <- traverse (updateBody upds) body |
| 222 | log 10 $ "Implementation body: " ++ show body' | 222 | log 10 $ "Implementation body: " ++ show body' |
| 223 | traverse (processDecl [] nest env) body' | 223 | traverse (processDecl [] nest env) body' |
| | 224 | |
| | 225 | -- 6. Add transnformation rules for top level methods |
| | 226 | traverse (addTransform impName upds) (methods cdata) |
| | 227 | |
| 224 | -- Reset the open hints (remove the named implementation) | 228 | -- Reset the open hints (remove the named implementation) |
| 225 | setOpenHints hs | 229 | setOpenHints hs |
| 226 | pure ()) mbody | 230 | pure ()) mbody |
| @@ -283,7 +287,8 @@ elabImplementation {vars} fc vis opts_in pass env nest is cons iname ps impln nu · 56 unmodified lines |
| 283 | methName : Name -> Name | 287 | methName : Name -> Name |
| 284 | methName (NS _ n) = methName n | 288 | methName (NS _ n) = methName n |
| 285 | methName n | 289 | methName n |
| 286 | = DN (show n) (UN (show n ++ "_" ++ show iname ++ "_" ++ | 290 | = DN (show n) |
| | 291 | (UN (show n ++ "_" ++ show iname ++ "_" ++ |
| 287 | maybe "" show impln ++ "_" ++ | 292 | maybe "" show impln ++ "_" ++ |
| 288 | showSep "_" (map show ps))) | 293 | showSep "_" (map show ps))) |
| 289 | | 294 | |
| @@ -404,3 +409,24 @@ elabImplementation {vars} fc vis opts_in pass env nest is cons iname ps impln nu · 114 unmodified lines |
| 404 | updateBody ns _ | 409 | updateBody ns _ |
| 405 | = throw (GenericMsg fc | 410 | = throw (GenericMsg fc |
| 406 | "Implementation body can only contain definitions") | 411 | "Implementation body can only contain definitions") |
| | 412 | |
| | 413 | addTransform : Name -> List (Name, Name) -> |
| | 414 | (Name, RigCount, Bool, RawImp) -> |
| | 415 | Core () |
| | 416 | addTransform iname ns (top, _, _, ty) |
| | 417 | = do log 3 $ "Adding transform for " ++ show top ++ " : " ++ show ty ++ |
| | 418 | "\n\tfor " ++ show iname ++ " in " ++ show ns |
| | 419 | let lhs = IImplicitApp fc (IVar fc top) |
| | 420 | (Just (UN "__con")) |
| | 421 | (IVar fc iname) |
| | 422 | let Just mname = lookup (dropNS top) ns |
| | 423 | | Nothing => pure () |
| | 424 | let rhs = IVar fc mname |
| | 425 | log 5 $ show lhs ++ " ==> " ++ show rhs |
| | 426 | handleUnify |
| | 427 | (processDecl [] nest env |
| | 428 | (ITransform fc (UN (show top ++ " " ++ show iname)) lhs rhs)) |
| | 429 | (\err => |
| | 430 | log 5 $ "Can't add transform " ++ |
| | 431 | show lhs ++ " ==> " ++ show rhs ++ |
| | 432 | "\n\t" ++ show err) |