From: Jay Freeman (saurik) Date: Tue, 21 Jan 2014 18:29:22 +0000 (-0800) Subject: Do not ever use NULL type_s, even for ? encoding. X-Git-Tag: v0.9.500~8 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/03db6a67c728f631b6c6f6fd140eb86a8050cf12 Do not ever use NULL type_s, even for ? encoding. --- diff --git a/Decode.cpp b/Decode.cpp index e31b469..dd2bc02 100644 --- a/Decode.cpp +++ b/Decode.cpp @@ -26,6 +26,8 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) { switch (type->primitive) { + case sig::unknown_P: return $ CYTypedIdentifier($ CYTypeError()); + case sig::function_P: { _assert(type->data.signature.count != 0); CYTypedParameter *parameter(NULL); diff --git a/Output.cpp b/Output.cpp index 42d1854..9b9bc72 100644 --- a/Output.cpp +++ b/Output.cpp @@ -748,6 +748,10 @@ void Try::Output(CYOutput &out, CYFlags flags) const { } } +void CYTypeError::Output(CYOutput &out) const { + out << "@error"; +} + void CYTypeLong::Output(CYOutput &out) const { out << "long" << specifier_; } diff --git a/Parser.hpp b/Parser.hpp index d9530df..fa0bc09 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -1612,6 +1612,16 @@ struct CYTypeSpecifier : virtual CYExpression *Replace(CYContext &context) = 0; }; +struct CYTypeError : + CYTypeSpecifier +{ + CYTypeError() { + } + + virtual CYExpression *Replace(CYContext &context); + virtual void Output(CYOutput &out) const; +}; + struct CYTypeVoid : CYTypeSpecifier { diff --git a/Replace.cpp b/Replace.cpp index ba73201..f914af9 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -898,6 +898,11 @@ CYStatement *CYTypeDefinition::Replace(CYContext &context) { return $E($ CYAssign($V(typed_->identifier_), typed_->Replace(context))); } +CYExpression *CYTypeError::Replace(CYContext &context) { + _assert(false); + return NULL; +} + CYExpression *CYTypeModifier::Replace(CYContext &context, CYExpression *type) { $T(type) return Replace_(context, type); } diff --git a/sig/parse.cpp b/sig/parse.cpp index d95af2f..3a8a7af 100644 --- a/sig/parse.cpp +++ b/sig/parse.cpp @@ -84,8 +84,6 @@ void Parse_(CYPool &pool, struct Signature *signature, const char **name, char e Type *Parse_(CYPool &pool, const char **name, char eos, bool named, Callback callback) { char next = *(*name)++; - if (next == '?') - return NULL; Type *type(new(pool) Type()); _assert(type != NULL); @@ -93,6 +91,7 @@ Type *Parse_(CYPool &pool, const char **name, char eos, bool named, Callback cal parse: switch (next) { + case '?': type->primitive = unknown_P; break; case '#': type->primitive = typename_P; break; case '(': @@ -258,6 +257,7 @@ const char *Unparse_(CYPool &pool, struct Type *type) { return pool.strdup(out.str().c_str()); } break; + case unknown_P: return "?"; case typename_P: return "#"; case union_P: return pool.strcat("(", Unparse(pool, &type->data.signature), ")", NULL); case string_P: return "*"; diff --git a/sig/types.hpp b/sig/types.hpp index 150a057..1c8b94d 100644 --- a/sig/types.hpp +++ b/sig/types.hpp @@ -31,11 +31,13 @@ namespace sig { enum Primitive { function_P = '\0', + block_P = '\a', + + unknown_P = '?', typename_P = '#', union_P = '(', string_P = '*', selector_P = ':', - block_P = '?', object_P = 'W', boolean_P = 'B', uchar_P = 'C',