]> git.saurik.com Git - cycript.git/commitdiff
Do not ever use NULL type_s, even for ? encoding.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 21 Jan 2014 18:29:22 +0000 (10:29 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 21 Jan 2014 18:29:22 +0000 (10:29 -0800)
Decode.cpp
Output.cpp
Parser.hpp
Replace.cpp
sig/parse.cpp
sig/types.hpp

index e31b4691afaa5f1a65152852589f9c20b5d777ea..dd2bc02de55aa8ee53e09af12478b4fa6aed13e5 100644 (file)
@@ -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);
index 42d1854847d6849c06e9bb64ad9fa6e716c60924..9b9bc72b222e7f0d5b2257382fd829980af9b7c5 100644 (file)
@@ -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_;
 }
index d9530df7a795f4659b2631800acc1418f57b336b..fa0bc095a738186eaee23b112a7cc969f30729cc 100644 (file)
@@ -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
 {
index ba73201d1c2c57a39ed1766011102e81aae9100c..f914af98b82aed992fd4363c8849b8c94a917de7 100644 (file)
@@ -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);
 }
index d95af2fa57e053ccaac778fd97c9c9a0ac78b803..3a8a7afe0a6dd3a0b55b1bef12b6204173f287a4 100644 (file)
@@ -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 "*";
index 150a057539c4faf20e36ca34d7c4f49eb26feac0..1c8b94db8bf009e9a79b1a2d2b00b1e28cf18ce4 100644 (file)
@@ -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',