diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-08-09 12:33:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 06:33:19 +0200 |
commit | ce079a8da45c8513b8864f92be4baba40a44fb7b (patch) | |
tree | b8e943dcd9aecfb2655775be8008aa366d6af362 | |
parent | 3aaef9e4cf014d5df65a686efe6b8bd99d3ea465 (diff) | |
download | Nim-ce079a8da45c8513b8864f92be4baba40a44fb7b.tar.gz |
modernize jsgen; clean up some leftovers (#22423)
-rw-r--r-- | compiler/jsgen.nim | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index a3df0a2ba..1a3154753 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -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 |