Cosmetics
This commit is contained in:
parent
3cbc07ac78
commit
44589e9ca8
1 changed files with 13 additions and 18 deletions
|
|
@ -155,6 +155,10 @@ type
|
||||||
nearestFinally: int # Index of the nearest finally block. For try/except it
|
nearestFinally: int # Index of the nearest finally block. For try/except it
|
||||||
# is their finally. For finally it is parent finally. Otherwise -1
|
# is their finally. For finally it is parent finally. Otherwise -1
|
||||||
|
|
||||||
|
const
|
||||||
|
nkSkip = { nkEmpty..nkNilLit, nkTemplateDef, nkTypeSection, nkStaticStmt,
|
||||||
|
nkCommentStmt } + procDefs
|
||||||
|
|
||||||
proc newStateAccess(ctx: var Ctx): PNode =
|
proc newStateAccess(ctx: var Ctx): PNode =
|
||||||
if ctx.stateVarSym.isNil:
|
if ctx.stateVarSym.isNil:
|
||||||
result = rawIndirectAccess(newSymNode(getEnvParam(ctx.fn)),
|
result = rawIndirectAccess(newSymNode(getEnvParam(ctx.fn)),
|
||||||
|
|
@ -247,8 +251,7 @@ proc hasYields(n: PNode): bool =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkYieldStmt:
|
of nkYieldStmt:
|
||||||
result = true
|
result = true
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
for c in n:
|
for c in n:
|
||||||
|
|
@ -259,8 +262,7 @@ proc hasYields(n: PNode): bool =
|
||||||
proc transformBreaksAndContinuesInWhile(ctx: var Ctx, n: PNode, before, after: PNode): PNode =
|
proc transformBreaksAndContinuesInWhile(ctx: var Ctx, n: PNode, before, after: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
of nkWhileStmt: discard # Do not recurse into nested whiles
|
of nkWhileStmt: discard # Do not recurse into nested whiles
|
||||||
of nkContinueStmt:
|
of nkContinueStmt:
|
||||||
|
|
@ -279,8 +281,7 @@ proc transformBreaksAndContinuesInWhile(ctx: var Ctx, n: PNode, before, after: P
|
||||||
proc transformBreaksInBlock(ctx: var Ctx, n: PNode, label, after: PNode): PNode =
|
proc transformBreaksInBlock(ctx: var Ctx, n: PNode, label, after: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
of nkBlockStmt, nkWhileStmt:
|
of nkBlockStmt, nkWhileStmt:
|
||||||
inc ctx.blockLevel
|
inc ctx.blockLevel
|
||||||
|
|
@ -380,8 +381,7 @@ proc getFinallyNode(n: PNode): PNode =
|
||||||
|
|
||||||
proc hasYieldsInExpressions(n: PNode): bool =
|
proc hasYieldsInExpressions(n: PNode): bool =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
of nkStmtListExpr:
|
of nkStmtListExpr:
|
||||||
if isEmptyType(n.typ):
|
if isEmptyType(n.typ):
|
||||||
|
|
@ -433,8 +433,7 @@ proc newNotCall(g: ModuleGraph; e: PNode): PNode =
|
||||||
proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
|
proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
|
||||||
result = n
|
result = n
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
|
|
||||||
of nkYieldStmt:
|
of nkYieldStmt:
|
||||||
|
|
@ -797,8 +796,7 @@ proc transformReturnsInTry(ctx: var Ctx, n: PNode): PNode =
|
||||||
let goto = newTree(nkGotoState, ctx.g.newIntLit(n.info, ctx.nearestFinally))
|
let goto = newTree(nkGotoState, ctx.g.newIntLit(n.info, ctx.nearestFinally))
|
||||||
result.add(goto)
|
result.add(goto)
|
||||||
|
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
for i in 0 ..< n.len:
|
for i in 0 ..< n.len:
|
||||||
|
|
@ -807,8 +805,7 @@ proc transformReturnsInTry(ctx: var Ctx, n: PNode): PNode =
|
||||||
proc transformClosureIteratorBody(ctx: var Ctx, n: PNode, gotoOut: PNode): PNode =
|
proc transformClosureIteratorBody(ctx: var Ctx, n: PNode, gotoOut: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
case n.kind:
|
case n.kind:
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
|
|
||||||
of nkStmtList, nkStmtListExpr:
|
of nkStmtList, nkStmtListExpr:
|
||||||
|
|
@ -1013,8 +1010,7 @@ proc tranformStateAssignments(ctx: var Ctx, n: PNode): PNode =
|
||||||
for i in 0 ..< n.len:
|
for i in 0 ..< n.len:
|
||||||
n[i] = ctx.tranformStateAssignments(n[i])
|
n[i] = ctx.tranformStateAssignments(n[i])
|
||||||
|
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
|
|
||||||
of nkReturnStmt:
|
of nkReturnStmt:
|
||||||
|
|
@ -1066,8 +1062,7 @@ proc skipEmptyStates(ctx: Ctx, stateIdx: int): int =
|
||||||
proc skipThroughEmptyStates(ctx: var Ctx, n: PNode): PNode =
|
proc skipThroughEmptyStates(ctx: var Ctx, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCharLit..nkUInt64Lit, nkFloatLit..nkFloat128Lit, nkStrLit..nkTripleStrLit,
|
of nkSkip:
|
||||||
nkSym, nkIdent, procDefs, nkTemplateDef:
|
|
||||||
discard
|
discard
|
||||||
of nkGotoState:
|
of nkGotoState:
|
||||||
result = copyTree(n)
|
result = copyTree(n)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue