Implements the MIR pass for:
- replacing copy and move assignments with the =copy or =sink hook (if available for the type).
- replacing destroy operations with calls to the =destroy hook (if available for the type)
Imports
-
../ast/ast_query, ../ast/ast_types, ../ast/lineinfos, ../front/msgs, ../front/options, mirbodies, mirchangesets, mirconstr, mirenv, mirtrees, mirtypes, ../modules/modulegraphs, ../sem/sighashes, ../utils/idioms, ../ast/reports_sem, ../ast/report_enums, ../sem/injectdestructors, ../sem/liftdestructors
Procs
proc genDestroy(bu: var MirBuilder; graph: ModuleGraph; env: var MirEnv; target: Value) {....raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
- Emits a destructor call with target as the argument. Source Edit
proc getOp(g: ModuleGraph; t: PType; kind: TTypeAttachedOp): PSym {. ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
- Returns the symbol for the kind type-bound hook for t (or nil, if there's none). Source Edit
proc injectHooks(body: MirBody; graph: ModuleGraph; env: var MirEnv; owner: PSym; changes: var Changeset) {. ...raises: [KeyError, Exception, ERecoverableError], tags: [ReadDirEffect, RootEffect].}
- Replaces all copy and move assignments for locations with lifetime hooks to the types' respective hook. Source Edit
proc injectHooks(body: var MirBody; graph: ModuleGraph; env: var MirEnv; owner: PSym) {....raises: [KeyError, Exception, ERecoverableError], tags: [ReadDirEffect, RootEffect].}
- Adapter for the legacy pass-application pipeline. Once possible, the pass needs to be treated as just another MIR pass. Source Edit