Rename CloneContext::mod to CloneContext::dst

In the future, CloneContext will be operating on `Program`s so a field called `mod` is poorly named.
CloneContext has a `src` member, so rename to `dst` to keep symmetry.

Bug: tint:390
Change-Id: Ic724f8a18b46ef719790394cdc810f7eb3681234
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38364
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-01-22 13:41:06 +00:00 committed by Commit Bot service account
parent 6761160dc1
commit 5c243f824c
67 changed files with 81 additions and 81 deletions

View File

@ -33,7 +33,7 @@ void AccessDecoration::to_str(std::ostream& out, size_t indent) const {
} }
AccessDecoration* AccessDecoration::Clone(CloneContext* ctx) const { AccessDecoration* AccessDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<AccessDecoration>(ctx->Clone(source()), value_); return ctx->dst->create<AccessDecoration>(ctx->Clone(source()), value_);
} }
} // namespace ast } // namespace ast

View File

@ -34,7 +34,7 @@ ArrayAccessorExpression::~ArrayAccessorExpression() = default;
ArrayAccessorExpression* ArrayAccessorExpression::Clone( ArrayAccessorExpression* ArrayAccessorExpression::Clone(
CloneContext* ctx) const { CloneContext* ctx) const {
return ctx->mod->create<ArrayAccessorExpression>( return ctx->dst->create<ArrayAccessorExpression>(
ctx->Clone(source()), ctx->Clone(array_), ctx->Clone(idx_expr_)); ctx->Clone(source()), ctx->Clone(array_), ctx->Clone(idx_expr_));
} }

View File

@ -32,7 +32,7 @@ AssignmentStatement::AssignmentStatement(AssignmentStatement&&) = default;
AssignmentStatement::~AssignmentStatement() = default; AssignmentStatement::~AssignmentStatement() = default;
AssignmentStatement* AssignmentStatement::Clone(CloneContext* ctx) const { AssignmentStatement* AssignmentStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<AssignmentStatement>( return ctx->dst->create<AssignmentStatement>(
ctx->Clone(source()), ctx->Clone(lhs_), ctx->Clone(rhs_)); ctx->Clone(source()), ctx->Clone(lhs_), ctx->Clone(rhs_));
} }

View File

@ -33,7 +33,7 @@ BinaryExpression::BinaryExpression(BinaryExpression&&) = default;
BinaryExpression::~BinaryExpression() = default; BinaryExpression::~BinaryExpression() = default;
BinaryExpression* BinaryExpression::Clone(CloneContext* ctx) const { BinaryExpression* BinaryExpression::Clone(CloneContext* ctx) const {
return ctx->mod->create<BinaryExpression>(ctx->Clone(source()), op_, return ctx->dst->create<BinaryExpression>(ctx->Clone(source()), op_,
ctx->Clone(lhs_), ctx->Clone(rhs_)); ctx->Clone(lhs_), ctx->Clone(rhs_));
} }

View File

@ -33,7 +33,7 @@ void BindingDecoration::to_str(std::ostream& out, size_t indent) const {
} }
BindingDecoration* BindingDecoration::Clone(CloneContext* ctx) const { BindingDecoration* BindingDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<BindingDecoration>(ctx->Clone(source()), value_); return ctx->dst->create<BindingDecoration>(ctx->Clone(source()), value_);
} }
} // namespace ast } // namespace ast

View File

@ -31,7 +31,7 @@ BitcastExpression::BitcastExpression(BitcastExpression&&) = default;
BitcastExpression::~BitcastExpression() = default; BitcastExpression::~BitcastExpression() = default;
BitcastExpression* BitcastExpression::Clone(CloneContext* ctx) const { BitcastExpression* BitcastExpression::Clone(CloneContext* ctx) const {
return ctx->mod->create<BitcastExpression>( return ctx->dst->create<BitcastExpression>(
ctx->Clone(source()), ctx->Clone(type_), ctx->Clone(expr_)); ctx->Clone(source()), ctx->Clone(type_), ctx->Clone(expr_));
} }

View File

@ -31,7 +31,7 @@ BlockStatement::BlockStatement(BlockStatement&&) = default;
BlockStatement::~BlockStatement() = default; BlockStatement::~BlockStatement() = default;
BlockStatement* BlockStatement::Clone(CloneContext* ctx) const { BlockStatement* BlockStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<BlockStatement>(ctx->Clone(source()), return ctx->dst->create<BlockStatement>(ctx->Clone(source()),
ctx->Clone(statements_)); ctx->Clone(statements_));
} }

View File

@ -36,7 +36,7 @@ std::string BoolLiteral::name() const {
} }
BoolLiteral* BoolLiteral::Clone(CloneContext* ctx) const { BoolLiteral* BoolLiteral::Clone(CloneContext* ctx) const {
return ctx->mod->create<BoolLiteral>(ctx->Clone(source()), ctx->Clone(type()), return ctx->dst->create<BoolLiteral>(ctx->Clone(source()), ctx->Clone(type()),
value_); value_);
} }

View File

