Skip to content

Commit

Permalink
Improve ScopeTable lookup
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Oct 11, 2024
1 parent c4c2481 commit 1abfb24
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 261 deletions.
22 changes: 13 additions & 9 deletions src/timpkg/engine/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ type
## the node value of the command
of ntIdentVar:
identVarName*: string
identVarSafe*: bool
of ntIdent, ntBlockIdent:
identName*: string
# identifier name
Expand Down Expand Up @@ -397,13 +398,12 @@ type
## ScopeTable is used to store variables,
## functions and blocks
data*: OrderedTable[Hash, seq[Node]]
# variables*: OrderedTable[Hash, Node]
# ## an ordered table of Node, here
# ## we'll store scoped variable declarations
# functions*, blocks*: OrderedTable[Hash, seq[Node]]
# ## an ordered table of seq[Node] where we store
# ## all functions and blocks. these are stored
## in sequenece to support function overrides
variables*: OrderedTable[Hash, Node]
## an ordered table of Node, here
## we'll store variable declarations
functions*, blocks*: OrderedTable[Hash, Node]
## an ordered table of seq[Node] where we store
## all functions and blocks.

TimPartialsTable* = TableRef[string, (Ast, seq[cli.Row])]
TimModulesTable* = TableRef[string, Ast]
Expand Down Expand Up @@ -771,7 +771,7 @@ proc newComponent*(tk: TokenTuple): Node =
proc newBlockIdent*(tk: TokenTuple): Node =
## Create a new macro call Node
result = newNode(ntBlockIdent, tk)
result.identName = "@" & tk.value
result.identName = tk.value

proc newStmtList*(tk: TokenTuple): Node =
## Create a new statement Node
Expand All @@ -789,10 +789,14 @@ proc newCommand*(cmdType: CommandType, node: Node, tk: TokenTuple): Node =
result.cmdType = cmdType
result.cmdValue = node

proc newIdent*(tk: TokenTuple): Node=
proc newIdent*(tk: TokenTuple): Node =
result = newNode(ntIdent, tk)
result.identName = tk.value

proc newIdentVar*(tk: TokenTuple): Node =
result = newNode(ntIdentVar, tk)
result.identVarName = tk.value

proc newHtmlElement*(tag: HtmlTag, tk: TokenTuple): Node =
result = newNode(ntHtmlElement, tk)
result.tag = tag
Expand Down
Loading

0 comments on commit 1abfb24

Please sign in to comment.