Split Program into Program and ProgramBuilder
Program is now immutable*, and remains part of the public Tint
interface.
ProgramBuilder is the mutable builder for Programs, and is not part of
the public Tint interface. ast::Builder has been folded into
ProgramBuilder.
Immutable Programs can be cloned into a mutable ProgramBuilder with
Program::CloneAsBuilder().
Mutable ProgramBuilders can be moved into immutable Programs.
* - mostly immutable. It still has a move constructor and move
assignment operator - required for practical usage - and the
semantic information on AST nodes is still mutable.
Bug: tint:390
Change-Id: Ia856c50b1880c2f95c91467a9eef5024cbc380c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38240
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/ast/module.cc b/src/ast/module.cc
index e39e048..9d99c17 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -18,8 +18,7 @@
#include <string>
#include <utility>
-#include "src/clone_context.h"
-#include "src/program.h"
+#include "src/program_builder.h"
#include "src/type/alias_type.h"
#include "src/type/struct_type.h"
@@ -28,12 +27,13 @@
namespace tint {
namespace ast {
-Module::Module() : Base(Source{}) {}
+Module::Module(const Source& source) : Base(source) {}
-Module::Module(std::vector<type::Type*> constructed_types,
+Module::Module(const Source& source,
+ std::vector<type::Type*> constructed_types,
FunctionList functions,
VariableList global_variables)
- : Base(Source{}),
+ : Base(source),
constructed_types_(std::move(constructed_types)),
functions_(std::move(functions)),
global_variables_(std::move(global_variables)) {}