diff options
author | Araq <rumpf_a@web.de> | 2017-02-26 17:40:46 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-02-26 17:41:00 +0100 |
commit | 46b672a6c4771d150d78b1fb62ebd6323af3227a (patch) | |
tree | 1ceae03ac392b33ea59d72cd7a3fd663c50df635 | |
parent | 4c5ecb46b0b1bd14af80e7bf234e92e1bf85b28a (diff) | |
download | Nim-46b672a6c4771d150d78b1fb62ebd6323af3227a.tar.gz |
minor codegen bugfix: don't use names for closures that are also mangled Nim names
-rw-r--r-- | compiler/ccgcalls.nim | 4 | ||||
-rw-r--r-- | compiler/ccgexprs.nim | 14 | ||||
-rw-r--r-- | compiler/ccgstmts.nim | 2 | ||||
-rw-r--r-- | compiler/ccgtrav.nim | 2 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 10 | ||||
-rw-r--r-- | compiler/cgen.nim | 2 |
6 files changed, 17 insertions, 17 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 9dd5e7bb2..7493a50ca 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -200,8 +200,8 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) = proc addComma(r: Rope): Rope = result = if r == nil: r else: r & ~", " - const PatProc = "$1.ClEnv? $1.ClPrc($3$1.ClEnv):(($4)($1.ClPrc))($2)" - const PatIter = "$1.ClPrc($3$1.ClEnv)" # we know the env exists + const PatProc = "$1.ClE_0? $1.ClP_0($3$1.ClE_0):(($4)($1.ClP_0))($2)" + const PatIter = "$1.ClP_0($3$1.ClE_0)" # we know the env exists var op: TLoc initLocExpr(p, ri.sons[0], op) var pl: Rope diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index b5492f22e..309fb1f20 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -296,10 +296,10 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = of tyProc: if needsComplexAssignment(dest.t): # optimize closure assignment: - let a = optAsgnLoc(dest, dest.t, "ClEnv".rope) - let b = optAsgnLoc(src, dest.t, "ClEnv".rope) + let a = optAsgnLoc(dest, dest.t, "ClE_0".rope) + let b = optAsgnLoc(src, dest.t, "ClE_0".rope) genRefAssign(p, a, b, flags) - linefmt(p, cpsStmts, "$1.ClPrc = $2.ClPrc;$n", rdLoc(dest), rdLoc(src)) + linefmt(p, cpsStmts, "$1.ClP_0 = $2.ClP_0;$n", rdLoc(dest), rdLoc(src)) else: linefmt(p, cpsStmts, "$1 = $2;$n", rdLoc(dest), rdLoc(src)) of tyTuple: @@ -602,14 +602,14 @@ proc genEqProc(p: BProc, e: PNode, d: var TLoc) = initLocExpr(p, e.sons[2], b) if a.t.skipTypes(abstractInst).callConv == ccClosure: putIntoDest(p, d, e.typ, - "($1.ClPrc == $2.ClPrc && $1.ClEnv == $2.ClEnv)" % [rdLoc(a), rdLoc(b)]) + "($1.ClP_0 == $2.ClP_0 && $1.ClE_0 == $2.ClE_0)" % [rdLoc(a), rdLoc(b)]) else: putIntoDest(p, d, e.typ, "($1 == $2)" % [rdLoc(a), rdLoc(b)]) proc genIsNil(p: BProc, e: PNode, d: var TLoc) = let t = skipTypes(e.sons[1].typ, abstractRange) if t.kind == tyProc and t.callConv == ccClosure: - unaryExpr(p, e, d, "($1.ClPrc == 0)") + unaryExpr(p, e, d, "($1.ClP_0 == 0)") else: unaryExpr(p, e, d, "($1 == 0)") @@ -1851,11 +1851,11 @@ proc genClosure(p: BProc, n: PNode, d: var TLoc) = # tasyncawait.nim breaks with this optimization: when false: if d.k != locNone: - linefmt(p, cpsStmts, "$1.ClPrc = $2; $1.ClEnv = $3;$n", + linefmt(p, cpsStmts, "$1.ClP_0 = $2; $1.ClE_0 = $3;$n", d.rdLoc, a.rdLoc, b.rdLoc) else: getTemp(p, n.typ, tmp) - linefmt(p, cpsStmts, "$1.ClPrc = $2; $1.ClEnv = $3;$n", + linefmt(p, cpsStmts, "$1.ClP_0 = $2; $1.ClE_0 = $3;$n", tmp.rdLoc, a.rdLoc, b.rdLoc) putLocIntoDest(p, d, tmp) diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 3a861ebd4..cc925b150 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -170,7 +170,7 @@ proc genBreakState(p: BProc, n: PNode) = else: initLocExpr(p, n.sons[0], a) # the environment is guaranteed to contain the 'state' field at offset 0: - lineF(p, cpsStmts, "if ((((NI*) $1.ClEnv)[0]) < 0) break;$n", [rdLoc(a)]) + lineF(p, cpsStmts, "if ((((NI*) $1.ClE_0)[0]) < 0) break;$n", [rdLoc(a)]) # lineF(p, cpsStmts, "if (($1) < 0) break;$n", [rdLoc(a)]) proc genVarPrototypeAux(m: BModule, sym: PSym) diff --git a/compiler/ccgtrav.nim b/compiler/ccgtrav.nim index 547504afb..457093c61 100644 --- a/compiler/ccgtrav.nim +++ b/compiler/ccgtrav.nim @@ -87,7 +87,7 @@ proc genTraverseProc(c: var TTraversalClosure, accessor: Rope, typ: PType) = lineCg(p, cpsStmts, c.visitorFrmt, accessor) of tyProc: if typ.callConv == ccClosure: - lineCg(p, cpsStmts, c.visitorFrmt, rfmt(nil, "$1.ClEnv", accessor)) + lineCg(p, cpsStmts, c.visitorFrmt, rfmt(nil, "$1.ClE_0", accessor)) else: discard diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 08755941e..8fdd97428 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -427,7 +427,7 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var Rope, addf(params, " Result", []) if t.callConv == ccClosure and declareEnvironment: if params != nil: add(params, ", ") - add(params, "void* ClEnv") + add(params, "void* ClE_0") if tfVarargs in t.flags: if params != nil: add(params, ", ") add(params, "...") @@ -678,8 +678,8 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope = [rope(CallingConvToStr[t.callConv]), rettype, result, desc]) else: addf(m.s[cfsTypes], "typedef struct {$n" & - "N_NIMCALL_PTR($2, ClPrc) $3;$n" & - "void* ClEnv;$n} $1;$n", + "N_NIMCALL_PTR($2, ClP_0) $3;$n" & + "void* ClE_0;$n} $1;$n", [result, rettype, desc]) of tySequence: # we cannot use getTypeForward here because then t would be associated @@ -815,8 +815,8 @@ proc getClosureType(m: BModule, t: PType, kind: TClosureTypeKind): Rope = [rope(CallingConvToStr[t.callConv]), rettype, result, desc]) else: addf(m.s[cfsTypes], "typedef struct {$n" & - "N_NIMCALL_PTR($2, ClPrc) $3;$n" & - "void* ClEnv;$n} $1;$n", + "N_NIMCALL_PTR($2, ClP_0) $3;$n" & + "void* ClE_0;$n} $1;$n", [result, rettype, desc]) proc finishTypeDescriptions(m: BModule) = diff --git a/compiler/cgen.nim b/compiler/cgen.nim index decbe55c3..c829a463e 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -628,7 +628,7 @@ proc closureSetup(p: BProc, prc: PSym) = #echo "created environment: ", env.id, " for ", prc.name.s assignLocalVar(p, env) # generate cast assignment: - linefmt(p, cpsStmts, "$1 = ($2) ClEnv;$n", + linefmt(p, cpsStmts, "$1 = ($2) ClE_0;$n", rdLoc(env.loc), getTypeDesc(p.module, env.typ)) proc easyResultAsgn(n: PNode): PNode = |