]>
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 | { | |
80 | CYStatement *Replace(CYContext &context) const; | |
81 | void Output(CYOutput &out) const; | |
82 | }; | |
83 | ||
84 | struct CYMessageParameter : | |
85 | CYNext<CYMessageParameter> | |
86 | { | |
87 | CYWord *tag_; | |
88 | CYExpression *type_; | |
89 | CYIdentifier *name_; | |
90 | ||
91 | CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) : | |
92 | tag_(tag), | |
93 | type_(type), | |
94 | name_(name) | |
95 | { | |
96 | } | |
97 | ||
98 | CYFunctionParameter *Parameters(CYContext &context) const; | |
99 | CYSelector *Selector(CYContext &context) const; | |
100 | CYSelectorPart *SelectorPart(CYContext &context) const; | |
101 | }; | |
102 | ||
103 | struct CYMessage : | |
104 | CYNext<CYMessage> | |
105 | { | |
106 | bool instance_; | |
107 | CYExpression *type_; | |
108 | CYMessageParameter *parameters_; | |
4644480a | 109 | CYBlock code_; |
4de0686f JF |
110 | |
111 | CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) : | |
112 | instance_(instance), | |
113 | type_(type), | |
114 | parameters_(parameter), | |
4644480a | 115 | code_(statements) |
4de0686f JF |
116 | { |
117 | } | |
118 | ||
119 | CYStatement *Replace(CYContext &context, bool replace) const; | |
120 | void Output(CYOutput &out, bool replace) const; | |
121 | }; | |
122 | ||
64b8d29f JF |
123 | struct CYProtocol : |
124 | CYNext<CYProtocol>, | |
125 | CYThing | |
126 | { | |
127 | CYExpression *name_; | |
128 | ||
129 | CYProtocol(CYExpression *name, CYProtocol *next = NULL) : | |
130 | CYNext<CYProtocol>(next), | |
131 | name_(name) | |
132 | { | |
133 | } | |
134 | ||
135 | CYStatement *Replace(CYContext &context) const; | |
136 | void Output(CYOutput &out) const; | |
137 | }; | |
138 | ||
1ba6903e JF |
139 | struct CYImport : |
140 | CYStatement | |
141 | { | |
142 | virtual CYStatement *Replace(CYContext &context); | |
143 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
144 | }; | |
145 | ||
4de0686f JF |
146 | struct CYClass { |
147 | CYClassName *name_; | |
148 | CYExpression *super_; | |
64b8d29f | 149 | CYProtocol *protocols_; |
4de0686f JF |
150 | CYField *fields_; |
151 | CYMessage *messages_; | |
152 | ||
64b8d29f | 153 | CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : |
4de0686f JF |
154 | name_(name), |
155 | super_(super), | |
64b8d29f | 156 | protocols_(protocols), |
4de0686f JF |
157 | fields_(fields), |
158 | messages_(messages) | |
159 | { | |
160 | } | |
161 | ||
7c6c5b0a JF |
162 | virtual ~CYClass() { |
163 | } | |
164 | ||
4de0686f JF |
165 | CYExpression *Replace_(CYContext &context); |
166 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
167 | }; | |
168 | ||
169 | struct CYClassExpression : | |
170 | CYClass, | |
171 | CYExpression | |
172 | { | |
64b8d29f JF |
173 | CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : |
174 | CYClass(name, super, protocols, fields, messages) | |
4de0686f JF |
175 | { |
176 | } | |
177 | ||
178 | CYPrecedence(0) | |
179 | ||
180 | virtual CYExpression *Replace(CYContext &context); | |
181 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
182 | }; | |
183 | ||
184 | struct CYClassStatement : | |
185 | CYClass, | |
186 | CYStatement | |
187 | { | |
64b8d29f JF |
188 | CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) : |
189 | CYClass(name, super, protocols, fields, messages) | |
4de0686f JF |
190 | { |
191 | } | |
192 | ||
193 | virtual CYStatement *Replace(CYContext &context); | |
194 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
195 | }; | |
196 | ||
197 | struct CYCategory : | |
198 | CYStatement | |
199 | { | |
200 | CYClassName *name_; | |
201 | CYMessage *messages_; | |
202 | ||
203 | CYCategory(CYClassName *name, CYMessage *messages) : | |
204 | name_(name), | |
205 | messages_(messages) | |
206 | { | |
207 | } | |
208 | ||
209 | virtual CYStatement *Replace(CYContext &context); | |
210 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
211 | }; | |
212 | ||
213 | struct CYSend : | |
214 | CYExpression | |
215 | { | |
4de0686f JF |
216 | CYArgument *arguments_; |
217 | ||
cacd1a88 | 218 | CYSend(CYArgument *arguments) : |
4de0686f JF |
219 | arguments_(arguments) |
220 | { | |
221 | } | |
222 | ||
223 | CYPrecedence(0) | |
224 | ||
cacd1a88 JF |
225 | virtual void Output(CYOutput &out, CYFlags flags) const; |
226 | }; | |
227 | ||
228 | struct CYSendDirect : | |
229 | CYSend | |
230 | { | |
231 | CYExpression *self_; | |
232 | ||
233 | CYSendDirect(CYExpression *self, CYArgument *arguments) : | |
234 | CYSend(arguments), | |
235 | self_(self) | |
236 | { | |
237 | } | |
238 | ||
239 | virtual CYExpression *Replace(CYContext &context); | |
240 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
241 | }; | |
242 | ||
243 | struct CYSendSuper : | |
244 | CYSend | |
245 | { | |
246 | CYSendSuper(CYArgument *arguments) : | |
247 | CYSend(arguments) | |
248 | { | |
249 | } | |
250 | ||
4de0686f JF |
251 | virtual CYExpression *Replace(CYContext &context); |
252 | virtual void Output(CYOutput &out, CYFlags flags) const; | |
253 | }; | |
254 | ||
3c1c3635 | 255 | #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/ |