1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 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;
46 CYTypedIdentifier *typed_;
47 CYTypedParameter *parameters_;
50 CYObjCBlock(CYTypedIdentifier *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>
162 CYTypedIdentifier *typed_;
164 CYImplementationField(CYTypedIdentifier *typed, CYImplementationField *next = NULL) :
165 CYNext<CYImplementationField>(next),
170 CYStatement *Replace(CYContext &context) const;
171 void Output(CYOutput &out) const;
174 struct CYMessageParameter :
175 CYNext<CYMessageParameter>
178 CYTypedIdentifier *type_;
180 CYMessageParameter(CYWord *name, CYTypedIdentifier *type, CYMessageParameter *next = NULL) :
181 CYNext<CYMessageParameter>(next),
187 CYFunctionParameter *Parameters(CYContext &context) const;
188 CYSelector *Selector(CYContext &context) const;
189 CYSelectorPart *SelectorPart(CYContext &context) const;
190 CYExpression *TypeSignature(CYContext &context) const;
197 CYTypedIdentifier *type_;
198 CYMessageParameter *parameters_;
201 CYMessage(bool instance, CYTypedIdentifier *type, CYMessageParameter *parameters, CYStatement *code) :
204 parameters_(parameters),
209 CYStatement *Replace(CYContext &context, bool replace) const;
210 void Output(CYOutput &out) const;
212 CYExpression *TypeSignature(CYContext &context) const;
221 CYProtocol(CYExpression *name, CYProtocol *next = NULL) :
222 CYNext<CYProtocol>(next),
227 CYStatement *Replace(CYContext &context) const;
228 void Output(CYOutput &out) const;
231 struct CYImplementation :
235 CYExpression *extends_;
236 CYProtocol *protocols_;
237 CYImplementationField *fields_;
238 CYMessage *messages_;
240 CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) :
243 protocols_(protocols),
251 virtual CYStatement *Replace(CYContext &context);
252 virtual void Output(CYOutput &out, CYFlags flags) const;
259 CYMessage *messages_;
261 CYCategory(CYIdentifier *name, CYMessage *messages) :
269 virtual CYStatement *Replace(CYContext &context);
270 virtual void Output(CYOutput &out, CYFlags flags) const;
276 CYArgument *arguments_;
278 CYSend(CYArgument *arguments) :
279 arguments_(arguments)
285 virtual void Output(CYOutput &out, CYFlags flags) const;
288 struct CYSendDirect :
293 CYSendDirect(CYExpression *self, CYArgument *arguments) :
299 virtual CYTarget *Replace(CYContext &context);
300 virtual void Output(CYOutput &out, CYFlags flags) const;
306 CYSendSuper(CYArgument *arguments) :
311 virtual CYTarget *Replace(CYContext &context);
312 virtual void Output(CYOutput &out, CYFlags flags) const;
315 #endif/*CYCRIPT_OBJECTIVEC_SYNTAX_HPP*/