@ -29,7 +29,7 @@ BreakStatement::BreakStatement(BreakStatement&&) = default;
BreakStatement::~BreakStatement() = default; BreakStatement::~BreakStatement() = default;
BreakStatement* BreakStatement::Clone(CloneContext* ctx) const { BreakStatement* BreakStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<BreakStatement>(ctx->Clone(source())); return ctx->dst->create<BreakStatement>(ctx->Clone(source()));
} }
bool BreakStatement::IsValid() const { bool BreakStatement::IsValid() const {

View File

@ -33,7 +33,7 @@ void BuiltinDecoration::to_str(std::ostream& out, size_t indent) const {
} }
BuiltinDecoration* BuiltinDecoration::Clone(CloneContext* ctx) const { BuiltinDecoration* BuiltinDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<BuiltinDecoration>(ctx->Clone(source()), builtin_); return ctx->dst->create<BuiltinDecoration>(ctx->Clone(source()), builtin_);
} }
} // namespace ast } // namespace ast

View File

@ -32,7 +32,7 @@ CallExpression::CallExpression(CallExpression&&) = default;
CallExpression::~CallExpression() = default; CallExpression::~CallExpression() = default;
CallExpression* CallExpression::Clone(CloneContext* ctx) const { CallExpression* CallExpression::Clone(CloneContext* ctx) const {
return ctx->mod->create<CallExpression>( return ctx->dst->create<CallExpression>(
ctx->Clone(source()), ctx->Clone(func_), ctx->Clone(params_)); ctx->Clone(source()), ctx->Clone(func_), ctx->Clone(params_));
} }

View File

@ -31,7 +31,7 @@ CallStatement::CallStatement(CallStatement&&) = default;
CallStatement::~CallStatement() = default; CallStatement::~CallStatement() = default;
CallStatement* CallStatement::Clone(CloneContext* ctx) const { CallStatement* CallStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<CallStatement>(ctx->Clone(source()), return ctx->dst->create<CallStatement>(ctx->Clone(source()),
ctx->Clone(call_)); ctx->Clone(call_));
} }

View File

@ -32,7 +32,7 @@ CaseStatement::CaseStatement(CaseStatement&&) = default;
CaseStatement::~CaseStatement() = default; CaseStatement::~CaseStatement() = default;
CaseStatement* CaseStatement::Clone(CloneContext* ctx) const { CaseStatement* CaseStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<CaseStatement>( return ctx->dst->create<CaseStatement>(
ctx->Clone(source()), ctx->Clone(selectors_), ctx->Clone(body_)); ctx->Clone(source()), ctx->Clone(selectors_), ctx->Clone(body_));
} }

View File

@ -33,7 +33,7 @@ void ConstantIdDecoration::to_str(std::ostream& out, size_t indent) const {
} }
ConstantIdDecoration* ConstantIdDecoration::Clone(CloneContext* ctx) const { ConstantIdDecoration* ConstantIdDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<ConstantIdDecoration>(ctx->Clone(source()), value_); return ctx->dst->create<ConstantIdDecoration>(ctx->Clone(source()), value_);
} }
} // namespace ast } // namespace ast

View File

@ -29,7 +29,7 @@ ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
ContinueStatement::~ContinueStatement() = default; ContinueStatement::~ContinueStatement() = default;
ContinueStatement* ContinueStatement::Clone(CloneContext* ctx) const { ContinueStatement* ContinueStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<ContinueStatement>(ctx->Clone(source())); return ctx->dst->create<ContinueStatement>(ctx->Clone(source()));
} }
bool ContinueStatement::IsValid() const { bool ContinueStatement::IsValid() const {

View File

@ -29,7 +29,7 @@ DiscardStatement::DiscardStatement(DiscardStatement&&) = default;
DiscardStatement::~DiscardStatement() = default; DiscardStatement::~DiscardStatement() = default;
DiscardStatement* DiscardStatement::Clone(CloneContext* ctx) const { DiscardStatement* DiscardStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<DiscardStatement>(ctx->Clone(source())); return ctx->dst->create<DiscardStatement>(ctx->Clone(source()));
} }
bool DiscardStatement::IsValid() const { bool DiscardStatement::IsValid() const {

View File

@ -32,7 +32,7 @@ ElseStatement::ElseStatement(ElseStatement&&) = default;
ElseStatement::~ElseStatement() = default; ElseStatement::~ElseStatement() = default;
ElseStatement* ElseStatement::Clone(CloneContext* ctx) const { ElseStatement* ElseStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<ElseStatement>( return ctx->dst->create<ElseStatement>(
ctx->Clone(source()), ctx->Clone(condition_), ctx->Clone(body_)); ctx->Clone(source()), ctx->Clone(condition_), ctx->Clone(body_));
} }

View File

@ -30,7 +30,7 @@ FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
FallthroughStatement::~FallthroughStatement() = default; FallthroughStatement::~FallthroughStatement() = default;
FallthroughStatement* FallthroughStatement::Clone(CloneContext* ctx) const { FallthroughStatement* FallthroughStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<FallthroughStatement>(ctx->Clone(source())); return ctx->dst->create<FallthroughStatement>(ctx->Clone(source()));
} }
bool FallthroughStatement::IsValid() const { bool FallthroughStatement::IsValid() const {

View File

@ -43,7 +43,7 @@ std::string FloatLiteral::name() const {
} }
FloatLiteral* FloatLiteral::Clone(CloneContext* ctx) const { FloatLiteral* FloatLiteral::Clone(CloneContext* ctx) const {
return ctx->mod->create<FloatLiteral>(ctx->Clone(source()), return ctx->dst->create<FloatLiteral>(ctx->Clone(source()),
ctx->Clone(type()), value_); ctx->Clone(type()), value_);
} }

View File

@ -225,7 +225,7 @@ const Statement* Function::get_last_statement() const {
} }
Function* Function::Clone(CloneContext* ctx) const { Function* Function::Clone(CloneContext* ctx) const {
return ctx->mod->create<Function>( return ctx->dst->create<Function>(
ctx->Clone(source()), ctx->Clone(symbol()), ctx->Clone(params_), ctx->Clone(source()), ctx->Clone(symbol()), ctx->Clone(params_),
ctx->Clone(return_type_), ctx->Clone(body_), ctx->Clone(decorations_)); ctx->Clone(return_type_), ctx->Clone(body_), ctx->Clone(decorations_));
} }

View File

@ -33,7 +33,7 @@ void GroupDecoration::to_str(std::ostream& out, size_t indent) const {
} }
GroupDecoration* GroupDecoration::Clone(CloneContext* ctx) const { GroupDecoration* GroupDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<GroupDecoration>(ctx->Clone(source()), value_); return ctx->dst->create<GroupDecoration>(ctx->Clone(source()), value_);
} }
} // namespace ast } // namespace ast

