MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / validateExportName

Function validateExportName

lib/validator/component_validator.cpp:212–231  ·  view source on GitHub ↗

Validate that a name may appear at an export position: reject the `relative-url=` prefix (not part of the extern-name grammar) and any plainname/interfacename kind that isn't allowed on an export.

Source from the content-addressed store, hash-verified

210// `relative-url=` prefix (not part of the extern-name grammar) and any
211// plainname/interfacename kind that isn't allowed on an export.
212Expect<void> validateExportName(std::string_view Name) noexcept {
213 if (Name.rfind("relative-url="sv, 0) == 0) {
214 spdlog::error(ErrCode::Value::InvalidExternName);
215 spdlog::error(" Export name '{}' is not a valid extern name"sv, Name);
216 return Unexpect(ErrCode::Value::InvalidExternName);
217 }
218 EXPECTED_TRY(ComponentName CName, ComponentName::parse(Name));
219 switch (CName.getKind()) {
220 case ComponentNameKind::Label:
221 case ComponentNameKind::Constructor:
222 case ComponentNameKind::Method:
223 case ComponentNameKind::Static:
224 case ComponentNameKind::InterfaceType:
225 return {};
226 default:
227 spdlog::error(ErrCode::Value::InvalidExportName);
228 spdlog::error(" Export name '{}' kind is not valid for exports"sv, Name);
229 return Unexpect(ErrCode::Value::InvalidExportName);
230 }
231}
232} // namespace
233
234Expect<void>

Callers 1

validateMethod · 0.85

Calls 3

UnexpectFunction · 0.85
getKindMethod · 0.80
errorFunction · 0.50

Tested by

no test coverage detected