Migrate from using ast::Module to Program

Enforce all places where Dawn passes in or returns a ast::Module, now takes a `const Program* ` or returns a `Program`.

As the end goal of all this is to have immutable Programs, all Program inputs take a pointer instead of moving the actual object.

As consumers of a Program are now all const, we have to const_cast to work around all the places we've been incorrectly mutating a ast::Module.
These const_casts are temporary, and will be fixed in the next set of changes.

Depends on https://dawn-review.googlesource.com/c/dawn/+/38522

Bug: tint:390
Change-Id: Ie05b112b16134937d1b601e9b713ea4ec4e1c677
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38541
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2021-01-26 16:57:10 +00:00
parent be610ba987
commit c40f627bea
252 changed files with 1978 additions and 2017 deletions

View File

@@ -24,7 +24,6 @@
#include "src/ast/call_expression.h"
#include "src/ast/expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
#include "src/ast/return_statement.h"
#include "src/ast/statement.h"
#include "src/ast/switch_statement.h"
@@ -32,16 +31,17 @@
#include "src/ast/variable_decl_statement.h"
#include "src/diagnostic/diagnostic.h"
#include "src/diagnostic/formatter.h"
#include "src/program.h"
#include "src/scope_stack.h"
namespace tint {
/// Determines if the module is complete and valid
/// Determines if the program is complete and valid
class ValidatorImpl {
public:
/// Constructor
/// @param module the module to validate
explicit ValidatorImpl(const ast::Module* module);
/// @param program the program to validate
explicit ValidatorImpl(const Program* program);
~ValidatorImpl();
/// Runs the validator
@@ -159,7 +159,7 @@ class ValidatorImpl {
}
private:
const ast::Module& module_;
const Program* program_;
diag::List diags_;
ScopeStack<ast::Variable*> variable_stack_;
ScopeStack<ast::Function*> function_stack_;