View File

@ -30,7 +30,7 @@ IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default;
IdentifierExpression::~IdentifierExpression() = default; IdentifierExpression::~IdentifierExpression() = default;
IdentifierExpression* IdentifierExpression::Clone(CloneContext* ctx) const { IdentifierExpression* IdentifierExpression::Clone(CloneContext* ctx) const {
return ctx->mod->create<IdentifierExpression>(ctx->Clone(source()), return ctx->dst->create<IdentifierExpression>(ctx->Clone(source()),
ctx->Clone(symbol())); ctx->Clone(symbol()));
} }

View File

@ -37,7 +37,7 @@ IfStatement::IfStatement(IfStatement&&) = default;
IfStatement::~IfStatement() = default; IfStatement::~IfStatement() = default;
IfStatement* IfStatement::Clone(CloneContext* ctx) const { IfStatement* IfStatement::Clone(CloneContext* ctx) const {
auto* cloned = ctx->mod->create<IfStatement>( auto* cloned = ctx->dst->create<IfStatement>(
ctx->Clone(source()), ctx->Clone(condition_), ctx->Clone(body_), ctx->Clone(source()), ctx->Clone(condition_), ctx->Clone(body_),
ctx->Clone(else_statements_)); ctx->Clone(else_statements_));
return cloned; return cloned;

View File

@ -33,7 +33,7 @@ void LocationDecoration::to_str(std::ostream& out, size_t indent) const {
} }
LocationDecoration* LocationDecoration::Clone(CloneContext* ctx) const { LocationDecoration* LocationDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<LocationDecoration>(ctx->Clone(source()), value_); return ctx->dst->create<LocationDecoration>(ctx->Clone(source()), value_);
} }
} // namespace ast } // namespace ast

View File

@ -32,7 +32,7 @@ LoopStatement::LoopStatement(LoopStatement&&) = default;
LoopStatement::~LoopStatement() = default; LoopStatement::~LoopStatement() = default;
LoopStatement* LoopStatement::Clone(CloneContext* ctx) const { LoopStatement* LoopStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<LoopStatement>( return ctx->dst->create<LoopStatement>(
ctx->Clone(source()), ctx->Clone(body_), ctx->Clone(continuing_)); ctx->Clone(source()), ctx->Clone(body_), ctx->Clone(continuing_));
} }

View File

@ -34,7 +34,7 @@ MemberAccessorExpression::~MemberAccessorExpression() = default;
MemberAccessorExpression* MemberAccessorExpression::Clone( MemberAccessorExpression* MemberAccessorExpression::Clone(
CloneContext* ctx) const { CloneContext* ctx) const {
return ctx->mod->create<MemberAccessorExpression>( return ctx->dst->create<MemberAccessorExpression>(
ctx->Clone(source()), ctx->Clone(struct_), ctx->Clone(member_)); ctx->Clone(source()), ctx->Clone(struct_), ctx->Clone(member_));
} }

View File

