mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add support for C++ pointers to Carbon methods (#7881)
C++ pointers to Carbon methods are supported using the same mechanisms as for Carbon functions: we export the method to C++ and then form a pointer to the exported method. This change does not support invoking a C++ method pointer from Carbon, which will be more complicated because we need to model instance binding on the Carbon side.
This commit is contained in:
@@ -503,14 +503,12 @@ static auto ConvertTupleToArray(Context& context, SemIR::TupleType tuple_type,
|
||||
}
|
||||
|
||||
// Performs a conversion from a function to a C++ function pointer type.
|
||||
static auto ConvertFunctionToCppPointer(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::FunctionType src_type,
|
||||
SemIR::CppFunctionPointerType dest_type,
|
||||
SemIR::InstId value_id,
|
||||
ConversionTarget target)
|
||||
-> SemIR::InstId {
|
||||
static auto ConvertFunctionToCppPointer(
|
||||
Context& context, SemIR::LocId loc_id, SemIR::FunctionType src_type,
|
||||
SemIR::CppFunctionPointerType target_type, SemIR::InstId value_id,
|
||||
ConversionTarget target) -> SemIR::InstId {
|
||||
if (!ExportFunctionToCppPointerConversion(context, value_id, src_type,
|
||||
dest_type, target.diagnose)) {
|
||||
target_type, target.diagnose)) {
|
||||
return SemIR::ErrorInst::InstId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user