mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[wasm] add @_extern(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "import"ed from host environment. It's equivalent of Clang's
`__attribute__((import_module("module"), import_name("field")))`
This commit is contained in:
@@ -303,6 +303,9 @@ private:
|
||||
/// empty.
|
||||
StringRef WasmExportName;
|
||||
|
||||
/// Name of a Wasm import module and field if @_extern(wasm) attribute
|
||||
llvm::Optional<std::pair<StringRef, StringRef>> WasmImportModuleAndField;
|
||||
|
||||
/// Has value if there's a profile for this function
|
||||
/// Contains Function Entry Count
|
||||
ProfileCounter EntryCount;
|
||||
@@ -1278,6 +1281,24 @@ public:
|
||||
StringRef wasmExportName() const { return WasmExportName; }
|
||||
void setWasmExportName(StringRef value) { WasmExportName = value; }
|
||||
|
||||
/// Return Wasm import module name if @_extern(wasm) was used otherwise empty
|
||||
StringRef wasmImportModuleName() const {
|
||||
if (WasmImportModuleAndField)
|
||||
return WasmImportModuleAndField->first;
|
||||
return StringRef();
|
||||
}
|
||||
|
||||
/// Return Wasm import field name if @_extern(wasm) was used otherwise empty
|
||||
StringRef wasmImportFieldName() const {
|
||||
if (WasmImportModuleAndField)
|
||||
return WasmImportModuleAndField->second;
|
||||
return StringRef();
|
||||
}
|
||||
|
||||
void setWasmImportModuleAndField(StringRef module, StringRef field) {
|
||||
WasmImportModuleAndField = std::make_pair(module, field);
|
||||
}
|
||||
|
||||
/// Returns true if this function belongs to a declaration that returns
|
||||
/// an opaque result type with one or more availability conditions that are
|
||||
/// allowed to produce a different underlying type at runtime.
|
||||
|
||||
Reference in New Issue
Block a user