Skip to content

Commit 87a2ced

Browse files
committed
there is only one style -- my style
1 parent 73cc029 commit 87a2ced

File tree

16 files changed

+232
-213
lines changed

16 files changed

+232
-213
lines changed

compiler/cgen.nim

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,20 +1474,20 @@ proc registerModuleToMain(g: BModuleList; m: BModule) =
14741474
datInit = m.getDatInitName
14751475

14761476
if m.hcrOn:
1477-
var hcr_module_meta = "$nN_LIB_PRIVATE const char* hcr_module_list[] = {$n" % []
1477+
var hcrModuleMeta = "$nN_LIB_PRIVATE const char* hcr_module_list[] = {$n" % []
14781478
let systemModulePath = getModuleDllPath(m, g.modules[g.graph.config.m.systemFileIdx.int].module)
14791479
let mainModulePath = getModuleDllPath(m, m.module)
14801480
if sfMainModule in m.module.flags:
1481-
addf(hcr_module_meta, "\t$1,$n", [systemModulePath])
1481+
addf(hcrModuleMeta, "\t$1,$n", [systemModulePath])
14821482
g.graph.importDeps.withValue(FileIndex(m.module.position), deps):
14831483
for curr in deps[]:
1484-
addf(hcr_module_meta, "\t$1,$n", [getModuleDllPath(m, g.modules[curr.int].module)])
1485-
addf(hcr_module_meta, "\t\"\"};$n", [])
1486-
addf(hcr_module_meta, "$nN_LIB_EXPORT N_NIMCALL(void**, HcrGetImportedModules)() { return (void**)hcr_module_list; }$n", [])
1487-
addf(hcr_module_meta, "$nN_LIB_EXPORT N_NIMCALL(char*, HcrGetSigHash)() { return \"$1\"; }$n$n",
1484+
addf(hcrModuleMeta, "\t$1,$n", [getModuleDllPath(m, g.modules[curr.int].module)])
1485+
addf(hcrModuleMeta, "\t\"\"};$n", [])
1486+
addf(hcrModuleMeta, "$nN_LIB_EXPORT N_NIMCALL(void**, HcrGetImportedModules)() { return (void**)hcr_module_list; }$n", [])
1487+
addf(hcrModuleMeta, "$nN_LIB_EXPORT N_NIMCALL(char*, HcrGetSigHash)() { return \"$1\"; }$n$n",
14881488
[($sigHash(m.module)).rope])
14891489
if sfMainModule in m.module.flags:
1490-
add(g.mainModProcs, hcr_module_meta)
1490+
add(g.mainModProcs, hcrModuleMeta)
14911491
addf(g.mainModProcs, "static void* hcr_handle;$N", [])
14921492
addf(g.mainModProcs, "N_LIB_EXPORT N_NIMCALL(void, $1)(void);$N", [init])
14931493
addf(g.mainModProcs, "N_LIB_EXPORT N_NIMCALL(void, $1)(void);$N", [datInit])
@@ -1511,7 +1511,7 @@ proc registerModuleToMain(g: BModuleList; m: BModule) =
15111511
add(g.mainDatInit, "\t*cmd_count = cmdCount;\n")
15121512
add(g.mainDatInit, "\t*cmd_line = cmdLine;\n")
15131513
else:
1514-
add(m.s[cfsInitProc], hcr_module_meta)
1514+
add(m.s[cfsInitProc], hcrModuleMeta)
15151515
return
15161516

15171517
if m.s[cfsDatInitProc].len > 0:
@@ -1876,11 +1876,11 @@ proc myProcess(b: PPassContext, n: PNode): PNode =
18761876
m.initProc.options = initProcOptions(m)
18771877
#softRnl = if optLineDir in m.config.options: noRnl else: rnl
18781878
# XXX replicate this logic!
1879-
let transformed_n = transformStmt(m.g.graph, m.module, n)
1879+
let transformedN = transformStmt(m.g.graph, m.module, n)
18801880
if m.hcrOn:
1881-
addHcrInitGuards(m.initProc, transformed_n, m.inHcrInitGuard)
1881+
addHcrInitGuards(m.initProc, transformedN, m.inHcrInitGuard)
18821882
else:
1883-
genStmts(m.initProc, transformed_n)
1883+
genStmts(m.initProc, transformedN)
18841884

18851885
proc shouldRecompile(m: BModule; code: Rope, cfile: Cfile): bool =
18861886
result = true
@@ -2020,7 +2020,7 @@ proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
20202020
let disp = generateMethodDispatchers(graph)
20212021
for x in disp: genProcAux(m, x.sym)
20222022

2023-
m.g.modules_closed.add m
2023+
m.g.modulesClosed.add m
20242024

20252025
proc genForwardedProcs(g: BModuleList) =
20262026
# Forward declared proc:s lack bodies when first encountered, so they're given

compiler/cgendata.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type
114114
mainModProcs*, mainModInit*, otherModsInit*, mainDatInit*: Rope
115115
mapping*: Rope # the generated mapping file (if requested)
116116
modules*: seq[BModule] # list of all compiled modules
117-
modules_closed*: seq[BModule] # list of the same compiled modules, but in the order they were closed
117+
modulesClosed*: seq[BModule] # list of the same compiled modules, but in the order they were closed
118118
forwardedProcs*: seq[PSym] # proc:s that did not yet have a body
119119
generatedHeader*: BModule
120120
breakPointId*: int
@@ -196,6 +196,6 @@ proc newModuleList*(g: ModuleGraph): BModuleList =
196196
config: g.config, graph: g, nimtvDeclared: initIntSet())
197197

