1 /* Cycript - The Truly Universal Scripting Language
2 * Copyright (C) 2009-2016 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
23 #define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
25 #include "../Syntax.hpp"
27 struct CYInstanceLiteral :
32 CYInstanceLiteral(CYNumber *number) :
39 virtual CYTarget *Replace(CYContext &context);
40 virtual void Output(CYOutput &out, CYFlags flags) const;
47 CYTypedParameter *parameters_;
50 CYObjCBlock(CYType *typed, CYTypedParameter *parameters, CYStatement *code) :
52 parameters_(parameters),
59 virtual CYTarget *Replace(CYContext &context);
60 virtual void Output(CYOutput &out, CYFlags flags) const;
68 CYBox(CYExpression *value) :
75 virtual CYTarget *Replace(CYContext &context);
76 virtual void Output(CYOutput &out, CYFlags flags) const;
84 CYObjCArray(CYElement *elements = NULL) :
91 virtual CYTarget *Replace(CYContext &context);
92 virtual void Output(CYOutput &out, CYFlags flags) const;
95 struct CYObjCKeyValue :
96 CYNext<CYObjCKeyValue>
101 CYObjCKeyValue(CYExpression *key, CYExpression *value, CYObjCKeyValue *next) :
102 CYNext<CYObjCKeyValue>(next),
109 struct CYObjCDictionary :
112 CYObjCKeyValue *pairs_;
114 CYObjCDictionary(CYObjCKeyValue *pairs) :
121 virtual CYTarget *Replace(CYContext &context);
122 virtual void Output(CYOutput &out, CYFlags flags) const;
125 struct CYSelectorPart :
126 CYNext<CYSelectorPart>,
132 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
133 CYNext<CYSelectorPart>(next),
139 CYString *Replace(CYContext &context);
140 virtual void Output(CYOutput &out) const;
146 CYSelectorPart *parts_;
148 CYSelector(CYSelectorPart *parts) :
155 virtual CYTarget *Replace(CYContext &context);
156 virtual void Output(CYOutput &out, CYFlags flags) const;
159 struct CYImplementationField :
160 CYNext<CYImplementationField>
163 CYPropertyName *name_;
165 CYImplementationField(CYType *type, CYPropertyName *name, CYImplementationField *next = NULL) :
166 CYNext<CYImplementationField>(next),
172 CYStatement *Replace(CYContext &context) const;
173 void Output(CYOutput &out) const;
176 struct CYMessageParameter :
177 CYNext<CYMessageParameter>
181 CYIdentifier *identifier_;
183 CYMessageParameter(CYWord *name, CYType *type = NULL, CYIdentifier *identifier = NULL, CYMessageParameter *next = NULL) :
184 CYNext<CYMessageParameter>(next),
187 identifier_(identifier)
191 CYFunctionParameter *Parameters(CYContext &context) const;
192 CYSelector *Selector(CYContext &context) const;
193 CYSelectorPart *SelectorPart(CYContext &context) const;
194 CYExpression *TypeSignature(CYContext &context) const;
202 CYMessageParameter *parameters_;
205 CYMessage(bool instance, CYType *type, CYMessageParameter *parameters, CYStatement *code) :
208 parameters_(parameters),
213 CYStatement *Replace(CYContext &context, bool replace) const;
214 void Output(CYOutput &out) const;
216 CYExpression *TypeSignature(CYContext &context) const;
225 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
226 CYNext<CYProtocol>(next),
231 CYStatement *Replace(CYContext &context) const;
232 void Output(CYOutput &out) const;
235 struct CYImplementation :
239 CYExpression *extends_;
240 CYProtocol *protocols_;
241 CYImplementationField *fields_;
242 CYMessage *messages_;
244 CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) :
247 protocols_(protocols),
255 virtual CYStatement *Replace(CYContext &context);
256 virtual void Output(CYOutput &out, CYFlags flags) const;
263 CYMessage *messages_;
265 CYCategory(CYIdentifier *name, CYMessage *messages) :
273 virtual CYStatement *Replace(CYContext &context);
274 virtual void Output(CYOutput &out, CYFlags flags) const;
280 CYArgument *arguments_;
282 CYSend(CYArgument *arguments) :
283 arguments_(arguments)
289 virtual void Output(CYOutput &out, CYFlags flags) const;
292 struct CYSendDirect :
297 CYSendDirect(CYExpression *self, CYArgument *arguments) :
303 virtual CYTarget *Replace(CYContext &context);
304 virtual void Output(CYOutput &out, CYFlags flags) const;
310 CYSendSuper(CYArgument *arguments) :
315 virtual CYTarget *Replace(CYContext &context);
316 virtual void Output(CYOutput &out, CYFlags flags) const;
319 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/