]> git.saurik.com Git - cycript.git/blame - ObjectiveC/Syntax.hpp
On ARM64, the isa instance variable is a tagged.
[cycript.git] / ObjectiveC / Syntax.hpp
CommitLineData
b3378a02 1/* Cycript - Optimizing JavaScript Compiler/Runtime
c15969fd 2 * Copyright (C) 2009-2013 Jay Freeman (saurik)
4644480a
JF
3*/
4
c15969fd 5/* GNU General Public License, Version 3 {{{ */
4644480a 6/*
c15969fd
JF
7 * Cycript is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
4644480a 11 *
c15969fd
JF
12 * Cycript is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
4644480a 16 *
c15969fd 17 * You should have received a copy of the GNU General Public License
b3378a02
JF
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
19**/
4644480a
JF
20/* }}} */
21
3c1c3635
JF
22#ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23#define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
4de0686f
JF
24
25#include "Parser.hpp"
26
561e7f1c
JF
27struct CYTypeModifier :
28 CYNext<CYTypeModifier>
46f4f308 29{
561e7f1c
JF
30 CYTypeModifier(CYTypeModifier *next) :
31 CYNext<CYTypeModifier>(next)
32 {
33 }
34
35 virtual CYExpression *Replace(CYContext &context) = 0;
36};
37
38struct CYTypeArrayOf :
39 CYTypeModifier
40{
3b1534c0 41 CYExpression *size_;
561e7f1c 42
3b1534c0 43 CYTypeArrayOf(CYExpression *size, CYTypeModifier *next = NULL) :
561e7f1c
JF
44 CYTypeModifier(next),
45 size_(size)
46 {
47 }
48
49 CYPrecedence(2)
50
51 virtual CYExpression *Replace(CYContext &context);
52};
53
54struct CYTypeConstant :
55 CYTypeModifier
56{
57 CYTypeConstant(CYTypeModifier *next = NULL) :
58 CYTypeModifier(next)
59 {
60 }
61
62 CYPrecedence(3)
63
64 virtual CYExpression *Replace(CYContext &context);
65};
66
67struct CYTypePointerTo :
68 CYTypeModifier
69{
70 CYTypePointerTo(CYTypeModifier *next = NULL) :
71 CYTypeModifier(next)
72 {
73 }
74
75 CYPrecedence(3)
76
77 virtual CYExpression *Replace(CYContext &context);
78};
79
80struct CYTypeVariable :
81 CYTypeModifier
82{
83 CYExpression *expression_;
46f4f308 84
561e7f1c
JF
85 CYTypeVariable(CYExpression *expression) :
86 CYTypeModifier(NULL),
87 expression_(expression)
46f4f308
JF
88 {
89 }
90
561e7f1c
JF
91 CYPrecedence(1)
92
93 virtual CYExpression *Replace(CYContext &context);
94};
95
96struct CYTypedIdentifier :
97 CYNext<CYTypedIdentifier>
98{
99 CYIdentifier *identifier_;
100 CYTypeModifier *type_;
101
102 CYTypedIdentifier(CYIdentifier *identifier) :
103 identifier_(identifier),
104 type_(NULL)
105 {
106 }
46f4f308
JF
107};
108
56e02e5b
JF
109struct CYTypedParameter :
110 CYNext<CYTypedParameter>
111{
112 CYTypedIdentifier *typed_;
113
114 CYTypedParameter(CYTypedIdentifier *typed, CYTypedParameter *next) :
115 CYNext<CYTypedParameter>(next),
116 typed_(typed)
117 {
118 }
119
120 CYFunctionParameter *Parameters(CYContext &context);
121 CYExpression *TypeSignature(CYContext &context, CYExpression *prefix);
122};
123
124struct CYObjCBlock :
125 CYExpression
126{
127 CYTypeModifier *type_;
128 CYTypedParameter *parameters_;
129 CYStatement *statements_;
130
131 CYObjCBlock(CYTypeModifier *type, CYTypedParameter *parameters, CYStatement *statements) :
132 type_(type),
133 parameters_(parameters),
134 statements_(statements)
135 {
136 }
137
138 CYPrecedence(1)
139
140 virtual CYExpression *Replace(CYContext &context);
141 virtual void Output(CYOutput &out, CYFlags flags) const;
142};
143
46f4f308
JF
144struct CYEncodedType :
145 CYExpression
146{
561e7f1c 147 CYTypeModifier *type_;
46f4f308 148
561e7f1c
JF
149 CYEncodedType(CYTypeModifier *type) :
150 type_(type)
46f4f308
JF
151 {
152 }
153
154 CYPrecedence(1)
155
156 virtual CYExpression *Replace(CYContext &context);
157 virtual void Output(CYOutput &out, CYFlags flags) const;
158};
159
f2f0d1d1
JF
160struct CYBox :
161 CYExpression
162{
163 CYExpression *value_;
164
165 CYBox(CYExpression *value) :
166 value_(value)
167 {
168 }
169
170 CYPrecedence(1)
171
172 virtual CYExpression *Replace(CYContext &context);
173 virtual void Output(CYOutput &out, CYFlags flags) const;
174};
175
4de0686f
JF
176struct CYSelectorPart :
177 CYNext<CYSelectorPart>,
178 CYThing
179{
180 CYWord *name_;
181 bool value_;
182
2385c806 183 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
4de0686f
JF
184 CYNext<CYSelectorPart>(next),
185 name_(name),
186 value_(value)
187 {
188 }
189
190 CYString *Replace(CYContext &context);
191 virtual void Output(CYOutput &out) const;
192};
193
194struct CYSelector :
195 CYLiteral
196{
197 CYSelectorPart *name_;
198
199 CYSelector(CYSelectorPart *name) :
200 name_(name)
201 {
202 }
203
204 CYPrecedence(1)
205
206 virtual CYExpression *Replace(CYContext &context);
207 virtual void Output(CYOutput &out, CYFlags flags) const;
208};
209
210struct CYField :
211 CYNext<CYField>
212{
cfd73c6d
JF
213 CYExpression *type_;
214 CYIdentifier *name_;
215
216 CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) :
217 CYNext<CYField>(next),
218 type_(type),
219 name_(name)
220 {
221 }
222
4de0686f
JF
223 CYStatement *Replace(CYContext &context) const;
224 void Output(CYOutput &out) const;
225};
226
227struct CYMessageParameter :
228 CYNext<CYMessageParameter>
229{
230 CYWord *tag_;
231 CYExpression *type_;
232 CYIdentifier *name_;
233
234 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
235 tag_(tag),
236 type_(type),
237 name_(name)
238 {
239 }
240
241 CYFunctionParameter *Parameters(CYContext &context) const;
242 CYSelector *Selector(CYContext &context) const;
243 CYSelectorPart *SelectorPart(CYContext &context) const;
9a7c375c 244 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
245};
246
247struct CYMessage :
248 CYNext<CYMessage>
249{
250 bool instance_;
251 CYExpression *type_;
252 CYMessageParameter *parameters_;
4644480a 253 CYBlock code_;
4de0686f
JF
254
255 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
256 instance_(instance),
257 type_(type),
258 parameters_(parameter),
4644480a 259 code_(statements)
4de0686f
JF
260 {
261 }
262
263 CYStatement *Replace(CYContext &context, bool replace) const;
264 void Output(CYOutput &out, bool replace) const;
9a7c375c
JF
265
266 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
267};
268
64b8d29f
JF
269struct CYProtocol :
270 CYNext<CYProtocol>,
271 CYThing
272{
273 CYExpression *name_;
274
275 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
276 CYNext<CYProtocol>(next),
277 name_(name)
278 {
279 }
280
281 CYStatement *Replace(CYContext &context) const;
282 void Output(CYOutput &out) const;
283};
284
1ba6903e
JF
285struct CYImport :
286 CYStatement
287{
288 virtual CYStatement *Replace(CYContext &context);
289 virtual void Output(CYOutput &out, CYFlags flags) const;
290};
291
4de0686f
JF
292struct CYClass {
293 CYClassName *name_;
294 CYExpression *super_;
64b8d29f 295 CYProtocol *protocols_;
4de0686f
JF
296 CYField *fields_;
297 CYMessage *messages_;
298
64b8d29f 299 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
4de0686f
JF
300 name_(name),
301 super_(super),
64b8d29f 302 protocols_(protocols),
4de0686f
JF
303 fields_(fields),
304 messages_(messages)
305 {
306 }
307
7c6c5b0a
JF
308 virtual ~CYClass() {
309 }
310
4de0686f
JF
311 CYExpression *Replace_(CYContext &context);
312 virtual void Output(CYOutput &out, CYFlags flags) const;
313};
314
315struct CYClassExpression :
316 CYClass,
317 CYExpression
318{
64b8d29f
JF
319 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
320 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
321 {
322 }
323
324 CYPrecedence(0)
325
326 virtual CYExpression *Replace(CYContext &context);
327 virtual void Output(CYOutput &out, CYFlags flags) const;
328};
329
330struct CYClassStatement :
331 CYClass,
332 CYStatement
333{
64b8d29f
JF
334 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
335 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
336 {
337 }
338
339 virtual CYStatement *Replace(CYContext &context);
340 virtual void Output(CYOutput &out, CYFlags flags) const;
341};
342
343struct CYCategory :
344 CYStatement
345{
346 CYClassName *name_;
347 CYMessage *messages_;
348
349 CYCategory(CYClassName *name, CYMessage *messages) :
350 name_(name),
351 messages_(messages)
352 {
353 }
354
355 virtual CYStatement *Replace(CYContext &context);
356 virtual void Output(CYOutput &out, CYFlags flags) const;
357};
358
359struct CYSend :
360 CYExpression
361{
4de0686f
JF
362 CYArgument *arguments_;
363
cacd1a88 364 CYSend(CYArgument *arguments) :
4de0686f
JF
365 arguments_(arguments)
366 {
367 }
368
369 CYPrecedence(0)
370
cacd1a88
JF
371 virtual void Output(CYOutput &out, CYFlags flags) const;
372};
373
374struct CYSendDirect :
375 CYSend
376{
377 CYExpression *self_;
378
379 CYSendDirect(CYExpression *self, CYArgument *arguments) :
380 CYSend(arguments),
381 self_(self)
382 {
383 }
384
385 virtual CYExpression *Replace(CYContext &context);
386 virtual void Output(CYOutput &out, CYFlags flags) const;
387};
388
389struct CYSendSuper :
390 CYSend
391{
392 CYSendSuper(CYArgument *arguments) :
393 CYSend(arguments)
394 {
395 }
396
4de0686f
JF
397 virtual CYExpression *Replace(CYContext &context);
398 virtual void Output(CYOutput &out, CYFlags flags) const;
399};
400
3c1c3635 401#endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/