summary refs log tree commit diff stats
path: root/lib/system/reprjs.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-09-24 00:46:54 +0200
committerAraq <rumpf_a@web.de>2011-09-24 00:46:54 +0200
commit3824b6ea5f320f956473bdfaf0894fe89c90f0ab (patch)
tree6185dd432665cff1596e4a85bf1f6c43229570be /lib/system/reprjs.nim
parent6023e994fbc949c77abbbe4ffae761ca982732db (diff)
parent6deda5a973312e86fe58e319e97afd93bc07c82d (diff)
downloadNim-3824b6ea5f320f956473bdfaf0894fe89c90f0ab.tar.gz
Merge branch 'master' of git@github.com:Araq/Nimrod
Diffstat (limited to 'lib/system/reprjs.nim')
-rw-r--r--lib/system/reprjs.nim23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/system/reprjs.nim b/lib/system/reprjs.nim
new file mode 100644
index 000000000..b6b6ffe9c
--- /dev/null
+++ b/lib/system/reprjs.nim
@@ -0,0 +1,23 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2011 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+proc reprInt(x: int64): string {.compilerproc.} = return $x
+
+proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
+  if ntfEnumHole notin typ.flags:
+    if e <% typ.node.len:
+      return $typ.node.sons[e].name
+  else:
+    # ugh we need a slow linear search:
+    var n = typ.node
+    var s = n.sons
+    for i in 0 .. n.len-1:
+      if s[i].offset == e: return $s[i].name
+  result = $e & " (invalid data!)"
+