]> git.saurik.com Git - cycript.git/blame - ObjectiveC/Syntax.hpp
Allow strings to be used as extern or field names.
[cycript.git] / ObjectiveC / Syntax.hpp
CommitLineData
7341eedb
JF
1/* Cycript - The Truly Universal Scripting Language
2 * Copyright (C) 2009-2016 Jay Freeman (saurik)
4644480a
JF
3*/
4
f95d2598 5/* GNU Affero General Public License, Version 3 {{{ */
4644480a 6/*
f95d2598
JF
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c15969fd 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f95d2598
JF
15 * GNU Affero General Public License for more details.
16
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b3378a02 19**/
4644480a
JF
20/* }}} */
21
3c1c3635
JF
22#ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23#define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
4de0686f 24
20052ff7 25#include "../Syntax.hpp"
4de0686f 26
61769f4f 27struct CYInstanceLiteral :
7085e1ab 28 CYTarget
61769f4f
JF
29{
30 CYNumber *number_;
31
32 CYInstanceLiteral(CYNumber *number) :
33 number_(number)
34 {
35 }
36
37 CYPrecedence(1)
38
7085e1ab 39 virtual CYTarget *Replace(CYContext &context);
61769f4f
JF
40 virtual void Output(CYOutput &out, CYFlags flags) const;
41};
42
56e02e5b 43struct CYObjCBlock :
7085e1ab 44 CYTarget
56e02e5b 45{
5b4dabb2 46 CYType *typed_;
56e02e5b 47 CYTypedParameter *parameters_;
b0385401 48 CYStatement *code_;
56e02e5b 49
5b4dabb2 50 CYObjCBlock(CYType *typed, CYTypedParameter *parameters, CYStatement *code) :
9a39f705 51 typed_(typed),
56e02e5b 52 parameters_(parameters),
b0385401 53 code_(code)
56e02e5b
JF
54 {
55 }
56
57 CYPrecedence(1)
58
7085e1ab 59 virtual CYTarget *Replace(CYContext &context);
56e02e5b
JF
60 virtual void Output(CYOutput &out, CYFlags flags) const;
61};
62
f2f0d1d1 63struct CYBox :
7085e1ab 64 CYTarget
f2f0d1d1
JF
65{
66 CYExpression *value_;
67
68 CYBox(CYExpression *value) :
69 value_(value)
70 {
71 }
72
73 CYPrecedence(1)
74
5a6c975a
JF
75 virtual CYTarget *Replace(CYContext &context);
76 virtual void Output(CYOutput &out, CYFlags flags) const;
77};
78
79struct CYObjCArray :
80 CYTarget
81{
82 CYElement *elements_;
83
84 CYObjCArray(CYElement *elements = NULL) :
85 elements_(elements)
86 {
87 }
88
89 CYPrecedence(0)
90
91 virtual CYTarget *Replace(CYContext &context);
92 virtual void Output(CYOutput &out, CYFlags flags) const;
93};
94
95struct CYObjCKeyValue :
96 CYNext<CYObjCKeyValue>
97{
98 CYExpression *key_;
99 CYExpression *value_;
100
101 CYObjCKeyValue(CYExpression *key, CYExpression *value, CYObjCKeyValue *next) :
102 CYNext<CYObjCKeyValue>(next),
103 key_(key),
104 value_(value)
105 {
106 }
107};
108
109struct CYObjCDictionary :
110 CYTarget
111{
112 CYObjCKeyValue *pairs_;
113
114 CYObjCDictionary(CYObjCKeyValue *pairs) :
115 pairs_(pairs)
116 {
117 }
118
119 CYPrecedence(0)
120
7085e1ab 121 virtual CYTarget *Replace(CYContext &context);
f2f0d1d1
JF
122 virtual void Output(CYOutput &out, CYFlags flags) const;
123};
124
4de0686f
JF
125struct CYSelectorPart :
126 CYNext<CYSelectorPart>,
127 CYThing
128{
129 CYWord *name_;
130 bool value_;
131
2385c806 132 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
4de0686f
JF
133 CYNext<CYSelectorPart>(next),
134 name_(name),
135 value_(value)
136 {
137 }
138
139 CYString *Replace(CYContext &context);
140 virtual void Output(CYOutput &out) const;
141};
142
143struct CYSelector :
144 CYLiteral
145{
09fc3efb 146 CYSelectorPart *parts_;
4de0686f 147
09fc3efb
JF
148 CYSelector(CYSelectorPart *parts) :
149 parts_(parts)
4de0686f
JF
150 {
151 }
152
153 CYPrecedence(1)
154
7085e1ab 155 virtual CYTarget *Replace(CYContext &context);
4de0686f
JF
156 virtual void Output(CYOutput &out, CYFlags flags) const;
157};
158
c5b15840
JF
159struct CYImplementationField :
160 CYNext<CYImplementationField>
4de0686f 161{
5b4dabb2
JF
162 CYType *type_;
163 CYPropertyName *name_;
cfd73c6d 164
5b4dabb2 165 CYImplementationField(CYType *type, CYPropertyName *name, CYImplementationField *next = NULL) :
c5b15840 166 CYNext<CYImplementationField>(next),
5b4dabb2
JF
167 type_(type),
168 name_(name)
cfd73c6d
JF
169 {
170 }
171
4de0686f
JF
172 CYStatement *Replace(CYContext &context) const;
173 void Output(CYOutput &out) const;
174};
175
176struct CYMessageParameter :
177 CYNext<CYMessageParameter>
178{
09fc3efb 179 CYWord *name_;
5b4dabb2
JF
180 CYType *type_;
181 CYIdentifier *identifier_;
4de0686f 182
5b4dabb2 183 CYMessageParameter(CYWord *name, CYType *type = NULL, CYIdentifier *identifier = NULL, CYMessageParameter *next = NULL) :
574d4720 184 CYNext<CYMessageParameter>(next),
09fc3efb 185 name_(name),
5b4dabb2
JF
186 type_(type),
187 identifier_(identifier)
4de0686f
JF
188 {
189 }
190
191 CYFunctionParameter *Parameters(CYContext &context) const;
192 CYSelector *Selector(CYContext &context) const;
193 CYSelectorPart *SelectorPart(CYContext &context) const;
9a7c375c 194 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
195};
196
197struct CYMessage :
198 CYNext<CYMessage>
199{
200 bool instance_;
5b4dabb2 201 CYType *type_;
4de0686f 202 CYMessageParameter *parameters_;
4644480a 203 CYBlock code_;
4de0686f 204
5b4dabb2 205 CYMessage(bool instance, CYType *type, CYMessageParameter *parameters, CYStatement *code) :
4de0686f
JF
206 instance_(instance),
207 type_(type),
09fc3efb 208 parameters_(parameters),
b0385401 209 code_(code)
4de0686f
JF
210 {
211 }
212
213 CYStatement *Replace(CYContext &context, bool replace) const;
c5b15840 214 void Output(CYOutput &out) const;
9a7c375c
JF
215
216 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
217};
218
64b8d29f
JF
219struct CYProtocol :
220 CYNext<CYProtocol>,
221 CYThing
222{
223 CYExpression *name_;
224
225 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
226 CYNext<CYProtocol>(next),
227 name_(name)
228 {
229 }
230
231 CYStatement *Replace(CYContext &context) const;
232 void Output(CYOutput &out) const;
233};
234
c5b15840 235struct CYImplementation :
ec18682d
JF
236 CYStatement
237{
c5b15840 238 CYIdentifier *name_;
09fc3efb 239 CYExpression *extends_;
64b8d29f 240 CYProtocol *protocols_;
c5b15840 241 CYImplementationField *fields_;
4de0686f
JF
242 CYMessage *messages_;
243
09fc3efb 244 CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) :
4de0686f 245 name_(name),
09fc3efb 246 extends_(extends),
64b8d29f 247 protocols_(protocols),
4de0686f
JF
248 fields_(fields),
249 messages_(messages)
250 {
251 }
252
efd689d8
JF
253 CYCompact(None)
254
4de0686f
JF
255 virtual CYStatement *Replace(CYContext &context);
256 virtual void Output(CYOutput &out, CYFlags flags) const;
257};
258
259struct CYCategory :
260 CYStatement
261{
c5b15840 262 CYIdentifier *name_;
4de0686f
JF
263 CYMessage *messages_;
264
c5b15840 265 CYCategory(CYIdentifier *name, CYMessage *messages) :
4de0686f
JF
266 name_(name),
267 messages_(messages)
268 {
269 }
270
efd689d8
JF
271 CYCompact(None)
272
4de0686f
JF
273 virtual CYStatement *Replace(CYContext &context);
274 virtual void Output(CYOutput &out, CYFlags flags) const;
275};
276
277struct CYSend :
7085e1ab 278 CYTarget
4de0686f 279{
4de0686f
JF
280 CYArgument *arguments_;
281
cacd1a88 282 CYSend(CYArgument *arguments) :
4de0686f
JF
283 arguments_(arguments)
284 {
285 }
286
287 CYPrecedence(0)
288
cacd1a88
JF
289 virtual void Output(CYOutput &out, CYFlags flags) const;
290};
291
292struct CYSendDirect :
293 CYSend
294{
295 CYExpression *self_;
296
297 CYSendDirect(CYExpression *self, CYArgument *arguments) :
298 CYSend(arguments),
299 self_(self)
300 {
301 }
302
7085e1ab 303 virtual CYTarget *Replace(CYContext &context);
cacd1a88
JF
304 virtual void Output(CYOutput &out, CYFlags flags) const;
305};
306
307struct CYSendSuper :
308 CYSend
309{
310 CYSendSuper(CYArgument *arguments) :
311 CYSend(arguments)
312 {
313 }
314
7085e1ab 315 virtual CYTarget *Replace(CYContext &context);
4de0686f
JF
316 virtual void Output(CYOutput &out, CYFlags flags) const;
317};
318
3c1c3635 319#endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/