diff options
author | Araq <rumpf_a@web.de> | 2013-07-30 17:15:58 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-07-30 17:15:58 +0200 |
commit | d640121ce62adfae4506e1d980b3920ebd1a7168 (patch) | |
tree | c00d2025e14d9c5d1145397f5372ef2f70683e2d | |
parent | fd2a808266f8d4a66b2921c5bc5543d78c92a633 (diff) | |
download | Nim-d640121ce62adfae4506e1d980b3920ebd1a7168.tar.gz |
lfFullExternalName for 'nimrod pretty'
-rw-r--r-- | compiler/ast.nim | 3 | ||||
-rw-r--r-- | compiler/pragmas.nim | 15 | ||||
-rw-r--r-- | compiler/pretty.nim | 3 |
3 files changed, 14 insertions, 7 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index c86ba52c6..514ab6a7c 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -795,6 +795,9 @@ const skLocalVars* = {skVar, skLet, skForVar, skParam, skResult} + lfFullExternalName* = lfParamCopy # \ + # only used when 'gCmd == cmdPretty': Indicates that the symbol has been + # imported via 'importc: "fullname"' and no format string. # creator procs: proc NewSym*(symKind: TSymKind, Name: PIdent, owner: PSym, diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index bf4f25014..30478c9ee 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -84,8 +84,11 @@ proc pragmaAsm*(c: PContext, n: PNode): char = else: invalidPragma(it) -proc setExternName(s: PSym, extname: string) = +proc setExternName(s: PSym, extname: string) = s.loc.r = toRope(extname % s.name.s) + if gCmd == cmdPretty and '$' notin extname: + # note that '{.importc.}' is transformed into '{.importc: "$1".}' + s.loc.flags.incl(lfFullExternalName) proc MakeExternImport(s: PSym, extname: string) = setExternName(s, extname) @@ -513,11 +516,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int, if k in validPragmas: case k of wExportc: - makeExternExport(sym, getOptionalStr(c, it, sym.name.s)) + makeExternExport(sym, getOptionalStr(c, it, "$1")) incl(sym.flags, sfUsed) # avoid wrong hints - of wImportc: makeExternImport(sym, getOptionalStr(c, it, sym.name.s)) + of wImportc: makeExternImport(sym, getOptionalStr(c, it, "$1")) of wImportCompilerProc: - processImportCompilerProc(sym, getOptionalStr(c, it, sym.name.s)) + processImportCompilerProc(sym, getOptionalStr(c, it, "$1")) of wExtern: setExternName(sym, expectStrLit(c, it)) of wImmediate: if sym.kind in {skTemplate, skMacro}: incl(sym.flags, sfImmediate) @@ -526,9 +529,9 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int, if sym.kind == skTemplate: incl(sym.flags, sfDirty) else: invalidPragma(it) of wImportCpp: - processImportCpp(sym, getOptionalStr(c, it, sym.name.s)) + processImportCpp(sym, getOptionalStr(c, it, "$1")) of wImportObjC: - processImportObjC(sym, getOptionalStr(c, it, sym.name.s)) + processImportObjC(sym, getOptionalStr(c, it, "$1")) of wAlign: if sym.typ == nil: invalidPragma(it) var align = expectIntLit(c, it) diff --git a/compiler/pretty.nim b/compiler/pretty.nim index e9094cdf7..07f547837 100644 --- a/compiler/pretty.nim +++ b/compiler/pretty.nim @@ -119,7 +119,8 @@ proc processSym(c: PPassContext, n: PNode): PNode = if {sfImportc, sfExportc} * s.flags != {}: # careful, we must ensure the resulting name still matches the external # name: - if newName != s.name.s and newName != s.loc.r.ropeToStr: + if newName != s.name.s and newName != s.loc.r.ropeToStr and + lfFullExternalName notin s.loc.flags: Message(n.info, errGenerated, "cannot rename $# to $# due to external name" % [s.name.s, newName]) cannotRename.incl(s.id) |