mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add 'typeof' to value witness tables.
To be able to get the dynamic type of a generic value, the 'typeof' operation needs to be part of the value witness for the type. Add 'typeof' to the value witness table layout, and in the runtime, provide standard typeof witnesses for static, Swift class, and ObjC class values. Swift SVN r5013
This commit is contained in:
@@ -434,6 +434,42 @@ llvm::Constant *IRGenModule::getGetObjCClassMetadataFn() {
|
||||
return GetObjCClassMetadataFn;
|
||||
}
|
||||
|
||||
llvm::Constant *IRGenModule::getStaticTypeofFn() {
|
||||
if (StaticTypeofFn) return StaticTypeofFn;
|
||||
|
||||
// type_metadata_t *swift_staticTypeof(opaque_t *obj, type_metadata_t *self);
|
||||
llvm::Type *argTypes[] = { OpaquePtrTy, TypeMetadataPtrTy };
|
||||
llvm::FunctionType *fnType =
|
||||
llvm::FunctionType::get(TypeMetadataPtrTy, argTypes, false);
|
||||
StaticTypeofFn =
|
||||
createReadnoneRuntimeFunction(*this, "swift_staticTypeof", fnType);
|
||||
return StaticTypeofFn;
|
||||
}
|
||||
|
||||
llvm::Constant *IRGenModule::getObjectTypeofFn() {
|
||||
if (ObjectTypeofFn) return ObjectTypeofFn;
|
||||
|
||||
// type_metadata_t *swift_objectTypeof(opaque_t *obj, type_metadata_t *self);
|
||||
llvm::Type *argTypes[] = { OpaquePtrTy, TypeMetadataPtrTy };
|
||||
llvm::FunctionType *fnType =
|
||||
llvm::FunctionType::get(TypeMetadataPtrTy, argTypes, false);
|
||||
ObjectTypeofFn =
|
||||
createRuntimeFunction(*this, "swift_objectTypeof", fnType);
|
||||
return ObjectTypeofFn;
|
||||
}
|
||||
|
||||
llvm::Constant *IRGenModule::getObjCTypeofFn() {
|
||||
if (ObjectTypeofFn) return ObjCTypeofFn;
|
||||
|
||||
// type_metadata_t *swift_objcTypeof(opaque_t *obj, type_metadata_t *self);
|
||||
llvm::Type *argTypes[] = { OpaquePtrTy, TypeMetadataPtrTy };
|
||||
llvm::FunctionType *fnType =
|
||||
llvm::FunctionType::get(TypeMetadataPtrTy, argTypes, false);
|
||||
ObjCTypeofFn =
|
||||
createRuntimeFunction(*this, "swift_objcTypeof", fnType);
|
||||
return ObjCTypeofFn;
|
||||
}
|
||||
|
||||
llvm::Constant *IRGenModule::getGetTupleMetadataFn() {
|
||||
if (GetTupleMetadataFn) return GetTupleMetadataFn;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user