1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2013 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
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.
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.
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/>.
22 #ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23 #define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
27 struct CYInstanceLiteral :
32 CYInstanceLiteral(CYNumber *number) :
39 virtual CYExpression *Replace(CYContext &context);
40 virtual void Output(CYOutput &out, CYFlags flags) const;
46 CYTypedIdentifier *typed_;
47 CYTypedParameter *parameters_;
48 CYStatement *statements_;
50 CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *statements) :
52 parameters_(parameters),
53 statements_(statements)
59 virtual CYExpression *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
68 CYBox(CYExpression *value) :
75 virtual CYExpression *Replace(CYContext &context);
76 virtual void Output(CYOutput &out, CYFlags flags) const;
79 struct CYSelectorPart :
80 CYNext<CYSelectorPart>,
86 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
87 CYNext<CYSelectorPart>(next),
93 CYString *Replace(CYContext &context);
94 virtual void Output(CYOutput &out) const;
100 CYSelectorPart *name_;
102 CYSelector(CYSelectorPart *name) :
109 virtual CYExpression *Replace(CYContext &context);
110 virtual void Output(CYOutput &out, CYFlags flags) const;
116 CYTypedIdentifier *typed_;
118 CYField(CYTypedIdentifier *typed, CYField *next = NULL) :
119 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;
192 CYModule(CYWord *part, CYModule *next = NULL) :
193 CYNext<CYModule>(next),
198 CYString *Replace(CYContext &context, const char *separator) const;
199 void Output(CYOutput &out) const;
207 CYImport(CYModule *module) :
212 virtual CYStatement *Replace(CYContext &context);
213 virtual void Output(CYOutput &out, CYFlags flags) const;
218 CYExpression *super_;
219 CYProtocol *protocols_;
221 CYMessage *messages_;
223 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
226 protocols_(protocols),
235 CYExpression *Replace_(CYContext &context);
236 virtual void Output(CYOutput &out, CYFlags flags) const;
239 struct CYClassExpression :
243 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
244 CYClass(name, super, protocols, fields, messages)
250 virtual CYExpression *Replace(CYContext &context);
251 virtual void Output(CYOutput &out, CYFlags flags) const;
254 struct CYClassStatement :
258 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
259 CYClass(name, super, protocols, fields, messages)
263 virtual CYStatement *Replace(CYContext &context);
264 virtual void Output(CYOutput &out, CYFlags flags) const;
271 CYMessage *messages_;
273 CYCategory(CYClassName *name, CYMessage *messages) :
279 virtual CYStatement *Replace(CYContext &context);
280 virtual void Output(CYOutput &out, CYFlags flags) const;
286 CYArgument *arguments_;
288 CYSend(CYArgument *arguments) :
289 arguments_(arguments)
295 virtual void Output(CYOutput &out, CYFlags flags) const;
298 struct CYSendDirect :
303 CYSendDirect(CYExpression *self, CYArgument *arguments) :
309 virtual CYExpression *Replace(CYContext &context);
310 virtual void Output(CYOutput &out, CYFlags flags) const;
316 CYSendSuper(CYArgument *arguments) :
321 virtual CYExpression *Replace(CYContext &context);
322 virtual void Output(CYOutput &out, CYFlags flags) const;
325 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/