@ -38,13 +38,13 @@ Module Module::Clone() const {
void Module::Clone(CloneContext* ctx) const { void Module::Clone(CloneContext* ctx) const {
for (auto* ty : constructed_types_) { for (auto* ty : constructed_types_) {
ctx->mod->constructed_types_.emplace_back(ctx->Clone(ty)); ctx->dst->constructed_types_.emplace_back(ctx->Clone(ty));
} }
for (auto* var : global_variables_) { for (auto* var : global_variables_) {
ctx->mod->global_variables_.emplace_back(ctx->Clone(var)); ctx->dst->global_variables_.emplace_back(ctx->Clone(var));
} }
for (auto* func : functions_) { for (auto* func : functions_) {
ctx->mod->functions_.emplace_back(ctx->Clone(func)); ctx->dst->functions_.emplace_back(ctx->Clone(func));
} }
} }

View File

@ -36,7 +36,7 @@ std::string NullLiteral::name() const {
} }
NullLiteral* NullLiteral::Clone(CloneContext* ctx) const { NullLiteral* NullLiteral::Clone(CloneContext* ctx) const {
return ctx->mod->create<NullLiteral>(ctx->Clone(source()), return ctx->dst->create<NullLiteral>(ctx->Clone(source()),
ctx->Clone(type())); ctx->Clone(type()));
} }

View File

@ -33,7 +33,7 @@ ReturnStatement::ReturnStatement(ReturnStatement&&) = default;
ReturnStatement::~ReturnStatement() = default; ReturnStatement::~ReturnStatement() = default;
ReturnStatement* ReturnStatement::Clone(CloneContext* ctx) const { ReturnStatement* ReturnStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<ReturnStatement>(ctx->Clone(source()), return ctx->dst->create<ReturnStatement>(ctx->Clone(source()),
ctx->Clone(value_)); ctx->Clone(value_));
} }

View File

@ -33,7 +33,7 @@ ScalarConstructorExpression::~ScalarConstructorExpression() = default;
ScalarConstructorExpression* ScalarConstructorExpression::Clone( ScalarConstructorExpression* ScalarConstructorExpression::Clone(
CloneContext* ctx) const { CloneContext* ctx) const {
return ctx->mod->create<ScalarConstructorExpression>(ctx->Clone(source()), return ctx->dst->create<ScalarConstructorExpression>(ctx->Clone(source()),
ctx->Clone(literal_)); ctx->Clone(literal_));
} }

View File

@ -36,7 +36,7 @@ std::string SintLiteral::name() const {
} }
SintLiteral* SintLiteral::Clone(CloneContext* ctx) const { SintLiteral* SintLiteral::Clone(CloneContext* ctx) const {
return ctx->mod->create<SintLiteral>(ctx->Clone(source()), ctx->Clone(type()), return ctx->dst->create<SintLiteral>(ctx->Clone(source()), ctx->Clone(type()),
value_); value_);
} }

View File

@ -33,7 +33,7 @@ void StageDecoration::to_str(std::ostream& out, size_t indent) const {
} }
StageDecoration* StageDecoration::Clone(CloneContext* ctx) const { StageDecoration* StageDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<StageDecoration>(ctx->Clone(source()), stage_); return ctx->dst->create<StageDecoration>(ctx->Clone(source()), stage_);
} }
} // namespace ast } // namespace ast

View File

@ -33,7 +33,7 @@ void StrideDecoration::to_str(std::ostream& out, size_t indent) const {
} }
StrideDecoration* StrideDecoration::Clone(CloneContext* ctx) const { StrideDecoration* StrideDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<StrideDecoration>(ctx->Clone(source()), stride_); return ctx->dst->create<StrideDecoration>(ctx->Clone(source()), stride_);
} }
} // namespace ast } // namespace ast

View File

@ -53,7 +53,7 @@ bool Struct::IsBlockDecorated() const {
} }
Struct* Struct::Clone(CloneContext* ctx) const { Struct* Struct::Clone(CloneContext* ctx) const {
return ctx->mod->create<Struct>(ctx->Clone(source()), ctx->Clone(members_), return ctx->dst->create<Struct>(ctx->Clone(source()), ctx->Clone(members_),
ctx->Clone(decorations_)); ctx->Clone(decorations_));
} }

View File

@ -33,7 +33,7 @@ void StructBlockDecoration::to_str(std::ostream& out, size_t indent) const {
} }
StructBlockDecoration* StructBlockDecoration::Clone(CloneContext* ctx) const { StructBlockDecoration* StructBlockDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<StructBlockDecoration>(ctx->Clone(source())); return ctx->dst->create<StructBlockDecoration>(ctx->Clone(source()));
} }
} // namespace ast } // namespace ast

View File

@ -55,7 +55,7 @@ uint32_t StructMember::offset() const {
} }
StructMember* StructMember::Clone(CloneContext* ctx) const { StructMember* StructMember::Clone(CloneContext* ctx) const {
return ctx->mod->create<StructMember>(ctx->Clone(source()), return ctx->dst->create<StructMember>(ctx->Clone(source()),
ctx->Clone(symbol_), ctx->Clone(type_), ctx->Clone(symbol_), ctx->Clone(type_),
ctx->Clone(decorations_)); ctx->Clone(decorations_));
} }

View File

