]>
Commit | Line | Data |
---|---|---|
1 | /* Cycript - Optimizing JavaScript Compiler/Runtime | |
2 | * Copyright (C) 2009-2013 Jay Freeman (saurik) | |
3 | */ | |
4 | ||
5 | /* GNU General Public License, Version 3 {{{ */ | |
6 | /* | |
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. | |
11 | * | |
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. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Cycript. If not, see <http://www.gnu.org/licenses/>. | |
19 | **/ | |
20 | /* }}} */ | |
21 | ||
22 | #ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP | |
23 | #define CYCRIPT_OBJECTIVEC_SYNTAX_HPP | |
24 | ||
25 | #include "Parser.hpp" | |
26 | ||
27 | struct CYObjCBlock : | |
28 | CYExpression | |
29 | { | |
30 | CYTypedIdentifier *typed_; | |
31 | CYTypedParameter *parameters_; | |
32 | CYStatement *statements_; | |
33 | ||
34 | CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *statements) : | |
35 | typed_(typed), | |
36 | parameters_(parameters), | |
37 | statements_(statements) | |
38 | { | |
39 | } | |
40 | ||
41 | CYPrecedence(1) | |
42 | ||
43 | virtual CYExpression *Replace(CYContext &context); | |
44 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
45 | }; | |
46 | ||
47 | struct CYBox : | |
48 | CYExpression | |
49 | { | |
50 | CYExpression *value_; | |
51 | ||
52 | CYBox(CYExpression *value) : | |
53 | value_(value) | |
54 | { | |
55 | } | |
56 | ||
57 | CYPrecedence(1) | |
58 | ||
59 | virtual CYExpression *Replace(CYContext &context); | |
60 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
61 | }; | |
62 | ||
63 | struct CYSelectorPart : | |
64 | CYNext<CYSelectorPart>, | |
65 | CYThing | |
66 | { | |
67 | CYWord *name_; | |
68 | bool value_; | |
69 | ||
70 | CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) : | |
71 | CYNext<CYSelectorPart>(next), | |
72 | name_(name), | |
73 | value_(value) | |
74 | { | |
75 | } | |
76 | ||
77 | CYString *Replace(CYContext &context); | |
78 | virtual void Output(CYOutput &out) const; | |
79 | }; | |
80 | ||
81 | struct CYSelector : | |
82 | CYLiteral | |
83 | { | |
84 | CYSelectorPart *name_; | |
85 | ||
86 | CYSelector(CYSelectorPart *name) : | |
87 | name_(name) | |
88 | { | |
89 | } | |
90 | ||
91 | CYPrecedence(1) | |
92 | ||
93 | virtual CYExpression *Replace(CYContext &context); | |
94 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
95 | }; | |
96 | ||
97 | struct CYField : | |
98 | CYNext<CYField> | |
99 | { | |
100 | CYExpression *type_; | |
101 | CYIdentifier *name_; | |
102 | ||
103 | CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) : | |
104 | CYNext<CYField>(next), | |
105 | type_(type), | |
106 | name_(name) | |
107 | { | |
108 | } | |
109 | ||
110 | CYStatement *Replace(CYContext &context) const; | |
111 | void Output(CYOutput &out) const; | |
112 | }; | |
113 | ||
114 | struct CYMessageParameter : | |
115 | CYNext<CYMessageParameter> | |
116 | { | |
117 | CYWord *tag_; | |
118 | CYExpression *type_; | |
119 | CYIdentifier *name_; | |
120 | ||
121 | CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) : | |
122 | tag_(tag), | |
123 | type_(type), | |
124 | name_(name) | |
125 | { | |
126 | } | |
127 | ||
128 | CYFunctionParameter *Parameters(CYContext &context) const; | |
129 | CYSelector *Selector(CYContext &context) const; | |
130 | CYSelectorPart *SelectorPart(CYContext &context) const; | |
131 | CYExpression *TypeSignature(CYContext &context) const; | |
132 | }; | |
133 | ||
134 | struct CYMessage : | |
135 | CYNext<CYMessage> | |
136 | { | |
137 | bool instance_; | |
138 | CYExpression *type_; | |
139 | CYMessageParameter *parameters_; | |
140 | CYBlock code_; | |
141 | ||
142 | CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) : | |
143 | instance_(instance), | |
144 | type_(type), | |
145 | parameters_(parameter), | |
146 | code_(statements) | |
147 | { | |
148 | } | |
149 | ||
150 | CYStatement *Replace(CYContext &context, bool replace) const; | |
151 | void Output(CYOutput &out, bool replace) const; | |
152 | ||
153 | CYExpression *TypeSignature(CYContext &context) const; | |
154 | }; | |
155 | ||
156 | struct CYProtocol : | |
157 | CYNext<CYProtocol>, | |
158 | CYThing | |
159 | { | |
160 | CYExpression *name_; | |
161 | ||
162 | CYProtocol(CYExpression *name, CYProtocol *next = NULL) : | |
163 | CYNext<CYProtocol>(next), | |
164 | name_(name) | |
165 | { | |
166 | } | |
167 | ||
168 | CYStatement *Replace(CYContext &context) const; | |
169 | void Output(CYOutput &out) const; | |
170 | }; | |
171 | ||
172 | struct CYImport : | |
173 | CYStatement | |
174 | { | |
175 | virtual CYStatement *Replace(CYContext &context); | |
176 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
177 | }; | |
178 | ||
179 | struct CYClass { | |
180 | CYClassName *name_; | |
181 | CYExpression *super_; | |
182 | CYProtocol *protocols_; | |
183 | CYField *fields_; | |
184 | CYMessage *messages_; | |
185 | ||
186 | CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : | |
187 | name_(name), | |
188 | super_(super), | |
189 | protocols_(protocols), | |
190 | fields_(fields), | |
191 | messages_(messages) | |
192 | { | |
193 | } | |
194 | ||
195 | virtual ~CYClass() { | |
196 | } | |
197 | ||
198 | CYExpression *Replace_(CYContext &context); | |
199 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
200 | }; | |
201 | ||
202 | struct CYClassExpression : | |
203 | CYClass, | |
204 | CYExpression | |
205 | { | |
206 | CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : | |
207 | CYClass(name, super, protocols, fields, messages) | |
208 | { | |
209 | } | |
210 | ||
211 | CYPrecedence(0) | |
212 | ||
213 | virtual CYExpression *Replace(CYContext &context); | |
214 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
215 | }; | |
216 | ||
217 | struct CYClassStatement : | |
218 | CYClass, | |
219 | CYStatement | |
220 | { | |
221 | CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : | |
222 | CYClass(name, super, protocols, fields, messages) | |
223 | { | |
224 | } | |
225 | ||
226 | virtual CYStatement *Replace(CYContext &context); | |
227 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
228 | }; | |
229 | ||
230 | struct CYCategory : | |
231 | CYStatement | |
232 | { | |
233 | CYClassName *name_; | |
234 | CYMessage *messages_; | |
235 | ||
236 | CYCategory(CYClassName *name, CYMessage *messages) : | |
237 | name_(name), | |
238 | messages_(messages) | |
239 | { | |
240 | } | |
241 | ||
242 | virtual CYStatement *Replace(CYContext &context); | |
243 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
244 | }; | |
245 | ||
246 | struct CYSend : | |
247 | CYExpression | |
248 | { | |
249 | CYArgument *arguments_; | |
250 | ||
251 | CYSend(CYArgument *arguments) : | |
252 | arguments_(arguments) | |
253 | { | |
254 | } | |
255 | ||
256 | CYPrecedence(0) | |
257 | ||
258 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
259 | }; | |
260 | ||
261 | struct CYSendDirect : | |
262 | CYSend | |
263 | { | |
264 | CYExpression *self_; | |
265 | ||
266 | CYSendDirect(CYExpression *self, CYArgument *arguments) : | |
267 | CYSend(arguments), | |
268 | self_(self) | |
269 | { | |
270 | } | |
271 | ||
272 | virtual CYExpression *Replace(CYContext &context); | |
273 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
274 | }; | |
275 | ||
276 | struct CYSendSuper : | |
277 | CYSend | |
278 | { | |
279 | CYSendSuper(CYArgument *arguments) : | |
280 | CYSend(arguments) | |
281 | { | |
282 | } | |
283 | ||
284 | virtual CYExpression *Replace(CYContext &context); | |
285 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
286 | }; | |
287 | ||
288 | #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/ |