@@ -25,16 +25,16 @@ proc newModuleGraphForSem(cache: IdentCache; conf: ConfigRef): ModuleGraph =
2525 graph.config.cmd = oldCmd
2626 result = graph
2727
28- proc getSystemNif (graph: ModuleGraph ): string =
29- assert graph.systemModule != nil
30- assert graph.systemModule.kind == skModule
31- assert graph.systemModule.ast != nil
32-
33- let n = graph.systemModule.ast
34- # if nil is not assigned, it generates large NIF
35- graph.systemModule .ast = nil
36- result = saveNifToBuffer (n, graph.config, graph.systemModule )
37- # writeFile("system .nif", result)
28+ proc getSystemNif (graph: ModuleGraph ): seq [ string ] =
29+ result = newSeqOfCap [ string ](graph.ifaces.len)
30+ for i, iface in graph.ifaces.mpairs:
31+ if iface.module != nil :
32+ let n = iface.module.ast
33+ assert n != nil
34+ # if nil is not assigned, it generates large NIF
35+ iface.module .ast = nil
36+ result . add saveNifToBuffer (n, graph.config, iface.module )
37+ # writeFile(iface.module.name.s & " .nif", result[^1] )
3838
3939proc sem (graph: ModuleGraph ; path: AbsoluteFile ): (PNode , PSym ) =
4040 result = (nil , nil )
@@ -169,10 +169,12 @@ proc eql(x, y: PSym; c: var EqlContext): bool =
169169 elif x.magic != y.magic:
170170 echo " symbol magic mismatch: " , x.magic, " /" , y.magic
171171 result = false
172- elif not eql (x.info, y.info, c):
172+ elif x.kind != skPackage and not eql (x.info, y.info, c):
173+ # fileIndex of info of skPackage is just a path of first semchecked module in the package
173174 echo " symbol line info mismatch"
174175 result = false
175- elif x.flags != y.flags:
176+ elif x.kind != skModule and x.flags != y.flags:
177+ # TODO : check the flag of skModule
176178 echo " symbol flag mismatch: " , x.flags, " /" , y.flags
177179 result = false
178180 elif x.options != y.options:
@@ -360,10 +362,11 @@ proc eql(x, y: PNode; c: var EqlContext): bool =
360362 debug (y)
361363 result = false
362364
363- proc testNifEncDec (graph: ModuleGraph ; src: string ; systemNif: string ) =
365+ proc testNifEncDec (graph: ModuleGraph ; src: string ; systemNif: openArray [ string ] ) =
364366 let fullPath = TestCodeDir / RelativeFile (src)
365367 let (n, module) = sem (graph, fullPath)
366368 assert n != nil , " failed to sem " & $ fullPath
369+ assert module.owner.kind == skPackage
367370
368371 # debug(n)
369372 let nif = saveNifToBuffer (n, graph.config, module)
@@ -374,7 +377,8 @@ proc testNifEncDec(graph: ModuleGraph; src: string; systemNif: string) =
374377 # Don't reuse the ModuleGraph used for semcheck when load NIF.
375378 var graphForLoad = newModuleGraph (newIdentCache (), newConfigRefForTest ())
376379 var prog = NifProgram ()
377- discard loadNifFromBuffer (systemNif, graphForLoad, prog)
380+ for sysNif in systemNif:
381+ discard loadNifFromBuffer (sysNif, graphForLoad, prog)
378382 let n2 = loadNifFromBuffer (nif, graphForLoad, prog)
379383 # debug(n2)
380384 var c = EqlContext (confX: graph.config, confY: graphForLoad.config)
0 commit comments