Introduce track field

This commit is contained in:
Roman Vishnevskii 2017-05-04 14:35:44 +07:00
commit 78a47158a1
2 changed files with 3 additions and 2 deletions

View file

@ -4,7 +4,7 @@ from strutils import startsWith, toLowerAscii
const const
StmtContext = ["kout", "inc", "echo", "dec", "!"] StmtContext = ["kout", "inc", "echo", "dec", "!"]
SpecialAttrs = ["id", "class", "value", "key"] SpecialAttrs = ["id", "class", "value", "key", "track"]
proc getName(n: NimNode): string = proc getName(n: NimNode): string =
case n.kind case n.kind

View file

@ -102,6 +102,7 @@ type
kind*: VNodeKind kind*: VNodeKind
key*: VKey key*: VKey
id*, class*, text*: cstring id*, class*, text*: cstring
track*: int
kids: seq[VNode] kids: seq[VNode]
# even index: key, odd index: value; done this way for memory efficiency: # even index: key, odd index: value; done this way for memory efficiency:
attrs: seq[cstring] attrs: seq[cstring]
@ -166,7 +167,7 @@ proc getAttr*(n: VNode; key: cstring): cstring =
proc len*(x: VNode): int = x.kids.len proc len*(x: VNode): int = x.kids.len
proc `[]`*(x: VNode; idx: int): VNode = x.kids[idx] proc `[]`*(x: VNode; idx: int): VNode = x.kids[idx]
proc `[]=`*(x: VNode; idx: int, y: VNode) = x.kids[idx] = y proc `[]=`*(x: VNode; idx: int; y: VNode) = x.kids[idx] = y
proc add*(parent, kid: VNode) = parent.kids.add kid proc add*(parent, kid: VNode) = parent.kids.add kid
proc newVNode*(kind: VNodeKind): VNode = VNode(kind: kind, key: -1) proc newVNode*(kind: VNodeKind): VNode = VNode(kind: kind, key: -1)