mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
compiler almost free of deprecated expr/stmt names
This commit is contained in:
@@ -990,12 +990,12 @@ proc add*(father, son: PNode) =
|
||||
proc `[]`*(n: PNode, i: int): PNode {.inline.} =
|
||||
result = n.sons[i]
|
||||
|
||||
template `-|`*(b, s: expr): expr =
|
||||
template `-|`*(b, s: untyped): untyped =
|
||||
(if b >= 0: b else: s.len + b)
|
||||
|
||||
# son access operators with support for negative indices
|
||||
template `{}`*(n: PNode, i: int): expr = n[i -| n]
|
||||
template `{}=`*(n: PNode, i: int, s: PNode): stmt =
|
||||
template `{}`*(n: PNode, i: int): untyped = n[i -| n]
|
||||
template `{}=`*(n: PNode, i: int, s: PNode) =
|
||||
n.sons[i -| n] = s
|
||||
|
||||
when defined(useNodeIds):
|
||||
|
||||
@@ -113,7 +113,7 @@ proc genMergeInfo*(m: BModule): Rope =
|
||||
s.add("*/")
|
||||
result = s.rope
|
||||
|
||||
template `^`(pos: int): expr = L.buf[pos]
|
||||
template `^`(pos: int): untyped = L.buf[pos]
|
||||
|
||||
proc skipWhite(L: var TBaseLexer) =
|
||||
var pos = L.bufpos
|
||||
|
||||
@@ -129,7 +129,7 @@ proc ropecg(m: BModule, frmt: FormatStr, args: varargs[Rope]): Rope =
|
||||
if i - 1 >= start:
|
||||
add(result, substr(frmt, start, i - 1))
|
||||
|
||||
template rfmt(m: BModule, fmt: string, args: varargs[Rope]): expr =
|
||||
template rfmt(m: BModule, fmt: string, args: varargs[Rope]): untyped =
|
||||
ropecg(m, fmt, args)
|
||||
|
||||
proc appcg(m: BModule, c: var Rope, frmt: FormatStr,
|
||||
@@ -215,7 +215,7 @@ proc accessThreadLocalVar(p: BProc, s: PSym)
|
||||
proc emulatedThreadVars(): bool {.inline.}
|
||||
proc genProc(m: BModule, prc: PSym)
|
||||
|
||||
template compileToCpp(m: BModule): expr =
|
||||
template compileToCpp(m: BModule): untyped =
|
||||
gCmd == cmdCompileToCpp or sfCompileToCpp in m.module.flags
|
||||
|
||||
include "ccgtypes.nim"
|
||||
|
||||
@@ -728,12 +728,12 @@ proc simpleSlice*(a, b: PNode): BiggestInt =
|
||||
result = -1
|
||||
|
||||
|
||||
template isMul(x): expr = x.getMagic in someMul
|
||||
template isDiv(x): expr = x.getMagic in someDiv
|
||||
template isAdd(x): expr = x.getMagic in someAdd
|
||||
template isSub(x): expr = x.getMagic in someSub
|
||||
template isVal(x): expr = x.kind in {nkCharLit..nkUInt64Lit}
|
||||
template isIntVal(x, y): expr = x.intVal == y
|
||||
template isMul(x): untyped = x.getMagic in someMul
|
||||
template isDiv(x): untyped = x.getMagic in someDiv
|
||||
template isAdd(x): untyped = x.getMagic in someAdd
|
||||
template isSub(x): untyped = x.getMagic in someSub
|
||||
template isVal(x): untyped = x.kind in {nkCharLit..nkUInt64Lit}
|
||||
template isIntVal(x, y): untyped = x.intVal == y
|
||||
|
||||
import macros
|
||||
|
||||
@@ -776,8 +776,8 @@ proc isMinusOne(n: PNode): bool =
|
||||
proc pleViaModel(model: TModel; aa, bb: PNode): TImplication
|
||||
|
||||
proc ple(m: TModel; a, b: PNode): TImplication =
|
||||
template `<=?`(a,b): expr = ple(m,a,b) == impYes
|
||||
template `>=?`(a,b): expr = ple(m, nkIntLit.newIntNode(b), a) == impYes
|
||||
template `<=?`(a,b): untyped = ple(m,a,b) == impYes
|
||||
template `>=?`(a,b): untyped = ple(m, nkIntLit.newIntNode(b), a) == impYes
|
||||
|
||||
# 0 <= 3
|
||||
if a.isValue and b.isValue:
|
||||
|
||||
@@ -138,7 +138,7 @@ proc getLineInfo*(L: TLexer, tok: TToken): TLineInfo {.inline.} =
|
||||
proc isKeyword*(kind: TTokType): bool =
|
||||
result = (kind >= tokKeywordLow) and (kind <= tokKeywordHigh)
|
||||
|
||||
template ones(n: expr): expr = ((1 shl n)-1) # for utf-8 conversion
|
||||
template ones(n): untyped = ((1 shl n)-1) # for utf-8 conversion
|
||||
|
||||
proc isNimIdentifier*(s: string): bool =
|
||||
if s[0] in SymStartChars:
|
||||
@@ -893,10 +893,10 @@ proc scanComment(L: var TLexer, tok: var TToken) =
|
||||
inc(indent)
|
||||
|
||||
when defined(nimfix):
|
||||
template doContinue(): expr =
|
||||
template doContinue(): untyped =
|
||||
buf[pos] == '#' and (col == indent or lastBackslash > 0)
|
||||
else:
|
||||
template doContinue(): expr =
|
||||
template doContinue(): untyped =
|
||||
buf[pos] == '#' and buf[pos+1] == '#'
|
||||
if doContinue():
|
||||
tok.literal.add "\n"
|
||||
@@ -942,9 +942,9 @@ proc skip(L: var TLexer, tok: var TToken) =
|
||||
break
|
||||
tok.strongSpaceA = 0
|
||||
when defined(nimfix):
|
||||
template doBreak(): expr = buf[pos] > ' '
|
||||
template doBreak(): untyped = buf[pos] > ' '
|
||||
else:
|
||||
template doBreak(): expr =
|
||||
template doBreak(): untyped =
|
||||
buf[pos] > ' ' and (buf[pos] != '#' or buf[pos+1] == '#')
|
||||
if doBreak():
|
||||
tok.indent = indent
|
||||
|
||||
@@ -217,14 +217,14 @@ when defined(nimfix):
|
||||
of 'a'..'z': result = getIdent(toLower(x.s[0]) & x.s.substr(1))
|
||||
else: result = x
|
||||
|
||||
template fixSpelling(n: PNode; ident: PIdent; op: expr) =
|
||||
template fixSpelling(n: PNode; ident: PIdent; op: untyped) =
|
||||
let alt = ident.altSpelling
|
||||
result = op(c, alt).skipAlias(n)
|
||||
if result != nil:
|
||||
prettybase.replaceDeprecated(n.info, ident, alt)
|
||||
return result
|
||||
else:
|
||||
template fixSpelling(n: PNode; ident: PIdent; op: expr) = discard
|
||||
template fixSpelling(n: PNode; ident: PIdent; op: untyped) = discard
|
||||
|
||||
proc errorUseQualifier*(c: PContext; info: TLineInfo; s: PSym) =
|
||||
var err = "Error: ambiguous identifier: '" & s.name.s & "'"
|
||||
|
||||
@@ -38,7 +38,7 @@ proc getModule*(fileIdx: int32): PSym =
|
||||
if fileIdx >= 0 and fileIdx < gCompiledModules.len:
|
||||
result = gCompiledModules[fileIdx]
|
||||
|
||||
template hash(x: PSym): expr =
|
||||
template hash(x: PSym): untyped =
|
||||
gMemCacheData[x.position].hash
|
||||
|
||||
proc hashChanged(fileIdx: int32): bool =
|
||||
|
||||
@@ -121,7 +121,7 @@ proc toTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode =
|
||||
e = b
|
||||
inc(e)
|
||||
|
||||
template nodeSetOp(a, b: PNode, op: expr) {.dirty.} =
|
||||
template nodeSetOp(a, b: PNode, op: untyped) {.dirty.} =
|
||||
var x, y: TBitSet
|
||||
toBitSet(a, x)
|
||||
toBitSet(b, y)
|
||||
|
||||
@@ -202,7 +202,7 @@ proc isRightAssociative(tok: TToken): bool {.inline.} =
|
||||
|
||||
proc getPrecedence(tok: TToken, strongSpaces: bool): int =
|
||||
## Calculates the precedence of the given token.
|
||||
template considerStrongSpaces(x): expr =
|
||||
template considerStrongSpaces(x): untyped =
|
||||
x + (if strongSpaces: 100 - tok.strongSpaceA.int*10 else: 0)
|
||||
|
||||
case tok.tokType
|
||||
@@ -214,7 +214,7 @@ proc getPrecedence(tok: TToken, strongSpaces: bool): int =
|
||||
if L > 1 and tok.ident.s[L-1] == '>' and
|
||||
tok.ident.s[L-2] in {'-', '~', '='}: return considerStrongSpaces(1)
|
||||
|
||||
template considerAsgn(value: expr) =
|
||||
template considerAsgn(value: untyped) =
|
||||
result = if tok.ident.s[L-1] == '=': 1 else: value
|
||||
|
||||
case relevantChar
|
||||
|
||||
@@ -64,7 +64,7 @@ const
|
||||
const
|
||||
vintDelta = 5
|
||||
|
||||
template encodeIntImpl(self: expr) =
|
||||
template encodeIntImpl(self) =
|
||||
var d: char
|
||||
var v = x
|
||||
var rem = v mod 190
|
||||
|
||||
@@ -87,7 +87,7 @@ proc destroyCase(c: PContext, n: PNode, holder: PNode): PNode =
|
||||
result = nil
|
||||
|
||||
proc destroyFieldOrFields(c: PContext, field: PNode, holder: PNode): PNode =
|
||||
template maybeAddLine(e: expr): stmt =
|
||||
template maybeAddLine(e) =
|
||||
let stmt = e
|
||||
if stmt != nil:
|
||||
if result == nil: result = newNode(nkStmtList)
|
||||
|
||||
@@ -1363,7 +1363,7 @@ proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
|
||||
n.sons[1] = takeImplicitAddr(c, ri)
|
||||
x.typ.flags.incl tfVarIsPtr
|
||||
|
||||
template resultTypeIsInferrable(typ: PType): expr =
|
||||
template resultTypeIsInferrable(typ: PType): untyped =
|
||||
typ.isMetaType and typ.kind != tyTypeDesc
|
||||
|
||||
proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||
@@ -1888,7 +1888,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
||||
# the correct branch. Otherwise the AST will be passed through semStmt.
|
||||
result = nil
|
||||
|
||||
template setResult(e: expr) =
|
||||
template setResult(e: untyped) =
|
||||
if semCheck: result = semExpr(c, e) # do not open a new scope!
|
||||
else: result = e
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ proc semGenericStmtScope(c: PContext, n: PNode,
|
||||
result = semGenericStmt(c, n, flags, ctx)
|
||||
closeScope(c)
|
||||
|
||||
template macroToExpand(s: expr): expr =
|
||||
template macroToExpand(s): untyped =
|
||||
s.kind in {skMacro, skTemplate} and (s.typ.len == 1 or sfAllUntyped in s.flags)
|
||||
|
||||
template macroToExpandSym(s: expr): expr =
|
||||
template macroToExpandSym(s): untyped =
|
||||
s.kind in {skMacro, skTemplate} and (s.typ.len == 1)
|
||||
|
||||
proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym,
|
||||
|
||||
@@ -121,7 +121,7 @@ proc checkLocal(c: AnalysisCtx; n: PNode) =
|
||||
else:
|
||||
for i in 0 .. <n.safeLen: checkLocal(c, n.sons[i])
|
||||
|
||||
template `?`(x): expr = x.renderTree
|
||||
template `?`(x): untyped = x.renderTree
|
||||
|
||||
proc checkLe(c: AnalysisCtx; a, b: PNode) =
|
||||
case proveLe(c.guards, a, b)
|
||||
|
||||
@@ -151,7 +151,7 @@ proc guardDotAccess(a: PEffects; n: PNode) =
|
||||
guardGlobal(a, n, g)
|
||||
|
||||
proc makeVolatile(a: PEffects; s: PSym) {.inline.} =
|
||||
template compileToCpp(a): expr =
|
||||
template compileToCpp(a): untyped =
|
||||
gCmd == cmdCompileToCpp or sfCompileToCpp in getModule(a.owner).flags
|
||||
if a.inTryStmt > 0 and not compileToCpp(a):
|
||||
incl(s.flags, sfVolatile)
|
||||
@@ -459,7 +459,7 @@ proc documentRaises*(n: PNode) =
|
||||
if p4 != nil: n.sons[pragmasPos].add p4
|
||||
if p5 != nil: n.sons[pragmasPos].add p5
|
||||
|
||||
template notGcSafe(t): expr = {tfGcSafe, tfNoSideEffect} * t.flags == {}
|
||||
template notGcSafe(t): untyped = {tfGcSafe, tfNoSideEffect} * t.flags == {}
|
||||
|
||||
proc importedFromC(n: PNode): bool =
|
||||
# when imported from C, we assume GC-safety.
|
||||
|
||||
@@ -632,7 +632,7 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||
c.patterns.add(s)
|
||||
|
||||
proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||
template templToExpand(s: expr): expr =
|
||||
template templToExpand(s: untyped): untyped =
|
||||
s.kind == skTemplate and (s.typ.len == 1 or sfAllUntyped in s.flags)
|
||||
|
||||
proc newParam(c: var TemplCtx, n: PNode, s: PSym): PNode =
|
||||
|
||||
@@ -754,18 +754,18 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
||||
addDecl(c, s)
|
||||
|
||||
# XXX: There are codegen errors if this is turned into a nested proc
|
||||
template liftingWalk(typ: PType, anonFlag = false): expr =
|
||||
template liftingWalk(typ: PType, anonFlag = false): untyped =
|
||||
liftParamType(c, procKind, genericParams, typ, paramName, info, anonFlag)
|
||||
#proc liftingWalk(paramType: PType, anon = false): PType =
|
||||
|
||||
var paramTypId = if not anon and paramType.sym != nil: paramType.sym.name
|
||||
else: nil
|
||||
|
||||
template maybeLift(typ: PType): expr =
|
||||
template maybeLift(typ: PType): untyped =
|
||||
let lifted = liftingWalk(typ)
|
||||
(if lifted != nil: lifted else: typ)
|
||||
|
||||
template addImplicitGeneric(e: expr): expr =
|
||||
template addImplicitGeneric(e): untyped =
|
||||
addImplicitGenericImpl(e, paramTypId)
|
||||
|
||||
case paramType.kind:
|
||||
|
||||
@@ -511,6 +511,6 @@ proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
||||
popInfoContext()
|
||||
|
||||
template generateTypeInstance*(p: PContext, pt: TIdTable, arg: PNode,
|
||||
t: PType): expr =
|
||||
t: PType): untyped =
|
||||
generateTypeInstance(p, pt, arg.info, t)
|
||||
|
||||
|
||||
@@ -575,7 +575,7 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
|
||||
typ = ff.sons[i]
|
||||
param: PSym
|
||||
|
||||
template paramSym(kind): expr =
|
||||
template paramSym(kind): untyped =
|
||||
newSym(kind, typeParamName, body.sym, body.sym.info)
|
||||
|
||||
case typ.kind
|
||||
@@ -1585,7 +1585,7 @@ proc incrIndexType(t: PType) =
|
||||
assert t.kind == tyArrayConstr
|
||||
inc t.sons[0].n.sons[1].intVal
|
||||
|
||||
template isVarargsUntyped(x): expr =
|
||||
template isVarargsUntyped(x): untyped =
|
||||
x.kind == tyVarargs and x.sons[0].kind == tyExpr and
|
||||
tfOldSchoolExprStmt notin x.sons[0].flags
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ template decodeBImm(k: untyped) {.dirty.} =
|
||||
let imm = instr.regC - byteExcess
|
||||
ensureKind(k)
|
||||
|
||||
template decodeBx(k: expr) {.dirty.} =
|
||||
template decodeBx(k: untyped) {.dirty.} =
|
||||
let rbx = instr.regBx - wordExcess
|
||||
ensureKind(k)
|
||||
|
||||
@@ -162,7 +162,7 @@ proc moveConst(x: var TFullReg, y: TFullReg) =
|
||||
|
||||
# this seems to be the best way to model the reference semantics
|
||||
# of system.NimNode:
|
||||
template asgnRef(x, y: expr) = moveConst(x, y)
|
||||
template asgnRef(x, y: untyped) = moveConst(x, y)
|
||||
|
||||
proc copyValue(src: PNode): PNode =
|
||||
if src == nil or nfIsRef in src.flags:
|
||||
@@ -233,7 +233,7 @@ proc regToNode(x: TFullReg): PNode =
|
||||
of rkRegisterAddr: result = regToNode(x.regAddr[])
|
||||
of rkNodeAddr: result = x.nodeAddr[]
|
||||
|
||||
template getstr(a: expr): expr =
|
||||
template getstr(a: untyped): untyped =
|
||||
(if a.kind == rkNode: a.node.strVal else: $chr(int(a.intVal)))
|
||||
|
||||
proc pushSafePoint(f: PStackFrame; pc: int) =
|
||||
|
||||
@@ -88,27 +88,27 @@ proc mapTypeToBracketX(name: string; m: TMagic; t: PType; info: TLineInfo;
|
||||
proc mapTypeToAstX(t: PType; info: TLineInfo;
|
||||
inst=false; allowRecursionX=false): PNode =
|
||||
var allowRecursion = allowRecursionX
|
||||
template atomicType(name, m): expr = atomicTypeX(name, m, t, info)
|
||||
template mapTypeToAst(t,info): expr = mapTypeToAstX(t, info, inst)
|
||||
template mapTypeToAstR(t,info): expr = mapTypeToAstX(t, info, inst, true)
|
||||
template mapTypeToAst(t,i,info): expr =
|
||||
template atomicType(name, m): untyped = atomicTypeX(name, m, t, info)
|
||||
template mapTypeToAst(t,info): untyped = mapTypeToAstX(t, info, inst)
|
||||
template mapTypeToAstR(t,info): untyped = mapTypeToAstX(t, info, inst, true)
|
||||
template mapTypeToAst(t,i,info): untyped =
|
||||
if i<t.len and t.sons[i]!=nil: mapTypeToAstX(t.sons[i], info, inst)
|
||||
else: ast.emptyNode
|
||||
template mapTypeToBracket(name, m, t, info): expr =
|
||||
template mapTypeToBracket(name, m, t, info): untyped =
|
||||
mapTypeToBracketX(name, m, t, info, inst)
|
||||
template newNodeX(kind):expr =
|
||||
template newNodeX(kind): untyped =
|
||||
newNodeIT(kind, if t.n.isNil: info else: t.n.info, t)
|
||||
template newIdent(s):expr =
|
||||
template newIdent(s): untyped =
|
||||
var r = newNodeX(nkIdent)
|
||||
r.add !s
|
||||
r
|
||||
template newIdentDefs(n,t):expr =
|
||||
template newIdentDefs(n,t): untyped =
|
||||
var id = newNodeX(nkIdentDefs)
|
||||
id.add n # name
|
||||
id.add mapTypeToAst(t, info) # type
|
||||
id.add ast.emptyNode # no assigned value
|
||||
id
|
||||
template newIdentDefs(s):expr = newIdentDefs(s, s.typ)
|
||||
template newIdentDefs(s): untyped = newIdentDefs(s, s.typ)
|
||||
|
||||
if inst:
|
||||
if t.sym != nil: # if this node has a symbol
|
||||
|
||||
@@ -1266,7 +1266,7 @@ proc checkCanEval(c: PCtx; n: PNode) =
|
||||
proc isTemp(c: PCtx; dest: TDest): bool =
|
||||
result = dest >= 0 and c.prc.slots[dest].kind >= slotTempUnknown
|
||||
|
||||
template needsAdditionalCopy(n): expr =
|
||||
template needsAdditionalCopy(n): untyped =
|
||||
not c.isTemp(dest) and not fitsRegister(n.typ)
|
||||
|
||||
proc skipDeref(n: PNode): PNode =
|
||||
@@ -1404,7 +1404,7 @@ proc genRdVar(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
|
||||
# see tests/t99bott for an example that triggers it:
|
||||
cannotEval(n)
|
||||
|
||||
template needsRegLoad(): expr =
|
||||
template needsRegLoad(): untyped =
|
||||
gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar}))
|
||||
|
||||
proc genArrAccess2(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
||||
|
||||
Reference in New Issue
Block a user