Merge pull request #586 from mflamer/master

Add arity typetrait
This commit is contained in:
zah
2013-09-03 09:05:12 -07:00
2 changed files with 6 additions and 0 deletions

View File

@@ -914,6 +914,10 @@ proc evalTypeTrait*(trait, operand: PNode, context: PSym): PNode =
result = newStrNode(nkStrLit, typ.typeToString(preferName))
result.typ = newType(tyString, context)
result.info = trait.info
of "arity":
result = newIntNode(nkIntLit, typ.n.len-1)
result.typ = newType(tyInt, context)
result.info = trait.info
else:
internalAssert false

View File

@@ -13,3 +13,5 @@
proc name*(t: typedesc): string {.magic: "TypeTrait".}
## Returns the name of the given type
proc arity*(t: typedesc): int {.magic: "TypeTrait".}
## Returns the arity of the given type