implements 'export' feature

This commit is contained in:
Araq 2012-12-01 19:10:47 +01:00
commit c98e3d2c27
10 changed files with 137 additions and 40 deletions

View file

@ -585,8 +585,9 @@ proc StrTableContains(t: TStrTable, n: PSym): bool =
proc StrTableRawInsert(data: var TSymSeq, n: PSym) =
var h: THash = n.name.h and high(data)
while data[h] != nil:
if data[h] == n:
InternalError(n.info, "StrTableRawInsert: " & n.name.s)
if data[h] == n:
# allowed for 'export' feature:
#InternalError(n.info, "StrTableRawInsert: " & n.name.s)
return
h = nextTry(h, high(data))
assert(data[h] == nil)
@ -617,23 +618,23 @@ proc StrTableAdd(t: var TStrTable, n: PSym) =
StrTableRawInsert(t.data, n)
inc(t.counter)
proc StrTableIncl*(t: var TStrTable, n: PSym): bool =
proc StrTableIncl*(t: var TStrTable, n: PSym): bool {.discardable.} =
# returns true if n is already in the string table:
# It is essential that `n` is written nevertheless!
# This way the newest redefinition is picked by the semantic analyses!
assert n.name != nil
var h: THash = n.name.h and high(t.data)
while true:
while true:
var it = t.data[h]
if it == nil: break
if it.name.id == n.name.id:
if it == nil: break
if it.name.id == n.name.id:
t.data[h] = n # overwrite it with newer definition!
return true # found it
h = nextTry(h, high(t.data))
if mustRehash(len(t.data), t.counter):
if mustRehash(len(t.data), t.counter):
StrTableEnlarge(t)
StrTableRawInsert(t.data, n)
else:
else:
assert(t.data[h] == nil)
t.data[h] = n
inc(t.counter)