diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-08-10 11:29:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 11:29:42 +0800 |
commit | fa58d23080dad13283cd180260b14cf8c57ab501 (patch) | |
tree | 919a39b63edf952a59fdd1271b1a76dee2bd28bb | |
parent | 6ec1c80779831875b2552d6ba2d613503b53a012 (diff) | |
download | Nim-fa58d23080dad13283cd180260b14cf8c57ab501.tar.gz |
modernize sempass2; `initEffects` now returns `TEffects` (#22435)
-rw-r--r-- | compiler/sempass2.nim | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index c12cc6cb3..0aa808059 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -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): |