diff options
author | Araq <rumpf_a@web.de> | 2019-07-10 19:17:06 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-07-10 19:17:06 +0200 |
commit | 87a2ced1baec059922a567e2000c0fe16cc1db52 (patch) | |
tree | 7f29bfe00f2b0b26dce69593e0cfe47d47b177e2 /compiler | |
parent | 73cc029fec8ff52ace34cc94ccee0ff89e975862 (diff) | |
download | Nim-87a2ced1baec059922a567e2000c0fe16cc1db52.tar.gz |
there is only one style -- my style
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cgen.nim | 24 | ||||
-rw-r--r-- | compiler/cgendata.nim | 4 | ||||
-rw-r--r-- | compiler/dfa.nim | 58 | ||||
-rw-r--r-- | compiler/jsgen.nim | 10 | ||||
-rw-r--r-- | compiler/renderer.nim | 14 | ||||
-rw-r--r-- | compiler/semstmts.nim | 18 | ||||
-rw-r--r-- | compiler/sizealignoffsetimpl.nim | 8 | ||||
-rw-r--r-- | compiler/vmgen.nim | 76 |
8 files changed, 106 insertions, 106 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 851c8c2a4..dec8e936a 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1474,20 +1474,20 @@ proc registerModuleToMain(g: BModuleList; m: BModule) = datInit = m.getDatInitName if m.hcrOn: - var hcr_module_meta = "$nN_LIB_PRIVATE const char* hcr_module_list[] = {$n" % [] + var hcrModuleMeta = "$nN_LIB_PRIVATE const char* hcr_module_list[] = {$n" % [] let systemModulePath = getModuleDllPath(m, g.modules[g.graph.config.m.systemFileIdx.int].module) let mainModulePath = getModuleDllPath(m, m.module) if sfMainModule in m.module.flags: - addf(hcr_module_meta, "\t$1,$n", [systemModulePath]) + addf(hcrModuleMeta, "\t$1,$n", [systemModulePath]) g.graph.importDeps.withValue(FileIndex(m.module.position), deps): for curr in deps[]: - addf(hcr_module_meta, "\t$1,$n", [getModuleDllPath(m, g.modules[curr.int].module)]) - addf(hcr_module_meta, "\t\"\"};$n", []) - addf(hcr_module_meta, "$nN_LIB_EXPORT N_NIMCALL(void**, HcrGetImportedModules)() { return (void**)hcr_module_list; }$n", []) - addf(hcr_module_meta, "$nN_LIB_EXPORT N_NIMCALL(char*, HcrGetSigHash)() { return \"$1\"; }$n$n", + addf(hcrModuleMeta, "\t$1,$n", [getModuleDllPath(m, g.modules[curr.int].module)]) + addf(hcrModuleMeta, "\t\"\"};$n", []) + addf(hcrModuleMeta, "$nN_LIB_EXPORT N_NIMCALL(void**, HcrGetImportedModules)() { return (void**)hcr_module_list; }$n", []) + addf(hcrModuleMeta, "$nN_LIB_EXPORT N_NIMCALL(char*, HcrGetSigHash)() { return \"$1\"; }$n$n", [($sigHash(m.module)).rope]) if sfMainModule in m.module.flags: - add(g.mainModProcs, hcr_module_meta) + add(g.mainModProcs, hcrModuleMeta) addf(g.mainModProcs, "static void* hcr_handle;$N", []) addf(g.mainModProcs, "N_LIB_EXPORT N_NIMCALL(void, $1)(void);$N", [init]) addf(g.mainModProcs, "N_LIB_EXPORT N_NIMCALL(void, $1)(void);$N", [datInit]) @@ -1511,7 +1511,7 @@ proc registerModuleToMain(g: BModuleList; m: BModule) = add(g.mainDatInit, "\t*cmd_count = cmdCount;\n") add(g.mainDatInit, "\t*cmd_line = cmdLine;\n") else: - add(m.s[cfsInitProc], hcr_module_meta) + add(m.s[cfsInitProc], hcrModuleMeta) return if m.s[cfsDatInitProc].len > 0: @@ -1876,11 +1876,11 @@ proc myProcess(b: PPassContext, n: PNode): PNode = m.initProc.options = initProcOptions(m) #softRnl = if optLineDir in m.config.options: noRnl else: rnl # XXX replicate this logic! - let transformed_n = transformStmt(m.g.graph, m.module, n) + let transformedN = transformStmt(m.g.graph, m.module, n) if m.hcrOn: - addHcrInitGuards(m.initProc, transformed_n, m.inHcrInitGuard) + addHcrInitGuards(m.initProc, transformedN, m.inHcrInitGuard) else: - genStmts(m.initProc, transformed_n) + genStmts(m.initProc, transformedN) proc shouldRecompile(m: BModule; code: Rope, cfile: Cfile): bool = result = true @@ -2020,7 +2020,7 @@ proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode = let disp = generateMethodDispatchers(graph) for x in disp: genProcAux(m, x.sym) - m.g.modules_closed.add m + m.g.modulesClosed.add m proc genForwardedProcs(g: BModuleList) = # Forward declared proc:s lack bodies when first encountered, so they're given diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim index 48dda0716..76c64782c 100644 --- a/compiler/cgendata.nim +++ b/compiler/cgendata.nim @@ -114,7 +114,7 @@ type mainModProcs*, mainModInit*, otherModsInit*, mainDatInit*: Rope mapping*: Rope # the generated mapping file (if requested) modules*: seq[BModule] # list of all compiled modules - modules_closed*: seq[BModule] # list of the same compiled modules, but in the order they were closed + modulesClosed*: seq[BModule] # list of the same compiled modules, but in the order they were closed forwardedProcs*: seq[PSym] # proc:s that did not yet have a body generatedHeader*: BModule breakPointId*: int @@ -196,6 +196,6 @@ proc newModuleList*(g: ModuleGraph): BModuleList = config: g.config, graph: g, nimtvDeclared: initIntSet()) iterator cgenModules*(g: BModuleList): BModule = - for m in g.modules_closed: + for m in g.modulesClosed: # iterate modules in the order they were closed yield m diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 758f4a8f4..f97d8f298 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -119,10 +119,10 @@ use(x) Generates: -L0: fork L1 +L0: fork lab1 join L0 # patched. goto Louter -L1: +lab1: def x join L0 Louter: @@ -354,24 +354,24 @@ when true: else: proc genWhile(c: var Con; n: PNode) = - # L1: + # lab1: # cond, tmp - # fork tmp, L2 + # fork tmp, lab2 # body - # jmp L1 - # L2: + # jmp lab1 + # lab2: let oldForksLen = c.forks.len - let L1 = c.genLabel + let lab1 = c.genLabel withBlock(nil): if isTrue(n.sons[0]): c.gen(n.sons[1]) - c.jmpBack(n, L1) + c.jmpBack(n, lab1) else: c.gen(n.sons[0]) - let L2 = c.forkI(n) + let lab2 = c.forkI(n) c.gen(n.sons[1]) - c.jmpBack(n, L1) - c.patch(L2) + c.jmpBack(n, lab1) + c.patch(lab2) setLen(c.forks, oldForksLen) proc genBlock(c: var Con; n: PNode) = @@ -383,23 +383,23 @@ proc genJoins(c: var Con; n: PNode) = proc genBreak(c: var Con; n: PNode) = genJoins(c, n) - let L1 = c.gotoI(n) + let lab1 = c.gotoI(n) if n.sons[0].kind == nkSym: #echo cast[int](n.sons[0].sym) for i in countdown(c.blocks.len-1, 0): if c.blocks[i].label == n.sons[0].sym: - c.blocks[i].fixups.add L1 + c.blocks[i].fixups.add lab1 return #globalError(n.info, "VM problem: cannot find 'break' target") else: - c.blocks[c.blocks.high].fixups.add L1 + c.blocks[c.blocks.high].fixups.add lab1 template forkT(n, body) = let oldLen = c.forks.len - let L1 = c.forkI(n) + let lab1 = c.forkI(n) body - c.patch(L1) - c.joinI(L1, n) + c.patch(lab1) + c.joinI(lab1, n) setLen(c.forks, oldLen) proc genIf(c: var Con, n: PNode) = @@ -415,15 +415,15 @@ proc genIf(c: var Con, n: PNode) = D cond - fork L1 + fork lab1 A goto Lend - L1: + lab1: condB - fork L2 + fork lab2 B goto Lend2 - L2: + lab2: condC fork L3 C @@ -457,23 +457,23 @@ proc genIf(c: var Con, n: PNode) = proc genAndOr(c: var Con; n: PNode) = # asgn dest, a - # fork L1 + # fork lab1 # asgn dest, b - # L1: + # lab1: # join F1 c.gen(n.sons[1]) forkT(n): c.gen(n.sons[2]) proc genCase(c: var Con; n: PNode) = - # if (!expr1) goto L1; + # if (!expr1) goto lab1; # thenPart # goto LEnd - # L1: - # if (!expr2) goto L2; + # lab1: + # if (!expr2) goto lab2; # thenPart2 # goto LEnd - # L2: + # lab2: # elsePart # Lend: let isExhaustive = skipTypes(n.sons[0].typ, @@ -714,9 +714,9 @@ proc genCall(c: var Con; n: PNode) = # every call can potentially raise: if c.inTryStmt > 0 and canRaise(n[0]): # we generate the instruction sequence: - # fork L1 + # fork lab1 # goto exceptionHandler (except or finally) - # L1: + # lab1: # join F1 let endGoto = c.forkI(n) c.tryStmtFixups.add c.gotoI(n) diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 444ce0191..84909b745 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -2260,8 +2260,8 @@ proc genProc(oldProc: PProc, prc: PSym): Rope = else: returnStmt = "return $#;$n" % [a.res] - let transformed_body = transformBody(oldProc.module.graph, prc, cache = false) - p.nested: genStmt(p, transformed_body) + let transformedBody = transformBody(oldProc.module.graph, prc, cache = false) + p.nested: genStmt(p, transformedBody) var def: Rope if not prc.constraint.isNil: @@ -2541,7 +2541,7 @@ proc genModule(p: PProc, n: PNode) = add(p.body, frameCreate(p, makeJSString("module " & p.module.module.name.s), makeJSString(toFilename(p.config, p.module.module.info)))) - let n_transformed = transformStmt(p.module.graph, p.module.module, n) + let transformedN = transformStmt(p.module.graph, p.module.module, n) if p.config.hcrOn and n.kind == nkStmtList: let moduleSym = p.module.module var moduleLoadedVar = rope(moduleSym.name.s) & "_loaded" & @@ -2549,7 +2549,7 @@ proc genModule(p: PProc, n: PNode) = lineF(p, "var $1;$n", [moduleLoadedVar]) var inGuardedBlock = false - addHcrInitGuards(p, n_transformed, moduleLoadedVar, inGuardedBlock) + addHcrInitGuards(p, transformedN, moduleLoadedVar, inGuardedBlock) if inGuardedBlock: dec p.extraIndent @@ -2557,7 +2557,7 @@ proc genModule(p: PProc, n: PNode) = lineF(p, "$1 = true;$n", [moduleLoadedVar]) else: - genStmt(p, n_transformed) + genStmt(p, transformedN) if optStackTrace in p.options: add(p.body, frameDestroy(p)) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 80ce28666..11eaec146 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -897,10 +897,10 @@ proc accentedName(g: var TSrcGen, n: PNode) = proc infixArgument(g: var TSrcGen, n: PNode, i: int) = if i < 1 and i > 2: return var needsParenthesis = false - let n_next = n[i].skipHiddenNodes - if n_next.kind == nkInfix: - if n_next[0].kind in {nkSym, nkIdent} and n[0].kind in {nkSym, nkIdent}: - let nextId = if n_next[0].kind == nkSym: n_next[0].sym.name else: n_next[0].ident + let nNext = n[i].skipHiddenNodes + if nNext.kind == nkInfix: + if nNext[0].kind in {nkSym, nkIdent} and n[0].kind in {nkSym, nkIdent}: + let nextId = if nNext[0].kind == nkSym: nNext[0].sym.name else: nNext[0].ident let nnId = if n[0].kind == nkSym: n[0].sym.name else: n[0].ident if i == 1: if getPrecedence(nextId) < getPrecedence(nnId): @@ -1144,10 +1144,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = elif n[0].kind == nkSym: n[0].sym.name elif n[0].kind in {nkOpenSymChoice, nkClosedSymChoice}: n[0][0].sym.name else: nil - let n_next = skipHiddenNodes(n[1]) - if n_next.kind == nkPrefix or (opr != nil and renderer.isKeyword(opr)): + let nNext = skipHiddenNodes(n[1]) + if nNext.kind == nkPrefix or (opr != nil and renderer.isKeyword(opr)): put(g, tkSpaces, Space) - if n_next.kind == nkInfix: + if nNext.kind == nkInfix: put(g, tkParLe, "(") gsub(g, n.sons[1]) put(g, tkParRi, ")") diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 8d9e416ac..2020f10f8 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -189,16 +189,16 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = template semExceptBranchType(typeNode: PNode): bool = # returns true if exception type is imported type let typ = semTypeNode(c, typeNode, nil).toObject() - var is_imported = false + var isImported = false if isImportedException(typ, c.config): - is_imported = true + isImported = true elif not isException(typ): localError(c.config, typeNode.info, errExprCannotBeRaised) if containsOrIncl(check, typ.id): localError(c.config, typeNode.info, errExceptionAlreadyHandled) typeNode = newNodeIT(nkType, typeNode.info, typ) - is_imported + isImported result = n inc c.p.inTryStmt @@ -223,9 +223,9 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = if a.len == 2 and a[0].isInfixAs(): # support ``except Exception as ex: body`` - let is_imported = semExceptBranchType(a[0][1]) + let isImported = semExceptBranchType(a[0][1]) let symbol = newSymG(skLet, a[0][2], c) - symbol.typ = if is_imported: a[0][1].typ + symbol.typ = if isImported: a[0][1].typ else: a[0][1].typ.toRef() addDecl(c, symbol) # Overwrite symbol in AST with the symbol in the symbol table. @@ -241,13 +241,13 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = # if ``except: body`` already encountered, # cannot be followed by a ``except KeyError, ... : body`` block inc catchAllExcepts - var is_native, is_imported: bool + var isNative, isImported: bool for j in 0..a.len-2: let tmp = semExceptBranchType(a[j]) - if tmp: is_imported = true - else: is_native = true + if tmp: isImported = true + else: isNative = true - if is_native and is_imported: + if isNative and isImported: localError(c.config, a[0].info, "Mix of imported and native exception types is not allowed in one except branch") elif a.kind == nkFinally: diff --git a/compiler/sizealignoffsetimpl.nim b/compiler/sizealignoffsetimpl.nim index 641b823a3..bc9e3812d 100644 --- a/compiler/sizealignoffsetimpl.nim +++ b/compiler/sizealignoffsetimpl.nim @@ -143,17 +143,17 @@ proc computeObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode, result.align = 1 # maximum of all member alignments var offset = initialOffset for i, child in n.sons: - let (new_offset, align) = computeObjectOffsetsFoldFunction(conf, child, offset) - if new_offset == szIllegalRecursion: + let (newOffset, align) = computeObjectOffsetsFoldFunction(conf, child, offset) + if newOffset == szIllegalRecursion: result.offset = szIllegalRecursion result.align = szIllegalRecursion return - elif new_offset == szUnknownSize or offset == szUnknownSize: + elif newOffset == szUnknownSize or offset == szUnknownSize: # if anything is unknown, the rest becomes unknown as well offset = szUnknownSize result.align = szUnknownSize else: - offset = new_offset + offset = newOffset result.align = max(result.align, align) # final alignment if offset == szUnknownSize: diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 58517c2b8..e63eb1fd9 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -304,31 +304,31 @@ proc isTrue(n: PNode): bool = n.kind == nkIntLit and n.intVal != 0 proc genWhile(c: PCtx; n: PNode) = - # L1: + # lab1: # cond, tmp - # fjmp tmp, L2 + # fjmp tmp, lab2 # body - # jmp L1 - # L2: - let L1 = c.genLabel + # jmp lab1 + # lab2: + let lab1 = c.genLabel withBlock(nil): if isTrue(n.sons[0]): c.gen(n.sons[1]) - c.jmpBack(n, L1) + c.jmpBack(n, lab1) elif isNotOpr(n.sons[0]): var tmp = c.genx(n.sons[0].sons[1]) - let L2 = c.xjmp(n, opcTJmp, tmp) + let lab2 = c.xjmp(n, opcTJmp, tmp) c.freeTemp(tmp) c.gen(n.sons[1]) - c.jmpBack(n, L1) - c.patch(L2) + c.jmpBack(n, lab1) + c.patch(lab2) else: var tmp = c.genx(n.sons[0]) - let L2 = c.xjmp(n, opcFJmp, tmp) + let lab2 = c.xjmp(n, opcFJmp, tmp) c.freeTemp(tmp) c.gen(n.sons[1]) - c.jmpBack(n, L1) - c.patch(L2) + c.jmpBack(n, lab1) + c.patch(lab2) proc genBlock(c: PCtx; n: PNode; dest: var TDest) = let oldRegisterCount = c.prc.maxSlots @@ -342,26 +342,26 @@ proc genBlock(c: PCtx; n: PNode; dest: var TDest) = c.clearDest(n, dest) proc genBreak(c: PCtx; n: PNode) = - let L1 = c.xjmp(n, opcJmp) + let lab1 = c.xjmp(n, opcJmp) if n.sons[0].kind == nkSym: #echo cast[int](n.sons[0].sym) for i in countdown(c.prc.blocks.len-1, 0): if c.prc.blocks[i].label == n.sons[0].sym: - c.prc.blocks[i].fixups.add L1 + c.prc.blocks[i].fixups.add lab1 return globalError(c.config, n.info, "VM problem: cannot find 'break' target") else: - c.prc.blocks[c.prc.blocks.high].fixups.add L1 + c.prc.blocks[c.prc.blocks.high].fixups.add lab1 proc genIf(c: PCtx, n: PNode; dest: var TDest) = - # if (!expr1) goto L1; + # if (!expr1) goto lab1; # thenPart # goto LEnd - # L1: - # if (!expr2) goto L2; + # lab1: + # if (!expr2) goto lab2; # thenPart2 # goto LEnd - # L2: + # lab2: # elsePart # Lend: if dest < 0 and not isEmptyType(n.typ): dest = getTemp(c, n.typ) @@ -393,18 +393,18 @@ proc isTemp(c: PCtx; dest: TDest): bool = proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) = # asgn dest, a - # tjmp|fjmp L1 + # tjmp|fjmp lab1 # asgn dest, b - # L1: + # lab1: let copyBack = dest < 0 or not isTemp(c, dest) let tmp = if copyBack: getTemp(c, n.typ) else: TRegister dest c.gen(n.sons[1], tmp) - let L1 = c.xjmp(n, opc, tmp) + let lab1 = c.xjmp(n, opc, tmp) c.gen(n.sons[2], tmp) - c.patch(L1) + c.patch(lab1) if dest < 0: dest = tmp elif copyBack: @@ -452,14 +452,14 @@ proc unused(c: PCtx; n: PNode; x: TDest) {.inline.} = globalError(c.config, n.info, "not unused") proc genCase(c: PCtx; n: PNode; dest: var TDest) = - # if (!expr1) goto L1; + # if (!expr1) goto lab1; # thenPart # goto LEnd - # L1: - # if (!expr2) goto L2; + # lab1: + # if (!expr2) goto lab2; # thenPart2 # goto LEnd - # L2: + # lab2: # elsePart # Lend: if not isEmptyType(n.typ): @@ -820,25 +820,25 @@ proc genCastIntFloat(c: PCtx; n: PNode; dest: var TDest) = var unsignedIntegers = {tyUInt..tyUInt64, tyChar} let src = n.sons[1].typ.skipTypes(abstractRange)#.kind let dst = n.sons[0].typ.skipTypes(abstractRange)#.kind - let src_size = getSize(c.config, src) - let dst_size = getSize(c.config, dst) + let srcSize = getSize(c.config, src) + let dstSize = getSize(c.config, dst) if src.kind in allowedIntegers and dst.kind in allowedIntegers: let tmp = c.genx(n.sons[1]) if dest < 0: dest = c.getTemp(n[0].typ) c.gABC(n, opcAsgnInt, dest, tmp) - if dst_size != sizeof(BiggestInt): # don't do anything on biggest int types + if dstSize != sizeof(BiggestInt): # don't do anything on biggest int types if dst.kind in signedIntegers: # we need to do sign extensions - if dst_size <= src_size: + if dstSize <= srcSize: # Sign extension can be omitted when the size increases. - c.gABC(n, opcSignExtend, dest, TRegister(dst_size*8)) + c.gABC(n, opcSignExtend, dest, TRegister(dstSize*8)) elif dst.kind in unsignedIntegers: - if src.kind in signedIntegers or dst_size < src_size: + if src.kind in signedIntegers or dstSize < srcSize: # Cast from signed to unsigned always needs narrowing. Cast # from unsigned to unsigned only needs narrowing when target # is smaller than source. - c.gABC(n, opcNarrowU, dest, TRegister(dst_size*8)) + c.gABC(n, opcNarrowU, dest, TRegister(dstSize*8)) c.freeTemp(tmp) - elif src_size == dst_size and src.kind in allowedIntegers and + elif srcSize == dstSize and src.kind in allowedIntegers and dst.kind in {tyFloat, tyFloat32, tyFloat64}: let tmp = c.genx(n[1]) if dest < 0: dest = c.getTemp(n[0].typ) @@ -848,7 +848,7 @@ proc genCastIntFloat(c: PCtx; n: PNode; dest: var TDest) = c.gABC(n, opcAsgnFloat64FromInt, dest, tmp) c.freeTemp(tmp) - elif src_size == dst_size and src.kind in {tyFloat, tyFloat32, tyFloat64} and + elif srcSize == dstSize and src.kind in {tyFloat, tyFloat32, tyFloat64} and dst.kind in allowedIntegers: let tmp = c.genx(n[1]) if dest < 0: dest = c.getTemp(n[0].typ) @@ -1682,11 +1682,11 @@ proc genCheckedObjAccessAux(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags c.gABC(n, opcContainsSet, rs, setLit, discVal) c.freeTemp(setLit) # If the check fails let the user know - let L1 = c.xjmp(n, if negCheck: opcFJmp else: opcTJmp, rs) + let lab1 = c.xjmp(n, if negCheck: opcFJmp else: opcTJmp, rs) c.freeTemp(rs) # Not ideal but will do for the moment c.gABC(n, opcQuit) - c.patch(L1) + c.patch(lab1) proc genCheckedObjAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) = var objR: TDest = -1 |