This commit is contained in:
Araq
2025-12-15 10:37:17 +01:00
parent 4ea4edfe5c
commit 60e117786e
2 changed files with 17 additions and 3 deletions

View File

@@ -649,6 +649,8 @@ let repDeepCopyTag = registerTag("repdeepcopy")
let repEnumToStrTag = registerTag("repenumtostr")
let repMethodTag = registerTag("repmethod")
#let repClassTag = registerTag("repclass")
let includeTag = registerTag("include")
let importTag = registerTag("import")
proc writeOp(w: var Writer; content: var TokenBuf; op: LogEntry) =
case op.kind
@@ -1448,6 +1450,18 @@ proc loadLogOp(c: var DecodeContext; logOps: var seq[LogEntry]; s: ptr Stream; k
else:
raiseAssert "expected ParRi but got " & $result.kind
proc skipTree(s: var Stream): PackedToken =
result = next(s)
var nested = 1
while nested > 0:
if result.kind == ParLe:
inc nested
elif result.kind == ParRi:
dec nested
elif result.kind == EofToken:
break
result = next(s)
proc loadNifModule*(c: var DecodeContext; f: FileIndex; interf, interfHidden: var TStrTable;
logOps: var seq[LogEntry];
loadFullAst: bool = false): PNode =
@@ -1511,6 +1525,8 @@ proc loadNifModule*(c: var DecodeContext; f: FileIndex; interf, interfHidden: va
t = loadLogOp(c, logOps, s, MethodEntry, attachedTrace)
#elif t.tagId == repClassTag:
# t = loadLogOp(c, logOps, s, ClassEntry, attachedTrace)
elif t.tagId == includeTag or t.tagId == importTag:
t = skipTree(s[])
elif loadFullAst:
# Parse the full statement
var buf = createTokenBuf(50)

View File

@@ -794,7 +794,6 @@ when not defined(nimKochBootstrap):
## Returns 'nil' if the module needs to be recompiled.
## Loads module from NIF file when optCompress is enabled.
## When loadFullAst is true, loads the complete module AST for code generation.
if not fileExists(toNifFilename(g.config, fileIdx)):
return nil
@@ -805,8 +804,7 @@ when not defined(nimKochBootstrap):
itemId: ItemId(module: int32(fileIdx), item: 0'i32),
name: getIdent(g.cache, splitFile(filename).name),
infoImpl: newLineInfo(fileIdx, 1, 1),
positionImpl: int(fileIdx),
)
positionImpl: int(fileIdx))
setOwner(result, getPackage(g.config, g.cache, fileIdx))
# Register module in graph