constant folding for cnst[i] and cnst.attr
This commit is contained in:
parent
22115a2c6a
commit
299390a585
5 changed files with 78 additions and 49 deletions
|
|
@ -719,7 +719,9 @@ proc transform(c: PTransf, n: PNode): PTransNode =
|
|||
else:
|
||||
result = transformSons(c, n)
|
||||
var cnst = getConstExpr(c.module, PNode(result))
|
||||
if cnst != nil and (cnst.kind != nkBracket or cnst.len == 0):
|
||||
# we inline constants if they are not complex constants:
|
||||
if cnst != nil and (cnst.kind notin {nkCurly, nkPar, nkBracket} or
|
||||
cnst.len == 0):
|
||||
result = PTransNode(cnst) # do not miss an optimization
|
||||
|
||||
proc processTransf(context: PPassContext, n: PNode): PNode =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue