1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2010 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 CYSelectorPart :
28 CYNext<CYSelectorPart>,
34 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
35 CYNext<CYSelectorPart>(next),
41 CYString *Replace(CYContext &context);
42 virtual void Output(CYOutput &out) const;
48 CYSelectorPart *name_;
50 CYSelector(CYSelectorPart *name) :
57 virtual CYExpression *Replace(CYContext &context);
58 virtual void Output(CYOutput &out, CYFlags flags) const;
64 CYStatement *Replace(CYContext &context) const;
65 void Output(CYOutput &out) const;
68 struct CYMessageParameter :
69 CYNext<CYMessageParameter>
75 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
82 CYFunctionParameter *Parameters(CYContext &context) const;
83 CYSelector *Selector(CYContext &context) const;
84 CYSelectorPart *SelectorPart(CYContext &context) const;
92 CYMessageParameter *parameters_;
95 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
98 parameters_(parameter),
103 CYStatement *Replace(CYContext &context, bool replace) const;
104 void Output(CYOutput &out, bool replace) const;
113 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
114 CYNext<CYProtocol>(next),
119 CYStatement *Replace(CYContext &context) const;
120 void Output(CYOutput &out) const;
126 virtual CYStatement *Replace(CYContext &context);
127 virtual void Output(CYOutput &out, CYFlags flags) const;
132 CYExpression *super_;
133 CYProtocol *protocols_;
135 CYMessage *messages_;
137 CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
140 protocols_(protocols),
149 CYExpression *Replace_(CYContext &context);
150 virtual void Output(CYOutput &out, CYFlags flags) const;
153 struct CYClassExpression :
157 CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
158 CYClass(name, super, protocols, fields, messages)
164 virtual CYExpression *Replace(CYContext &context);
165 virtual void Output(CYOutput &out, CYFlags flags) const;
168 struct CYClassStatement :
172 CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYField *fields, CYMessage *messages) :
173 CYClass(name, super, protocols, fields, messages)
177 virtual CYStatement *Replace(CYContext &context);
178 virtual void Output(CYOutput &out, CYFlags flags) const;
185 CYMessage *messages_;
187 CYCategory(CYClassName *name, CYMessage *messages) :
193 virtual CYStatement *Replace(CYContext &context);
194 virtual void Output(CYOutput &out, CYFlags flags) const;
200 CYArgument *arguments_;
202 CYSend(CYArgument *arguments) :
203 arguments_(arguments)
209 virtual void Output(CYOutput &out, CYFlags flags) const;
212 struct CYSendDirect :
217 CYSendDirect(CYExpression *self, CYArgument *arguments) :
223 virtual CYExpression *Replace(CYContext &context);
224 virtual void Output(CYOutput &out, CYFlags flags) const;
230 CYSendSuper(CYArgument *arguments) :
235 virtual CYExpression *Replace(CYContext &context);
236 virtual void Output(CYOutput &out, CYFlags flags) const;
239 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/