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
30 CYTypedIdentifier *typed_;
31 CYTypedParameter *parameters_;
32 CYStatement *statements_;
34 CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *statements) :
36 parameters_(parameters),
37 statements_(statements)
43 virtual CYExpression *Replace(CYContext &context);
44 virtual void Output(CYOutput &out, CYFlags flags) const;
52 CYBox(CYExpression *value) :
59 virtual CYExpression *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
63 struct CYSelectorPart :
64 CYNext<CYSelectorPart>,
70 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
71 CYNext<CYSelectorPart>(next),
77 CYString *Replace(CYContext &context);
78 virtual void Output(CYOutput &out) const;
84 CYSelectorPart *name_;
86 CYSelector(CYSelectorPart *name) :
93 virtual CYExpression *Replace(CYContext &context);
94 virtual void Output(CYOutput &out, CYFlags flags) const;
103 CYField(CYExpression *type, CYIdentifier *name, CYField *next = NULL) :
104 CYNext<CYField>(next),
110 CYStatement *Replace(CYContext &context) const;
111 void Output(CYOutput &out) const;
114 struct CYMessageParameter :
115 CYNext<CYMessageParameter>
121 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
128 CYFunctionParameter *Parameters(CYContext &context) const;
129 CYSelector *Selector(CYContext &context) const;
130 CYSelectorPart *SelectorPart(CYContext &context) const;
131 CYExpression *TypeSignature(CYContext &context) const;
139 CYMessageParameter *parameters_;
142 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
145 parameters_(parameter),
150 CYStatement *Replace(CYContext &context, bool replace) const;
151 void Output(CYOutput &out, bool replace) const;
153 CYExpression *TypeSignature(CYContext &context) const;
162 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
163 CYNext<CYProtocol>(next),
168 CYStatement *Replace(CYContext &context) const;
169 void Output(CYOutput &out) const;
178 CYModule(CYWord *part, CYModule *next = NULL) :
179 CYNext<CYModule>(next),
184 CYString *Replace(CYContext &context, const char *separator) const;
185 void Output(CYOutput &out) const;
193 CYImport(CYModule *module) :
198 virtual CYStatement *Replace(CYContext &context);
199 virtual void Output(CYOutput &out, CYFlags flags) const;
204 CYExpression *super_;
205 CYProtocol *protocols_;
207 CYMessage *messages_;
209 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
212 protocols_(protocols),
221 CYExpression *Replace_(CYContext &context);
222 virtual void Output(CYOutput &out, CYFlags flags) const;
225 struct CYClassExpression :
229 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
230 CYClass(name, super, protocols, fields, messages)
236 virtual CYExpression *Replace(CYContext &context);
237 virtual void Output(CYOutput &out, CYFlags flags) const;
240 struct CYClassStatement :
244 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
245 CYClass(name, super, protocols, fields, messages)
249 virtual CYStatement *Replace(CYContext &context);
250 virtual void Output(CYOutput &out, CYFlags flags) const;
257 CYMessage *messages_;
259 CYCategory(CYClassName *name, CYMessage *messages) :
265 virtual CYStatement *Replace(CYContext &context);
266 virtual void Output(CYOutput &out, CYFlags flags) const;
272 CYArgument *arguments_;
274 CYSend(CYArgument *arguments) :
275 arguments_(arguments)
281 virtual void Output(CYOutput &out, CYFlags flags) const;
284 struct CYSendDirect :
289 CYSendDirect(CYExpression *self, CYArgument *arguments) :
295 virtual CYExpression *Replace(CYContext &context);
296 virtual void Output(CYOutput &out, CYFlags flags) const;
302 CYSendSuper(CYArgument *arguments) :
307 virtual CYExpression *Replace(CYContext &context);
308 virtual void Output(CYOutput &out, CYFlags flags) const;
311 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/