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
12 changes: 7 additions & 5 deletions src/runtime/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,21 @@ Waiter* Store::getWaiter(void* address)
return waiter;
}

void Store::registerComponentInstance(std::string& name, ComponentInstance* instance)
#ifdef ENABLE_WASI
void Store::registerWasiComponentInstance(size_t instanceId, ComponentInstance* instance)
{
m_namedComponentInstances[name] = instance;
m_wasiInstances[instanceId] = instance;
}

ComponentInstance* Store::findComponentInstance(std::string& name)
ComponentInstance* Store::findWasiComponentInstance(size_t instanceId)
{
auto it = m_namedComponentInstances.find(name);
if (it == m_namedComponentInstances.end()) {
auto it = m_wasiInstances.find(instanceId);
if (it == m_wasiInstances.end()) {
return nullptr;
}
return it->second;
}
#endif

FunctionType* Store::createDefinedFunctionType(DefinedFunctionType type)
{
Expand Down
10 changes: 7 additions & 3 deletions src/runtime/Store.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ class Store {
return m_context;
}

void registerComponentInstance(std::string& name, ComponentInstance* instance);
ComponentInstance* findComponentInstance(std::string& name);
#ifdef ENABLE_WASI
void registerWasiComponentInstance(size_t instanceId, ComponentInstance* instance);
ComponentInstance* findWasiComponentInstance(size_t instanceId);
#endif

private:
FunctionType* createDefinedFunctionType(DefinedFunctionType type);
Expand All @@ -196,7 +198,9 @@ class Store {
std::vector<Waiter*> m_waiterList;

ComponentContext* m_context;
std::map<std::string, ComponentInstance*> m_namedComponentInstances;
#ifdef ENABLE_WASI
std::map<size_t, ComponentInstance*> m_wasiInstances;
#endif
};

} // namespace Walrus
Expand Down
Loading
Loading