mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Remove internal usage of Context.
This CL removes all internal usage of the Context object. It is still accepted as a parameter until we update Dawn, but all usage is removed. The namer has been removed from the SPIR-V backend with this change and the emitted names reverted to their non-modified version. Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740 Commit-Queue: dan sinclair <dsinclair@chromium.org> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
573d8939f4
commit
685cb02ea8
@@ -17,7 +17,7 @@
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
||||
Reader::Reader(Context* ctx) : ctx_(*ctx) {}
|
||||
Reader::Reader() = default;
|
||||
|
||||
Reader::~Reader() = default;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "src/ast/module.h"
|
||||
#include "src/context.h"
|
||||
#include "src/diagnostic/diagnostic.h"
|
||||
#include "src/diagnostic/formatter.h"
|
||||
|
||||
@@ -52,16 +51,12 @@ class Reader {
|
||||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param ctx the context object, must be non-null
|
||||
explicit Reader(Context* ctx);
|
||||
Reader();
|
||||
|
||||
/// Sets the diagnostic messages
|
||||
/// @param diags the list of diagnostic messages
|
||||
void set_diagnostics(const diag::List& diags) { diags_ = diags; }
|
||||
|
||||
/// The Tint context object
|
||||
Context& ctx_;
|
||||
|
||||
/// All diagnostic messages from the reader.
|
||||
diag::List diags_;
|
||||
};
|
||||
|
||||
@@ -20,8 +20,11 @@ namespace tint {
|
||||
namespace reader {
|
||||
namespace spirv {
|
||||
|
||||
Parser::Parser(Context* ctx, const std::vector<uint32_t>& spv_binary)
|
||||
: Reader(ctx), impl_(std::make_unique<ParserImpl>(ctx, spv_binary)) {}
|
||||
Parser::Parser(const std::vector<uint32_t>& spv_binary)
|
||||
: Reader(), impl_(std::make_unique<ParserImpl>(spv_binary)) {}
|
||||
|
||||
Parser::Parser(Context*, const std::vector<uint32_t>& spv_binary)
|
||||
: Parser(spv_binary) {}
|
||||
|
||||
Parser::~Parser() = default;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "src/context.h"
|
||||
#include "src/reader/reader.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -31,6 +32,10 @@ class ParserImpl;
|
||||
class Parser : public Reader {
|
||||
public:
|
||||
/// Creates a new parser
|
||||
/// @param input the input data to parse
|
||||
explicit Parser(const std::vector<uint32_t>& input);
|
||||
/// Creates a new parser
|
||||
/// DEPRECATED
|
||||
/// @param ctx the non-null context object
|
||||
/// @param input the input data to parse
|
||||
Parser(Context* ctx, const std::vector<uint32_t>& input);
|
||||
|
||||
@@ -192,8 +192,8 @@ bool AssumesResultSignednessMatchesBinaryFirstOperand(SpvOp opcode) {
|
||||
|
||||
} // namespace
|
||||
|
||||
ParserImpl::ParserImpl(Context* ctx, const std::vector<uint32_t>& spv_binary)
|
||||
: Reader(ctx),
|
||||
ParserImpl::ParserImpl(const std::vector<uint32_t>& spv_binary)
|
||||
: Reader(),
|
||||
spv_binary_(spv_binary),
|
||||
fail_stream_(&success_, &errors_),
|
||||
bool_type_(ast_module_.create<ast::type::Bool>()),
|
||||
|
||||
@@ -86,9 +86,8 @@ struct TypedExpression {
|
||||
class ParserImpl : Reader {
|
||||
public:
|
||||
/// Creates a new parser
|
||||
/// @param ctx the non-null context object
|
||||
/// @param input the input data to parse
|
||||
ParserImpl(Context* ctx, const std::vector<uint32_t>& input);
|
||||
explicit ParserImpl(const std::vector<uint32_t>& input);
|
||||
/// Destructor
|
||||
~ParserImpl() override;
|
||||
|
||||
@@ -96,11 +95,6 @@ class ParserImpl : Reader {
|
||||
/// @returns true if the parse was successful, false otherwise.
|
||||
bool Parse() override;
|
||||
|
||||
/// @returns the Tint context.
|
||||
Context& context() {
|
||||
return ctx_; // Inherited from Reader
|
||||
}
|
||||
|
||||
/// @returns the module. The module in the parser will be reset after this.
|
||||
ast::Module module() override;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "source/opt/ir_context.h"
|
||||
#include "src/context.h"
|
||||
#include "src/reader/spirv/parser_impl.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -40,7 +39,7 @@ class SpvParserTestBase : public T {
|
||||
/// @param input the SPIR-V binary to parse
|
||||
/// @returns a parser for the given binary
|
||||
std::unique_ptr<ParserImpl> parser(const std::vector<uint32_t>& input) {
|
||||
return std::make_unique<ParserImpl>(&ctx_, input);
|
||||
return std::make_unique<ParserImpl>(input);
|
||||
}
|
||||
|
||||
/// Gets the internal representation of the function with the given ID.
|
||||
@@ -52,9 +51,6 @@ class SpvParserTestBase : public T {
|
||||
spvtools::opt::Function* spirv_function(ParserImpl* parser, uint32_t id) {
|
||||
return parser->ir_context()->GetFunction(id);
|
||||
}
|
||||
|
||||
private:
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
// Use this form when you don't need to template any further.
|
||||
|
||||
@@ -22,8 +22,10 @@ namespace tint {
|
||||
namespace reader {
|
||||
namespace wgsl {
|
||||
|
||||
Parser::Parser(Context* ctx, Source::File const* file)
|
||||
: Reader(ctx), impl_(std::make_unique<ParserImpl>(ctx, file)) {}
|
||||
Parser::Parser(Source::File const* file)
|
||||
: Reader(), impl_(std::make_unique<ParserImpl>(file)) {}
|
||||
|
||||
Parser::Parser(Context*, Source::File const* file) : Parser(file) {}
|
||||
|
||||
Parser::~Parser() = default;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "src/context.h"
|
||||
#include "src/reader/reader.h"
|
||||
#include "src/source.h"
|
||||
|
||||
@@ -31,6 +32,10 @@ class ParserImpl;
|
||||
class Parser : public Reader {
|
||||
public:
|
||||
/// Creates a new parser from the given file.
|
||||
/// @param file the input source file to parse
|
||||
explicit Parser(Source::File const* file);
|
||||
/// Creates a new parser from the given file.
|
||||
/// DEPRECATED
|
||||
/// @param ctx the non-null context object
|
||||
/// @param file the input source file to parse
|
||||
Parser(Context* ctx, Source::File const* file);
|
||||
|
||||
@@ -186,7 +186,7 @@ struct BlockCounters {
|
||||
|
||||
} // namespace
|
||||
|
||||
ParserImpl::ParserImpl(Context*, Source::File const* file)
|
||||
ParserImpl::ParserImpl(Source::File const* file)
|
||||
: lexer_(std::make_unique<Lexer>(file)) {}
|
||||
|
||||
ParserImpl::~ParserImpl() = default;
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/ast/variable_decl_statement.h"
|
||||
#include "src/ast/variable_decoration.h"
|
||||
#include "src/context.h"
|
||||
#include "src/diagnostic/diagnostic.h"
|
||||
#include "src/diagnostic/formatter.h"
|
||||
#include "src/reader/wgsl/parser_impl_detail.h"
|
||||
@@ -231,9 +230,8 @@ class ParserImpl {
|
||||
};
|
||||
|
||||
/// Creates a new parser using the given file
|
||||
/// @param ctx the non-null context object
|
||||
/// @param file the input source file to parse
|
||||
ParserImpl(Context* ctx, Source::File const* file);
|
||||
explicit ParserImpl(Source::File const* file);
|
||||
~ParserImpl();
|
||||
|
||||
/// Run the parser
|
||||
|
||||
@@ -40,14 +40,13 @@ class ParserImplTest : public testing::Test {
|
||||
/// @returns the parser implementation
|
||||
std::unique_ptr<ParserImpl> parser(const std::string& str) {
|
||||
auto file = std::make_unique<Source::File>("test.wgsl", str);
|
||||
auto impl = std::make_unique<ParserImpl>(&ctx_, file.get());
|
||||
auto impl = std::make_unique<ParserImpl>(file.get());
|
||||
files_.emplace_back(std::move(file));
|
||||
return impl;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
/// WGSL Parser test class with param
|
||||
@@ -63,14 +62,13 @@ class ParserImplTestWithParam : public testing::TestWithParam<T> {
|
||||
/// @returns the parser implementation
|
||||
std::unique_ptr<ParserImpl> parser(const std::string& str) {
|
||||
auto file = std::make_unique<Source::File>("test.wgsl", str);
|
||||
auto impl = std::make_unique<ParserImpl>(&ctx_, file.get());
|
||||
auto impl = std::make_unique<ParserImpl>(file.get());
|
||||
files_.emplace_back(std::move(file));
|
||||
return impl;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
} // namespace wgsl
|
||||
|
||||
Reference in New Issue
Block a user