Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base
* Unify add calls
* Unify len invocations
* Unify range operators
* Fix oversight
* Remove {.procvar.} pragma
* initCandidate -> newCandidate where reasonable
* Unify safeLen calls
This commit is contained in:
parent
b662842bd0
commit
7e747d11c6
109 changed files with 6115 additions and 6254 deletions
|
|
@ -156,31 +156,31 @@ proc encodeNode(g: ModuleGraph; fInfo: TLineInfo, n: PNode,
|
|||
encodeVInt(n.sym.id, result)
|
||||
pushSym(w, n.sym)
|
||||
else:
|
||||
for i in 0 ..< len(n):
|
||||
encodeNode(g, n.info, n.sons[i], result)
|
||||
add(result, ')')
|
||||
for i in 0..<n.len:
|
||||
encodeNode(g, n.info, n[i], result)
|
||||
result.add(')')
|
||||
|
||||
proc encodeLoc(g: ModuleGraph; loc: TLoc, result: var string) =
|
||||
var oldLen = result.len
|
||||
result.add('<')
|
||||
if loc.k != low(loc.k): encodeVInt(ord(loc.k), result)
|
||||
if loc.storage != low(loc.storage):
|
||||
add(result, '*')
|
||||
result.add('*')
|
||||
encodeVInt(ord(loc.storage), result)
|
||||
if loc.flags != {}:
|
||||
add(result, '$')
|
||||
result.add('$')
|
||||
encodeVInt(cast[int32](loc.flags), result)
|
||||
if loc.lode != nil:
|
||||
add(result, '^')
|
||||
result.add('^')
|
||||
encodeNode(g, unknownLineInfo(), loc.lode, result)
|
||||
if loc.r != nil:
|
||||
add(result, '!')
|
||||
result.add('!')
|
||||
encodeStr($loc.r, result)
|
||||
if oldLen + 1 == result.len:
|
||||
# no data was necessary, so remove the '<' again:
|
||||
setLen(result, oldLen)
|
||||
else:
|
||||
add(result, '>')
|
||||
result.add('>')
|
||||
|
||||
proc encodeType(g: ModuleGraph, t: PType, result: var string) =
|
||||
if t == nil:
|
||||
|
|
@ -191,73 +191,73 @@ proc encodeType(g: ModuleGraph, t: PType, result: var string) =
|
|||
if t.kind == tyForward: internalError(g.config, "encodeType: tyForward")
|
||||
# for the new rodfile viewer we use a preceding [ so that the data section
|
||||
# can easily be disambiguated:
|
||||
add(result, '[')
|
||||
result.add('[')
|
||||
encodeVInt(ord(t.kind), result)
|
||||
add(result, '+')
|
||||
result.add('+')
|
||||
encodeVInt(t.uniqueId, result)
|
||||
if t.id != t.uniqueId:
|
||||
add(result, '+')
|
||||
result.add('+')
|
||||
encodeVInt(t.id, result)
|
||||
if t.n != nil:
|
||||
encodeNode(g, unknownLineInfo(), t.n, result)
|
||||
if t.flags != {}:
|
||||
add(result, '$')
|
||||
result.add('$')
|
||||
encodeVInt(cast[int32](t.flags), result)
|
||||
if t.callConv != low(t.callConv):
|
||||
add(result, '?')
|
||||
result.add('?')
|
||||
encodeVInt(ord(t.callConv), result)
|
||||
if t.owner != nil:
|
||||
add(result, '*')
|
||||
result.add('*')
|
||||
encodeVInt(t.owner.id, result)
|
||||
pushSym(w, t.owner)
|
||||
if t.sym != nil:
|
||||
add(result, '&')
|
||||
result.add('&')
|
||||
encodeVInt(t.sym.id, result)
|
||||
pushSym(w, t.sym)
|
||||
if t.size != - 1:
|
||||
add(result, '/')
|
||||
result.add('/')
|
||||
encodeVBiggestInt(t.size, result)
|
||||
if t.align != 2:
|
||||
add(result, '=')
|
||||
result.add('=')
|
||||
encodeVInt(t.align, result)
|
||||
if t.lockLevel.ord != UnspecifiedLockLevel.ord:
|
||||
add(result, '\14')
|
||||
result.add('\14')
|
||||
encodeVInt(t.lockLevel.int16, result)
|
||||
if t.paddingAtEnd != 0:
|
||||
add(result, '\15')
|
||||
result.add('\15')
|
||||
encodeVInt(t.paddingAtEnd, result)
|
||||
for a in t.attachedOps:
|
||||
add(result, '\16')
|
||||
result.add('\16')
|
||||
if a == nil:
|
||||
encodeVInt(-1, result)
|
||||
else:
|
||||
encodeVInt(a.id, result)
|
||||
pushSym(w, a)
|
||||
for i, s in items(t.methods):
|
||||
add(result, '\19')
|
||||
result.add('\19')
|
||||
encodeVInt(i, result)
|
||||
add(result, '\20')
|
||||
result.add('\20')
|
||||
encodeVInt(s.id, result)
|
||||
pushSym(w, s)
|
||||
encodeLoc(g, t.loc, result)
|
||||
if t.typeInst != nil:
|
||||
add(result, '\21')
|
||||
result.add('\21')
|
||||
encodeVInt(t.typeInst.uniqueId, result)
|
||||
pushType(w, t.typeInst)
|
||||
for i in 0 ..< len(t):
|
||||
if t.sons[i] == nil:
|
||||
add(result, "^()")
|
||||
for i in 0..<t.len:
|
||||
if t[i] == nil:
|
||||
result.add("^()")
|
||||
else:
|
||||
add(result, '^')
|
||||
encodeVInt(t.sons[i].uniqueId, result)
|
||||
pushType(w, t.sons[i])
|
||||
result.add('^')
|
||||
encodeVInt(t[i].uniqueId, result)
|
||||
pushType(w, t[i])
|
||||
|
||||
proc encodeLib(g: ModuleGraph, lib: PLib, info: TLineInfo, result: var string) =
|
||||
add(result, '|')
|
||||
result.add('|')
|
||||
encodeVInt(ord(lib.kind), result)
|
||||
add(result, '|')
|
||||
result.add('|')
|
||||
encodeStr($lib.name, result)
|
||||
add(result, '|')
|
||||
result.add('|')
|
||||
encodeNode(g, info, lib.path, result)
|
||||
|
||||
proc encodeInstantiations(g: ModuleGraph; s: seq[PInstantiation];
|
||||
|
|
@ -316,7 +316,7 @@ proc encodeSym(g: ModuleGraph, s: PSym, result: var string) =
|
|||
encodeLoc(g, s.loc, result)
|
||||
if s.annex != nil: encodeLib(g, s.annex, s.info, result)
|
||||
if s.constraint != nil:
|
||||
add(result, '#')
|
||||
result.add('#')
|
||||
encodeNode(g, unknownLineInfo(), s.constraint, result)
|
||||
case s.kind
|
||||
of skType, skGenericParam:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue