]> git.saurik.com Git - cycript.git/blobdiff - Decode.cpp
Provide some kind of feedback while running ?gc.
[cycript.git] / Decode.cpp
index 7901515ba39be2d7cfa5e67dca094e4737e607a2..9cb165c8b3358e677a699b00db43ee5f1bda05b0 100644 (file)
@@ -36,9 +36,16 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
 
         case sig::typename_P: return $ CYTypedIdentifier($V("Class"));
         case sig::union_P: _assert(false); break;
-        case sig::string_P: return $ CYTypedIdentifier($V("char"), $ CYTypeConstant($ CYTypePointerTo()));
+        case sig::string_P: return $ CYTypedIdentifier($V("char"), $ CYTypePointerTo());
         case sig::selector_P: return $ CYTypedIdentifier($V("SEL"));
-        case sig::block_P: _assert(false); break;
+
+        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));
+        } break;
 
         case sig::object_P: {
             if (type->name == NULL)
@@ -89,7 +96,11 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
 
 CYTypedIdentifier *Decode(CYPool &pool, struct sig::Type *type) {
     CYTypedIdentifier *typed(Decode_(pool, type));
-    if ((type->flags & JOC_TYPE_CONST) != 0)
-        typed = typed->Modify($ CYTypeConstant());
+    if ((type->flags & JOC_TYPE_CONST) != 0) {
+        if (type->primitive == sig::string_P)
+            typed->modifier_ = $ CYTypeConstant(typed->modifier_);
+        else
+            typed = typed->Modify($ CYTypeConstant());
+    }
     return typed;
 }