Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored and mildred committed Jan 11, 2021
1 parent 903b5c9 commit 6ba0009
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions compiler/parampatterns.nim
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ proc isAssignable*(owner: PSym, n: PNode; isUnsafeAddr=false): TAssignableResult
result = arLValue
elif isUnsafeAddr and n.sym.kind == skParam:
result = arLValue
elif isUnsafeAddr and n.sym.kind == skConst and dontInlineConstant(n, n.sym.ast):
result = arLValue
elif n.sym.kind in kinds:
if owner != nil and owner == n.sym.owner and
sfGlobal notin n.sym.flags:
Expand Down
7 changes: 0 additions & 7 deletions compiler/transf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,6 @@ proc transformExceptBranch(c: PTransf, n: PNode): PNode =
else:
result = transformSons(c, n)

proc dontInlineConstant(orig, cnst: PNode): bool {.inline.} =
# symbols that expand to a complex constant (array, etc.) should not be
# inlined, unless it's the empty array:
result = orig.kind == nkSym and
cnst.kind in {nkCurly, nkPar, nkTupleConstr, nkBracket} and
cnst.len != 0

proc commonOptimizations*(g: ModuleGraph; c: PSym, n: PNode): PNode =
result = n
for i in 0..<n.safeLen:
Expand Down
7 changes: 7 additions & 0 deletions compiler/trees.nim
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,10 @@ proc stupidStmtListExpr*(n: PNode): bool =
for i in 0..<n.len-1:
if n[i].kind notin {nkEmpty, nkCommentStmt}: return false
result = true

proc dontInlineConstant*(orig, cnst: PNode): bool {.inline.} =
# symbols that expand to a complex constant (array, etc.) should not be
# inlined, unless it's the empty array:
result = orig.kind == nkSym and
cnst.kind in {nkCurly, nkPar, nkTupleConstr, nkBracket} and
cnst.len != 0

0 comments on commit 6ba0009

Please sign in to comment.