From b0388073c43e647688ed8cdcf4d83291d0132411 Mon Sep 17 00:00:00 2001 From: Yury Benesh Date: Wed, 21 Nov 2012 23:42:11 +0300 Subject: [PATCH] Added base() proc to typeinfo. --- lib/core/typeinfo.nim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 3032ccb192..26a14f4447 100755 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -198,6 +198,13 @@ proc len*(x: TAny): int = of tySequence: result = cast[PGenSeq](cast[ppointer](x.value)[]).len else: assert false + +proc base*(x: TAny): TAny = + ## returns base TAny (useful for inherited object types). + result.rawType = x.rawType.base + result.value = x.value + + proc isNil*(x: TAny): bool = ## `isNil` for an any `x` that represents a sequence, string, cstring, ## proc or some pointer type.