more Objective-C and C keywords are now escaped
This commit is contained in:
parent
3d65c0a73f
commit
38710b614f
2 changed files with 15 additions and 7 deletions
|
|
@ -32,11 +32,11 @@ proc mangle(name: string): string =
|
||||||
add(result, "HEX")
|
add(result, "HEX")
|
||||||
add(result, toHex(ord(name[i]), 2))
|
add(result, toHex(ord(name[i]), 2))
|
||||||
|
|
||||||
proc isCKeyword(w: PIdent): bool =
|
proc isKeyword(w: PIdent): bool =
|
||||||
# nimrod and C++ share some keywords
|
# nimrod and C++ share some keywords
|
||||||
# it's more efficient to test the whole nimrod keywords range
|
# it's more efficient to test the whole nimrod keywords range
|
||||||
case w.id
|
case w.id
|
||||||
of cppKeywordsLow..cppKeywordsHigh,
|
of ccgKeywordsLow..ccgKeywordsHigh,
|
||||||
nimKeywordsLow..nimKeywordsHigh,
|
nimKeywordsLow..nimKeywordsHigh,
|
||||||
ord(wInline): return true
|
ord(wInline): return true
|
||||||
else: return false
|
else: return false
|
||||||
|
|
@ -57,7 +57,7 @@ proc mangleName(s: PSym): PRope =
|
||||||
when oKeepVariableNames:
|
when oKeepVariableNames:
|
||||||
let keepOrigName = s.kind in skLocalVars - {skForVar} and
|
let keepOrigName = s.kind in skLocalVars - {skForVar} and
|
||||||
{sfFromGeneric, sfGlobal, sfShadowed} * s.flags == {} and
|
{sfFromGeneric, sfGlobal, sfShadowed} * s.flags == {} and
|
||||||
not isCKeyword(s.name)
|
not isKeyword(s.name)
|
||||||
# XXX: This is still very experimental
|
# XXX: This is still very experimental
|
||||||
#
|
#
|
||||||
# Even with all these inefficient checks, the bootstrap
|
# Even with all these inefficient checks, the bootstrap
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ type
|
||||||
wNosideeffect, wNoreturn, wMerge, wLib, wDynlib, wCompilerproc, wProcVar,
|
wNosideeffect, wNoreturn, wMerge, wLib, wDynlib, wCompilerproc, wProcVar,
|
||||||
wFatal, wError, wWarning, wHint, wLine, wPush, wPop, wDefine, wUndef,
|
wFatal, wError, wWarning, wHint, wLine, wPush, wPop, wDefine, wUndef,
|
||||||
wLinedir, wStacktrace, wLinetrace, wLink, wCompile,
|
wLinedir, wStacktrace, wLinetrace, wLink, wCompile,
|
||||||
wLinksys, wDeprecated, wVarargs, wByref, wCallconv, wBreakpoint, wDebugger,
|
wLinksys, wDeprecated, wVarargs, wCallconv, wBreakpoint, wDebugger,
|
||||||
wNimcall, wStdcall, wCdecl, wSafecall, wSyscall, wInline, wNoInline,
|
wNimcall, wStdcall, wCdecl, wSafecall, wSyscall, wInline, wNoInline,
|
||||||
wFastcall, wClosure, wNoconv, wOn, wOff, wChecks, wRangechecks,
|
wFastcall, wClosure, wNoconv, wOn, wOff, wChecks, wRangechecks,
|
||||||
wBoundchecks, wOverflowchecks, wNilchecks,
|
wBoundchecks, wOverflowchecks, wNilchecks,
|
||||||
|
|
@ -71,6 +71,10 @@ type
|
||||||
|
|
||||||
wAlignas, wAlignof, wConstexpr, wDecltype, wNullptr, wNoexcept,
|
wAlignas, wAlignof, wConstexpr, wDecltype, wNullptr, wNoexcept,
|
||||||
wThread_local, wStatic_assert, wChar16_t, wChar32_t,
|
wThread_local, wStatic_assert, wChar16_t, wChar32_t,
|
||||||
|
|
||||||
|
wStdIn, wStdOut, wStdErr,
|
||||||
|
|
||||||
|
wInOut, wByCopy, wByRef, wOneWay,
|
||||||
|
|
||||||
TSpecialWords* = set[TSpecialWord]
|
TSpecialWords* = set[TSpecialWord]
|
||||||
|
|
||||||
|
|
@ -81,8 +85,8 @@ const
|
||||||
nimKeywordsLow* = ord(wAsm)
|
nimKeywordsLow* = ord(wAsm)
|
||||||
nimKeywordsHigh* = ord(wYield)
|
nimKeywordsHigh* = ord(wYield)
|
||||||
|
|
||||||
cppKeywordsLow* = ord(wAuto)
|
ccgKeywordsLow* = ord(wAuto)
|
||||||
cppKeywordsHigh* = ord(wChar32_t)
|
ccgKeywordsHigh* = ord(wOneWay)
|
||||||
|
|
||||||
cppNimSharedKeywords* = {
|
cppNimSharedKeywords* = {
|
||||||
wAsm, wBreak, wCase, wConst, wContinue, wDo, wElse, wEnum, wExport,
|
wAsm, wBreak, wCase, wConst, wContinue, wDo, wElse, wEnum, wExport,
|
||||||
|
|
@ -115,7 +119,7 @@ const
|
||||||
"compilerproc", "procvar", "fatal", "error", "warning", "hint", "line",
|
"compilerproc", "procvar", "fatal", "error", "warning", "hint", "line",
|
||||||
"push", "pop", "define", "undef", "linedir", "stacktrace", "linetrace",
|
"push", "pop", "define", "undef", "linedir", "stacktrace", "linetrace",
|
||||||
"link", "compile", "linksys", "deprecated", "varargs",
|
"link", "compile", "linksys", "deprecated", "varargs",
|
||||||
"byref", "callconv", "breakpoint", "debugger", "nimcall", "stdcall",
|
"callconv", "breakpoint", "debugger", "nimcall", "stdcall",
|
||||||
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "closure",
|
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "closure",
|
||||||
"noconv", "on", "off", "checks", "rangechecks", "boundchecks",
|
"noconv", "on", "off", "checks", "rangechecks", "boundchecks",
|
||||||
"overflowchecks", "nilchecks",
|
"overflowchecks", "nilchecks",
|
||||||
|
|
@ -145,6 +149,10 @@ const
|
||||||
|
|
||||||
"alignas", "alignof", "constexpr", "decltype", "nullptr", "noexcept",
|
"alignas", "alignof", "constexpr", "decltype", "nullptr", "noexcept",
|
||||||
"thread_local", "static_assert", "char16_t", "char32_t",
|
"thread_local", "static_assert", "char16_t", "char32_t",
|
||||||
|
|
||||||
|
"stdin", "stdout", "stderr",
|
||||||
|
|
||||||
|
"inout", "bycopy", "byref", "oneway",
|
||||||
]
|
]
|
||||||
|
|
||||||
proc findStr*(a: openarray[string], s: string): int =
|
proc findStr*(a: openarray[string], s: string): int =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue