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>
This commit is contained in:
Ben Clayton 2020-11-02 17:55:18 +00:00 committed by Commit Bot service account
parent 3d0e273ec3
commit cd5e4a8083
4 changed files with 5 additions and 33 deletions

View File

@ -21,13 +21,7 @@ namespace reader {
namespace wgsl { namespace wgsl {
Parser::Parser(Context* ctx, Source::File const* file) Parser::Parser(Context* ctx, Source::File const* file)
: Reader(ctx), impl_(std::make_unique<ParserImpl>(ctx, file, false)) {} : Reader(ctx), impl_(std::make_unique<ParserImpl>(ctx, file)) {}
Parser::Parser(Context* ctx, const std::string& content)
: Reader(ctx),
impl_(std::make_unique<ParserImpl>(ctx,
new Source::File("", content),
true)) {}
Parser::~Parser() = default; Parser::~Parser() = default;

View File

@ -34,14 +34,6 @@ class Parser : public Reader {
/// @param ctx the non-null context object /// @param ctx the non-null context object
/// @param file the input source file to parse /// @param file the input source file to parse
Parser(Context* ctx, Source::File const* file); 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; ~Parser() override;
/// Run the parser /// Run the parser

View File

@ -119,17 +119,10 @@ bool IsFunctionDecoration(Token t) {
} // namespace } // namespace
ParserImpl::ParserImpl(Context* ctx, Source::File const* file, bool owns_file) ParserImpl::ParserImpl(Context* ctx, Source::File const* file)
: ctx_(*ctx), : ctx_(*ctx), lexer_(std::make_unique<Lexer>(file)) {}
lexer_(std::make_unique<Lexer>(file)),
file_(file),
owns_file_(owns_file) {}
ParserImpl::~ParserImpl() { ParserImpl::~ParserImpl() = default;
if (owns_file_) {
delete file_;
}
}
void ParserImpl::set_error(const Token& t, const std::string& err) { void ParserImpl::set_error(const Token& t, const std::string& err) {
diag::Diagnostic diagnostic; diag::Diagnostic diagnostic;

View File

@ -89,11 +89,7 @@ class ParserImpl {
/// Creates a new parser using the given file /// Creates a new parser using the given file
/// @param ctx the non-null context object /// @param ctx the non-null context object
/// @param file the input source file to parse /// @param file the input source file to parse
/// @param owns_file if true, the file will be deleted on parser destruction. ParserImpl(Context* ctx, Source::File const* file);
/// 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(); ~ParserImpl();
/// Run the parser /// Run the parser
@ -431,9 +427,6 @@ class ParserImpl {
std::deque<Token> token_queue_; std::deque<Token> token_queue_;
std::unordered_map<std::string, ast::type::Type*> registered_constructs_; std::unordered_map<std::string, ast::type::Type*> registered_constructs_;
ast::Module module_; ast::Module module_;
Source::File const* file_;
bool owns_file_;
}; };
} // namespace wgsl } // namespace wgsl