the foundations of a type traits module; better error messages for expr, typedesc and typeclasses params

This commit is contained in:
Zahary Karadjov 2012-04-06 05:02:48 +03:00
commit efb53233cb
8 changed files with 65 additions and 12 deletions

View file

@ -8,6 +8,7 @@
#
# This include file implements the semantic checking for magics.
# included from sem.nim
proc semIsPartOf(c: PContext, n: PNode, flags: TExprFlags): PNode =
var r = isPartOf(n[1], n[2])
@ -43,11 +44,21 @@ proc semInstantiationInfo(c: PContext, n: PNode): PNode =
result.add(filename)
result.add(line)
proc semTypeTraits(c: PContext, n: PNode): PNode =
checkMinSonsLen(n, 2)
internalAssert n.sons[1].kind == nkSym
if n.sons[1].sym.kind == skType:
result = evalTypeTrait(n, GetCurrOwner())
else:
# pass unmodified to evals
result = n
proc magicsAfterOverloadResolution(c: PContext, n: PNode,
flags: TExprFlags): PNode =
case n[0].sym.magic
of mSlurp: result = semSlurp(c, n, flags)
of mIsPartOf: result = semIsPartOf(c, n, flags)
of mTypeTrait: result = semTypeTraits(c, n)
of mAstToStr:
result = newStrNodeT(renderTree(n[1], {renderNoComments}), n)
result.typ = getSysType(tyString)