198198
iterator cgenModules*(g: BModuleList): BModule =
199-
for m in g.modules_closed:
199+
for m in g.modulesClosed:
200200
# iterate modules in the order they were closed
201201
yield m

compiler/dfa.nim

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ use(x)
119119
120120
Generates:
121121
122-
L0: fork L1
122+
L0: fork lab1
123123
join L0 # patched.
124124
goto Louter
125-
L1:
125+
lab1:
126126
def x
127127
join L0
128128
Louter:
@@ -354,24 +354,24 @@ when true:
354354
else:
355355

356356
proc genWhile(c: var Con; n: PNode) =
357-
# L1:
357+
# lab1:
358358
# cond, tmp
359-
# fork tmp, L2
359+
# fork tmp, lab2
360360
# body
361-
# jmp L1
362-
# L2:
361+
# jmp lab1
362+
# lab2:
363363
let oldForksLen = c.forks.len
364-
let L1 = c.genLabel
364+
let lab1 = c.genLabel
365365
withBlock(nil):
366366
if isTrue(n.sons[0]):
367367
c.gen(n.sons[1])
368-
c.jmpBack(n, L1)
368+
c.jmpBack(n, lab1)
369369
else:
370370
c.gen(n.sons[0])
371-
let L2 = c.forkI(n)
371+
let lab2 = c.forkI(n)
372372
c.gen(n.sons[1])
373-
c.jmpBack(n, L1)
374-
c.patch(L2)
373+
c.jmpBack(n, lab1)
374+
c.patch(lab2)
375375
setLen(c.forks, oldForksLen)
376376

377377
proc genBlock(c: var Con; n: PNode) =
@@ -383,23 +383,23 @@ proc genJoins(c: var Con; n: PNode) =
383383

384384
proc genBreak(c: var Con; n: PNode) =
385385
genJoins(c, n)
386-
let L1 = c.gotoI(n)
386+
let lab1 = c.gotoI(n)
387387
if n.sons[0].kind == nkSym:
388388
#echo cast[int](n.sons[0].sym)
389389
for i in countdown(c.blocks.len-1, 0):
390390
if c.blocks[i].label == n.sons[0].sym:
391-
c.blocks[i].fixups.add L1
391+
c.blocks[i].fixups.add lab1
392392
return
393393
#globalError(n.info, "VM problem: cannot find 'break' target")
394394
else:
395-
c.blocks[c.blocks.high].fixups.add L1
395+
c.blocks[c.blocks.high].fixups.add lab1
396396

397397
template forkT(n, body) =
398398
let oldLen = c.forks.len
399-
let L1 = c.forkI(n)
399+
let lab1 = c.forkI(n)
400400
body
401-
c.patch(L1)
402-
c.joinI(L1, n)
401+
c.patch(lab1)
402+
c.joinI(lab1, n)
403403
setLen(c.forks, oldLen)
404404

405405
proc genIf(c: var Con, n: PNode) =
@@ -415,15 +415,15 @@ proc genIf(c: var Con, n: PNode) =
415415
D
416416
417417
cond
418-
fork L1
418+
fork lab1
419419
A
420420
goto Lend
421-
L1:
421+
lab1:
422422
condB
423-
fork L2
423+
fork lab2
424424
B
425425
goto Lend2
426-
L2:
426+
lab2:
427427
condC
428428
fork L3
429429
C
@@ -457,23 +457,23 @@ proc genIf(c: var Con, n: PNode) =
457457

