Merge branch 'master' of github.com:Araq/Nimrod

This commit is contained in:
Araq 2013-02-19 07:07:20 +01:00
commit 4a51209e9f
2 changed files with 30 additions and 20 deletions

View file

@ -1655,7 +1655,7 @@ proc semCaseExpr(c: PContext, caseStmt: PNode): PNode =
proc fixImmediateParams(n: PNode): PNode = proc fixImmediateParams(n: PNode): PNode =
# XXX: Temporary work-around until we carry out # XXX: Temporary work-around until we carry out
# the planned overload resolution reforms # the planned overload resolution reforms
for i in 1 .. <n.len: for i in 1 .. <safeLen(n):
if n[i].kind == nkDo: n.sons[i] = n[i][bodyPos] if n[i].kind == nkDo: n.sons[i] = n[i][bodyPos]
result = n result = n

View file

@ -393,15 +393,7 @@ proc rangeToStr(n: PNode): string =
assert(n.kind == nkRange) assert(n.kind == nkRange)
result = ValueToString(n.sons[0]) & ".." & ValueToString(n.sons[1]) result = ValueToString(n.sons[0]) & ".." & ValueToString(n.sons[1])
proc constraintsToStr(t: PType): string = const
let sep = if tfAny in t.flags: " or " else: " and "
result = ""
for i in countup(0, t.sons.len - 1):
if i > 0: result.add(sep)
result.add(t.sons[i].typeToString)
proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
const
typeToStr: array[TTypeKind, string] = ["None", "bool", "Char", "empty", typeToStr: array[TTypeKind, string] = ["None", "bool", "Char", "empty",
"Array Constructor [$1]", "nil", "expr", "stmt", "typeDesc", "Array Constructor [$1]", "nil", "expr", "stmt", "typeDesc",
"GenericInvokation", "GenericBody", "GenericInst", "GenericParam", "GenericInvokation", "GenericBody", "GenericInst", "GenericParam",
@ -413,6 +405,24 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
"uint", "uint8", "uint16", "uint32", "uint64", "uint", "uint8", "uint16", "uint32", "uint64",
"bignum", "const ", "bignum", "const ",
"!", "varargs[$1]", "iter[$1]", "Error Type", "TypeClass"] "!", "varargs[$1]", "iter[$1]", "Error Type", "TypeClass"]
proc constraintsToStr(t: PType): string =
proc consToStr(t: PType): string =
if t.len > 0: result = t.typeToString
else: result = typeToStr[t.kind].strip
# better error messages are nice:
case t.len
of 0: result = "constraint[]"
of 1: result = "constraint[" & consToStr(t.sons[0]) & "]"
else:
let sep = if tfAny in t.flags: " or " else: " and "
result = ""
for i in countup(0, t.len - 1):
if i > 0: result.add(sep)
result.add(t.sons[i].consToStr)
proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
var t = typ var t = typ
result = "" result = ""
if t == nil: return if t == nil: return
@ -433,12 +443,12 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
add(result, typeToString(t.sons[i])) add(result, typeToString(t.sons[i]))
add(result, ']') add(result, ']')
of tyTypeDesc: of tyTypeDesc:
if t.sons == nil or t.sons.len == 0: result = "typedesc" if t.len == 0: result = "typedesc"
else: result = "typedesc[" & constraintsToStr(t) & "]" else: result = "typedesc[" & constraintsToStr(t) & "]"
of tyTypeClass: of tyTypeClass:
result = constraintsToStr(t) result = constraintsToStr(t)
of tyExpr: of tyExpr:
if t.sons.len == 0: result = "expr" if t.len == 0: result = "expr"
else: result = "expr[" & constraintsToStr(t) & "]" else: result = "expr[" & constraintsToStr(t) & "]"
of tyArray: of tyArray:
if t.sons[0].kind == tyRange: if t.sons[0].kind == tyRange: