make tsigbreak.nim compile
This commit is contained in:
parent
34143ee122
commit
e169eaac5b
5 changed files with 42 additions and 7 deletions
|
|
@ -444,7 +444,7 @@ type
|
||||||
nfPreventCg # this node should be ignored by the codegen
|
nfPreventCg # this node should be ignored by the codegen
|
||||||
|
|
||||||
TNodeFlags* = set[TNodeFlag]
|
TNodeFlags* = set[TNodeFlag]
|
||||||
TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 28)
|
TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 30)
|
||||||
tfVarargs, # procedure has C styled varargs
|
tfVarargs, # procedure has C styled varargs
|
||||||
tfNoSideEffect, # procedure type does not allow side effects
|
tfNoSideEffect, # procedure type does not allow side effects
|
||||||
tfFinal, # is the object final?
|
tfFinal, # is the object final?
|
||||||
|
|
@ -488,6 +488,7 @@ type
|
||||||
tfBorrowDot # distinct type borrows '.'
|
tfBorrowDot # distinct type borrows '.'
|
||||||
tfTriggersCompileTime # uses the NimNode type which make the proc
|
tfTriggersCompileTime # uses the NimNode type which make the proc
|
||||||
# implicitly '.compiletime'
|
# implicitly '.compiletime'
|
||||||
|
tfRefsAnonObj # used for 'ref object' and 'ptr object'
|
||||||
|
|
||||||
TTypeFlags* = set[TTypeFlag]
|
TTypeFlags* = set[TTypeFlag]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -759,9 +759,11 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
||||||
if st.kind == tyGenericBody: st = st.lastSon
|
if st.kind == tyGenericBody: st = st.lastSon
|
||||||
internalAssert st.kind in {tyPtr, tyRef}
|
internalAssert st.kind in {tyPtr, tyRef}
|
||||||
internalAssert st.lastSon.sym == nil
|
internalAssert st.lastSon.sym == nil
|
||||||
|
incl st.flags, tfRefsAnonObj
|
||||||
st.lastSon.sym = newSym(skType, getIdent(s.name.s & ":ObjectType"),
|
st.lastSon.sym = newSym(skType, getIdent(s.name.s & ":ObjectType"),
|
||||||
getCurrOwner(), s.info)
|
getCurrOwner(), s.info)
|
||||||
|
|
||||||
|
|
||||||
proc checkForMetaFields(n: PNode) =
|
proc checkForMetaFields(n: PNode) =
|
||||||
template checkMeta(t) =
|
template checkMeta(t) =
|
||||||
if t != nil and t.isMetaType and tfGenericTypeParam notin t.flags:
|
if t != nil and t.isMetaType and tfGenericTypeParam notin t.flags:
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
|
|
||||||
let bbody = lastSon body
|
let bbody = lastSon body
|
||||||
var newbody = replaceTypeVarsT(cl, bbody)
|
var newbody = replaceTypeVarsT(cl, bbody)
|
||||||
|
let bodyIsNew = newbody != bbody
|
||||||
cl.skipTypedesc = oldSkipTypedesc
|
cl.skipTypedesc = oldSkipTypedesc
|
||||||
newbody.flags = newbody.flags + (t.flags + body.flags - tfInstClearedFlags)
|
newbody.flags = newbody.flags + (t.flags + body.flags - tfInstClearedFlags)
|
||||||
result.flags = result.flags + newbody.flags - tfInstClearedFlags
|
result.flags = result.flags + newbody.flags - tfInstClearedFlags
|
||||||
|
|
@ -310,9 +311,13 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
# generics *when the type is constructed*:
|
# generics *when the type is constructed*:
|
||||||
newbody.deepCopy = cl.c.instTypeBoundOp(cl.c, dc, result, cl.info,
|
newbody.deepCopy = cl.c.instTypeBoundOp(cl.c, dc, result, cl.info,
|
||||||
attachedDeepCopy, 1)
|
attachedDeepCopy, 1)
|
||||||
newbody.typeInst = result
|
if bodyIsNew and newbody.typeInst == nil:
|
||||||
if newbody.kind == tyRef:
|
#doassert newbody.typeInst == nil
|
||||||
newbody.lastSon.typeInst = result
|
newbody.typeInst = result
|
||||||
|
if tfRefsAnonObj in newbody.flags:
|
||||||
|
assert newbody.kind in {tyRef, tyPtr}
|
||||||
|
assert newbody.lastSon.typeInst == nil
|
||||||
|
newbody.lastSon.typeInst = result
|
||||||
let asgn = newbody.assignment
|
let asgn = newbody.assignment
|
||||||
if asgn != nil and sfFromGeneric notin asgn.flags:
|
if asgn != nil and sfFromGeneric notin asgn.flags:
|
||||||
# '=' needs to be instantiated for generics when the type is constructed:
|
# '=' needs to be instantiated for generics when the type is constructed:
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,6 @@ type
|
||||||
ConsiderFlag* = enum
|
ConsiderFlag* = enum
|
||||||
CoProc
|
CoProc
|
||||||
CoType
|
CoType
|
||||||
CoNoGeneric
|
|
||||||
|
|
||||||
proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
if t == nil:
|
if t == nil:
|
||||||
|
|
@ -153,10 +152,10 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
if t.sym != nil and {sfImportc, sfExportc} * t.sym.flags != {}:
|
if t.sym != nil and {sfImportc, sfExportc} * t.sym.flags != {}:
|
||||||
c.hashSym(t.sym)
|
c.hashSym(t.sym)
|
||||||
of tyObject, tyEnum:
|
of tyObject, tyEnum:
|
||||||
if t.typeInst != nil and CoNoGeneric notin flags:
|
if t.typeInst != nil:
|
||||||
assert t.typeInst.kind == tyGenericInst
|
assert t.typeInst.kind == tyGenericInst
|
||||||
for i in countup(1, sonsLen(t.typeInst) - 2):
|
for i in countup(1, sonsLen(t.typeInst) - 2):
|
||||||
c.hashType t.typeInst.sons[i], flags+{CoNoGeneric}
|
c.hashType t.typeInst.sons[i], flags
|
||||||
# Every cyclic type in Nim need to be constructed via some 't.sym', so this
|
# Every cyclic type in Nim need to be constructed via some 't.sym', so this
|
||||||
# is actually safe without an infinite recursion check:
|
# is actually safe without an infinite recursion check:
|
||||||
if t.sym != nil:
|
if t.sym != nil:
|
||||||
|
|
|
||||||
28
tests/cpp/tsigbreak.nim
Normal file
28
tests/cpp/tsigbreak.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nim cpp $file"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import tables, lists
|
||||||
|
|
||||||
|
type
|
||||||
|
ListTable[K, V] = object
|
||||||
|
table: Table[K, DoublyLinkedNode[V]]
|
||||||
|
|
||||||
|
proc initListTable*[K, V](initialSize = 64): ListTable[K, V] =
|
||||||
|
result.table = initTable[K, DoublyLinkedNode[V]]()
|
||||||
|
|
||||||
|
proc `[]=`*[K, V](t: var ListTable[K, V], key: K, val: V) =
|
||||||
|
t.table[key].value = val
|
||||||
|
|
||||||
|
type
|
||||||
|
SomeObj = object
|
||||||
|
OtherObj = object
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
var someTable = initListTable[int, SomeObj]()
|
||||||
|
var otherTable = initListTable[int, OtherObj]()
|
||||||
|
|
||||||
|
someTable[1] = SomeObj()
|
||||||
|
otherTable[42] = OtherObj()
|
||||||
|
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue