Merge pull request #1468 from Varriount/fix-1435

Fix 1435
This commit is contained in:
Andreas Rumpf
2014-08-09 22:55:18 +02:00
3 changed files with 7 additions and 0 deletions

View File

@@ -1313,6 +1313,10 @@ proc newSons(father: PNode, length: int) =
setLen(father.sons, length)
proc skipTypes*(t: PType, kinds: TTypeKinds): PType =
## Used throughout the compiler code to test whether a type tree contains or
## doesn't contain a specific type/types - it is often the case that only the
## last child nodes of a type tree need to be searched. This is a really hot
## path within the compiler!
result = t
while result.kind in kinds: result = lastSon(result)

View File

@@ -122,6 +122,7 @@ proc mapSetType(typ: PType): TCTypeKind =
else: result = ctArray
proc mapType(typ: PType): TCTypeKind =
## Maps a nimrod type to a C type
case typ.kind
of tyNone, tyStmt: result = ctVoid
of tyBool: result = ctBool

View File

@@ -199,6 +199,8 @@ proc isCastable(dst, src: PType): bool =
result = (dstSize >= srcSize) or
(skipTypes(dst, abstractInst).kind in IntegralTypes) or
(skipTypes(src, abstractInst-{tyTypeDesc}).kind in IntegralTypes)
if result and src.kind == tyNil:
result = dst.size <= platform.ptrSize
proc isSymChoice(n: PNode): bool {.inline.} =
result = n.kind in nkSymChoices