From 38710b614f4b34b5c1564e9910a8f275d1ddcce9 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 18 Apr 2012 12:46:02 +0300 Subject: more Objective-C and C keywords are now escaped --- compiler/ccgtypes.nim | 6 +++--- compiler/wordrecg.nim | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index a7ad44db6..6082d96e6 100755 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -32,11 +32,11 @@ proc mangle(name: string): string = add(result, "HEX") add(result, toHex(ord(name[i]), 2)) -proc isCKeyword(w: PIdent): bool = +proc isKeyword(w: PIdent): bool = # nimrod and C++ share some keywords # it's more efficient to test the whole nimrod keywords range case w.id - of cppKeywordsLow..cppKeywordsHigh, + of ccgKeywordsLow..ccgKeywordsHigh, nimKeywordsLow..nimKeywordsHigh, ord(wInline): return true else: return false @@ -57,7 +57,7 @@ proc mangleName(s: PSym): PRope = when oKeepVariableNames: let keepOrigName = s.kind in skLocalVars - {skForVar} and {sfFromGeneric, sfGlobal, sfShadowed} * s.flags == {} and - not isCKeyword(s.name) + not isKeyword(s.name) # XXX: This is still very experimental # # Even with all these inefficient checks, the bootstrap diff --git a/compiler/wordrecg.nim b/compiler/wordrecg.nim index 3ae9f7be9..30a6b3c2c 100755 --- a/compiler/wordrecg.nim +++ b/compiler/wordrecg.nim @@ -43,7 +43,7 @@ type wNosideeffect, wNoreturn, wMerge, wLib, wDynlib, wCompilerproc, wProcVar, wFatal, wError, wWarning, wHint, wLine, wPush, wPop, wDefine, wUndef, 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, wFastcall, wClosure, wNoconv, wOn, wOff, wChecks, wRangechecks, wBoundchecks, wOverflowchecks, wNilchecks, @@ -71,6 +71,10 @@ type wAlignas, wAlignof, wConstexpr, wDecltype, wNullptr, wNoexcept, wThread_local, wStatic_assert, wChar16_t, wChar32_t, + + wStdIn, wStdOut, wStdErr, + + wInOut, wByCopy, wByRef, wOneWay, TSpecialWords* = set[TSpecialWord] @@ -81,8 +85,8 @@ const nimKeywordsLow* = ord(wAsm) nimKeywordsHigh* = ord(wYield) - cppKeywordsLow* = ord(wAuto) - cppKeywordsHigh* = ord(wChar32_t) + ccgKeywordsLow* = ord(wAuto) + ccgKeywordsHigh* = ord(wOneWay) cppNimSharedKeywords* = { wAsm, wBreak, wCase, wConst, wContinue, wDo, wElse, wEnum, wExport, @@ -115,7 +119,7 @@ const "compilerproc", "procvar", "fatal", "error", "warning", "hint", "line", "push", "pop", "define", "undef", "linedir", "stacktrace", "linetrace", "link", "compile", "linksys", "deprecated", "varargs", - "byref", "callconv", "breakpoint", "debugger", "nimcall", "stdcall", + "callconv", "breakpoint", "debugger", "nimcall", "stdcall", "cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "closure", "noconv", "on", "off", "checks", "rangechecks", "boundchecks", "overflowchecks", "nilchecks", @@ -145,6 +149,10 @@ const "alignas", "alignof", "constexpr", "decltype", "nullptr", "noexcept", "thread_local", "static_assert", "char16_t", "char32_t", + + "stdin", "stdout", "stderr", + + "inout", "bycopy", "byref", "oneway", ] proc findStr*(a: openarray[string], s: string): int = -- cgit 1.4.1-2-gfad0 dbf9117c5 ^
3119fe087 ^
ef975d277 ^





dbf9117c5 ^
ef975d277 ^
2d9a24f3f ^


5348fef00 ^











ef975d277 ^
201a08e9a ^
611d5d776 ^
201a08e9a ^



611d5d776 ^
201a08e9a ^
7eb39d9d2 ^

c640bd2d1 ^




c53a27f0d ^

c640bd2d1 ^
c53a27f0d ^



c640bd2d1 ^
c53a27f0d ^

7eb39d9d2 ^
ef975d277 ^
1a792d46d ^



6810a0e3e ^
2df9b442c ^




6810a0e3e ^



2df9b442c ^
1a792d46d ^


2df9b442c ^


1a792d46d ^

9605435f2 ^
6810a0e3e ^



fd2a80826 ^

2df9b442c ^
9605435f2 ^
6810a0e3e ^
6810a0e3e ^

2df9b442c ^






9605435f2 ^
6810a0e3e ^
9605435f2 ^
6810a0e3e ^



5348fef00 ^



bf6c2c5cc ^
c640bd2d1 ^
611d5d776 ^


5348fef00 ^
611d5d776 ^

2d9a24f3f ^
611d5d776 ^

2d9a24f3f ^

c640bd2d1 ^

611d5d776 ^
40ec7be45 ^
e5be2e9f9 ^

2d9a24f3f ^
40ec7be45 ^
bf6c2c5cc ^
611d5d776 ^
7eb39d9d2 ^
e5be2e9f9 ^
40ec7be45 ^
2df9b442c ^
5348fef00 ^
569fbe8c3 ^
b731e6ef1 ^
40ec7be45 ^
2df9b442c ^
5348fef00 ^










c5dbcb548 ^
40ec7be45 ^
c5dbcb548 ^
5348fef00 ^



b731e6ef1 ^
5348fef00 ^
33b69f0ed ^
2df9b442c ^

2d9a24f3f ^
2df9b442c ^
5348fef00 ^
dbf9117c5 ^
2df9b442c ^

611d5d776 ^
bf6c2c5cc ^
611d5d776 ^
d330a72a4 ^


5348fef00 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176