Commit 1075baee by Ben Clayton

Vulkan/Debug: Add Context::Lock::findFile()

Useful for lazily building a new `File` if it hasn't been registered already. Also assign the file to the location of a new frame. This is a sensible default to have. Bug: b/145351270 Change-Id: I7c0abff22a0010923428ff5ed0760d6ae63b0c6b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48697 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 0f0f9795
......@@ -20,6 +20,8 @@
#include "Variable.hpp"
#include "WeakMap.hpp"
#include "System/Debug.hpp"
#include <memory>
#include <mutex>
#include <thread>
......@@ -348,6 +350,19 @@ std::shared_ptr<File> Context::Lock::get(File::ID id)
return ctx->files.get(id);
}
std::shared_ptr<File> Context::Lock::findFile(const std::string &path)
{
for(auto it : ctx->files)
{
auto &file = it.second;
if(file->path() == path)
{
return file;
}
}
return nullptr;
}
std::vector<std::shared_ptr<File>> Context::Lock::files()
{
std::vector<std::shared_ptr<File>> out;
......@@ -368,6 +383,7 @@ std::shared_ptr<Frame> Context::Lock::createFrame(
frame->locals = createScope(file);
frame->registers = createScope(file);
frame->hovers = createScope(file);
frame->location.file = file;
return frame;
}
......
......@@ -88,6 +88,10 @@ public:
// does not exist or no longer has any external shared_ptr references.
std::shared_ptr<File> get(ID<File>);
// findFile() returns the file with the given path, or nullptr if not
// found.
std::shared_ptr<File> findFile(const std::string &path);
// files() returns the full list of files.
std::vector<std::shared_ptr<File>> files();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment