-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2015 Jay Freeman (saurik)
+/* Cycript - The Truly Universal Scripting Language
+ * Copyright (C) 2009-2016 Jay Freeman (saurik)
*/
/* GNU Affero General Public License, Version 3 {{{ */
#ifndef CYCRIPT_OBJECTIVEC_SYNTAX_HPP
#define CYCRIPT_OBJECTIVEC_SYNTAX_HPP
-#include "Parser.hpp"
+#include "../Syntax.hpp"
struct CYInstanceLiteral :
- CYExpression
+ CYTarget
{
CYNumber *number_;
CYPrecedence(1)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYTarget *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};
struct CYObjCBlock :
- CYExpression
+ CYTarget
{
- CYTypedIdentifier *typed_;
+ CYType *typed_;
CYTypedParameter *parameters_;
CYStatement *code_;
- CYObjCBlock(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *code) :
+ CYObjCBlock(CYType *typed, CYTypedParameter *parameters, CYStatement *code) :
typed_(typed),
parameters_(parameters),
code_(code)
CYPrecedence(1)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYTarget *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};
struct CYBox :
- CYExpression
+ CYTarget
{
CYExpression *value_;
CYPrecedence(1)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYTarget *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYObjCArray :
+ CYTarget
+{
+ CYElement *elements_;
+
+ CYObjCArray(CYElement *elements = NULL) :
+ elements_(elements)
+ {
+ }
+
+ CYPrecedence(0)
+
+ virtual CYTarget *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYObjCKeyValue :
+ CYNext<CYObjCKeyValue>
+{
+ CYExpression *key_;
+ CYExpression *value_;
+
+ CYObjCKeyValue(CYExpression *key, CYExpression *value, CYObjCKeyValue *next) :
+ CYNext<CYObjCKeyValue>(next),
+ key_(key),
+ value_(value)
+ {
+ }
+};
+
+struct CYObjCDictionary :
+ CYTarget
+{
+ CYObjCKeyValue *pairs_;
+
+ CYObjCDictionary(CYObjCKeyValue *pairs) :
+ pairs_(pairs)
+ {
+ }
+
+ CYPrecedence(0)
+
+ virtual CYTarget *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};
struct CYSelector :
CYLiteral
{
- CYSelectorPart *name_;
+ CYSelectorPart *parts_;
- CYSelector(CYSelectorPart *name) :
- name_(name)
+ CYSelector(CYSelectorPart *parts) :
+ parts_(parts)
{
}
CYPrecedence(1)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYTarget *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};
-struct CYClassField :
- CYNext<CYClassField>
+struct CYImplementationField :
+ CYNext<CYImplementationField>
{
- CYTypedIdentifier *typed_;
+ CYType *type_;
+ CYPropertyName *name_;
- CYClassField(CYTypedIdentifier *typed, CYClassField *next = NULL) :
- CYNext<CYClassField>(next),
- typed_(typed)
+ CYImplementationField(CYType *type, CYPropertyName *name, CYImplementationField *next = NULL) :
+ CYNext<CYImplementationField>(next),
+ type_(type),
+ name_(name)
{
}
struct CYMessageParameter :
CYNext<CYMessageParameter>
{
- CYWord *tag_;
- CYTypedIdentifier *type_;
+ CYWord *name_;
+ CYType *type_;
+ CYIdentifier *identifier_;
- CYMessageParameter(CYWord *tag, CYTypedIdentifier *type) :
- tag_(tag),
- type_(type)
+ CYMessageParameter(CYWord *name, CYType *type = NULL, CYIdentifier *identifier = NULL, CYMessageParameter *next = NULL) :
+ CYNext<CYMessageParameter>(next),
+ name_(name),
+ type_(type),
+ identifier_(identifier)
{
}
CYNext<CYMessage>
{
bool instance_;
- CYTypedIdentifier *type_;
+ CYType *type_;
CYMessageParameter *parameters_;
CYBlock code_;
- CYMessage(bool instance, CYTypedIdentifier *type, CYMessageParameter *parameter, CYStatement *code) :
+ CYMessage(bool instance, CYType *type, CYMessageParameter *parameters, CYStatement *code) :
instance_(instance),
type_(type),
- parameters_(parameter),
+ parameters_(parameters),
code_(code)
{
}
CYStatement *Replace(CYContext &context, bool replace) const;
- void Output(CYOutput &out, bool replace) const;
+ void Output(CYOutput &out) const;
CYExpression *TypeSignature(CYContext &context) const;
};
void Output(CYOutput &out) const;
};
-struct CYClass {
- CYClassName *name_;
- CYExpression *super_;
+struct CYImplementation :
+ CYStatement
+{
+ CYIdentifier *name_;
+ CYExpression *extends_;
CYProtocol *protocols_;
- CYClassField *fields_;
+ CYImplementationField *fields_;
CYMessage *messages_;
- CYClass(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYClassField *fields, CYMessage *messages) :
+ CYImplementation(CYIdentifier *name, CYExpression *extends, CYProtocol *protocols, CYImplementationField *fields, CYMessage *messages) :
name_(name),
- super_(super),
+ extends_(extends),
protocols_(protocols),
fields_(fields),
messages_(messages)
{
}
- virtual ~CYClass() {
- }
-
- CYExpression *Replace_(CYContext &context);
- virtual void Output(CYOutput &out, CYFlags flags) const;
-};
-
-struct CYClassExpression :
- CYClass,
- CYExpression
-{
- CYClassExpression(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYClassField *fields, CYMessage *messages) :
- CYClass(name, super, protocols, fields, messages)
- {
- }
-
- CYPrecedence(0)
-
- virtual CYExpression *Replace(CYContext &context);
- virtual void Output(CYOutput &out, CYFlags flags) const;
-};
-
-struct CYClassStatement :
- CYClass,
- CYStatement
-{
- CYClassStatement(CYClassName *name, CYExpression *super, CYProtocol *protocols, CYClassField *fields, CYMessage *messages) :
- CYClass(name, super, protocols, fields, messages)
- {
- }
+ CYCompact(None)
virtual CYStatement *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
struct CYCategory :
CYStatement
{
- CYClassName *name_;
+ CYIdentifier *name_;
CYMessage *messages_;
- CYCategory(CYClassName *name, CYMessage *messages) :
+ CYCategory(CYIdentifier *name, CYMessage *messages) :
name_(name),
messages_(messages)
{
}
+ CYCompact(None)
+
virtual CYStatement *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};
struct CYSend :
- CYExpression
+ CYTarget
{
CYArgument *arguments_;
{
}
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYTarget *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};
{
}
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYTarget *Replace(CYContext &context);
virtual void Output(CYOutput &out, CYFlags flags) const;
};