]>
Commit | Line | Data |
---|---|---|
b3378a02 | 1 | /* Cycript - Optimizing JavaScript Compiler/Runtime |
c1d3e52e | 2 | * Copyright (C) 2009-2015 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 | 27 | struct 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 | 43 | struct CYObjCBlock : |
7085e1ab | 44 | CYTarget |
56e02e5b | 45 | { |
9a39f705 | 46 | CYTypedIdentifier *typed_; |
56e02e5b | 47 | CYTypedParameter *parameters_; |
b0385401 | 48 | CYStatement *code_; |
56e02e5b | 49 | |
b0385401 | 50 | CYObjCBlock(CYTypedIdentifier *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 | 63 | struct 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 | ||
79 | struct 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 | ||
95 | struct 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 | ||
109 | struct 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 |
125 | struct 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 | ||
143 | struct 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 |
159 | struct CYImplementationField : |
160 | CYNext<CYImplementationField> | |
4de0686f | 161 | { |
d2f6e642 | 162 | CYTypedIdentifier *typed_; |
cfd73c6d | 163 | |
c5b15840 JF |
164 | CYImplementationField(CYTypedIdentifier *typed, CYImplementationField *next = NULL) : |
165 | CYNext<CYImplementationField>(next), | |
d2f6e642 | 166 | typed_(typed) |
cfd73c6d JF |
167 | { |
168 | } | |
169 | ||
4de0686f JF |
170 | CYStatement *Replace(CYContext &context) const; |
171 | void Output(CYOutput &out) const; | |
172 | }; | |
173 | ||
174 | struct CYMessageParameter : | |
175 | CYNext<CYMessageParameter> | |
176 | { | |
09fc3efb | 177 | CYWord *name_; |
57d55714 | 178 | CYTypedIdentifier *type_; |
4de0686f | 179 | |
574d4720 JF |
180 | CYMessageParameter(CYWord *name, CYTypedIdentifier *type, CYMessageParameter *next = NULL) : |
181 | CYNext<CYMessageParameter>(next), | |
09fc3efb | 182 | name_(name), |
104cc5f5 | 183 | type_(type) |
4de0686f JF |
184 | { |
185 | } | |
186 | ||
187 | CYFunctionParameter *Parameters(CYContext &context) const; | |
188 | CYSelector *Selector(CYContext &context) const; | |
189 | CYSelectorPart *SelectorPart(CYContext &context) const; | |
9a7c375c | 190 | CYExpression *TypeSignature(CYContext &context) const; |
4de0686f JF |
191 | }; |
192 | ||
193 | struct CYMessage : | |
194 | CYNext<CYMessage> | |
195 | { | |
196 | bool instance_; | |
57d55714 | 197 | CYTypedIdentifier *type_; |
4de0686f | 198 | CYMessageParameter *parameters_; |
4644480a | 199 | CYBlock code_; |
4de0686f | 200 | |
09fc3efb | 201 | CYMessage(bool instance, CYTypedIdentifier *type, CYMessageParameter *parameters, CYStatement *code) : |
4de0686f JF |
202 | instance_(instance), |
203 | type_(type), | |
09fc3efb | 204 | parameters_(parameters), |
b0385401 | 205 | code_(code) |
4de0686f JF |
206 | { |
207 | } | |
208 | ||
209 | CYStatement *Replace(CYContext &context, bool replace) const; | |
c5b15840 | 210 | void Output(CYOutput &out) const; |
9a7c375c JF |
211 | |
212 | CYExpression *TypeSignature(CYContext &context) const; | |
4de0686f JF |
213 | }; |
214 | ||
64b8d29f JF |
215 | struct CYProtocol : |
216 | CYNext<CYProtocol>, | |
217 | CYThing | |
218 | { | |
219 | CYExpression *name_; | |
220 | ||
221 | CYProtocol(CYExpression *name, CYProtocol *next = NULL) : | |
222 | CYNext<CYProtocol>(next), | |
223 | name_(name) | |
224 | { | |
225 | } | |
226 | ||
227 | CYStatement *Replace(CYContext &context) const; | |
228 | void Output(CYOutput &out) const; | |
229 | }; | |
230 | ||
c5b15840 | 231 | struct CYImplementation : |
ec18682d JF |
232 | CYStatement |
233 | { | |
c5b15840 | 234 | CYIdentifier *name_; |
09fc3efb | 235 | CYExpression *extends_; |
64b8d29f | 236 | CYProtocol *protocols_; |
c5b15840 | 237 | CYImplementationField *fields_; |
4de0686f JF |
238 | CYMessage *messages_; |
239 | ||
09fc3efb | 240 | CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) : |
4de0686f | 241 | name_(name), |
09fc3efb | 242 | extends_(extends), |
64b8d29f | 243 | protocols_(protocols), |
4de0686f JF |
244 | fields_(fields), |
245 | messages_(messages) | |
246 | { | |
247 | } | |
248 | ||
efd689d8 JF |
249 | CYCompact(None) |
250 | ||
4de0686f JF |
251 | virtual CYStatement *Replace(CYContext &context); |
252 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
253 | }; | |
254 | ||
255 | struct CYCategory : | |
256 | CYStatement | |
257 | { | |
c5b15840 | 258 | CYIdentifier *name_; |
4de0686f JF |
259 | CYMessage *messages_; |
260 | ||
c5b15840 | 261 | CYCategory(CYIdentifier *name, CYMessage *messages) : |
4de0686f JF |
262 | name_(name), |
263 | messages_(messages) | |
264 | { | |
265 | } | |
266 | ||
efd689d8 JF |
267 | CYCompact(None) |
268 | ||
4de0686f JF |
269 | virtual CYStatement *Replace(CYContext &context); |
270 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
271 | }; | |
272 | ||
273 | struct CYSend : | |
7085e1ab | 274 | CYTarget |
4de0686f | 275 | { |
4de0686f JF |
276 | CYArgument *arguments_; |
277 | ||
cacd1a88 | 278 | CYSend(CYArgument *arguments) : |
4de0686f JF |
279 | arguments_(arguments) |
280 | { | |
281 | } | |
282 | ||
283 | CYPrecedence(0) | |
284 | ||
cacd1a88 JF |
285 | virtual void Output(CYOutput &out, CYFlags flags) const; |
286 | }; | |
287 | ||
288 | struct CYSendDirect : | |
289 | CYSend | |
290 | { | |
291 | CYExpression *self_; | |
292 | ||
293 | CYSendDirect(CYExpression *self, CYArgument *arguments) : | |
294 | CYSend(arguments), | |
295 | self_(self) | |
296 | { | |
297 | } | |
298 | ||
7085e1ab | 299 | virtual CYTarget *Replace(CYContext &context); |
cacd1a88 JF |
300 | virtual void Output(CYOutput &out, CYFlags flags) const; |
301 | }; | |
302 | ||
303 | struct CYSendSuper : | |
304 | CYSend | |
305 | { | |
306 | CYSendSuper(CYArgument *arguments) : | |
307 | CYSend(arguments) | |
308 | { | |
309 | } | |
310 | ||
7085e1ab | 311 | virtual CYTarget *Replace(CYContext &context); |
4de0686f JF |
312 | virtual void Output(CYOutput &out, CYFlags flags) const; |
313 | }; | |
314 | ||
3c1c3635 | 315 | #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/ |