2727# solves the opcLdConst vs opcAsgnConst issue. Of course whether we need
2828# this copy depends on the involved types.
2929
30+ import std / tables
31+
3032import
3133 strutils, ast, types, msgs, renderer, vmdef,
3234 intsets, magicsys, options, lowerings, lineinfos, transf
@@ -2248,8 +2250,8 @@ proc optimizeJumps(c: PCtx; start: int) =
22482250 else : discard
22492251
22502252proc genProc (c: PCtx ; s: PSym ): int =
2251- var x = s.ast[miscPos]
2252- if x.kind == nkEmpty or x[ 0 ].kind == nkEmpty :
2253+ let pos = c.procToCodePos. getOrDefault (s.id)
2254+ if pos == 0 :
22532255 # if s.name.s == "outterMacro" or s.name.s == "innerProc":
22542256 # echo "GENERATING CODE FOR ", s.name.s
22552257 let last = c.code.len- 1
@@ -2260,11 +2262,7 @@ proc genProc(c: PCtx; s: PSym): int =
22602262 c.debug.setLen (last)
22612263 # c.removeLastEof
22622264 result = c.code.len+ 1 # skip the jump instruction
2263- if x.kind == nkEmpty:
2264- x = newTree (nkBracket, newIntNode (nkIntLit, result ), x)
2265- else :
2266- x[0 ] = newIntNode (nkIntLit, result )
2267- s.ast[miscPos] = x
2265+ c.procToCodePos[s.id] = result
22682266 # thanks to the jmp we can add top level statements easily and also nest
22692267 # procs easily:
22702268 let body = transformBody (c.graph, c.idgen, s, cache = not isCompileTimeProc (s))
@@ -2297,4 +2295,4 @@ proc genProc(c: PCtx; s: PSym): int =
22972295 c.prc = oldPrc
22982296 else :
22992297 c.prc.maxSlots = s.offset
2300- result = x[ 0 ].intVal. int
2298+ result = pos
0 commit comments