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 CYTypeModifier :
28 CYNext<CYTypeModifier>
30 CYTypeModifier(CYTypeModifier *next) :
31 CYNext<CYTypeModifier>(next)
35 virtual CYExpression *Replace(CYContext &context) = 0;
38 struct CYTypeArrayOf :
43 CYTypeArrayOf(CYExpression *size, CYTypeModifier *next = NULL) :
51 virtual CYExpression *Replace(CYContext &context);
54 struct CYTypeConstant :
57 CYTypeConstant(CYTypeModifier *next = NULL) :
64 virtual CYExpression *Replace(CYContext &context);
67 struct CYTypePointerTo :
70 CYTypePointerTo(CYTypeModifier *next = NULL) :
77 virtual CYExpression *Replace(CYContext &context);
80 struct CYTypeVariable :
83 CYExpression *expression_;
85 CYTypeVariable(CYExpression *expression) :
87 expression_(expression)
93 virtual CYExpression *Replace(CYContext &context);
96 struct CYTypedIdentifier :
97 CYNext<CYTypedIdentifier>
99 CYIdentifier *identifier_;
100 CYTypeModifier *type_;
102 CYTypedIdentifier(CYIdentifier *identifier) :
103 identifier_(identifier),
109 struct CYTypedParameter :
110 CYNext<CYTypedParameter>
112 CYTypedIdentifier *typed_;
114 CYTypedParameter(CYTypedIdentifier *typed, CYTypedParameter *next) :
115 CYNext<CYTypedParameter>(next),
120 CYFunctionParameter *Parameters(CYContext &context);
121 CYExpression *TypeSignature(CYContext &context, CYExpression *prefix);
127 CYTypeModifier *type_;
128 CYTypedParameter *parameters_;
129 CYStatement *statements_;
131 CYObjCBlock(CYTypeModifier *type, CYTypedParameter *parameters, CYStatement *statements) :
133 parameters_(parameters),
134 statements_(statements)
140 virtual CYExpression *Replace(CYContext &context);
141 virtual void Output(CYOutput &out, CYFlags flags) const;
144 struct CYEncodedType :
147 CYTypeModifier *type_;
149 CYEncodedType(CYTypeModifier *type) :
156 virtual CYExpression *Replace(CYContext &context);
157 virtual void Output(CYOutput &out, CYFlags flags) const;
163 CYExpression *value_;
165 CYBox(CYExpression *value) :
172 virtual CYExpression *Replace(CYContext &context);
173 virtual void Output(CYOutput &out, CYFlags flags) const;
176 struct CYSelectorPart :
177 CYNext<CYSelectorPart>,
183 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
184 CYNext<CYSelectorPart>(next),
190 CYString *Replace(CYContext &context);
191 virtual void Output(CYOutput &out) const;
197 CYSelectorPart *name_;
199 CYSelector(CYSelectorPart *name) :
206 virtual CYExpression *Replace(CYContext &context);
207 virtual void Output(CYOutput &out, CYFlags flags) const;
216 CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) :
217 CYNext<CYField>(next),
223 CYStatement *Replace(CYContext &context) const;
224 void Output(CYOutput &out) const;
227 struct CYMessageParameter :
228 CYNext<CYMessageParameter>
234 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
241 CYFunctionParameter *Parameters(CYContext &context) const;
242 CYSelector *Selector(CYContext &context) const;
243 CYSelectorPart *SelectorPart(CYContext &context) const;
244 CYExpression *TypeSignature(CYContext &context) const;
252 CYMessageParameter *parameters_;
255 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
258 parameters_(parameter),
263 CYStatement *Replace(CYContext &context, bool replace) const;
264 void Output(CYOutput &out, bool replace) const;
266 CYExpression *TypeSignature(CYContext &context) const;
275 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
276 CYNext<CYProtocol>(next),
281 CYStatement *Replace(CYContext &context) const;
282 void Output(CYOutput &out) const;
288 virtual CYStatement *Replace(CYContext &context);
289 virtual void Output(CYOutput &out, CYFlags flags) const;
294 CYExpression *super_;
295 CYProtocol *protocols_;
297 CYMessage *messages_;
299 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
302 protocols_(protocols),
311 CYExpression *Replace_(CYContext &context);
312 virtual void Output(CYOutput &out, CYFlags flags) const;
315 struct CYClassExpression :
319 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
320 CYClass(name, super, protocols, fields, messages)
326 virtual CYExpression *Replace(CYContext &context);
327 virtual void Output(CYOutput &out, CYFlags flags) const;
330 struct CYClassStatement :
334 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
335 CYClass(name, super, protocols, fields, messages)
339 virtual CYStatement *Replace(CYContext &context);
340 virtual void Output(CYOutput &out, CYFlags flags) const;
347 CYMessage *messages_;
349 CYCategory(CYClassName *name, CYMessage *messages) :
355 virtual CYStatement *Replace(CYContext &context);
356 virtual void Output(CYOutput &out, CYFlags flags) const;
362 CYArgument *arguments_;
364 CYSend(CYArgument *arguments) :
365 arguments_(arguments)
371 virtual void Output(CYOutput &out, CYFlags flags) const;
374 struct CYSendDirect :
379 CYSendDirect(CYExpression *self, CYArgument *arguments) :
385 virtual CYExpression *Replace(CYContext &context);
386 virtual void Output(CYOutput &out, CYFlags flags) const;
392 CYSendSuper(CYArgument *arguments) :
397 virtual CYExpression *Replace(CYContext &context);
398 virtual void Output(CYOutput &out, CYFlags flags) const;
401 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/