@ -36,7 +36,7 @@ void StructMemberOffsetDecoration::to_str(std::ostream& out,
StructMemberOffsetDecoration* StructMemberOffsetDecoration::Clone( StructMemberOffsetDecoration* StructMemberOffsetDecoration::Clone(
CloneContext* ctx) const { CloneContext* ctx) const {
return ctx->mod->create<StructMemberOffsetDecoration>(ctx->Clone(source()), return ctx->dst->create<StructMemberOffsetDecoration>(ctx->Clone(source()),
offset_); offset_);
} }

View File

@ -33,7 +33,7 @@ SwitchStatement::SwitchStatement(SwitchStatement&&) = default;
SwitchStatement::~SwitchStatement() = default; SwitchStatement::~SwitchStatement() = default;
SwitchStatement* SwitchStatement::Clone(CloneContext* ctx) const { SwitchStatement* SwitchStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<SwitchStatement>( return ctx->dst->create<SwitchStatement>(
ctx->Clone(source()), ctx->Clone(condition_), ctx->Clone(body_)); ctx->Clone(source()), ctx->Clone(condition_), ctx->Clone(body_));
} }

View File

@ -34,7 +34,7 @@ TypeConstructorExpression::~TypeConstructorExpression() = default;
TypeConstructorExpression* TypeConstructorExpression::Clone( TypeConstructorExpression* TypeConstructorExpression::Clone(
CloneContext* ctx) const { CloneContext* ctx) const {
return ctx->mod->create<TypeConstructorExpression>( return ctx->dst->create<TypeConstructorExpression>(
ctx->Clone(source()), ctx->Clone(type_), ctx->Clone(values_)); ctx->Clone(source()), ctx->Clone(type_), ctx->Clone(values_));
} }

View File

@ -36,7 +36,7 @@ std::string UintLiteral::name() const {
} }
UintLiteral* UintLiteral::Clone(CloneContext* ctx) const { UintLiteral* UintLiteral::Clone(CloneContext* ctx) const {
return ctx->mod->create<UintLiteral>(ctx->Clone(source()), ctx->Clone(type()), return ctx->dst->create<UintLiteral>(ctx->Clone(source()), ctx->Clone(type()),
value_); value_);
} }

View File

@ -32,7 +32,7 @@ UnaryOpExpression::UnaryOpExpression(UnaryOpExpression&&) = default;
UnaryOpExpression::~UnaryOpExpression() = default; UnaryOpExpression::~UnaryOpExpression() = default;
UnaryOpExpression* UnaryOpExpression::Clone(CloneContext* ctx) const { UnaryOpExpression* UnaryOpExpression::Clone(CloneContext* ctx) const {
return ctx->mod->create<UnaryOpExpression>(ctx->Clone(source()), op_, return ctx->dst->create<UnaryOpExpression>(ctx->Clone(source()), op_,
ctx->Clone(expr_)); ctx->Clone(expr_));
} }

View File

