From 7ca72a733c7960eee1c86a4c46b0aac47fe851fc Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 28 Nov 2016 10:56:45 +0100 Subject: [PATCH] use -d:nimTypeNames to create RTTI with type names --- compiler/ccgtypes.nim | 2 ++ lib/system/hti.nim | 2 ++ 2 files changed, 4 insertions(+) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 60ee0eaeeb..68e98e92e2 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -816,6 +816,8 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType; name, base: Rope) = #else MessageOut("can contain a cycle: " & typeToString(typ)) if flags != 0: addf(m.s[cfsTypeInit3], "$1.flags = $2;$n", [name, rope(flags)]) + if isDefined("nimTypeNames"): + addf(m.s[cfsTypeInit3], "$1.name = $2;$n", [name, makeCstring typeToString origType]) discard cgsym(m, "TNimType") addf(m.s[cfsVars], "TNimType $1; /* $2 */$n", [name, rope(typeToString(typ))]) diff --git a/lib/system/hti.nim b/lib/system/hti.nim index 892a209df8..d5cca7c1c6 100644 --- a/lib/system/hti.nim +++ b/lib/system/hti.nim @@ -86,6 +86,8 @@ type finalizer: pointer # the finalizer for the type marker: proc (p: pointer, op: int) {.nimcall, benign.} # marker proc for GC deepcopy: proc (p: pointer): pointer {.nimcall, benign.} + when defined(nimTypeNames): + name: cstring PNimType = ptr TNimType # node.len may be the ``first`` element of a set