diff options
Diffstat (limited to 'compiler/jsgen.nim')
-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 |