@ -91,7 +91,7 @@ uint32_t Variable::constant_id() const {
} }
Variable* Variable::Clone(CloneContext* ctx) const { Variable* Variable::Clone(CloneContext* ctx) const {
return ctx->mod->create<Variable>(ctx->Clone(source()), ctx->Clone(symbol_), return ctx->dst->create<Variable>(ctx->Clone(source()), ctx->Clone(symbol_),
storage_class(), ctx->Clone(type()), storage_class(), ctx->Clone(type()),
is_const_, ctx->Clone(constructor()), is_const_, ctx->Clone(constructor()),
ctx->Clone(decorations_)); ctx->Clone(decorations_));

View File

@ -31,7 +31,7 @@ VariableDeclStatement::VariableDeclStatement(VariableDeclStatement&&) = default;
VariableDeclStatement::~VariableDeclStatement() = default; VariableDeclStatement::~VariableDeclStatement() = default;
VariableDeclStatement* VariableDeclStatement::Clone(CloneContext* ctx) const { VariableDeclStatement* VariableDeclStatement::Clone(CloneContext* ctx) const {
return ctx->mod->create<VariableDeclStatement>(ctx->Clone(source()), return ctx->dst->create<VariableDeclStatement>(ctx->Clone(source()),
ctx->Clone(variable_)); ctx->Clone(variable_));
} }

View File

@ -45,7 +45,7 @@ void WorkgroupDecoration::to_str(std::ostream& out, size_t indent) const {
} }
WorkgroupDecoration* WorkgroupDecoration::Clone(CloneContext* ctx) const { WorkgroupDecoration* WorkgroupDecoration::Clone(CloneContext* ctx) const {
return ctx->mod->create<WorkgroupDecoration>(ctx->Clone(source()), x_, y_, return ctx->dst->create<WorkgroupDecoration>(ctx->Clone(source()), x_, y_,
z_); z_);
} }

View File

@ -19,11 +19,11 @@
namespace tint { namespace tint {
CloneContext::CloneContext(ast::Module* to, ast::Module const* from) CloneContext::CloneContext(ast::Module* to, ast::Module const* from)
: mod(to), src(from) {} : dst(to), src(from) {}
CloneContext::~CloneContext() = default; CloneContext::~CloneContext() = default;
Symbol CloneContext::Clone(const Symbol& s) const { Symbol CloneContext::Clone(const Symbol& s) const {
return mod->RegisterSymbol(src->SymbolToName(s)); return dst->RegisterSymbol(src->SymbolToName(s));
} }
void CloneContext::Clone() { void CloneContext::Clone() {

View File

@ -42,7 +42,7 @@ class CloneContext {
/// Destructor /// Destructor
~CloneContext(); ~CloneContext();
/// Clones the Node or type::Type `a` into the module #mod if `a` is not /// Clones the Node or type::Type `a` into the module #dst if `a` is not
/// null. If `a` is null, then Clone() returns null. If `a` has been cloned /// null. If `a` is null, then Clone() returns null. If `a` has been cloned
/// already by this CloneContext then the same cloned pointer is returned. /// already by this CloneContext then the same cloned pointer is returned.
/// ///
@ -76,7 +76,7 @@ class CloneContext {
return static_cast<T*>(c); return static_cast<T*>(c);
} }
/// Clones the Source `s` into `mod` /// Clones the Source `s` into `dst`
/// TODO(bclayton) - Currently this 'clone' is a shallow copy. If/when /// TODO(bclayton) - Currently this 'clone' is a shallow copy. If/when
/// `Source.File`s are owned by the `Module` this should make a copy of the /// `Source.File`s are owned by the `Module` this should make a copy of the
/// file. /// file.
@ -84,7 +84,7 @@ class CloneContext {
/// @return the cloned source /// @return the cloned source
Source Clone(const Source& s) const { return s; } Source Clone(const Source& s) const { return s; }
/// Clones the Symbol `s` into `mod` /// Clones the Symbol `s` into `dst`
/// ///
/// The Symbol `s` must be owned by the module #src. /// The Symbol `s` must be owned by the module #src.
/// ///
@ -92,7 +92,7 @@ class CloneContext {
/// @return the cloned source /// @return the cloned source
Symbol Clone(const Symbol& s) const; Symbol Clone(const Symbol& s) const;
/// Clones each of the elements of the vector `v` into the module #mod-> /// Clones each of the elements of the vector `v` into the module #dst->
/// ///
/// All the elements of the vector `v` must be owned by the module #src. /// All the elements of the vector `v` must be owned by the module #src.
/// ///
@ -127,7 +127,7 @@ class CloneContext {
/// // Replace all ast::UintLiterals with the number 42 /// // Replace all ast::UintLiterals with the number 42
/// CloneCtx ctx(&out, in) /// CloneCtx ctx(&out, in)
/// .ReplaceAll([&] (CloneContext* ctx, ast::UintLiteral* l) { /// .ReplaceAll([&] (CloneContext* ctx, ast::UintLiteral* l) {
/// return ctx->mod->create<ast::UintLiteral>(ctx->Clone(l->source()), /// return ctx->dst->create<ast::UintLiteral>(ctx->Clone(l->source()),
/// ctx->Clone(l->type()), /// ctx->Clone(l->type()),
/// 42); /// 42);
/// }).Clone(); /// }).Clone();
@ -147,11 +147,11 @@ class CloneContext {
return *this; return *this;
} }
/// Clone performs the clone of the entire module #src to #mod. /// Clone performs the clone of the entire module #src to #dst.
void Clone(); void Clone();
/// The target module to clone into. /// The target module to clone into.
ast::Module* const mod; ast::Module* const dst;
/// The source module to clone from. /// The source module to clone from.
ast::Module const* const src; ast::Module const* const src;

View File

@ -29,7 +29,7 @@ struct Cloneable : public Castable<Cloneable, ast::Node> {
Cloneable* c = nullptr; Cloneable* c = nullptr;
Cloneable* Clone(CloneContext* ctx) const override { Cloneable* Clone(CloneContext* ctx) const override {
auto* out = ctx->mod->create<Cloneable>(); auto* out = ctx->dst->create<Cloneable>();
out->a = ctx->Clone(a); out->a = ctx->Clone(a);
out->b = ctx->Clone(b); out->b = ctx->Clone(b);
out->c = ctx->Clone(c); out->c = ctx->Clone(c);

View File

@ -75,7 +75,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
return nullptr; return nullptr;
} }
ast::Builder b(ctx->mod); ast::Builder b(ctx->dst);
using u32 = ast::Builder::u32; using u32 = ast::Builder::u32;
uint32_t size = 0; uint32_t size = 0;

View File

@ -64,9 +64,9 @@ constexpr char kIndexOffsetPrefix[] = "tint_first_index_offset_";
ast::Variable* clone_variable_with_new_name(CloneContext* ctx, ast::Variable* clone_variable_with_new_name(CloneContext* ctx,
ast::Variable* in, ast::Variable* in,
std::string new_name) { std::string new_name) {
return ctx->mod->create<ast::Variable>( return ctx->dst->create<ast::Variable>(
ctx->Clone(in->source()), // source ctx->Clone(in->source()), // source
ctx->mod->RegisterSymbol(new_name), // symbol ctx->dst->RegisterSymbol(new_name), // symbol
in->storage_class(), // storage_class in->storage_class(), // storage_class
ctx->Clone(in->type()), // type ctx->Clone(in->type()), // type
in->is_const(), // is_const in->is_const(), // is_const
@ -152,7 +152,7 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) {
// which determines the original builtin variable names, // which determines the original builtin variable names,
// but this should be fine, as variables are cloned first. // but this should be fine, as variables are cloned first.
[&](CloneContext* ctx, ast::Function* func) -> ast::Function* { [&](CloneContext* ctx, ast::Function* func) -> ast::Function* {
maybe_create_buffer_var(ctx->mod); maybe_create_buffer_var(ctx->dst);
if (buffer_var == nullptr) { if (buffer_var == nullptr) {
return nullptr; // no transform need, just clone func return nullptr; // no transform need, just clone func
} }
@ -162,11 +162,11 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) {
if (data.second->value() == ast::Builtin::kVertexIndex) { if (data.second->value() == ast::Builtin::kVertexIndex) {
statements.emplace_back(CreateFirstIndexOffset( statements.emplace_back(CreateFirstIndexOffset(
in->SymbolToName(vertex_index_sym), kFirstVertexName, in->SymbolToName(vertex_index_sym), kFirstVertexName,
buffer_var, ctx->mod)); buffer_var, ctx->dst));
} else if (data.second->value() == ast::Builtin::kInstanceIndex) { } else if (data.second->value() == ast::Builtin::kInstanceIndex) {
statements.emplace_back(CreateFirstIndexOffset( statements.emplace_back(CreateFirstIndexOffset(
in->SymbolToName(instance_index_sym), kFirstInstanceName, in->SymbolToName(instance_index_sym), kFirstInstanceName,
buffer_var, ctx->mod)); buffer_var, ctx->dst));
} }
} }
return CloneWithStatementsAtStart(ctx, func, statements); return CloneWithStatementsAtStart(ctx, func, statements);

View File

@ -31,10 +31,10 @@ ast::Function* Transform::CloneWithStatementsAtStart(
for (auto* s : *in->body()) { for (auto* s : *in->body()) {
statements.emplace_back(ctx->Clone(s)); statements.emplace_back(ctx->Clone(s));
} }
return ctx->mod->create<ast::Function>( return ctx->dst->create<ast::Function>(
ctx->Clone(in->source()), ctx->Clone(in->symbol()), ctx->Clone(in->source()), ctx->Clone(in->symbol()),
ctx->Clone(in->params()), ctx->Clone(in->return_type()), ctx->Clone(in->params()), ctx->Clone(in->return_type()),
ctx->mod->create<ast::BlockStatement>(ctx->Clone(in->body()->source()), ctx->dst->create<ast::BlockStatement>(ctx->Clone(in->body()->source()),
statements), statements),
ctx->Clone(in->decorations())); ctx->Clone(in->decorations()));
} }

View File

@ -59,7 +59,7 @@ uint64_t AccessControl::BaseAlignment(MemoryLayout mem_layout) const {
} }
AccessControl* AccessControl::Clone(CloneContext* ctx) const { AccessControl* AccessControl::Clone(CloneContext* ctx) const {
return ctx->mod->create<AccessControl>(access_, ctx->Clone(subtype_)); return ctx->dst->create<AccessControl>(access_, ctx->Clone(subtype_));
} }
} // namespace type } // namespace type

View File

@ -46,7 +46,7 @@ uint64_t Alias::BaseAlignment(MemoryLayout mem_layout) const {
} }
Alias* Alias::Clone(CloneContext* ctx) const { Alias* Alias::Clone(CloneContext* ctx) const {
return ctx->mod->create<Alias>(ctx->Clone(symbol()), ctx->Clone(subtype_)); return ctx->dst->create<Alias>(ctx->Clone(symbol()), ctx->Clone(subtype_));
} }
} // namespace type } // namespace type

View File

@ -96,7 +96,7 @@ std::string Array::type_name() const {
} }
Array* Array::Clone(CloneContext* ctx) const { Array* Array::Clone(CloneContext* ctx) const {
return ctx->mod->create<Array>(ctx->Clone(subtype_), size_, return ctx->dst->create<Array>(ctx->Clone(subtype_), size_,
ctx->Clone(decorations())); ctx->Clone(decorations()));
} }

View File

@ -33,7 +33,7 @@ std::string Bool::type_name() const {
} }
Bool* Bool::Clone(CloneContext* ctx) const { Bool* Bool::Clone(CloneContext* ctx) const {
return ctx->mod->create<Bool>(); return ctx->dst->create<Bool>();
} }
} // namespace type } // namespace type

View File

@ -52,7 +52,7 @@ std::string DepthTexture::type_name() const {
} }
DepthTexture* DepthTexture::Clone(CloneContext* ctx) const { DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
return ctx->mod->create<DepthTexture>(dim()); return ctx->dst->create<DepthTexture>(dim());
} }
} // namespace type } // namespace type

View File

@ -41,7 +41,7 @@ uint64_t F32::BaseAlignment(MemoryLayout) const {
} }
F32* F32::Clone(CloneContext* ctx) const { F32* F32::Clone(CloneContext* ctx) const {
return ctx->mod->create<F32>(); return ctx->dst->create<F32>();
} }
} // namespace type } // namespace type

