]> git.saurik.com Git - cycript.git/blame - ObjectiveC/Syntax.hpp
Allow errno exceptions to _syscall()'s _assert().
[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
61769f4f
JF
27struct CYInstanceLiteral :
28 CYExpression
29{
30 CYNumber *number_;
31
32 CYInstanceLiteral(CYNumber *number) :
33 number_(number)
34 {
35 }
36
37 CYPrecedence(1)
38
39 virtual CYExpression *Replace(CYContext &context);
40 virtual void Output(CYOutput &out, CYFlags flags) const;
41};
42
56e02e5b
JF
43struct CYObjCBlock :
44 CYExpression
45{
9a39f705 46 CYTypedIdentifier *typed_;
56e02e5b
JF
47 CYTypedParameter *parameters_;
48 CYStatement *statements_;
49
9a39f705
JF
50 CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *statements) :
51 typed_(typed),
56e02e5b
JF
52 parameters_(parameters),
53 statements_(statements)
54 {
55 }
56
57 CYPrecedence(1)
58
59 virtual CYExpression *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
61};
62
f2f0d1d1
JF
63struct CYBox :
64 CYExpression
65{
66 CYExpression *value_;
67
68 CYBox(CYExpression *value) :
69 value_(value)
70 {
71 }
72
73 CYPrecedence(1)
74
75 virtual CYExpression *Replace(CYContext &context);
76 virtual void Output(CYOutput &out, CYFlags flags) const;
77};
78
4de0686f
JF
79struct CYSelectorPart :
80 CYNext<CYSelectorPart>,
81 CYThing
82{
83 CYWord *name_;
84 bool value_;
85
2385c806 86 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
4de0686f
JF
87 CYNext<CYSelectorPart>(next),
88 name_(name),
89 value_(value)
90 {
91 }
92
93 CYString *Replace(CYContext &context);
94 virtual void Output(CYOutput &out) const;
95};
96
97struct CYSelector :
98 CYLiteral
99{
100 CYSelectorPart *name_;
101
102 CYSelector(CYSelectorPart *name) :
103 name_(name)
104 {
105 }
106
107 CYPrecedence(1)
108
109 virtual CYExpression *Replace(CYContext &context);
110 virtual void Output(CYOutput &out, CYFlags flags) const;
111};
112
113struct CYField :
114 CYNext<CYField>
115{
d2f6e642 116 CYTypedIdentifier *typed_;
cfd73c6d 117
d2f6e642 118 CYField(CYTypedIdentifier *typed, CYField *next = NULL) :
cfd73c6d 119 CYNext<CYField>(next),
d2f6e642 120 typed_(typed)
cfd73c6d
JF
121 {
122 }
123
4de0686f
JF
124 CYStatement *Replace(CYContext &context) const;
125 void Output(CYOutput &out) const;
126};
127
128struct CYMessageParameter :
129 CYNext<CYMessageParameter>
130{
131 CYWord *tag_;
132 CYExpression *type_;
133 CYIdentifier *name_;
134
135 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
136 tag_(tag),
137 type_(type),
138 name_(name)
139 {
140 }
141
142 CYFunctionParameter *Parameters(CYContext &context) const;
143 CYSelector *Selector(CYContext &context) const;
144 CYSelectorPart *SelectorPart(CYContext &context) const;
9a7c375c 145 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
146};
147
148struct CYMessage :
149 CYNext<CYMessage>
150{
151 bool instance_;
152 CYExpression *type_;
153 CYMessageParameter *parameters_;
4644480a 154 CYBlock code_;
4de0686f
JF
155
156 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
157 instance_(instance),
158 type_(type),
159 parameters_(parameter),
4644480a 160 code_(statements)
4de0686f
JF
161 {
162 }
163
164 CYStatement *Replace(CYContext &context, bool replace) const;
165 void Output(CYOutput &out, bool replace) const;
9a7c375c
JF
166
167 CYExpression *TypeSignature(CYContext &context) const;
4de0686f
JF
168};
169
64b8d29f
JF
170struct CYProtocol :
171 CYNext<CYProtocol>,
172 CYThing
173{
174 CYExpression *name_;
175
176 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
177 CYNext<CYProtocol>(next),
178 name_(name)
179 {
180 }
181
182 CYStatement *Replace(CYContext &context) const;
183 void Output(CYOutput &out) const;
184};
185
417dcc12
JF
186struct CYModule :
187 CYNext<CYModule>,
188 CYThing
189{
190 CYWord *part_;
191
192 CYModule(CYWord *part, CYModule *next = NULL) :
193 CYNext<CYModule>(next),
194 part_(part)
195 {
196 }
197
198 CYString *Replace(CYContext &context, const char *separator) const;
199 void Output(CYOutput &out) const;
200};
201
1ba6903e
JF
202struct CYImport :
203 CYStatement
204{
417dcc12
JF
205 CYModule *module_;
206
207 CYImport(CYModule *module) :
208 module_(module)
209 {
210 }
211
1ba6903e
JF
212 virtual CYStatement *Replace(CYContext &context);
213 virtual void Output(CYOutput &out, CYFlags flags) const;
214};
215
4de0686f
JF
216struct CYClass {
217 CYClassName *name_;
218 CYExpression *super_;
64b8d29f 219 CYProtocol *protocols_;
4de0686f
JF
220 CYField *fields_;
221 CYMessage *messages_;
222
64b8d29f 223 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
4de0686f
JF
224 name_(name),
225 super_(super),
64b8d29f 226 protocols_(protocols),
4de0686f
JF
227 fields_(fields),
228 messages_(messages)
229 {
230 }
231
7c6c5b0a
JF
232 virtual ~CYClass() {
233 }
234
4de0686f
JF
235 CYExpression *Replace_(CYContext &context);
236 virtual void Output(CYOutput &out, CYFlags flags) const;
237};
238
239struct CYClassExpression :
240 CYClass,
241 CYExpression
242{
64b8d29f
JF
243 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
244 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
245 {
246 }
247
248 CYPrecedence(0)
249
250 virtual CYExpression *Replace(CYContext &context);
251 virtual void Output(CYOutput &out, CYFlags flags) const;
252};
253
254struct CYClassStatement :
255 CYClass,
256 CYStatement
257{
64b8d29f
JF
258 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
259 CYClass(name, super, protocols, fields, messages)
4de0686f
JF
260 {
261 }
262
263 virtual CYStatement *Replace(CYContext &context);
264 virtual void Output(CYOutput &out, CYFlags flags) const;
265};
266
267struct CYCategory :
268 CYStatement
269{
270 CYClassName *name_;
271 CYMessage *messages_;
272
273 CYCategory(CYClassName *name, CYMessage *messages) :
274 name_(name),
275 messages_(messages)
276 {
277 }
278
279 virtual CYStatement *Replace(CYContext &context);
280 virtual void Output(CYOutput &out, CYFlags flags) const;
281};
282
283struct CYSend :
284 CYExpression
285{
4de0686f
JF
286 CYArgument *arguments_;
287
cacd1a88 288 CYSend(CYArgument *arguments) :
4de0686f
JF
289 arguments_(arguments)
290 {
291 }
292
293 CYPrecedence(0)
294
cacd1a88
JF
295 virtual void Output(CYOutput &out, CYFlags flags) const;
296};
297
298struct CYSendDirect :
299 CYSend
300{
301 CYExpression *self_;
302
303 CYSendDirect(CYExpression *self, CYArgument *arguments) :
304 CYSend(arguments),
305 self_(self)
306 {
307 }
308
309 virtual CYExpression *Replace(CYContext &context);
310 virtual void Output(CYOutput &out, CYFlags flags) const;
311};
312
313struct CYSendSuper :
314 CYSend
315{
316 CYSendSuper(CYArgument *arguments) :
317 CYSend(arguments)
318 {
319 }
320
4de0686f
JF
321 virtual CYExpression *Replace(CYContext &context);
322 virtual void Output(CYOutput &out, CYFlags flags) const;
323};
324
3c1c3635 325#endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/