case consistency part 2

This commit is contained in:
Araq 2013-12-27 16:35:21 +01:00
commit a427648c48
9 changed files with 90 additions and 94 deletions

View file

@ -49,7 +49,7 @@ proc parseExpr(L: var TLexer, tok: var TToken): bool =
var b = parseAndExpr(L, tok)
result = result or b
proc EvalppIf(L: var TLexer, tok: var TToken): bool =
proc evalppIf(L: var TLexer, tok: var TToken): bool =
ppGetTok(L, tok) # skip 'if' or 'elif'
result = parseExpr(L, tok)
if tok.tokType == tkColon: ppGetTok(L, tok)

View file

@ -273,17 +273,13 @@ proc check(c: PGen, n: PNode) =
nkMacroDef, nkConverterDef:
checkDef(c, n[namePos])
for i in namePos+1 .. <n.len: check(c, n.sons[i])
of nkVarSection, nkLetSection:
for i in countup(0, sonsLen(n) - 1):
let a = n.sons[i]
if a.kind == nkCommentStmt: continue
if a.kind != nkIdentDefs and a.kind != nkVarTuple:
globalError(a.info, errGenerated, "invalid ast")
checkMinSonsLen(a, 3)
let L = len(a)
for j in countup(0, L-3): checkDef(c, a.sons[j])
check(c, a.sons[L-2])
check(c, a.sons[L-1])
of nkIdentDefs, nkVarTuple:
let a = n
checkMinSonsLen(a, 3)
let L = len(a)
for j in countup(0, L-3): checkDef(c, a.sons[j])
check(c, a.sons[L-2])
check(c, a.sons[L-1])
of nkTypeSection, nkConstSection:
for i in countup(0, sonsLen(n) - 1):
let a = n.sons[i]

View file

@ -47,11 +47,11 @@ proc searchInstTypes*(key: PType): PType =
# types such as TChannel[empty]. Why?
# See the notes for PActor in handleGenericInvokation
return
block MatchType:
block matchType:
for j in 1 .. high(key.sons):
# XXX sameType is not really correct for nested generics?
if not sameType(inst.sons[j], key.sons[j]):
break MatchType
break matchType
return inst

View file

@ -387,7 +387,7 @@ proc mutateType(t: PType, iter: TTypeMutator, closure: PObject): PType =
var marker = InitIntSet()
result = mutateTypeAux(marker, t, iter, closure)
proc ValueToString(a: PNode): string =
proc valueToString(a: PNode): string =
case a.kind
of nkCharLit..nkUInt64Lit: result = $(a.intVal)
of nkFloatLit..nkFloat128Lit: result = $(a.floatVal)
@ -692,7 +692,7 @@ proc equalParams(a, b: PNode): TParamsEquality =
result = paramsIncompatible # overloading by different
# result types does not work
proc SameLiteral(x, y: PNode): bool =
proc sameLiteral(x, y: PNode): bool =
if x.kind == y.kind:
case x.kind
of nkCharLit..nkInt64Lit: result = x.intVal == y.intVal
@ -700,7 +700,7 @@ proc SameLiteral(x, y: PNode): bool =
of nkNilLit: result = true
else: assert(false)
proc SameRanges(a, b: PNode): bool =
proc sameRanges(a, b: PNode): bool =
result = SameLiteral(a.sons[0], b.sons[0]) and
SameLiteral(a.sons[1], b.sons[1])