View File

@ -41,7 +41,7 @@ uint64_t I32::BaseAlignment(MemoryLayout) const {
} }
I32* I32::Clone(CloneContext* ctx) const { I32* I32::Clone(CloneContext* ctx) const {
return ctx->mod->create<I32>(); return ctx->dst->create<I32>();
} }
} // namespace type } // namespace type

View File

@ -56,7 +56,7 @@ uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
} }
Matrix* Matrix::Clone(CloneContext* ctx) const { Matrix* Matrix::Clone(CloneContext* ctx) const {
return ctx->mod->create<Matrix>(ctx->Clone(subtype_), rows_, columns_); return ctx->dst->create<Matrix>(ctx->Clone(subtype_), rows_, columns_);
} }
} // namespace type } // namespace type

View File

@ -41,7 +41,7 @@ std::string MultisampledTexture::type_name() const {
} }
MultisampledTexture* MultisampledTexture::Clone(CloneContext* ctx) const { MultisampledTexture* MultisampledTexture::Clone(CloneContext* ctx) const {
return ctx->mod->create<MultisampledTexture>(dim(), ctx->Clone(type_)); return ctx->dst->create<MultisampledTexture>(dim(), ctx->Clone(type_));
} }
} // namespace type } // namespace type

View File

@ -36,7 +36,7 @@ Pointer::Pointer(Pointer&&) = default;
Pointer::~Pointer() = default; Pointer::~Pointer() = default;
Pointer* Pointer::Clone(CloneContext* ctx) const { Pointer* Pointer::Clone(CloneContext* ctx) const {
return ctx->mod->create<Pointer>(ctx->Clone(subtype_), storage_class_); return ctx->dst->create<Pointer>(ctx->Clone(subtype_), storage_class_);
} }
} // namespace type } // namespace type

