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:
Joe Groff
2013-05-01 18:49:25 +00:00
parent cd179b5e69
commit 08b6f87524
16 changed files with 244 additions and 9 deletions

View File

@@ -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;