diff options
author | Clay Sweetser <clay.sweetser@gmail.com> | 2014-05-24 08:10:40 -0400 |
---|---|---|
committer | Clay Sweetser <clay.sweetser@gmail.com> | 2014-05-24 08:10:40 -0400 |
commit | 055cdb2cdf2d96f8990da17abfce1a9c442d36a3 (patch) | |
tree | e78a9563a925136f8fa40fc07070b85ae524c8c6 /compiler | |
parent | b54f66eeff4c9977a7e855f9f310216f59729860 (diff) | |
download | Nim-055cdb2cdf2d96f8990da17abfce1a9c442d36a3.tar.gz |
Renamed 'considerAcc' to 'considerAccents' for clarity
Added documentation string to 'considerAccents' Modified renderParamType's assertion to allow nkAcc nodes.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/importer.nim | 4 | ||||
-rw-r--r-- | compiler/lookups.nim | 20 | ||||
-rw-r--r-- | compiler/pragmas.nim | 2 | ||||
-rw-r--r-- | compiler/sem.nim | 4 | ||||
-rw-r--r-- | compiler/semcall.nim | 2 | ||||
-rw-r--r-- | compiler/semexprs.nim | 10 | ||||
-rw-r--r-- | compiler/semgnrc.nim | 4 | ||||
-rw-r--r-- | compiler/semstmts.nim | 4 | ||||
-rw-r--r-- | compiler/semtempl.nim | 4 | ||||
-rw-r--r-- | compiler/semtypes.nim | 2 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 6 | ||||
-rw-r--r-- | compiler/typesrenderer.nim | 4 |
12 files changed, 33 insertions, 33 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index 7a73f2bbf..62fff63ee 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -93,7 +93,7 @@ proc rawImportSymbol(c: PContext, s: PSym) = if hasPattern(s): addPattern(c, s) proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = - let ident = lookups.considerAcc(n) + let ident = lookups.considerAccents(n) let s = strTableGet(fromMod.tab, ident) if s == nil: localError(n.info, errUndeclaredIdentifier, ident.s) @@ -193,7 +193,7 @@ proc evalImportExcept*(c: PContext, n: PNode): PNode = addDecl(c, m) # add symbol to symbol table of module var exceptSet = initIntSet() for i in countup(1, sonsLen(n) - 1): - let ident = lookups.considerAcc(n.sons[i]) + let ident = lookups.considerAccents(n.sons[i]) exceptSet.incl(ident.id) importAllSymbolsExcept(c, m, exceptSet) importForwarded(c, m.ast, exceptSet) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 60125177c..c08e2ce5c 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -15,14 +15,14 @@ import proc ensureNoMissingOrUnusedSymbols(scope: PScope) -proc considerAcc*(n: PNode): PIdent = +proc considerAccents*(n: PNode): PIdent = case n.kind of nkIdent: result = n.ident of nkSym: result = n.sym.name of nkAccQuoted: case n.len of 0: globalError(n.info, errIdentifierExpected, renderTree(n)) - of 1: result = considerAcc(n.sons[0]) + of 1: result = considerAccents(n.sons[0]) else: var id = "" for i in 0.. <n.len: @@ -82,10 +82,10 @@ proc searchInScopes*(c: PContext, s: PIdent, filter: TSymKinds): PSym = proc errorSym*(c: PContext, n: PNode): PSym = ## creates an error symbol to avoid cascading errors (for IDE support) var m = n - # ensure that 'considerAcc' can't fail: + # ensure that 'considerAccents' can't fail: if m.kind == nkDotExpr: m = m.sons[1] let ident = if m.kind in {nkIdent, nkSym, nkAccQuoted}: - considerAcc(m) + considerAccents(m) else: getIdent("err:" & renderTree(m)) result = newSym(skError, ident, getCurrOwner(), n.info) @@ -189,7 +189,7 @@ proc lookUp*(c: PContext, n: PNode): PSym = of nkSym: result = n.sym of nkAccQuoted: - var ident = considerAcc(n) + var ident = considerAccents(n) result = searchInScopes(c, ident) if result == nil: localError(n.info, errUndeclaredIdentifier, ident.s) @@ -208,7 +208,7 @@ type proc qualifiedLookUp*(c: PContext, n: PNode, flags = {checkUndeclared}): PSym = case n.kind of nkIdent, nkAccQuoted: - var ident = considerAcc(n) + var ident = considerAccents(n) result = searchInScopes(c, ident) if result == nil and checkUndeclared in flags: localError(n.info, errUndeclaredIdentifier, ident.s) @@ -228,7 +228,7 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags = {checkUndeclared}): PSym = if n.sons[1].kind == nkIdent: ident = n.sons[1].ident elif n.sons[1].kind == nkAccQuoted: - ident = considerAcc(n.sons[1]) + ident = considerAccents(n.sons[1]) if ident != nil: if m == c.module: result = strTableGet(c.topLevelScope.symbols, ident) @@ -251,7 +251,7 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags = {checkUndeclared}): PSym = proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = case n.kind of nkIdent, nkAccQuoted: - var ident = considerAcc(n) + var ident = considerAccents(n) o.scope = c.currentScope o.mode = oimNoQualifier while true: @@ -272,7 +272,7 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = if n.sons[1].kind == nkIdent: ident = n.sons[1].ident elif n.sons[1].kind == nkAccQuoted: - ident = considerAcc(n.sons[1]) + ident = considerAccents(n.sons[1]) if ident != nil: if o.m == c.module: # a module may access its private members: @@ -354,5 +354,5 @@ when false: if sfImmediate in a.flags: return a a = nextOverloadIter(o, c, n) if result == nil and checkUndeclared in flags: - localError(n.info, errUndeclaredIdentifier, n.considerAcc.s) + localError(n.info, errUndeclaredIdentifier, n.considerAccents.s) result = errorSym(c, n) diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index db9fe7cbe..fea29249d 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -517,7 +517,7 @@ proc pragmaUses(c: PContext, n: PNode) = proc processExc(c: PContext, x: PNode): PNode = if x.kind in {nkAccQuoted, nkIdent, nkSym, nkOpenSymChoice, nkClosedSymChoice}: - if considerAcc(x).s == "*": + if considerAccents(x).s == "*": return newSymNode(ast.anyGlobal) result = c.semExpr(c, x) if result.kind != nkSym or sfGlobal notin result.sym.flags: diff --git a/compiler/sem.nim b/compiler/sem.nim index 7d129caf4..3bde11744 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -134,7 +134,7 @@ proc isTopLevel(c: PContext): bool {.inline.} = result = c.currentScope.depthLevel <= 2 proc newSymS(kind: TSymKind, n: PNode, c: PContext): PSym = - result = newSym(kind, considerAcc(n), getCurrOwner(), n.info) + result = newSym(kind, considerAccents(n), getCurrOwner(), n.info) proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym = # like newSymS, but considers gensym'ed symbols @@ -147,7 +147,7 @@ proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym = # template; we must fix it here: see #909 result.owner = getCurrOwner() else: - result = newSym(kind, considerAcc(n), getCurrOwner(), n.info) + result = newSym(kind, considerAccents(n), getCurrOwner(), n.info) proc semIdentVis(c: PContext, kind: TSymKind, n: PNode, allowed: TSymFlags): PSym diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 04d280ce2..1ee493f05 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -168,7 +168,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode, pickBest(callOp) if overloadsState == csEmpty and result.state == csEmpty: - localError(n.info, errUndeclaredIdentifier, considerAcc(f).s) + localError(n.info, errUndeclaredIdentifier, considerAccents(f).s) return elif result.state != csMatch: if nfExprCall in n.flags: diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 9ea93a15e..f8e0be157 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -387,7 +387,7 @@ proc semOpAux(c: PContext, n: PNode) = var a = n.sons[i] if a.kind == nkExprEqExpr and sonsLen(a) == 2: var info = a.sons[0].info - a.sons[0] = newIdentNode(considerAcc(a.sons[0]), info) + a.sons[0] = newIdentNode(considerAccents(a.sons[0]), info) a.sons[1] = semExprWithType(c, a.sons[1], flags) a.typ = a.sons[1].typ else: @@ -970,7 +970,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode = n.sons[0] = semExprWithType(c, n.sons[0], flags+{efDetermineType}) #restoreOldStyleType(n.sons[0]) - var i = considerAcc(n.sons[1]) + var i = considerAccents(n.sons[1]) var ty = n.sons[0].typ var f: PSym = nil result = nil @@ -1051,7 +1051,7 @@ proc dotTransformation(c: PContext, n: PNode): PNode = addSon(result, n.sons[1]) addSon(result, copyTree(n[0])) else: - var i = considerAcc(n.sons[1]) + var i = considerAccents(n.sons[1]) result = newNodeI(nkDotCall, n.info) result.flags.incl nfDotField addSon(result, newIdentNode(i, n[1].info)) @@ -1135,7 +1135,7 @@ proc semArrayAccess(c: PContext, n: PNode, flags: TExprFlags): PNode = result = semExpr(c, buildOverloadedSubscripts(n, getIdent"[]")) proc propertyWriteAccess(c: PContext, n, nOrig, a: PNode): PNode = - var id = considerAcc(a[1]) + var id = considerAccents(a[1]) var setterId = newIdentNode(getIdent(id.s & '='), n.info) # a[0] is already checked for semantics, that does ``builtinFieldAccess`` # this is ugly. XXX Semantic checking should use the ``nfSem`` flag for @@ -1369,7 +1369,7 @@ proc lookUpForDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PSym = else: localError(n.sons[1].info, errIdentifierExpected, "") of nkAccQuoted: - result = lookUpForDefined(c, considerAcc(n), onlyCurrentScope) + result = lookUpForDefined(c, considerAccents(n), onlyCurrentScope) of nkSym: result = n.sym else: diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 63beb15b0..5a0457970 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -69,7 +69,7 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode = proc lookup(c: PContext, n: PNode, flags: TSemGenericFlags, ctx: var TIntSet): PNode = result = n - let ident = considerAcc(n) + let ident = considerAccents(n) var s = searchInScopes(c, ident) if s == nil: if ident.id notin ctx and withinMixin notin flags: @@ -114,7 +114,7 @@ proc semGenericStmt(c: PContext, n: PNode, let fn = n.sons[0] var s = qualifiedLookUp(c, fn, {}) if s == nil and withinMixin notin flags and - fn.kind in {nkIdent, nkAccQuoted} and considerAcc(fn).id notin ctx: + fn.kind in {nkIdent, nkAccQuoted} and considerAccents(fn).id notin ctx: localError(n.info, errUndeclaredIdentifier, fn.renderTree) var first = 0 diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c2827905c..b0afd7230 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -868,7 +868,7 @@ proc lookupMacro(c: PContext, n: PNode): PSym = result = n.sym if result.kind notin {skMacro, skTemplate}: result = nil else: - result = searchInScopes(c, considerAcc(n), {skMacro, skTemplate}) + result = searchInScopes(c, considerAccents(n), {skMacro, skTemplate}) proc semProcAnnotation(c: PContext, prc: PNode): PNode = var n = prc.sons[pragmasPos] @@ -879,7 +879,7 @@ proc semProcAnnotation(c: PContext, prc: PNode): PNode = let m = lookupMacro(c, key) if m == nil: if key.kind == nkIdent and key.ident.id == ord(wDelegator): - if considerAcc(prc.sons[namePos]).s == "()": + if considerAccents(prc.sons[namePos]).s == "()": prc.sons[namePos] = newIdentNode(idDelegator, prc.info) prc.sons[pragmasPos] = copyExcept(n, i) else: diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index ad34eea65..338812b94 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -93,7 +93,7 @@ proc semBindStmt(c: PContext, n: PNode, toBind: var TIntSet): PNode = proc semMixinStmt(c: PContext, n: PNode, toMixin: var TIntSet): PNode = for i in 0 .. < n.len: - toMixin.incl(considerAcc(n.sons[i]).id) + toMixin.incl(considerAccents(n.sons[i]).id) result = newNodeI(nkEmpty, n.info) proc replaceIdentBySym(n: var PNode, s: PNode) = @@ -151,7 +151,7 @@ proc onlyReplaceParams(c: var TemplCtx, n: PNode): PNode = result.sons[i] = onlyReplaceParams(c, n.sons[i]) proc newGenSym(kind: TSymKind, n: PNode, c: var TemplCtx): PSym = - result = newSym(kind, considerAcc(n), c.owner, n.info) + result = newSym(kind, considerAccents(n), c.owner, n.info) incl(result.flags, sfGenSym) incl(result.flags, sfShadowed) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 8fcb6ea99..508393903 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -116,7 +116,7 @@ proc semVarargs(c: PContext, n: PNode, prev: PType): PType = var base = semTypeNode(c, n.sons[1], nil) addSonSkipIntLit(result, base) if sonsLen(n) == 3: - result.n = newIdentNode(considerAcc(n.sons[2]), n.sons[2].info) + result.n = newIdentNode(considerAccents(n.sons[2]), n.sons[2].info) else: localError(n.info, errXExpectsOneTypeParam, "varargs") addSonSkipIntLit(result, errorType(c)) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 4b91a067e..5c5f6970e 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -497,11 +497,11 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate, proc shouldSkipDistinct(rules: PNode, callIdent: PIdent): bool = if rules.kind == nkWith: for r in rules: - if r.considerAcc == callIdent: return true + if r.considerAccents == callIdent: return true return false else: for r in rules: - if r.considerAcc == callIdent: return false + if r.considerAccents == callIdent: return false return true proc maybeSkipDistinct(t: PType, callee: PSym): PType = @@ -1302,7 +1302,7 @@ proc prepareOperand(c: PContext; a: PNode): PNode = proc prepareNamedParam(a: PNode) = if a.sons[0].kind != nkIdent: var info = a.sons[0].info - a.sons[0] = newIdentNode(considerAcc(a.sons[0]), info) + a.sons[0] = newIdentNode(considerAccents(a.sons[0]), info) proc arrayConstr(c: PContext, n: PNode): PType = result = newTypeS(tyArrayConstr, c) diff --git a/compiler/typesrenderer.nim b/compiler/typesrenderer.nim index 790bd1047..f3121a0b4 100644 --- a/compiler/typesrenderer.nim +++ b/compiler/typesrenderer.nim @@ -1,4 +1,4 @@ -import renderer, strutils, ast, msgs, types +import renderer, strutils, ast, msgs, types, astalgo const defaultParamSeparator* = "," @@ -92,7 +92,7 @@ proc renderParamTypes(found: var seq[string], n: PNode) = if not typ.isNil: typeStr = typeToString(typ, preferExported) if typeStr.len < 1: return for i in 0 .. <typePos: - assert n[i].kind == nkIdent + assert ((n[i].kind == nkIdent) or (n[i].kind == nkAccQuoted)) found.add(typeStr) else: internalError(n.info, "renderParamTypes(found,n) with " & $n.kind) |