-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2015 Jay Freeman (saurik)
+/* Cycript - The Truly Universal Scripting Language
+ * Copyright (C) 2009-2016 Jay Freeman (saurik)
*/
/* GNU Affero General Public License, Version 3 {{{ */
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 1));
}
+#ifdef __SIZEOF_INT128__
+template <>
+CYTypedIdentifier *Primitive<signed __int128>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeInt128(CYTypeSigned));
+}
+#endif
+
template <>
CYTypedIdentifier *Primitive<signed long int>::Decode(CYPool &pool) const {
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 2));
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 1));
}
+#ifdef __SIZEOF_INT128__
+template <>
+CYTypedIdentifier *Primitive<unsigned __int128>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeInt128(CYTypeUnsigned));
+}
+#endif
+
template <>
CYTypedIdentifier *Primitive<unsigned long int>::Decode(CYPool &pool) const {
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 2));
return $ CYTypedIdentifier($ CYTypeCharacter(CYTypeNeutral), $ CYTypePointerTo());
}
+#ifdef CY_OBJECTIVEC
CYTypedIdentifier *Meta::Decode(CYPool &pool) const {
return $ CYTypedIdentifier($ CYTypeVariable("Class"));
}
CYTypedIdentifier *Selector::Decode(CYPool &pool) const {
return $ CYTypedIdentifier($ CYTypeVariable("SEL"));
}
+#endif
CYTypedIdentifier *Bits::Decode(CYPool &pool) const {
_assert(false);
return CYDecodeType(pool, &type)->Modify($ CYTypeArrayOf($D(size)));
}
+#ifdef CY_OBJECTIVEC
CYTypedIdentifier *Object::Decode(CYPool &pool) const {
if (name == NULL)
return $ CYTypedIdentifier($ CYTypeVariable("id"));
else
return $ CYTypedIdentifier($ CYTypeVariable(name), $ CYTypePointerTo());
}
+#endif
CYTypedIdentifier *Aggregate::Decode(CYPool &pool) const {
_assert(!overlap);
return $ CYTypedIdentifier($ CYTypeStruct(identifier, $ CYStructTail(fields)));
}
-CYTypedIdentifier *Function::Decode(CYPool &pool) const {
+CYTypedIdentifier *Callable::Decode(CYPool &pool) const {
_assert(signature.count != 0);
- CYTypedParameter *parameter(NULL);
+ CYTypedParameter *parameters(NULL);
for (size_t i(signature.count - 1); i != 0; --i)
- parameter = $ CYTypedParameter(CYDecodeType(pool, signature.elements[i].type), parameter);
- return CYDecodeType(pool, signature.elements[0].type)->Modify($ CYTypeFunctionWith(parameter));
+ parameters = $ CYTypedParameter(CYDecodeType(pool, signature.elements[i].type), parameters);
+ return Modify(pool, CYDecodeType(pool, signature.elements[0].type), parameters);
+}
+
+CYTypedIdentifier *Function::Modify(CYPool &pool, CYTypedIdentifier *result, CYTypedParameter *parameters) const {
+ return result->Modify($ CYTypeFunctionWith(variadic, parameters));
+}
+
+#ifdef CY_OBJECTIVEC
+CYTypedIdentifier *Block::Modify(CYPool &pool, CYTypedIdentifier *result, CYTypedParameter *parameters) const {
+ return result->Modify($ CYTypeBlockWith(parameters));
}
CYTypedIdentifier *Block::Decode(CYPool &pool) const {
if (signature.count == 0)
return $ CYTypedIdentifier($ CYTypeVariable("NSBlock"), $ CYTypePointerTo());
- else {
- _assert(signature.count != 1);
- _assert(dynamic_cast<Object *>(signature.elements[1].type) != NULL);
-
- CYTypedParameter *parameter(NULL);
- for (size_t i(signature.count - 1); i != 0; --i)
- parameter = $ CYTypedParameter(CYDecodeType(pool, signature.elements[i].type), parameter);
- return CYDecodeType(pool, signature.elements[0].type)->Modify($ CYTypeBlockWith(parameter));
- }
+ return Callable::Decode(pool);
}
+#endif
}