X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/3935b9e5dc2b437a11a4b61a9fb5793af2d4beef..0559abf83c4cc9bbd896b69dfaae1e8422521479:/Syntax.hpp diff --git a/Syntax.hpp b/Syntax.hpp index a82ded1..5599f7e 100644 --- a/Syntax.hpp +++ b/Syntax.hpp @@ -1963,23 +1963,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) { } @@ -1987,60 +1983,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) { } @@ -2048,13 +2051,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)) { }