* minor code refactorings * fixes #19569
This commit is contained in:
parent
8f9dd5b349
commit
0d6795a771
2 changed files with 7 additions and 9 deletions
|
|
@ -881,7 +881,7 @@ proc containsResult(n: PNode): bool =
|
||||||
if containsResult(n[i]): return true
|
if containsResult(n[i]): return true
|
||||||
|
|
||||||
const harmless = {nkConstSection, nkTypeSection, nkEmpty, nkCommentStmt, nkTemplateDef,
|
const harmless = {nkConstSection, nkTypeSection, nkEmpty, nkCommentStmt, nkTemplateDef,
|
||||||
nkMacroDef, nkMixinStmt, nkBindStmt} +
|
nkMacroDef, nkMixinStmt, nkBindStmt, nkFormalParams} +
|
||||||
declarativeDefs
|
declarativeDefs
|
||||||
|
|
||||||
proc easyResultAsgn(n: PNode): PNode =
|
proc easyResultAsgn(n: PNode): PNode =
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ proc setOffsetsToUnknown(n: PNode) =
|
||||||
for i in 0..<n.safeLen:
|
for i in 0..<n.safeLen:
|
||||||
setOffsetsToUnknown(n[i])
|
setOffsetsToUnknown(n[i])
|
||||||
|
|
||||||
proc computeObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode, packed: bool, accum: var OffsetAccum) =
|
proc computeObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode; packed: bool; accum: var OffsetAccum) =
|
||||||
## ``offset`` is the offset within the object, after the node has been written, no padding bytes added
|
## ``offset`` is the offset within the object, after the node has been written, no padding bytes added
|
||||||
## ``align`` maximum alignment from all sub nodes
|
## ``align`` maximum alignment from all sub nodes
|
||||||
assert n != nil
|
assert n != nil
|
||||||
|
|
@ -380,10 +380,8 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
|
||||||
let info = if typ.sym != nil: typ.sym.info else: unknownLineInfo
|
let info = if typ.sym != nil: typ.sym.info else: unknownLineInfo
|
||||||
localError(conf, info, "union type may not have an object header")
|
localError(conf, info, "union type may not have an object header")
|
||||||
accum = OffsetAccum(offset: szUnknownSize, maxAlign: szUnknownSize)
|
accum = OffsetAccum(offset: szUnknownSize, maxAlign: szUnknownSize)
|
||||||
elif tfPacked in typ.flags:
|
|
||||||
computeUnionObjectOffsetsFoldFunction(conf, typ.n, true, accum)
|
|
||||||
else:
|
else:
|
||||||
computeUnionObjectOffsetsFoldFunction(conf, typ.n, false, accum)
|
computeUnionObjectOffsetsFoldFunction(conf, typ.n, tfPacked in typ.flags, accum)
|
||||||
elif tfPacked in typ.flags:
|
elif tfPacked in typ.flags:
|
||||||
accum.maxAlign = 1
|
accum.maxAlign = 1
|
||||||
computeObjectOffsetsFoldFunction(conf, typ.n, true, accum)
|
computeObjectOffsetsFoldFunction(conf, typ.n, true, accum)
|
||||||
|
|
@ -497,7 +495,7 @@ template foldOffsetOf*(conf: ConfigRef; n: PNode; fallback: PNode): PNode =
|
||||||
## Returns an int literal node of the given offsetof expression in `n`.
|
## Returns an int literal node of the given offsetof expression in `n`.
|
||||||
## Falls back to `fallback`, if the `offsetof` expression can't be processed.
|
## Falls back to `fallback`, if the `offsetof` expression can't be processed.
|
||||||
let config = conf
|
let config = conf
|
||||||
let node : PNode = n
|
let node = n
|
||||||
var dotExpr: PNode
|
var dotExpr: PNode
|
||||||
block findDotExpr:
|
block findDotExpr:
|
||||||
if node[1].kind == nkDotExpr:
|
if node[1].kind == nkDotExpr:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue