1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2012 Jay Freeman (saurik)
5 /* GNU Lesser General Public License, Version 3 {{{ */
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.
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.
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/>.
22 #ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23 #define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
27 struct CYEncodedPart :
31 CYArgument *arguments_;
33 CYEncodedPart(CYEncodedPart *next, const char *name, CYArgument *arguments = NULL) :
34 CYNext<CYEncodedPart>(next),
40 CYExpression *Replace(CYContext &context, CYExpression *base);
43 struct CYEncodedType :
47 CYEncodedPart *parts_;
49 CYEncodedType(CYExpression *base, CYEncodedPart *parts = NULL) :
57 virtual CYExpression *Replace(CYContext &context);
58 virtual void Output(CYOutput &out, CYFlags flags) const;
66 CYBox(CYExpression *value) :
73 virtual CYExpression *Replace(CYContext &context);
74 virtual void Output(CYOutput &out, CYFlags flags) const;
77 struct CYSelectorPart :
78 CYNext<CYSelectorPart>,
84 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
85 CYNext<CYSelectorPart>(next),
91 CYString *Replace(CYContext &context);
92 virtual void Output(CYOutput &out) const;
98 CYSelectorPart *name_;
100 CYSelector(CYSelectorPart *name) :
107 virtual CYExpression *Replace(CYContext &context);
108 virtual void Output(CYOutput &out, CYFlags flags) const;
117 CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) :
118 CYNext<CYField>(next),
124 CYStatement *Replace(CYContext &context) const;
125 void Output(CYOutput &out) const;
128 struct CYMessageParameter :
129 CYNext<CYMessageParameter>
135 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
142 CYFunctionParameter *Parameters(CYContext &context) const;
143 CYSelector *Selector(CYContext &context) const;
144 CYSelectorPart *SelectorPart(CYContext &context) const;
145 CYExpression *TypeSignature(CYContext &context) const;
153 CYMessageParameter *parameters_;
156 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
159 parameters_(parameter),
164 CYStatement *Replace(CYContext &context, bool replace) const;
165 void Output(CYOutput &out, bool replace) const;
167 CYExpression *TypeSignature(CYContext &context) const;
176 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
177 CYNext<CYProtocol>(next),
182 CYStatement *Replace(CYContext &context) const;
183 void Output(CYOutput &out) const;
189 virtual CYStatement *Replace(CYContext &context);
190 virtual void Output(CYOutput &out, CYFlags flags) const;
195 CYExpression *super_;
196 CYProtocol *protocols_;
198 CYMessage *messages_;
200 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
203 protocols_(protocols),
212 CYExpression *Replace_(CYContext &context);
213 virtual void Output(CYOutput &out, CYFlags flags) const;
216 struct CYClassExpression :
220 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
221 CYClass(name, super, protocols, fields, messages)
227 virtual CYExpression *Replace(CYContext &context);
228 virtual void Output(CYOutput &out, CYFlags flags) const;
231 struct CYClassStatement :
235 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
236 CYClass(name, super, protocols, fields, messages)
240 virtual CYStatement *Replace(CYContext &context);
241 virtual void Output(CYOutput &out, CYFlags flags) const;
248 CYMessage *messages_;
250 CYCategory(CYClassName *name, CYMessage *messages) :
256 virtual CYStatement *Replace(CYContext &context);
257 virtual void Output(CYOutput &out, CYFlags flags) const;
263 CYArgument *arguments_;
265 CYSend(CYArgument *arguments) :
266 arguments_(arguments)
272 virtual void Output(CYOutput &out, CYFlags flags) const;
275 struct CYSendDirect :
280 CYSendDirect(CYExpression *self, CYArgument *arguments) :
286 virtual CYExpression *Replace(CYContext &context);
287 virtual void Output(CYOutput &out, CYFlags flags) const;
293 CYSendSuper(CYArgument *arguments) :
298 virtual CYExpression *Replace(CYContext &context);
299 virtual void Output(CYOutput &out, CYFlags flags) const;
302 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/