summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2014-05-29 01:59:24 +0200
committerAndreas Rumpf <rumpf_a@web.de>2014-05-29 01:59:24 +0200
commit7ab2bc38e63d1428409f023c332949fd4eeea1cf (patch)
treef9c2cec02c830383976070d68c59b78f8db01a27
parent7d9042b1ba02b108c332f6383c06265f89ee5506 (diff)
parent85e6e2a240bf7c9766dce86ec44368997adb58f1 (diff)
downloadNim-7ab2bc38e63d1428409f023c332949fd4eeea1cf.tar.gz
Merge pull request #1230 from flaviut/fix1226
Fix 1226 and document associated methods
-rw-r--r--compiler/ccgtypes.nim4
-rw-r--r--compiler/ccgutils.nim3
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 7c11d3e9a..7a490082f 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -13,8 +13,8 @@
 
 proc mangleField(name: string): string =
   result = mangle(name)
-  if name[0] in 'a'..'z':
-    result[0] = name[0].toUpper
+  result[0] = result[0].toUpper # Mangling makes everything lowercase,
+                                # but some identifiers are C keywords
 
 proc isKeyword(w: PIdent): bool =
   # nimrod and C++ share some keywords
diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim
index 9beb08a21..04983d6a4 100644
--- a/compiler/ccgutils.nim
+++ b/compiler/ccgutils.nim
@@ -162,6 +162,9 @@ proc makeSingleLineCString*(s: string): string =
   result.add('\"')
 
 proc mangle*(name: string): string =
+  ## Lowercases the given name and manges any non-alphanumeric characters
+  ## so they are represented as `HEX____`. If the name starts with a number,
+  ## `N` is prepended
   result = ""
   case name[0]
   of Letters: