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:
parent
6761160dc1
commit
5c243f824c
|
@ -33,7 +33,7 @@ void AccessDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -34,7 +34,7 @@ ArrayAccessorExpression::~ArrayAccessorExpression() = default;
|
|||
|
||||
ArrayAccessorExpression* ArrayAccessorExpression::Clone(
|
||||
CloneContext* ctx) const {
|
||||
return ctx->mod->create<ArrayAccessorExpression>(
|
||||
return ctx->dst->create<ArrayAccessorExpression>(
|
||||
ctx->Clone(source()), ctx->Clone(array_), ctx->Clone(idx_expr_));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ AssignmentStatement::AssignmentStatement(AssignmentStatement&&) = default;
|
|||
AssignmentStatement::~AssignmentStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ BinaryExpression::BinaryExpression(BinaryExpression&&) = default;
|
|||
BinaryExpression::~BinaryExpression() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void BindingDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -31,7 +31,7 @@ BitcastExpression::BitcastExpression(BitcastExpression&&) = default;
|
|||
BitcastExpression::~BitcastExpression() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ BlockStatement::BlockStatement(BlockStatement&&) = default;
|
|||
BlockStatement::~BlockStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ std::string BoolLiteral::name() 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_);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ BreakStatement::BreakStatement(BreakStatement&&) = default;
|
|||
BreakStatement::~BreakStatement() = default;
|
||||
|
||||
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 {
|
||||
|
|
|
@ -33,7 +33,7 @@ void BuiltinDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -32,7 +32,7 @@ CallExpression::CallExpression(CallExpression&&) = default;
|
|||
CallExpression::~CallExpression() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ CallStatement::CallStatement(CallStatement&&) = default;
|
|||
CallStatement::~CallStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ CaseStatement::CaseStatement(CaseStatement&&) = default;
|
|||
CaseStatement::~CaseStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void ConstantIdDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -29,7 +29,7 @@ ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
|
|||
ContinueStatement::~ContinueStatement() = default;
|
||||
|
||||
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 {
|
||||
|
|
|
@ -29,7 +29,7 @@ DiscardStatement::DiscardStatement(DiscardStatement&&) = default;
|
|||
DiscardStatement::~DiscardStatement() = default;
|
||||
|
||||
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 {
|
||||
|
|
|
@ -32,7 +32,7 @@ ElseStatement::ElseStatement(ElseStatement&&) = default;
|
|||
ElseStatement::~ElseStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
|
|||
FallthroughStatement::~FallthroughStatement() = default;
|
||||
|
||||
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 {
|
||||
|
|
|
@ -43,7 +43,7 @@ std::string FloatLiteral::name() 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_);
|
||||
}
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ const Statement* Function::get_last_statement() 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(return_type_), ctx->Clone(body_), ctx->Clone(decorations_));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void GroupDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -30,7 +30,7 @@ IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default;
|
|||
IdentifierExpression::~IdentifierExpression() = default;
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ IfStatement::IfStatement(IfStatement&&) = default;
|
|||
IfStatement::~IfStatement() = default;
|
||||
|
||||
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(else_statements_));
|
||||
return cloned;
|
||||
|
|
|
@ -33,7 +33,7 @@ void LocationDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -32,7 +32,7 @@ LoopStatement::LoopStatement(LoopStatement&&) = default;
|
|||
LoopStatement::~LoopStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ MemberAccessorExpression::~MemberAccessorExpression() = default;
|
|||
|
||||
MemberAccessorExpression* MemberAccessorExpression::Clone(
|
||||
CloneContext* ctx) const {
|
||||
return ctx->mod->create<MemberAccessorExpression>(
|
||||
return ctx->dst->create<MemberAccessorExpression>(
|
||||
ctx->Clone(source()), ctx->Clone(struct_), ctx->Clone(member_));
|
||||
}
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@ Module Module::Clone() const {
|
|||
|
||||
void Module::Clone(CloneContext* ctx) const {
|
||||
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_) {
|
||||
ctx->mod->global_variables_.emplace_back(ctx->Clone(var));
|
||||
ctx->dst->global_variables_.emplace_back(ctx->Clone(var));
|
||||
}
|
||||
for (auto* func : functions_) {
|
||||
ctx->mod->functions_.emplace_back(ctx->Clone(func));
|
||||
ctx->dst->functions_.emplace_back(ctx->Clone(func));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ std::string NullLiteral::name() 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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ ReturnStatement::ReturnStatement(ReturnStatement&&) = default;
|
|||
ReturnStatement::~ReturnStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ ScalarConstructorExpression::~ScalarConstructorExpression() = default;
|
|||
|
||||
ScalarConstructorExpression* ScalarConstructorExpression::Clone(
|
||||
CloneContext* ctx) const {
|
||||
return ctx->mod->create<ScalarConstructorExpression>(ctx->Clone(source()),
|
||||
return ctx->dst->create<ScalarConstructorExpression>(ctx->Clone(source()),
|
||||
ctx->Clone(literal_));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ std::string SintLiteral::name() 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_);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void StageDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -33,7 +33,7 @@ void StrideDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -53,7 +53,7 @@ bool Struct::IsBlockDecorated() 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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void StructBlockDecoration::to_str(std::ostream& out, size_t indent) 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
|
||||
|
|
|
@ -55,7 +55,7 @@ uint32_t StructMember::offset() 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(decorations_));
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ void StructMemberOffsetDecoration::to_str(std::ostream& out,
|
|||
|
||||
StructMemberOffsetDecoration* StructMemberOffsetDecoration::Clone(
|
||||
CloneContext* ctx) const {
|
||||
return ctx->mod->create<StructMemberOffsetDecoration>(ctx->Clone(source()),
|
||||
return ctx->dst->create<StructMemberOffsetDecoration>(ctx->Clone(source()),
|
||||
offset_);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ SwitchStatement::SwitchStatement(SwitchStatement&&) = default;
|
|||
SwitchStatement::~SwitchStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ TypeConstructorExpression::~TypeConstructorExpression() = default;
|
|||
|
||||
TypeConstructorExpression* TypeConstructorExpression::Clone(
|
||||
CloneContext* ctx) const {
|
||||
return ctx->mod->create<TypeConstructorExpression>(
|
||||
return ctx->dst->create<TypeConstructorExpression>(
|
||||
ctx->Clone(source()), ctx->Clone(type_), ctx->Clone(values_));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ std::string UintLiteral::name() 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_);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ UnaryOpExpression::UnaryOpExpression(UnaryOpExpression&&) = default;
|
|||
UnaryOpExpression::~UnaryOpExpression() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ uint32_t Variable::constant_id() 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()),
|
||||
is_const_, ctx->Clone(constructor()),
|
||||
ctx->Clone(decorations_));
|
||||
|
|
|
@ -31,7 +31,7 @@ VariableDeclStatement::VariableDeclStatement(VariableDeclStatement&&) = default;
|
|||
VariableDeclStatement::~VariableDeclStatement() = default;
|
||||
|
||||
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_));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void WorkgroupDecoration::to_str(std::ostream& out, size_t indent) 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_);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
namespace tint {
|
||||
|
||||
CloneContext::CloneContext(ast::Module* to, ast::Module const* from)
|
||||
: mod(to), src(from) {}
|
||||
: dst(to), src(from) {}
|
||||
CloneContext::~CloneContext() = default;
|
||||
|
||||
Symbol CloneContext::Clone(const Symbol& s) const {
|
||||
return mod->RegisterSymbol(src->SymbolToName(s));
|
||||
return dst->RegisterSymbol(src->SymbolToName(s));
|
||||
}
|
||||
|
||||
void CloneContext::Clone() {
|
||||
|
|
|
@ -42,7 +42,7 @@ class CloneContext {
|
|||
/// Destructor
|
||||
~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
|
||||
/// already by this CloneContext then the same cloned pointer is returned.
|
||||
///
|
||||
|
@ -76,7 +76,7 @@ class CloneContext {
|
|||
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
|
||||
/// `Source.File`s are owned by the `Module` this should make a copy of the
|
||||
/// file.
|
||||
|
@ -84,7 +84,7 @@ class CloneContext {
|
|||
/// @return the cloned source
|
||||
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.
|
||||
///
|
||||
|
@ -92,7 +92,7 @@ class CloneContext {
|
|||
/// @return the cloned source
|
||||
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.
|
||||
///
|
||||
|
@ -127,7 +127,7 @@ class CloneContext {
|
|||
/// // Replace all ast::UintLiterals with the number 42
|
||||
/// CloneCtx ctx(&out, in)
|
||||
/// .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()),
|
||||
/// 42);
|
||||
/// }).Clone();
|
||||
|
@ -147,11 +147,11 @@ class CloneContext {
|
|||
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();
|
||||
|
||||
/// The target module to clone into.
|
||||
ast::Module* const mod;
|
||||
ast::Module* const dst;
|
||||
|
||||
/// The source module to clone from.
|
||||
ast::Module const* const src;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct Cloneable : public Castable<Cloneable, ast::Node> {
|
|||
Cloneable* c = nullptr;
|
||||
|
||||
Cloneable* Clone(CloneContext* ctx) const override {
|
||||
auto* out = ctx->mod->create<Cloneable>();
|
||||
auto* out = ctx->dst->create<Cloneable>();
|
||||
out->a = ctx->Clone(a);
|
||||
out->b = ctx->Clone(b);
|
||||
out->c = ctx->Clone(c);
|
||||
|
|
|
@ -75,7 +75,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ast::Builder b(ctx->mod);
|
||||
ast::Builder b(ctx->dst);
|
||||
using u32 = ast::Builder::u32;
|
||||
|
||||
uint32_t size = 0;
|
||||
|
|
|
@ -64,9 +64,9 @@ constexpr char kIndexOffsetPrefix[] = "tint_first_index_offset_";
|
|||
ast::Variable* clone_variable_with_new_name(CloneContext* ctx,
|
||||
ast::Variable* in,
|
||||
std::string new_name) {
|
||||
return ctx->mod->create<ast::Variable>(
|
||||
return ctx->dst->create<ast::Variable>(
|
||||
ctx->Clone(in->source()), // source
|
||||
ctx->mod->RegisterSymbol(new_name), // symbol
|
||||
ctx->dst->RegisterSymbol(new_name), // symbol
|
||||
in->storage_class(), // storage_class
|
||||
ctx->Clone(in->type()), // type
|
||||
in->is_const(), // is_const
|
||||
|
@ -152,7 +152,7 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) {
|
|||
// which determines the original builtin variable names,
|
||||
// but this should be fine, as variables are cloned first.
|
||||
[&](CloneContext* ctx, ast::Function* func) -> ast::Function* {
|
||||
maybe_create_buffer_var(ctx->mod);
|
||||
maybe_create_buffer_var(ctx->dst);
|
||||
if (buffer_var == nullptr) {
|
||||
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) {
|
||||
statements.emplace_back(CreateFirstIndexOffset(
|
||||
in->SymbolToName(vertex_index_sym), kFirstVertexName,
|
||||
buffer_var, ctx->mod));
|
||||
buffer_var, ctx->dst));
|
||||
} else if (data.second->value() == ast::Builtin::kInstanceIndex) {
|
||||
statements.emplace_back(CreateFirstIndexOffset(
|
||||
in->SymbolToName(instance_index_sym), kFirstInstanceName,
|
||||
buffer_var, ctx->mod));
|
||||
buffer_var, ctx->dst));
|
||||
}
|
||||
}
|
||||
return CloneWithStatementsAtStart(ctx, func, statements);
|
||||
|
|
|
@ -31,10 +31,10 @@ ast::Function* Transform::CloneWithStatementsAtStart(
|
|||
for (auto* s : *in->body()) {
|
||||
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->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),
|
||||
ctx->Clone(in->decorations()));
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ uint64_t AccessControl::BaseAlignment(MemoryLayout mem_layout) 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
|
||||
|
|
|
@ -46,7 +46,7 @@ uint64_t Alias::BaseAlignment(MemoryLayout mem_layout) 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
|
||||
|
|
|
@ -96,7 +96,7 @@ std::string Array::type_name() 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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ std::string Bool::type_name() const {
|
|||
}
|
||||
|
||||
Bool* Bool::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<Bool>();
|
||||
return ctx->dst->create<Bool>();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -52,7 +52,7 @@ std::string DepthTexture::type_name() const {
|
|||
}
|
||||
|
||||
DepthTexture* DepthTexture::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<DepthTexture>(dim());
|
||||
return ctx->dst->create<DepthTexture>(dim());
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -41,7 +41,7 @@ uint64_t F32::BaseAlignment(MemoryLayout) const {
|
|||
}
|
||||
|
||||
F32* F32::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<F32>();
|
||||
return ctx->dst->create<F32>();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -41,7 +41,7 @@ uint64_t I32::BaseAlignment(MemoryLayout) const {
|
|||
}
|
||||
|
||||
I32* I32::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<I32>();
|
||||
return ctx->dst->create<I32>();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -56,7 +56,7 @@ uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) 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
|
||||
|
|
|
@ -41,7 +41,7 @@ std::string MultisampledTexture::type_name() 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
|
||||
|
|
|
@ -36,7 +36,7 @@ Pointer::Pointer(Pointer&&) = default;
|
|||
Pointer::~Pointer() = default;
|
||||
|
||||
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
|
||||
|
|
|
@ -41,7 +41,7 @@ std::string SampledTexture::type_name() 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
|
||||
|
|
|
@ -46,7 +46,7 @@ std::string Sampler::type_name() const {
|
|||
}
|
||||
|
||||
Sampler* Sampler::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<Sampler>(kind_);
|
||||
return ctx->dst->create<Sampler>(kind_);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -163,7 +163,7 @@ std::string StorageTexture::type_name() 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
|
||||
|
|
|
@ -83,7 +83,7 @@ uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) 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
|
||||
|
|
|
@ -41,7 +41,7 @@ uint64_t U32::BaseAlignment(MemoryLayout) const {
|
|||
}
|
||||
|
||||
U32* U32::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<U32>();
|
||||
return ctx->dst->create<U32>();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -53,7 +53,7 @@ uint64_t Vector::BaseAlignment(MemoryLayout mem_layout) 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
|
||||
|
|
|
@ -33,7 +33,7 @@ std::string Void::type_name() const {
|
|||
}
|
||||
|
||||
Void* Void::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<Void>();
|
||||
return ctx->dst->create<Void>();
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
Loading…
Reference in New Issue