Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/runtime/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ class ComponentValueType : public ComponentRefCounted {
ASSERT(type != ComponentTypeRef::TypeIndex && type != ComponentTypeRef::TypeNone);
}

const ComponentTypeRef::Type& type() const
{
return m_type;
}

private:
ComponentTypeRef::Type m_type;
};
Expand Down
13 changes: 9 additions & 4 deletions src/runtime/ComponentInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ ComponentInstance* ComponentInstance::createInstance(Store* store, ComponentType
return instance;
}

bool ComponentInstance::compareTypes(ComponentRefCounted* expected, ComponentRefCounted* provided, std::vector<ComponentRefCounted*>& resources)
bool ComponentInstance::compareTypes(ComponentRefCounted* expected, ComponentRefCounted* provided, std::vector<ComponentRefCounted*>& resources, std::string& componentName)
{
switch (expected->kind()) {
case ComponentRefCounted::InstanceTypeKind: {
Expand All @@ -343,6 +343,7 @@ bool ComponentInstance::compareTypes(ComponentRefCounted* expected, ComponentRef
}
}

componentName = left.name;
if (found == nullptr || left.sort != found->sort) {
return false;
}
Expand Down Expand Up @@ -765,13 +766,17 @@ ComponentInstance* ComponentInstance::InstantiateContext::instantiate(Component*
Trap::throwException(m_state, message);
}

std::string componentName;
if (external.sort == ComponentSort::Instance) {
success = compareTypes(external.type, instance->m_instances.back()->type(), resources);
success = compareTypes(external.type, instance->m_instances.back()->type(), resources, componentName);
}

if (!success) {
std::string message = "import type mismatch: ";
message.append(external.name);
std::string message = "import type mismatch in: ";
message += external.name;
if (!componentName.empty()) {
message += " at: " + componentName;
}
Trap::throwException(m_state, message);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/ComponentInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class ComponentInstance : public Object {

static ComponentInstance* createInstance(Store* store, ComponentType* type);

static bool compareTypes(ComponentRefCounted* expected, ComponentRefCounted* provided, std::vector<ComponentRefCounted*>& resources);
static bool compareTypes(ComponentRefCounted* expected, ComponentRefCounted* provided, std::vector<ComponentRefCounted*>& resources, std::string& componentName);
void coreInstantiate(ExecutionState& state, Component* component, ComponentCoreInstantiate* instantiate);
void aliasExport(ComponentAliasExport* alias);
void aliasCoreExport(ComponentAliasExport* alias);
Expand Down
Loading
Loading