modernize sempass2; initEffects now returns TEffects (#22435)

This commit is contained in:
ringabout
2023-08-10 11:29:42 +08:00
committed by GitHub
parent 6ec1c80779
commit fa58d23080

View File

@@ -1433,27 +1433,21 @@ proc rawInitEffects(g: ModuleGraph; effects: PNode) =
effects[ensuresEffects] = g.emptyNode
effects[pragmasEffects] = g.emptyNode
proc initEffects(g: ModuleGraph; effects: PNode; s: PSym; t: var TEffects; c: PContext) =
proc initEffects(g: ModuleGraph; effects: PNode; s: PSym; c: PContext): TEffects =
rawInitEffects(g, effects)
t.exc = effects[exceptionEffects]
t.tags = effects[tagEffects]
t.forbids = effects[forbiddenEffects]
t.owner = s
t.ownerModule = s.getModule
t.init = @[]
t.guards.s = @[]
t.guards.g = g
result = TEffects(exc: effects[exceptionEffects], tags: effects[tagEffects],
forbids: effects[forbiddenEffects], owner: s, ownerModule: s.getModule,
init: @[], locked: @[], graph: g, config: g.config, c: c,
currentBlock: 1
)
result.guards.s = @[]
result.guards.g = g
when defined(drnim):
t.currOptions = g.config.options + s.options - {optStaticBoundsCheck}
result.currOptions = g.config.options + s.options - {optStaticBoundsCheck}
else:
t.currOptions = g.config.options + s.options
t.guards.beSmart = optStaticBoundsCheck in t.currOptions
t.locked = @[]
t.graph = g
t.config = g.config
t.c = c
t.currentBlock = 1
result.currOptions = g.config.options + s.options
result.guards.beSmart = optStaticBoundsCheck in result.currOptions
proc hasRealBody(s: PSym): bool =
## also handles importc procs with runnableExamples, which requires `=`,
@@ -1474,8 +1468,7 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) =
var inferredEffects = newNodeI(nkEffectList, s.info)
var t: TEffects = default(TEffects)
initEffects(g, inferredEffects, s, t, c)
var t: TEffects = initEffects(g, inferredEffects, s, c)
rawInitEffects g, effects
if not isEmptyType(s.typ[0]) and
@@ -1586,8 +1579,7 @@ proc trackStmt*(c: PContext; module: PSym; n: PNode, isTopLevel: bool) =
return
let g = c.graph
var effects = newNodeI(nkEffectList, n.info)
var t: TEffects
initEffects(g, effects, module, t, c)
var t: TEffects = initEffects(g, effects, module, c)
t.isTopLevel = isTopLevel
track(t, n)
when defined(drnim):