parent
c38ab3e257
commit
f915b3aa86
2 changed files with 57 additions and 7 deletions
|
|
@ -344,11 +344,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
x = lookupTypeVar(cl, x)
|
x = lookupTypeVar(cl, x)
|
||||||
if x != nil:
|
if x != nil:
|
||||||
if header == t: header = instCopyType(cl, t)
|
if header == t: header = instCopyType(cl, t)
|
||||||
header[i] =
|
header[i] = x
|
||||||
if x.kind == tyGenericInst:
|
|
||||||
t[i]
|
|
||||||
else:
|
|
||||||
x
|
|
||||||
propagateToOwner(header, x)
|
propagateToOwner(header, x)
|
||||||
else:
|
else:
|
||||||
propagateToOwner(header, x)
|
propagateToOwner(header, x)
|
||||||
|
|
@ -382,7 +378,11 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
cl.typeMap = newTypeMapLayer(cl)
|
cl.typeMap = newTypeMapLayer(cl)
|
||||||
|
|
||||||
for i in 1..<t.len:
|
for i in 1..<t.len:
|
||||||
var x = replaceTypeVarsT(cl, header[i])
|
var x = replaceTypeVarsT(cl):
|
||||||
|
if header[i].kind == tyGenericInst:
|
||||||
|
t[i]
|
||||||
|
else:
|
||||||
|
header[i]
|
||||||
assert x.kind != tyGenericInvocation
|
assert x.kind != tyGenericInvocation
|
||||||
header[i] = x
|
header[i] = x
|
||||||
propagateToOwner(header, x)
|
propagateToOwner(header, x)
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,54 @@ block:
|
||||||
ItemSimple = ref object
|
ItemSimple = ref object
|
||||||
link:DoublyLinkedNode[ ItemSimple ]
|
link:DoublyLinkedNode[ ItemSimple ]
|
||||||
|
|
||||||
let link = newDoublyLinkedNode( Item[Box]() )
|
let link = newDoublyLinkedNode( Item[Box]() )
|
||||||
|
|
||||||
|
block: #18897
|
||||||
|
type
|
||||||
|
SkipListObj[T] = object
|
||||||
|
over: SkipList[T]
|
||||||
|
down: SkipList[T]
|
||||||
|
value: T
|
||||||
|
|
||||||
|
SkipList[T] = ref SkipListObj[T]
|
||||||
|
|
||||||
|
GraphObj[N, E; F: static[int]] = object
|
||||||
|
nodes: SkipList[Node[N, E]]
|
||||||
|
|
||||||
|
Graph[N, E; F: static[int]] = ref GraphObj[N, E, F]
|
||||||
|
|
||||||
|
Node[N, E] = ref NodeObj[N, E]
|
||||||
|
|
||||||
|
NodeObj[N, E] = object
|
||||||
|
value: N
|
||||||
|
incoming: SkipList[Edge[N, E]]
|
||||||
|
outgoing: SkipList[Edge[N, E]]
|
||||||
|
|
||||||
|
Edge[N, E] = ref EdgeObj[N, E]
|
||||||
|
|
||||||
|
EdgeObj[N, E] = object
|
||||||
|
value: E
|
||||||
|
id: int
|
||||||
|
source: Node[N, E]
|
||||||
|
target: Node[N, E]
|
||||||
|
|
||||||
|
EdgeResult[N, E] = tuple
|
||||||
|
source: Node[N, E]
|
||||||
|
edge: Edge[N, E]
|
||||||
|
target: Node[N, E]
|
||||||
|
|
||||||
|
proc newSkipList[T](value: T): SkipList[T] =
|
||||||
|
static: echo T, " ", typeof(result.value)
|
||||||
|
result = SkipList[T](value: value)
|
||||||
|
|
||||||
|
proc toSkipList[T](values: openArray[T] = @[]): SkipList[T] =
|
||||||
|
for item in items(values):
|
||||||
|
if result.isNil:
|
||||||
|
result = newSkipList(item)
|
||||||
|
|
||||||
|
proc newContainer[N, E, F](graph: Graph[N, E, F]; form: typedesc): auto =
|
||||||
|
result = toSkipList[form]([])
|
||||||
|
|
||||||
|
var
|
||||||
|
result = Graph[int, string, 0]()
|
||||||
|
result.nodes = result.newContainer(Node[int, string])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue