]>
Commit | Line | Data |
---|---|---|
b3378a02 | 1 | /* Cycript - Optimizing JavaScript Compiler/Runtime |
8d7447c1 | 2 | * Copyright (C) 2009-2012 Jay Freeman (saurik) |
4644480a JF |
3 | */ |
4 | ||
b3378a02 | 5 | /* GNU Lesser General Public License, Version 3 {{{ */ |
4644480a | 6 | /* |
b3378a02 JF |
7 | * Cycript is free software: you can redistribute it and/or modify it under |
8 | * the terms of the GNU Lesser General Public License as published by the | |
9 | * Free Software Foundation, either version 3 of the License, or (at your | |
10 | * option) any later version. | |
4644480a | 11 | * |
b3378a02 JF |
12 | * Cycript is distributed in the hope that it will be useful, but WITHOUT |
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
15 | * License for more details. | |
4644480a | 16 | * |
b3378a02 JF |
17 | * You should have received a copy of the GNU Lesser General Public License |
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 | ||
f2f0d1d1 JF |
27 | struct CYBox : |
28 | CYExpression | |
29 | { | |
30 | CYExpression *value_; | |
31 | ||
32 | CYBox(CYExpression *value) : | |
33 | value_(value) | |
34 | { | |
35 | } | |
36 | ||
37 | CYPrecedence(1) | |
38 | ||
39 | virtual CYExpression *Replace(CYContext &context); | |
40 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
41 | }; | |
42 | ||
4de0686f JF |
43 | struct CYSelectorPart : |
44 | CYNext<CYSelectorPart>, | |
45 | CYThing | |
46 | { | |
47 | CYWord *name_; | |
48 | bool value_; | |
49 | ||
2385c806 | 50 | CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) : |
4de0686f JF |
51 | CYNext<CYSelectorPart>(next), |
52 | name_(name), | |
53 | value_(value) | |
54 | { | |
55 | } | |
56 | ||
57 | CYString *Replace(CYContext &context); | |
58 | virtual void Output(CYOutput &out) const; | |
59 | }; | |
60 | ||
61 | struct CYSelector : | |
62 | CYLiteral | |
63 | { | |
64 | CYSelectorPart *name_; | |
65 | ||
66 | CYSelector(CYSelectorPart *name) : | |
67 | name_(name) | |
68 | { | |
69 | } | |
70 | ||
71 | CYPrecedence(1) | |
72 | ||
73 | virtual CYExpression *Replace(CYContext &context); | |
74 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
75 | }; | |
76 | ||
77 | struct CYField : | |
78 | CYNext<CYField> | |
79 | { | |
cfd73c6d JF |
80 | CYExpression *type_; |
81 | CYIdentifier *name_; | |
82 | ||
83 | CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) : | |
84 | CYNext<CYField>(next), | |
85 | type_(type), | |
86 | name_(name) | |
87 | { | |
88 | } | |
89 | ||
4de0686f JF |
90 | CYStatement *Replace(CYContext &context) const; |
91 | void Output(CYOutput &out) const; | |
92 | }; | |
93 | ||
94 | struct CYMessageParameter : | |
95 | CYNext<CYMessageParameter> | |
96 | { | |
97 | CYWord *tag_; | |
98 | CYExpression *type_; | |
99 | CYIdentifier *name_; | |
100 | ||
101 | CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) : | |
102 | tag_(tag), | |
103 | type_(type), | |
104 | name_(name) | |
105 | { | |
106 | } | |
107 | ||
108 | CYFunctionParameter *Parameters(CYContext &context) const; | |
109 | CYSelector *Selector(CYContext &context) const; | |
110 | CYSelectorPart *SelectorPart(CYContext &context) const; | |
9a7c375c | 111 | CYExpression *TypeSignature(CYContext &context) const; |
4de0686f JF |
112 | }; |
113 | ||
114 | struct CYMessage : | |
115 | CYNext<CYMessage> | |
116 | { | |
117 | bool instance_; | |
118 | CYExpression *type_; | |
119 | CYMessageParameter *parameters_; | |
4644480a | 120 | CYBlock code_; |
4de0686f JF |
121 | |
122 | CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) : | |
123 | instance_(instance), | |
124 | type_(type), | |
125 | parameters_(parameter), | |
4644480a | 126 | code_(statements) |
4de0686f JF |
127 | { |
128 | } | |
129 | ||
130 | CYStatement *Replace(CYContext &context, bool replace) const; | |
131 | void Output(CYOutput &out, bool replace) const; | |
9a7c375c JF |
132 | |
133 | CYExpression *TypeSignature(CYContext &context) const; | |
4de0686f JF |
134 | }; |
135 | ||
64b8d29f JF |
136 | struct CYProtocol : |
137 | CYNext<CYProtocol>, | |
138 | CYThing | |
139 | { | |
140 | CYExpression *name_; | |
141 | ||
142 | CYProtocol(CYExpression *name, CYProtocol *next = NULL) : | |
143 | CYNext<CYProtocol>(next), | |
144 | name_(name) | |
145 | { | |
146 | } | |
147 | ||
148 | CYStatement *Replace(CYContext &context) const; | |
149 | void Output(CYOutput &out) const; | |
150 | }; | |
151 | ||
1ba6903e JF |
152 | struct CYImport : |
153 | CYStatement | |
154 | { | |
155 | virtual CYStatement *Replace(CYContext &context); | |
156 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
157 | }; | |
158 | ||
4de0686f JF |
159 | struct CYClass { |
160 | CYClassName *name_; | |
161 | CYExpression *super_; | |
64b8d29f | 162 | CYProtocol *protocols_; |
4de0686f JF |
163 | CYField *fields_; |
164 | CYMessage *messages_; | |
165 | ||
64b8d29f | 166 | CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : |
4de0686f JF |
167 | name_(name), |
168 | super_(super), | |
64b8d29f | 169 | protocols_(protocols), |
4de0686f JF |
170 | fields_(fields), |
171 | messages_(messages) | |
172 | { | |
173 | } | |
174 | ||
7c6c5b0a JF |
175 | virtual ~CYClass() { |
176 | } | |
177 | ||
4de0686f JF |
178 | CYExpression *Replace_(CYContext &context); |
179 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
180 | }; | |
181 | ||
182 | struct CYClassExpression : | |
183 | CYClass, | |
184 | CYExpression | |
185 | { | |
64b8d29f JF |
186 | CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : |
187 | CYClass(name, super, protocols, fields, messages) | |
4de0686f JF |
188 | { |
189 | } | |
190 | ||
191 | CYPrecedence(0) | |
192 | ||
193 | virtual CYExpression *Replace(CYContext &context); | |
194 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
195 | }; | |
196 | ||
197 | struct CYClassStatement : | |
198 | CYClass, | |
199 | CYStatement | |
200 | { | |
64b8d29f JF |
201 | CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : |
202 | CYClass(name, super, protocols, fields, messages) | |
4de0686f JF |
203 | { |
204 | } | |
205 | ||
206 | virtual CYStatement *Replace(CYContext &context); | |
207 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
208 | }; | |
209 | ||
210 | struct CYCategory : | |
211 | CYStatement | |
212 | { | |
213 | CYClassName *name_; | |
214 | CYMessage *messages_; | |
215 | ||
216 | CYCategory(CYClassName *name, CYMessage *messages) : | |
217 | name_(name), | |
218 | messages_(messages) | |
219 | { | |
220 | } | |
221 | ||
222 | virtual CYStatement *Replace(CYContext &context); | |
223 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
224 | }; | |
225 | ||
226 | struct CYSend : | |
227 | CYExpression | |
228 | { | |
4de0686f JF |
229 | CYArgument *arguments_; |
230 | ||
cacd1a88 | 231 | CYSend(CYArgument *arguments) : |
4de0686f JF |
232 | arguments_(arguments) |
233 | { | |
234 | } | |
235 | ||
236 | CYPrecedence(0) | |
237 | ||
cacd1a88 JF |
238 | virtual void Output(CYOutput &out, CYFlags flags) const; |
239 | }; | |
240 | ||
241 | struct CYSendDirect : | |
242 | CYSend | |
243 | { | |
244 | CYExpression *self_; | |
245 | ||
246 | CYSendDirect(CYExpression *self, CYArgument *arguments) : | |
247 | CYSend(arguments), | |
248 | self_(self) | |
249 | { | |
250 | } | |
251 | ||
252 | virtual CYExpression *Replace(CYContext &context); | |
253 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
254 | }; | |
255 | ||
256 | struct CYSendSuper : | |
257 | CYSend | |
258 | { | |
259 | CYSendSuper(CYArgument *arguments) : | |
260 | CYSend(arguments) | |
261 | { | |
262 | } | |
263 | ||
4de0686f JF |
264 | virtual CYExpression *Replace(CYContext &context); |
265 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
266 | }; | |
267 | ||
3c1c3635 | 268 | #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/ |