Remove Parser constructors that take a string
... for the content. Everything should be using a `Source::File*` now.
Bug: tint:282
Change-Id: I9bebb94995a946a5919ba6503f2b0ee2058f0fb1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31482
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/reader/wgsl/parser.cc b/src/reader/wgsl/parser.cc
index e24066a..323caea 100644
--- a/src/reader/wgsl/parser.cc
+++ b/src/reader/wgsl/parser.cc
@@ -21,13 +21,7 @@
namespace wgsl {
Parser::Parser(Context* ctx, Source::File const* file)
- : Reader(ctx), impl_(std::make_unique<ParserImpl>(ctx, file, false)) {}
-
-Parser::Parser(Context* ctx, const std::string& content)
- : Reader(ctx),
- impl_(std::make_unique<ParserImpl>(ctx,
- new Source::File("", content),
- true)) {}
+ : Reader(ctx), impl_(std::make_unique<ParserImpl>(ctx, file)) {}
Parser::~Parser() = default;
diff --git a/src/reader/wgsl/parser.h b/src/reader/wgsl/parser.h
index ff835b8..ddff63f 100644
--- a/src/reader/wgsl/parser.h
+++ b/src/reader/wgsl/parser.h
@@ -34,14 +34,6 @@
/// @param ctx the non-null context object
/// @param file the input source file to parse
Parser(Context* ctx, Source::File const* file);
-
- /// Creates a new parser from the given file content.
- /// @param ctx the non-null context object
- /// @param content the input string to parse
- /// TODO(bclayton): Remove this constructor.
- /// It purely exists to break up changes into bite sized pieces.
- Parser(Context* ctx, const std::string& content);
-
~Parser() override;
/// Run the parser
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 174bada..eb43221 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -119,17 +119,10 @@
} // namespace
-ParserImpl::ParserImpl(Context* ctx, Source::File const* file, bool owns_file)
- : ctx_(*ctx),
- lexer_(std::make_unique<Lexer>(file)),
- file_(file),
- owns_file_(owns_file) {}
+ParserImpl::ParserImpl(Context* ctx, Source::File const* file)
+ : ctx_(*ctx), lexer_(std::make_unique<Lexer>(file)) {}
-ParserImpl::~ParserImpl() {
- if (owns_file_) {
- delete file_;
- }
-}
+ParserImpl::~ParserImpl() = default;
void ParserImpl::set_error(const Token& t, const std::string& err) {
diag::Diagnostic diagnostic;
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 882093a..8ea3e6c 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -89,11 +89,7 @@
/// Creates a new parser using the given file
/// @param ctx the non-null context object
/// @param file the input source file to parse
- /// @param owns_file if true, the file will be deleted on parser destruction.
- /// TODO(bclayton): Remove owns_file.
- /// It purely exists to break up changes into bite sized pieces.
- ParserImpl(Context* ctx, Source::File const* file, bool owns_file = false);
-
+ ParserImpl(Context* ctx, Source::File const* file);
~ParserImpl();
/// Run the parser
@@ -431,9 +427,6 @@
std::deque<Token> token_queue_;
std::unordered_map<std::string, ast::type::Type*> registered_constructs_;
ast::Module module_;
-
- Source::File const* file_;
- bool owns_file_;
};
} // namespace wgsl