modernize jsgen; clean up some leftovers (#22423)

This commit is contained in:
ringabout
2023-08-09 12:33:19 +08:00
committed by GitHub
parent 3aaef9e4cf
commit ce079a8da4

View File

@@ -137,17 +137,15 @@ template nested(p, body) =
dec p.extraIndent
proc newGlobals(): PGlobals =
new(result)
result.forwarded = @[]
result.generatedSyms = initIntSet()
result.typeInfoGenerated = initIntSet()
result = PGlobals(forwarded: @[],
generatedSyms: initIntSet(),
typeInfoGenerated: initIntSet()
)
proc initCompRes(r: var TCompRes) =
r.address = ""
r.res = ""
r.tmpLoc = ""
r.typ = etyNone
r.kind = resNone
proc initCompRes(): TCompRes =
result = TCompRes(address: "", res: "",
tmpLoc: "", typ: etyNone, kind: resNone
)
proc rdLoc(a: TCompRes): Rope {.inline.} =
if a.typ != etyBaseIndex:
@@ -350,9 +348,10 @@ proc isSimpleExpr(p: PProc; n: PNode): bool =
if n[i].kind notin {nkCommentStmt, nkEmpty}: return false
result = isSimpleExpr(p, n.lastSon)
else:
result = false
if n.isAtom:
result = true
else:
result = false
proc getTemp(p: PProc, defineInLocals: bool = true): Rope =
inc(p.unique)
@@ -3006,13 +3005,11 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
proc newModule(g: ModuleGraph; module: PSym): BModule =
## Create a new JS backend module node.
new(result)
result.module = module
result.sigConflicts = initCountTable[SigHash]()
if g.backend == nil:
g.backend = newGlobals()
result.graph = g
result.config = g.config
result = BModule(module: module, sigConflicts: initCountTable[SigHash](),
graph: g, config: g.config
)
if sfSystemModule in module.flags:
PGlobals(g.backend).inSystem = true