mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Move the ast node ownership from Context to Module
Fixes: tint:335 Change-Id: I128e229daa56d43e7227ecab72269be33b3ee012 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33240 Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
627732c408
commit
2f4096b0d7
@@ -59,15 +59,6 @@ class Reader {
|
||||
/// @param diags the list of diagnostic messages
|
||||
void set_diagnostics(const diag::List& diags) { diags_ = diags; }
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Context. When the Context is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
T* create(ARGS&&... args) const {
|
||||
return ctx_.create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// The Tint context object
|
||||
Context& ctx_;
|
||||
|
||||
|
||||
@@ -797,14 +797,13 @@ class FunctionEmitter {
|
||||
/// @returns a boolean false expression.
|
||||
ast::Expression* MakeFalse() const;
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Context. When the Context is
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
T* create(ARGS&&... args) const {
|
||||
auto& ctx = parser_impl_.context();
|
||||
return ctx.create<T>(std::forward<ARGS>(args)...);
|
||||
return ast_module_.create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
ParserImpl& parser_impl_;
|
||||
|
||||
@@ -450,6 +450,15 @@ class ParserImpl : Reader {
|
||||
bool ApplyArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
|
||||
ast::type::ArrayType* ast_type);
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
T* create(ARGS&&... args) {
|
||||
return ast_module_.create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
// The SPIR-V binary we're parsing
|
||||
std::vector<uint32_t> spv_binary_;
|
||||
|
||||
|
||||
@@ -734,13 +734,13 @@ class ParserImpl {
|
||||
Maybe<ast::Statement*> for_header_initializer();
|
||||
Maybe<ast::Statement*> for_header_continuing();
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Context. When the Context is
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
T* create(ARGS&&... args) {
|
||||
return ctx_.create<T>(std::forward<ARGS>(args)...);
|
||||
return module_.create<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
Context& ctx_;
|
||||
|
||||
@@ -76,7 +76,6 @@ class ParserImplTestWithParam : public testing::TestWithParam<T> {
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
std::unique_ptr<ParserImpl> impl;
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user