]> git.saurik.com Git - cycript.git/blobdiff - Decode.cpp
Fix issue in 64-bit choose() reported by heardrwt.
[cycript.git] / Decode.cpp
index e31b4691afaa5f1a65152852589f9c20b5d777ea..bdef46b80e71727190797e95fddb55cb6c808322 100644 (file)
@@ -26,6 +26,8 @@
 
 CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
     switch (type->primitive) {
 
 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);
         case sig::function_P: {
             _assert(type->data.signature.count != 0);
             CYTypedParameter *parameter(NULL);
@@ -40,11 +42,14 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
         case sig::selector_P: return $ CYTypedIdentifier($ CYTypeVariable("SEL"));
 
         case sig::block_P: {
         case sig::selector_P: return $ CYTypedIdentifier($ CYTypeVariable("SEL"));
 
         case sig::block_P: {
-            _assert(type->data.signature.count != 0);
-            CYTypedParameter *parameter(NULL);
-            for (size_t i(type->data.signature.count - 1); i != 0; --i)
-                parameter = $ CYTypedParameter(Decode(pool, type->data.signature.elements[i].type), parameter);
-            return Decode(pool, type->data.signature.elements[0].type)->Modify($ CYTypeBlockWith(parameter));
+            if (type->data.signature.count == 0)
+                return $ CYTypedIdentifier($ CYTypeVariable("NSBlock"), $ CYTypePointerTo());
+            else {
+                CYTypedParameter *parameter(NULL);
+                for (size_t i(type->data.signature.count - 1); i != 0; --i)
+                    parameter = $ CYTypedParameter(Decode(pool, type->data.signature.elements[i].type), parameter);
+                return Decode(pool, type->data.signature.elements[0].type)->Modify($ CYTypeBlockWith(parameter));
+            }
         } break;
 
         case sig::object_P: {
         } break;
 
         case sig::object_P: {