View File

@ -41,7 +41,7 @@ std::string SampledTexture::type_name() const {
} }
SampledTexture* SampledTexture::Clone(CloneContext* ctx) const { SampledTexture* SampledTexture::Clone(CloneContext* ctx) const {
return ctx->mod->create<SampledTexture>(dim(), ctx->Clone(type_)); return ctx->dst->create<SampledTexture>(dim(), ctx->Clone(type_));
} }
} // namespace type } // namespace type

View File

@ -46,7 +46,7 @@ std::string Sampler::type_name() const {
} }
Sampler* Sampler::Clone(CloneContext* ctx) const { Sampler* Sampler::Clone(CloneContext* ctx) const {
return ctx->mod->create<Sampler>(kind_); return ctx->dst->create<Sampler>(kind_);
} }
} // namespace type } // namespace type

View File

@ -163,7 +163,7 @@ std::string StorageTexture::type_name() const {
} }
StorageTexture* StorageTexture::Clone(CloneContext* ctx) const { StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
return ctx->mod->create<StorageTexture>(dim(), image_format_); return ctx->dst->create<StorageTexture>(dim(), image_format_);
} }
} // namespace type } // namespace type

View File

@ -83,7 +83,7 @@ uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const {
} }
Struct* Struct::Clone(CloneContext* ctx) const { Struct* Struct::Clone(CloneContext* ctx) const {
return ctx->mod->create<Struct>(ctx->Clone(symbol()), ctx->Clone(struct_)); return ctx->dst->create<Struct>(ctx->Clone(symbol()), ctx->Clone(struct_));
} }
} // namespace type } // namespace type

View File

@ -41,7 +41,7 @@ uint64_t U32::BaseAlignment(MemoryLayout) const {
} }
U32* U32::Clone(CloneContext* ctx) const { U32* U32::Clone(CloneContext* ctx) const {
return ctx->mod->create<U32>(); return ctx->dst->create<U32>();
} }
} // namespace type } // namespace type

View File

@ -53,7 +53,7 @@ uint64_t Vector::BaseAlignment(MemoryLayout mem_layout) const {
} }
Vector* Vector::Clone(CloneContext* ctx) const { Vector* Vector::Clone(CloneContext* ctx) const {
return ctx->mod->create<Vector>(ctx->Clone(subtype_), size_); return ctx->dst->create<Vector>(ctx->Clone(subtype_), size_);
} }
} // namespace type } // namespace type

View File

@ -33,7 +33,7 @@ std::string Void::type_name() const {
} }
Void* Void::Clone(CloneContext* ctx) const { Void* Void::Clone(CloneContext* ctx) const {
return ctx->mod->create<Void>(); return ctx->dst->create<Void>();
} }
} // namespace type } // namespace type