wasiComponentWitWorldBindings function
({List<WASIComponentWitDependencyError> dependencyErrors, List<WASIComponentWitFunctionBinding> functions, List<WASIComponentWitInterfaceBinding> interfaces})
wasiComponentWitWorldBindings(
- WASIComponentWitDocument document,
- WASIComponentWitWorld world, {
- WASIComponentWitTargetResolver? resolveTarget,
- Set<
String> ? visiting, - String qualifyInterfaceName(
- String interfaceName
Elaborates interface dependencies and expands executable function metadata.
Implementation
({
List<WASIComponentWitInterfaceBinding> interfaces,
List<WASIComponentWitFunctionBinding> functions,
List<WASIComponentWitDependencyError> dependencyErrors,
})
wasiComponentWitWorldBindings(
WASIComponentWitDocument document,
WASIComponentWitWorld world, {
WASIComponentWitTargetResolver? resolveTarget,
Set<String>? visiting,
String Function(String interfaceName)? qualifyInterfaceName,
}) {
final resolvedTargets = <String, WASIComponentWitResolvedTarget?>{};
final WASIComponentWitTargetResolver? resolver = resolveTarget == null
? null
: (target) =>
resolvedTargets.putIfAbsent(target, () => resolveTarget(target));
final expansion = _expandWitWorldInterfaces(
document,
world,
resolveTarget: resolver,
visiting: visiting,
qualifyInterfaceName: qualifyInterfaceName,
);
final resourceOwners = <(String, String, String), WASIComponentWitResource>{};
final functions = <WASIComponentWitFunctionBinding>[];
for (final binding in expansion.interfaces) {
final resourceIdentities = binding.item.name == null
? null
: {
for (final resource in binding.interface.resources)
resource: Object(),
};
for (final function in binding.interface.functions) {
functions.add(
WASIComponentWitFunctionBinding._(
item: binding.item,
interfaceName: binding.interfaceName,
implicitInterfaceName: binding.isImplicit
? binding.canonicalName
: null,
function: function,
direction: binding.direction,
signature: _parseWitAdapterSignature(
function,
binding.interface,
document: binding.document,
resolveTarget: resolver,
resourceOwners: resourceOwners,
resourceIdentities: resourceIdentities,
),
),
);
}
}
return (
interfaces: expansion.interfaces,
functions: List<WASIComponentWitFunctionBinding>.unmodifiable(functions),
dependencyErrors: expansion.dependencyErrors,
);
}