X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/2e43a0b0c288f70981ab2715c8135ac7b9cd0f1b..5a6c975adbe2588a10190cba75e9152682bedeae:/Syntax.hpp diff --git a/Syntax.hpp b/Syntax.hpp index ae0a68b..9786ee7 100644 --- a/Syntax.hpp +++ b/Syntax.hpp @@ -37,10 +37,15 @@ double CYCastDouble(const char *value, size_t size); double CYCastDouble(const char *value); +double CYCastDouble(CYUTF8String value); void CYNumerify(std::ostringstream &str, double value); void CYStringify(std::ostringstream &str, const char *data, size_t size, bool c = false); +// XXX: this really should not be here ... :/ +void *CYPoolFile(CYPool &pool, const char *path, size_t *psize); +CYUTF8String CYPoolFileUTF8String(CYPool &pool, const char *path); + struct CYContext; struct CYThing { @@ -1084,21 +1089,26 @@ struct CYClause : }; struct CYElement : + CYNext, CYThing { + CYElement(CYElement *next) : + CYNext(next) + { + } + virtual bool Elision() const = 0; virtual void Replace(CYContext &context) = 0; }; struct CYElementValue : - CYNext, CYElement { CYExpression *value_; CYElementValue(CYExpression *value, CYElement *next = NULL) : - CYNext(next), + CYElement(next), value_(value) { } @@ -1116,7 +1126,8 @@ struct CYElementSpread : { CYExpression *value_; - CYElementSpread(CYExpression *value) : + CYElementSpread(CYExpression *value, CYElement *next = NULL) : + CYElement(next), value_(value) { } @@ -1958,23 +1969,19 @@ struct CYTypeError : virtual void Output(CYOutput &out) const; }; -struct CYTypeVoid : - CYTypeSpecifier -{ - CYTypeVoid() { - } - - virtual CYTarget *Replace(CYContext &context); - virtual void Output(CYOutput &out) const; +enum CYTypeSigning { + CYTypeNeutral, + CYTypeSigned, + CYTypeUnsigned, }; -struct CYTypeReference : +struct CYTypeCharacter : CYTypeSpecifier { - CYIdentifier *name_; + CYTypeSigning signing_; - CYTypeReference(CYIdentifier *name) : - name_(name) + CYTypeCharacter(CYTypeSigning signing) : + signing_(signing) { } @@ -1982,60 +1989,67 @@ struct CYTypeReference : virtual void Output(CYOutput &out) const; }; -struct CYTypeVariable : +struct CYTypeIntegral : CYTypeSpecifier { - CYIdentifier *name_; + CYTypeSigning signing_; + int length_; - CYTypeVariable(CYIdentifier *name) : - name_(name) + CYTypeIntegral(CYTypeSigning signing, int length = 1) : + signing_(signing), + length_(length) { } - CYTypeVariable(const char *name) : - name_(new($pool) CYIdentifier(name)) - { + CYTypeIntegral *Long() { + if (length_ != 1 && length_ != 2) + return NULL; + ++length_; + return this; } - virtual CYTarget *Replace(CYContext &context); - virtual void Output(CYOutput &out) const; -}; + CYTypeIntegral *Short() { + if (length_ != 1) + return NULL; + --length_; + return this; + } -struct CYTypeUnsigned : - CYTypeSpecifier -{ - CYTypeSpecifier *specifier_; + CYTypeIntegral *Signed() { + if (signing_ != CYTypeNeutral) + return NULL; + signing_ = CYTypeSigned; + return this; + } - CYTypeUnsigned(CYTypeSpecifier *specifier) : - specifier_(specifier) - { + CYTypeIntegral *Unsigned() { + if (signing_ != CYTypeNeutral) + return NULL; + signing_ = CYTypeUnsigned; + return this; } virtual CYTarget *Replace(CYContext &context); virtual void Output(CYOutput &out) const; }; -struct CYTypeSigned : +struct CYTypeVoid : CYTypeSpecifier { - CYTypeSpecifier *specifier_; - - CYTypeSigned(CYTypeSpecifier *specifier) : - specifier_(specifier) - { + CYTypeVoid() { } virtual CYTarget *Replace(CYContext &context); virtual void Output(CYOutput &out) const; }; -struct CYTypeLong : +struct CYTypeReference : CYTypeSpecifier { - CYTypeSpecifier *specifier_; + CYIdentifier *name_; - CYTypeLong(CYTypeSpecifier *specifier) : - specifier_(specifier) + CYTypeReference(CYIdentifier *name) : + name_(name) { } @@ -2043,13 +2057,18 @@ struct CYTypeLong : virtual void Output(CYOutput &out) const; }; -struct CYTypeShort : +struct CYTypeVariable : CYTypeSpecifier { - CYTypeSpecifier *specifier_; + CYIdentifier *name_; - CYTypeShort(CYTypeSpecifier *specifier) : - specifier_(specifier) + CYTypeVariable(CYIdentifier *name) : + name_(name) + { + } + + CYTypeVariable(const char *name) : + name_(new($pool) CYIdentifier(name)) { }