458458
proc genAndOr(c: var Con; n: PNode) =
459459
# asgn dest, a
460-
# fork L1
460+
# fork lab1
461461
# asgn dest, b
462-
# L1:
462+
# lab1:
463463
# join F1
464464
c.gen(n.sons[1])
465465
forkT(n):
466466
c.gen(n.sons[2])
467467

468468
proc genCase(c: var Con; n: PNode) =
469-
# if (!expr1) goto L1;
469+
# if (!expr1) goto lab1;
470470
# thenPart
471471
# goto LEnd
472-
# L1:
473-
# if (!expr2) goto L2;
472+
# lab1:
473+
# if (!expr2) goto lab2;
474474
# thenPart2
475475
# goto LEnd
476-
# L2:
476+
# lab2:
477477
# elsePart
478478
# Lend:
479479
let isExhaustive = skipTypes(n.sons[0].typ,
@@ -714,9 +714,9 @@ proc genCall(c: var Con; n: PNode) =
714714
# every call can potentially raise:
715715
if c.inTryStmt > 0 and canRaise(n[0]):
716716
# we generate the instruction sequence:
717-
# fork L1
717+
# fork lab1
718718
# goto exceptionHandler (except or finally)
719-
# L1:
719+
# lab1:
720720
# join F1
721721
let endGoto = c.forkI(n)
722722
c.tryStmtFixups.add c.gotoI(n)

compiler/jsgen.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,8 +2260,8 @@ proc genProc(oldProc: PProc, prc: PSym): Rope =
22602260
else:
22612261
returnStmt = "return $#;$n" % [a.res]
22622262

2263-
let transformed_body = transformBody(oldProc.module.graph, prc, cache = false)
2264-
p.nested: genStmt(p, transformed_body)
2263+
let transformedBody = transformBody(oldProc.module.graph, prc, cache = false)
2264+
p.nested: genStmt(p, transformedBody)
22652265

22662266
var def: Rope
22672267
if not prc.constraint.isNil:
@@ -2541,23 +2541,23 @@ proc genModule(p: PProc, n: PNode) =
25412541
add(p.body, frameCreate(p,
25422542
makeJSString("module " & p.module.module.name.s),
25432543
makeJSString(toFilename(p.config, p.module.module.info))))
2544-
let n_transformed = transformStmt(p.module.graph, p.module.module, n)
2544+
let transformedN = transformStmt(p.module.graph, p.module.module, n)
25452545
if p.config.hcrOn and n.kind == nkStmtList:
25462546
let moduleSym = p.module.module
25472547
var moduleLoadedVar = rope(moduleSym.name.s) & "_loaded" &
25482548
idOrSig(moduleSym, moduleSym.name.s, p.module.sigConflicts)
25492549
lineF(p, "var $1;$n", [moduleLoadedVar])
25502550
var inGuardedBlock = false
25512551

2552-
addHcrInitGuards(p, n_transformed, moduleLoadedVar, inGuardedBlock)
2552+
addHcrInitGuards(p, transformedN, moduleLoadedVar, inGuardedBlock)
25532553

25542554
if inGuardedBlock:
25552555
dec p.extraIndent
25562556
line(p, "}\L")
25572557

25582558
lineF(p, "$1 = true;$n", [moduleLoadedVar])
25592559
else:
2560-
genStmt(p, n_transformed)
2560+
genStmt(p, transformedN)
25612561

25622562
if optStackTrace in p.options:
25632563
add(p.body, frameDestroy(p))

compiler/renderer.nim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,10 +897,10 @@ proc accentedName(g: var TSrcGen, n: PNode) =
897897
proc infixArgument(g: var TSrcGen, n: PNode, i: int) =
898898
if i < 1 and i > 2: return
899899
var needsParenthesis = false
900-
let n_next = n[i].skipHiddenNodes
901-
if n_next.kind == nkInfix:
902-
if n_next[0].kind in {nkSym, nkIdent} and n[0].kind in {nkSym, nkIdent}:
903-
let nextId = if n_next[0].kind == nkSym: n_next[0].sym.name else: n_next[0].ident
900+
let nNext = n[i].skipHiddenNodes
901+
if nNext.kind == nkInfix:
902+
if nNext[0].kind in {nkSym, nkIdent} and n[0].kind in {nkSym, nkIdent}:
903+
let nextId = if nNext[0].kind == nkSym: nNext[0].sym.name else: nNext[0].ident
904904
let nnId = if n[0].kind == nkSym: n[0].sym.name else: n[0].ident
905905
if i == 1:
906906
if getPrecedence(nextId) < getPrecedence(nnId):
@@ -1144,10 +1144,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
11441144
elif n[0].kind == nkSym: n[0].sym.name
11451145
elif n[0].kind in {nkOpenSymChoice, nkClosedSymChoice}: n[0][0].sym.name
11461146
else: nil
1147-
let n_next = skipHiddenNodes(n[1])
1148-
if n_next.kind == nkPrefix or (opr != nil and renderer.isKeyword(opr)):
1147+
let nNext = skipHiddenNodes(n[1])
1148+
if nNext.kind == nkPrefix or (opr != nil and renderer.isKeyword(opr)):
11491149
put(g, tkSpaces, Space)
1150-
if n_next.kind == nkInfix:
1150+
if nNext.kind == nkInfix:
11511151
put(g, tkParLe, "(")
11521152
gsub(g, n.sons[1])
11531153
put(g, tkParRi, ")")

compiler/semstmts.nim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,16 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode =
189189
template semExceptBranchType(typeNode: PNode): bool =
190190
# returns true if exception type is imported type
191191
let typ = semTypeNode(c, typeNode, nil).toObject()
192-
var is_imported = false
192+
var isImported = false
193193
if isImportedException(typ, c.config):
194-
is_imported = true
194+
isImported = true
195195
elif not isException(typ):
196196
localError(c.config, typeNode.info, errExprCannotBeRaised)
197197

198198
if containsOrIncl(check, typ.id):
199199
localError(c.config, typeNode.info, errExceptionAlreadyHandled)
200200
typeNode = newNodeIT(nkType, typeNode.info, typ)
201-
is_imported
201+
isImported
202202

203203
result = n
204204
inc c.p.inTryStmt
@@ -223,9 +223,9 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode =
223223

224224
if a.len == 2 and a[0].isInfixAs():
225225
# support ``except Exception as ex: body``
226-
let is_imported = semExceptBranchType(a[0][1])
226+
let isImported = semExceptBranchType(a[0][1])
227227
let symbol = newSymG(skLet, a[0][2], c)
228-
symbol.typ = if is_imported: a[0][1].typ
228+
symbol.typ = if isImported: a[0][1].typ
229229
else: a[0][1].typ.toRef()
230230
addDecl(c, symbol)
231231
# Overwrite symbol in AST with the symbol in the symbol table.
@@ -241,13 +241,13 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode =
241241
# if ``except: body`` already encountered,
242242
# cannot be followed by a ``except KeyError, ... : body`` block
243243
inc catchAllExcepts
244-
var is_native, is_imported: bool
244+
var isNative, isImported: bool
245245
for j in 0..a.len-2:
246246
let tmp = semExceptBranchType(a[j])
247-
if tmp: is_imported = true
248-
else: is_native = true
247+
if tmp: isImported = true
248+
else: isNative = true
249249

250-
if is_native and is_imported:
250+
if isNative and isImported:
251251
localError(c.config, a[0].info, "Mix of imported and native exception types is not allowed in one except branch")
252252

253253
elif a.kind == nkFinally:

compiler/sizealignoffsetimpl.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,17 @@ proc computeObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode,
143143
result.align = 1 # maximum of all member alignments
144144
var offset = initialOffset
145145
for i, child in n.sons:
146-
let (new_offset, align) = computeObjectOffsetsFoldFunction(conf, child, offset)
147-
if new_offset == szIllegalRecursion:
146+
let (newOffset, align) = computeObjectOffsetsFoldFunction(conf, child, offset)
147+
if newOffset == szIllegalRecursion:
148148
result.offset = szIllegalRecursion
149149
result.align = szIllegalRecursion
150150
return
151-
elif new_offset == szUnknownSize or offset == szUnknownSize:
151+
elif newOffset == szUnknownSize or offset == szUnknownSize:
152152
# if anything is unknown, the rest becomes unknown as well
153153
offset = szUnknownSize
154154
result.align = szUnknownSize
155155
else:
156-
offset = new_offset
156+
offset = newOffset
157157
result.align = max(result.align, align)
158158
# final alignment
159159
if offset == szUnknownSize:

0 commit comments

Comments
 (0)