Move CloneContext and Traits from src/ast to src/

CloneContext clones the AST, types, symbols and in the future semantic info.
3/4 of these are non-ast, so promote these up to the root.

Bug: tint:390
Change-Id: I49619796e6f81f9ab64f79413a12c87312cb1901
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38361
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2021-01-21 16:20:40 +00:00 committed by Commit Bot service account
parent f12054ea2a
commit 1e29f4beb0
81 changed files with 150 additions and 158 deletions

View File

@ -258,8 +258,6 @@ source_set("libtint_core_src") {
"src/ast/call_statement.h", "src/ast/call_statement.h",
"src/ast/case_statement.cc", "src/ast/case_statement.cc",
"src/ast/case_statement.h", "src/ast/case_statement.h",
"src/ast/clone_context.cc",
"src/ast/clone_context.h",
"src/ast/constant_id_decoration.cc", "src/ast/constant_id_decoration.cc",
"src/ast/constant_id_decoration.h", "src/ast/constant_id_decoration.h",
"src/ast/constructor_expression.cc", "src/ast/constructor_expression.cc",
@ -336,7 +334,6 @@ source_set("libtint_core_src") {
"src/ast/struct_member_offset_decoration.h", "src/ast/struct_member_offset_decoration.h",
"src/ast/switch_statement.cc", "src/ast/switch_statement.cc",
"src/ast/switch_statement.h", "src/ast/switch_statement.h",
"src/ast/traits.h",
"src/ast/type_constructor_expression.cc", "src/ast/type_constructor_expression.cc",
"src/ast/type_constructor_expression.h", "src/ast/type_constructor_expression.h",
"src/ast/type_decoration.cc", "src/ast/type_decoration.cc",
@ -358,6 +355,8 @@ source_set("libtint_core_src") {
"src/block_allocator.h", "src/block_allocator.h",
"src/castable.cc", "src/castable.cc",
"src/castable.h", "src/castable.h",
"src/clone_context.cc",
"src/clone_context.h",
"src/demangler.cc", "src/demangler.cc",
"src/demangler.h", "src/demangler.h",
"src/diagnostic/diagnostic.cc", "src/diagnostic/diagnostic.cc",
@ -383,6 +382,7 @@ source_set("libtint_core_src") {
"src/symbol.h", "src/symbol.h",
"src/symbol_table.cc", "src/symbol_table.cc",
"src/symbol_table.h", "src/symbol_table.h",
"src/traits.h",
"src/transform/bound_array_accessors.cc", "src/transform/bound_array_accessors.cc",
"src/transform/bound_array_accessors.h", "src/transform/bound_array_accessors.h",
"src/transform/emit_vertex_point_size.cc", "src/transform/emit_vertex_point_size.cc",
@ -771,7 +771,6 @@ source_set("tint_unittests_core_src") {
"src/ast/call_expression_test.cc", "src/ast/call_expression_test.cc",
"src/ast/call_statement_test.cc", "src/ast/call_statement_test.cc",
"src/ast/case_statement_test.cc", "src/ast/case_statement_test.cc",
"src/ast/clone_context_test.cc",
"src/ast/constant_id_decoration_test.cc", "src/ast/constant_id_decoration_test.cc",
"src/ast/continue_statement_test.cc", "src/ast/continue_statement_test.cc",
"src/ast/decoration_test.cc", "src/ast/decoration_test.cc",
@ -803,7 +802,6 @@ source_set("tint_unittests_core_src") {
"src/ast/struct_test.cc", "src/ast/struct_test.cc",
"src/ast/switch_statement_test.cc", "src/ast/switch_statement_test.cc",
"src/ast/test_helper.h", "src/ast/test_helper.h",
"src/ast/traits_test.cc",
"src/ast/type_constructor_expression_test.cc", "src/ast/type_constructor_expression_test.cc",
"src/ast/uint_literal_test.cc", "src/ast/uint_literal_test.cc",
"src/ast/unary_op_expression_test.cc", "src/ast/unary_op_expression_test.cc",
@ -812,6 +810,7 @@ source_set("tint_unittests_core_src") {
"src/ast/workgroup_decoration_test.cc", "src/ast/workgroup_decoration_test.cc",
"src/block_allocator_test.cc", "src/block_allocator_test.cc",
"src/castable_test.cc", "src/castable_test.cc",
"src/clone_context_test.cc",
"src/demangler_test.cc", "src/demangler_test.cc",
"src/diagnostic/formatter_test.cc", "src/diagnostic/formatter_test.cc",
"src/diagnostic/printer_test.cc", "src/diagnostic/printer_test.cc",
@ -820,6 +819,7 @@ source_set("tint_unittests_core_src") {
"src/scope_stack_test.cc", "src/scope_stack_test.cc",
"src/symbol_table_test.cc", "src/symbol_table_test.cc",
"src/symbol_test.cc", "src/symbol_test.cc",
"src/traits_test.cc",
"src/transform/bound_array_accessors_test.cc", "src/transform/bound_array_accessors_test.cc",
"src/transform/emit_vertex_point_size_test.cc", "src/transform/emit_vertex_point_size_test.cc",
"src/transform/first_index_offset_test.cc", "src/transform/first_index_offset_test.cc",

View File

@ -72,8 +72,6 @@ set(TINT_LIB_SRCS
ast/call_statement.h ast/call_statement.h
ast/case_statement.cc ast/case_statement.cc
ast/case_statement.h ast/case_statement.h
ast/clone_context.cc
ast/clone_context.h
ast/constant_id_decoration.cc ast/constant_id_decoration.cc
ast/constant_id_decoration.h ast/constant_id_decoration.h
ast/constructor_expression.cc ast/constructor_expression.cc
@ -150,7 +148,6 @@ set(TINT_LIB_SRCS
ast/struct_member_offset_decoration.h ast/struct_member_offset_decoration.h
ast/switch_statement.cc ast/switch_statement.cc
ast/switch_statement.h ast/switch_statement.h
ast/traits.h
ast/type_constructor_expression.cc ast/type_constructor_expression.cc
ast/type_constructor_expression.h ast/type_constructor_expression.h
ast/type_decoration.cc ast/type_decoration.cc
@ -172,6 +169,8 @@ set(TINT_LIB_SRCS
block_allocator.h block_allocator.h
castable.cc castable.cc
castable.h castable.h
clone_context.cc
clone_context.h
demangler.cc demangler.cc
demangler.h; demangler.h;
diagnostic/diagnostic.cc diagnostic/diagnostic.cc
@ -197,6 +196,7 @@ set(TINT_LIB_SRCS
symbol.h symbol.h
symbol_table.cc symbol_table.cc
symbol_table.h symbol_table.h
traits.h
transform/emit_vertex_point_size.cc transform/emit_vertex_point_size.cc
transform/emit_vertex_point_size.h transform/emit_vertex_point_size.h
transform/bound_array_accessors.cc transform/bound_array_accessors.cc
@ -401,7 +401,6 @@ if(${TINT_BUILD_TESTS})
ast/call_expression_test.cc ast/call_expression_test.cc
ast/call_statement_test.cc ast/call_statement_test.cc
ast/case_statement_test.cc ast/case_statement_test.cc
ast/clone_context_test.cc
ast/constant_id_decoration_test.cc ast/constant_id_decoration_test.cc
ast/continue_statement_test.cc ast/continue_statement_test.cc
ast/decoration_test.cc ast/decoration_test.cc
@ -433,7 +432,6 @@ if(${TINT_BUILD_TESTS})
ast/struct_test.cc ast/struct_test.cc
ast/switch_statement_test.cc ast/switch_statement_test.cc
ast/test_helper.h ast/test_helper.h
ast/traits_test.cc
ast/type_constructor_expression_test.cc ast/type_constructor_expression_test.cc
ast/uint_literal_test.cc ast/uint_literal_test.cc
ast/unary_op_expression_test.cc ast/unary_op_expression_test.cc
@ -442,6 +440,7 @@ if(${TINT_BUILD_TESTS})
ast/workgroup_decoration_test.cc ast/workgroup_decoration_test.cc
block_allocator_test.cc block_allocator_test.cc
castable_test.cc castable_test.cc
clone_context_test.cc
demangler_test.cc demangler_test.cc
diagnostic/formatter_test.cc diagnostic/formatter_test.cc
diagnostic/printer_test.cc diagnostic/printer_test.cc
@ -450,6 +449,7 @@ if(${TINT_BUILD_TESTS})
scope_stack_test.cc scope_stack_test.cc
symbol_table_test.cc symbol_table_test.cc
symbol_test.cc symbol_test.cc
traits_test.cc
type_determiner_test.cc type_determiner_test.cc
type/access_control_type_test.cc type/access_control_type_test.cc
type/alias_type_test.cc type/alias_type_test.cc

View File

@ -14,8 +14,8 @@
#include "src/ast/access_decoration.h" #include "src/ast/access_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::AccessDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::AccessDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/array_accessor_expression.h" #include "src/ast/array_accessor_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::ArrayAccessorExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::ArrayAccessorExpression);

View File

@ -14,8 +14,8 @@
#include "src/ast/assignment_statement.h" #include "src/ast/assignment_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::AssignmentStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::AssignmentStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/binary_expression.h" #include "src/ast/binary_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BinaryExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::BinaryExpression);

View File

@ -14,8 +14,8 @@
#include "src/ast/binding_decoration.h" #include "src/ast/binding_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/bitcast_expression.h" #include "src/ast/bitcast_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BitcastExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::BitcastExpression);

View File

@ -14,8 +14,8 @@
#include "src/ast/block_statement.h" #include "src/ast/block_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BlockStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::BlockStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/bool_literal.h" #include "src/ast/bool_literal.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral); TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral);

View File

@ -14,8 +14,8 @@
#include "src/ast/break_statement.h" #include "src/ast/break_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BreakStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::BreakStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/builtin_decoration.h" #include "src/ast/builtin_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::BuiltinDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::BuiltinDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/call_expression.h" #include "src/ast/call_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::CallExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::CallExpression);

View File

@ -15,8 +15,8 @@
#include "src/ast/call_statement.h" #include "src/ast/call_statement.h"
#include "src/ast/call_expression.h" #include "src/ast/call_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::CallStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::CallStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/case_statement.h" #include "src/ast/case_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::CaseStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::CaseStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/constant_id_decoration.h" #include "src/ast/constant_id_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::ConstantIdDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::ConstantIdDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/continue_statement.h" #include "src/ast/continue_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::ContinueStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::ContinueStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::DiscardStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::DiscardStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/else_statement.h" #include "src/ast/else_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::ElseStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::ElseStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/fallthrough_statement.h" #include "src/ast/fallthrough_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::FallthroughStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::FallthroughStatement);

View File

@ -17,8 +17,8 @@
#include <limits> #include <limits>
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral); TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral);

View File

@ -16,11 +16,11 @@
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/ast/stage_decoration.h" #include "src/ast/stage_decoration.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "src/ast/workgroup_decoration.h" #include "src/ast/workgroup_decoration.h"
#include "src/clone_context.h"
#include "src/type/multisampled_texture_type.h" #include "src/type/multisampled_texture_type.h"
#include "src/type/sampled_texture_type.h" #include "src/type/sampled_texture_type.h"
#include "src/type/texture_type.h" #include "src/type/texture_type.h"

View File

@ -14,8 +14,8 @@
#include "src/ast/group_decoration.h" #include "src/ast/group_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::GroupDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::GroupDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::IdentifierExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::IdentifierExpression);

View File

@ -14,9 +14,9 @@
#include "src/ast/if_statement.h" #include "src/ast/if_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/else_statement.h" #include "src/ast/else_statement.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::IfStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::IfStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/location_decoration.h" #include "src/ast/location_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::LocationDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::LocationDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/loop_statement.h" #include "src/ast/loop_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::LoopStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::LoopStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/member_accessor_expression.h" #include "src/ast/member_accessor_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::MemberAccessorExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::MemberAccessorExpression);

View File

@ -16,7 +16,7 @@
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h" #include "src/clone_context.h"
#include "src/type/struct_type.h" #include "src/type/struct_type.h"
namespace tint { namespace tint {

View File

@ -24,10 +24,10 @@
#include <vector> #include <vector>
#include "src/ast/function.h" #include "src/ast/function.h"
#include "src/ast/traits.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "src/block_allocator.h" #include "src/block_allocator.h"
#include "src/symbol_table.h" #include "src/symbol_table.h"
#include "src/traits.h"
#include "src/type/alias_type.h" #include "src/type/alias_type.h"
#include "src/type/type_manager.h" #include "src/type/type_manager.h"

View File

@ -23,13 +23,16 @@
#include "src/source.h" #include "src/source.h"
namespace tint { namespace tint {
// Forward declarations
class CloneContext;
namespace type { namespace type {
class Type; class Type;
} }
namespace ast { namespace ast {
class Module; class Module;
class CloneContext;
/// AST base class node /// AST base class node
class Node : public Castable<Node> { class Node : public Castable<Node> {

View File

@ -14,8 +14,8 @@
#include "src/ast/null_literal.h" #include "src/ast/null_literal.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral); TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral);

View File

@ -14,8 +14,8 @@
#include "src/ast/return_statement.h" #include "src/ast/return_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::ReturnStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::ReturnStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/scalar_constructor_expression.h" #include "src/ast/scalar_constructor_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::ScalarConstructorExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::ScalarConstructorExpression);

View File

@ -14,8 +14,8 @@
#include "src/ast/sint_literal.h" #include "src/ast/sint_literal.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral); TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral);

View File

@ -14,8 +14,8 @@
#include "src/ast/stage_decoration.h" #include "src/ast/stage_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::StageDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::StageDecoration);

View File

@ -14,8 +14,8 @@
#include "src/ast/stride_decoration.h" #include "src/ast/stride_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::StrideDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::StrideDecoration);

View File

@ -14,9 +14,9 @@
#include "src/ast/struct.h" #include "src/ast/struct.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/ast/struct_block_decoration.h" #include "src/ast/struct_block_decoration.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct); TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct);

View File

@ -14,8 +14,8 @@
#include "src/ast/struct_block_decoration.h" #include "src/ast/struct_block_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructBlockDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::StructBlockDecoration);

View File

@ -14,9 +14,9 @@
#include "src/ast/struct_member.h" #include "src/ast/struct_member.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/ast/struct_member_offset_decoration.h" #include "src/ast/struct_member_offset_decoration.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMember); TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMember);

View File

@ -14,8 +14,8 @@
#include "src/ast/struct_member_offset_decoration.h" #include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMemberOffsetDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMemberOffsetDecoration);

View File

@ -15,8 +15,8 @@
#include "src/ast/switch_statement.h" #include "src/ast/switch_statement.h"
#include "src/ast/case_statement.h" #include "src/ast/case_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::SwitchStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::SwitchStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/type_constructor_expression.h" #include "src/ast/type_constructor_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::TypeConstructorExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::TypeConstructorExpression);

View File

@ -14,8 +14,8 @@
#include "src/ast/uint_literal.h" #include "src/ast/uint_literal.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral); TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral);

View File

@ -14,8 +14,8 @@
#include "src/ast/unary_op_expression.h" #include "src/ast/unary_op_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::UnaryOpExpression); TINT_INSTANTIATE_CLASS_ID(tint::ast::UnaryOpExpression);

View File

@ -16,9 +16,9 @@
#include <assert.h> #include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/constant_id_decoration.h" #include "src/ast/constant_id_decoration.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::Variable); TINT_INSTANTIATE_CLASS_ID(tint::ast::Variable);

View File

@ -14,8 +14,8 @@
#include "src/ast/variable_decl_statement.h" #include "src/ast/variable_decl_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::VariableDeclStatement); TINT_INSTANTIATE_CLASS_ID(tint::ast::VariableDeclStatement);

View File

@ -14,8 +14,8 @@
#include "src/ast/workgroup_decoration.h" #include "src/ast/workgroup_decoration.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::WorkgroupDecoration); TINT_INSTANTIATE_CLASS_ID(tint::ast::WorkgroupDecoration);

View File

@ -12,14 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/ast/clone_context.h" #include "src/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
namespace tint { namespace tint {
namespace ast {
CloneContext::CloneContext(Module* to, Module const* from) CloneContext::CloneContext(ast::Module* to, ast::Module const* from)
: mod(to), src(from) {} : mod(to), src(from) {}
CloneContext::~CloneContext() = default; CloneContext::~CloneContext() = default;
@ -31,5 +30,4 @@ void CloneContext::Clone() {
src->Clone(this); src->Clone(this);
} }
} // namespace ast
} // namespace tint } // namespace tint

View File

@ -12,22 +12,24 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_AST_CLONE_CONTEXT_H_ #ifndef SRC_CLONE_CONTEXT_H_
#define SRC_AST_CLONE_CONTEXT_H_ #define SRC_CLONE_CONTEXT_H_
#include <functional> #include <functional>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "src/ast/traits.h"
#include "src/castable.h" #include "src/castable.h"
#include "src/source.h" #include "src/source.h"
#include "src/symbol.h" #include "src/symbol.h"
#include "src/traits.h"
namespace tint { namespace tint {
namespace ast {
// Forward declarations
namespace ast {
class Module; class Module;
} // namespace ast
/// CloneContext holds the state used while cloning AST nodes and types. /// CloneContext holds the state used while cloning AST nodes and types.
class CloneContext { class CloneContext {
@ -35,7 +37,7 @@ class CloneContext {
/// Constructor /// Constructor
/// @param to the target module to clone into /// @param to the target module to clone into
/// @param from the source module to clone from /// @param from the source module to clone from
CloneContext(Module* to, Module const* from); CloneContext(ast::Module* to, ast::Module const* from);
/// Destructor /// Destructor
~CloneContext(); ~CloneContext();
@ -149,10 +151,10 @@ class CloneContext {
void Clone(); void Clone();
/// The target module to clone into. /// The target module to clone into.
Module* const mod; ast::Module* const mod;
/// The source module to clone from. /// The source module to clone from.
Module const* const src; ast::Module const* const src;
private: private:
using Transform = std::function<CastableBase*(CastableBase*)>; using Transform = std::function<CastableBase*(CastableBase*)>;
@ -187,7 +189,6 @@ class CloneContext {
std::vector<Transform> transforms_; std::vector<Transform> transforms_;
}; };
} // namespace ast
} // namespace tint } // namespace tint
#endif // SRC_AST_CLONE_CONTEXT_H_ #endif // SRC_CLONE_CONTEXT_H_

View File

@ -12,17 +12,16 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/ast/clone_context.h" #include "src/clone_context.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "src/ast/module.h" #include "src/ast/module.h"
namespace tint { namespace tint {
namespace ast {
namespace { namespace {
struct Cloneable : public Castable<Cloneable, Node> { struct Cloneable : public Castable<Cloneable, ast::Node> {
Cloneable() : Base(Source{}) {} Cloneable() : Base(Source{}) {}
Cloneable* a = nullptr; Cloneable* a = nullptr;
@ -162,10 +161,9 @@ TEST(CloneContext, CloneWithReplacements) {
} }
} // namespace } // namespace
} // namespace ast
TINT_INSTANTIATE_CLASS_ID(ast::Cloneable); TINT_INSTANTIATE_CLASS_ID(Cloneable);
TINT_INSTANTIATE_CLASS_ID(ast::Replaceable); TINT_INSTANTIATE_CLASS_ID(Replaceable);
TINT_INSTANTIATE_CLASS_ID(ast::Replacement); TINT_INSTANTIATE_CLASS_ID(Replacement);
} // namespace tint } // namespace tint

View File

@ -705,7 +705,7 @@ DefInfo::~DefInfo() = default;
bool StatementBuilder::IsValid() const { bool StatementBuilder::IsValid() const {
return true; return true;
} }
ast::Node* StatementBuilder::Clone(ast::CloneContext*) const { ast::Node* StatementBuilder::Clone(CloneContext*) const {
return nullptr; return nullptr;
} }
void StatementBuilder::to_str(std::ostream& out, size_t indent) const { void StatementBuilder::to_str(std::ostream& out, size_t indent) const {

View File

@ -350,7 +350,7 @@ class StatementBuilder : public Castable<StatementBuilder, ast::Statement> {
private: private:
bool IsValid() const override; bool IsValid() const override;
Node* Clone(ast::CloneContext*) const override; Node* Clone(CloneContext*) const override;
void to_str(std::ostream& out, size_t indent) const override; void to_str(std::ostream& out, size_t indent) const override;
}; };

View File

@ -12,14 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_AST_TRAITS_H_ #ifndef SRC_TRAITS_H_
#define SRC_AST_TRAITS_H_ #define SRC_TRAITS_H_
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
namespace tint { namespace tint {
namespace ast {
namespace traits { namespace traits {
/// NthTypeOf returns the `N`th type in `Types` /// NthTypeOf returns the `N`th type in `Types`
@ -72,7 +71,6 @@ using EnableIfIsType =
typename std::enable_if<std::is_base_of<BASE, T>::value, T>::type; typename std::enable_if<std::is_base_of<BASE, T>::value, T>::type;
} // namespace traits } // namespace traits
} // namespace ast
} // namespace tint } // namespace tint
#endif // SRC_AST_TRAITS_H_ #endif // SRC_TRAITS_H_

View File

@ -12,14 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/ast/traits.h" #include "src/traits.h"
#include <functional> #include <functional>
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint {
namespace ast {
namespace traits { namespace traits {
namespace { namespace {
@ -101,5 +100,4 @@ TEST(ParamType, Lambda) {
} }
} // namespace traits } // namespace traits
} // namespace ast
} // namespace tint } // namespace tint

View File

@ -27,7 +27,6 @@
#include "src/ast/call_expression.h" #include "src/ast/call_expression.h"
#include "src/ast/call_statement.h" #include "src/ast/call_statement.h"
#include "src/ast/case_statement.h" #include "src/ast/case_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/continue_statement.h" #include "src/ast/continue_statement.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/else_statement.h" #include "src/ast/else_statement.h"
@ -44,6 +43,7 @@
#include "src/ast/unary_op_expression.h" #include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h" #include "src/ast/variable_decl_statement.h"
#include "src/clone_context.h"
#include "src/type/array_type.h" #include "src/type/array_type.h"
#include "src/type/matrix_type.h" #include "src/type/matrix_type.h"
#include "src/type/u32_type.h" #include "src/type/u32_type.h"
@ -57,18 +57,17 @@ BoundArrayAccessors::~BoundArrayAccessors() = default;
Transform::Output BoundArrayAccessors::Run(ast::Module* in) { Transform::Output BoundArrayAccessors::Run(ast::Module* in) {
Output out; Output out;
ast::CloneContext(&out.module, in) CloneContext(&out.module, in)
.ReplaceAll( .ReplaceAll([&](CloneContext* ctx, ast::ArrayAccessorExpression* expr) {
[&](ast::CloneContext* ctx, ast::ArrayAccessorExpression* expr) { return Transform(expr, ctx, &out.diagnostics);
return Transform(expr, ctx, &out.diagnostics); })
})
.Clone(); .Clone();
return out; return out;
} }
ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
ast::ArrayAccessorExpression* expr, ast::ArrayAccessorExpression* expr,
ast::CloneContext* ctx, CloneContext* ctx,
diag::List* diags) { diag::List* diags) {
auto* ret_type = expr->array()->result_type()->UnwrapAll(); auto* ret_type = expr->array()->result_type()->UnwrapAll();
if (!ret_type->Is<type::Array>() && !ret_type->Is<type::Matrix>() && if (!ret_type->Is<type::Array>() && !ret_type->Is<type::Matrix>() &&

View File

@ -48,7 +48,7 @@ class BoundArrayAccessors : public Transform {
private: private:
ast::ArrayAccessorExpression* Transform(ast::ArrayAccessorExpression* expr, ast::ArrayAccessorExpression* Transform(ast::ArrayAccessorExpression* expr,
ast::CloneContext* ctx, CloneContext* ctx,
diag::List* diags); diag::List* diags);
}; };

View File

@ -19,11 +19,11 @@
#include "src/ast/assignment_statement.h" #include "src/ast/assignment_statement.h"
#include "src/ast/block_statement.h" #include "src/ast/block_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/float_literal.h" #include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h" #include "src/ast/scalar_constructor_expression.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "src/clone_context.h"
#include "src/type/f32_type.h" #include "src/type/f32_type.h"
#include "src/type/type_manager.h" #include "src/type/type_manager.h"
@ -73,9 +73,9 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
Source{}, pointsize_ident, one); Source{}, pointsize_ident, one);
// Add the pointsize assignment statement to the front of all vertex stages. // Add the pointsize assignment statement to the front of all vertex stages.
ast::CloneContext(&out.module, in) CloneContext(&out.module, in)
.ReplaceAll( .ReplaceAll(
[&](ast::CloneContext* ctx, ast::Function* func) -> ast::Function* { [&](CloneContext* ctx, ast::Function* func) -> ast::Function* {
if (func->pipeline_stage() != ast::PipelineStage::kVertex) { if (func->pipeline_stage() != ast::PipelineStage::kVertex) {
return nullptr; // Just clone func return nullptr; // Just clone func
} }

View File

@ -25,7 +25,6 @@
#include "src/ast/builtin_decoration.h" #include "src/ast/builtin_decoration.h"
#include "src/ast/call_statement.h" #include "src/ast/call_statement.h"
#include "src/ast/case_statement.h" #include "src/ast/case_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/constructor_expression.h" #include "src/ast/constructor_expression.h"
#include "src/ast/else_statement.h" #include "src/ast/else_statement.h"
#include "src/ast/expression.h" #include "src/ast/expression.h"
@ -47,6 +46,7 @@
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h" #include "src/ast/variable_decl_statement.h"
#include "src/ast/variable_decoration.h" #include "src/ast/variable_decoration.h"
#include "src/clone_context.h"
#include "src/type/struct_type.h" #include "src/type/struct_type.h"
#include "src/type/u32_type.h" #include "src/type/u32_type.h"
#include "src/type_determiner.h" #include "src/type_determiner.h"
@ -61,7 +61,7 @@ constexpr char kFirstVertexName[] = "tint_first_vertex_index";
constexpr char kFirstInstanceName[] = "tint_first_instance_index"; constexpr char kFirstInstanceName[] = "tint_first_instance_index";
constexpr char kIndexOffsetPrefix[] = "tint_first_index_offset_"; constexpr char kIndexOffsetPrefix[] = "tint_first_index_offset_";
ast::Variable* clone_variable_with_new_name(ast::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->mod->create<ast::Variable>(
@ -126,33 +126,32 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) {
// these builtins. // these builtins.
Output out; Output out;
ast::CloneContext(&out.module, in) CloneContext(&out.module, in)
.ReplaceAll( .ReplaceAll([&](CloneContext* ctx, ast::Variable* var) -> ast::Variable* {
[&](ast::CloneContext* ctx, ast::Variable* var) -> ast::Variable* { for (ast::VariableDecoration* dec : var->decorations()) {
for (ast::VariableDecoration* dec : var->decorations()) { if (auto* blt_dec = dec->As<ast::BuiltinDecoration>()) {
if (auto* blt_dec = dec->As<ast::BuiltinDecoration>()) { ast::Builtin blt_type = blt_dec->value();
ast::Builtin blt_type = blt_dec->value(); if (blt_type == ast::Builtin::kVertexIndex) {
if (blt_type == ast::Builtin::kVertexIndex) { vertex_index_sym = var->symbol();
vertex_index_sym = var->symbol(); has_vertex_index_ = true;
has_vertex_index_ = true; return clone_variable_with_new_name(
return clone_variable_with_new_name( ctx, var,
ctx, var, kIndexOffsetPrefix + in->SymbolToName(var->symbol()));
kIndexOffsetPrefix + in->SymbolToName(var->symbol())); } else if (blt_type == ast::Builtin::kInstanceIndex) {
} else if (blt_type == ast::Builtin::kInstanceIndex) { instance_index_sym = var->symbol();
instance_index_sym = var->symbol(); has_instance_index_ = true;
has_instance_index_ = true; return clone_variable_with_new_name(
return clone_variable_with_new_name( ctx, var,
ctx, var, kIndexOffsetPrefix + in->SymbolToName(var->symbol()));
kIndexOffsetPrefix + in->SymbolToName(var->symbol()));
}
}
} }
return nullptr; // Just clone var }
}) }
return nullptr; // Just clone var
})
.ReplaceAll( // Note: This happens in the same pass as the rename above .ReplaceAll( // Note: This happens in the same pass as the rename above
// 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.
[&](ast::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->mod);
if (buffer_var == nullptr) { if (buffer_var == nullptr) {
return nullptr; // no transform need, just clone func return nullptr; // no transform need, just clone func

View File

@ -15,8 +15,8 @@
#include "src/transform/transform.h" #include "src/transform/transform.h"
#include "src/ast/block_statement.h" #include "src/ast/block_statement.h"
#include "src/ast/clone_context.h"
#include "src/ast/function.h" #include "src/ast/function.h"
#include "src/clone_context.h"
namespace tint { namespace tint {
namespace transform { namespace transform {
@ -25,7 +25,7 @@ Transform::Transform() = default;
Transform::~Transform() = default; Transform::~Transform() = default;
ast::Function* Transform::CloneWithStatementsAtStart( ast::Function* Transform::CloneWithStatementsAtStart(
ast::CloneContext* ctx, CloneContext* ctx,
ast::Function* in, ast::Function* in,
ast::StatementList statements) { ast::StatementList statements) {
for (auto* s : *in->body()) { for (auto* s : *in->body()) {

View File

@ -57,7 +57,7 @@ class Transform {
/// @param statements the statements to prepend to `in`'s body /// @param statements the statements to prepend to `in`'s body
/// @return the cloned function /// @return the cloned function
static ast::Function* CloneWithStatementsAtStart( static ast::Function* CloneWithStatementsAtStart(
ast::CloneContext* ctx, CloneContext* ctx,
ast::Function* in, ast::Function* in,
ast::StatementList statements); ast::StatementList statements);
}; };

View File

@ -20,7 +20,6 @@
#include "src/ast/assignment_statement.h" #include "src/ast/assignment_statement.h"
#include "src/ast/binary_expression.h" #include "src/ast/binary_expression.h"
#include "src/ast/bitcast_expression.h" #include "src/ast/bitcast_expression.h"
#include "src/ast/clone_context.h"
#include "src/ast/member_accessor_expression.h" #include "src/ast/member_accessor_expression.h"
#include "src/ast/scalar_constructor_expression.h" #include "src/ast/scalar_constructor_expression.h"
#include "src/ast/stride_decoration.h" #include "src/ast/stride_decoration.h"
@ -33,6 +32,7 @@
#include "src/ast/uint_literal.h" #include "src/ast/uint_literal.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h" #include "src/ast/variable_decl_statement.h"
#include "src/clone_context.h"
#include "src/type/array_type.h" #include "src/type/array_type.h"
#include "src/type/f32_type.h" #include "src/type/f32_type.h"
#include "src/type/i32_type.h" #include "src/type/i32_type.h"
@ -109,15 +109,14 @@ Transform::Output VertexPulling::Run(ast::Module* in) {
state.ConvertVertexInputVariablesToPrivate(); state.ConvertVertexInputVariablesToPrivate();
state.AddVertexStorageBuffers(); state.AddVertexStorageBuffers();
ast::CloneContext(&out.module, in) CloneContext(&out.module, in)
.ReplaceAll( .ReplaceAll([&](CloneContext* ctx, ast::Function* f) -> ast::Function* {
[&](ast::CloneContext* ctx, ast::Function* f) -> ast::Function* { if (f == func) {
if (f == func) { return CloneWithStatementsAtStart(
return CloneWithStatementsAtStart( ctx, f, {state.CreateVertexPullingPreamble()});
ctx, f, {state.CreateVertexPullingPreamble()}); }
} return nullptr; // Just clone func
return nullptr; // Just clone func })
})
.Clone(); .Clone();
return out; return out;

View File

@ -16,8 +16,8 @@
#include <assert.h> #include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::AccessControl); TINT_INSTANTIATE_CLASS_ID(tint::type::AccessControl);

View File

@ -16,8 +16,8 @@
#include <assert.h> #include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Alias); TINT_INSTANTIATE_CLASS_ID(tint::type::Alias);

View File

@ -17,9 +17,9 @@
#include <cmath> #include <cmath>
#include <memory> #include <memory>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/ast/stride_decoration.h" #include "src/ast/stride_decoration.h"
#include "src/clone_context.h"
#include "src/type/vector_type.h" #include "src/type/vector_type.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Array); TINT_INSTANTIATE_CLASS_ID(tint::type::Array);

View File

@ -14,8 +14,8 @@
#include "src/type/bool_type.h" #include "src/type/bool_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Bool); TINT_INSTANTIATE_CLASS_ID(tint::type::Bool);

View File

@ -17,8 +17,8 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::DepthTexture); TINT_INSTANTIATE_CLASS_ID(tint::type::DepthTexture);

View File

@ -14,8 +14,8 @@
#include "src/type/f32_type.h" #include "src/type/f32_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::F32); TINT_INSTANTIATE_CLASS_ID(tint::type::F32);

View File

@ -14,8 +14,8 @@
#include "src/type/i32_type.h" #include "src/type/i32_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::I32); TINT_INSTANTIATE_CLASS_ID(tint::type::I32);

View File

@ -16,8 +16,8 @@
#include <assert.h> #include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/type/array_type.h" #include "src/type/array_type.h"
#include "src/type/vector_type.h" #include "src/type/vector_type.h"

View File

@ -17,8 +17,8 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::MultisampledTexture); TINT_INSTANTIATE_CLASS_ID(tint::type::MultisampledTexture);

View File

@ -14,8 +14,8 @@
#include "src/type/pointer_type.h" #include "src/type/pointer_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Pointer); TINT_INSTANTIATE_CLASS_ID(tint::type::Pointer);

View File

@ -17,8 +17,8 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::SampledTexture); TINT_INSTANTIATE_CLASS_ID(tint::type::SampledTexture);

View File

@ -14,8 +14,8 @@
#include "src/type/sampler_type.h" #include "src/type/sampler_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Sampler); TINT_INSTANTIATE_CLASS_ID(tint::type::Sampler);

View File

@ -17,8 +17,8 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::StorageTexture); TINT_INSTANTIATE_CLASS_ID(tint::type::StorageTexture);

View File

@ -17,8 +17,8 @@
#include <cmath> #include <cmath>
#include <utility> #include <utility>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
#include "src/type/alias_type.h" #include "src/type/alias_type.h"
#include "src/type/array_type.h" #include "src/type/array_type.h"
#include "src/type/matrix_type.h" #include "src/type/matrix_type.h"

View File

@ -21,15 +21,14 @@
namespace tint { namespace tint {
// Forward declarations
class CloneContext;
namespace ast { namespace ast {
class Module; class Module;
class CloneContext;
} // namespace ast } // namespace ast
namespace type { namespace type {
using CloneContext = ast::CloneContext; // TEMP
/// Supported memory layouts for calculating sizes /// Supported memory layouts for calculating sizes
enum class MemoryLayout { kUniformBuffer, kStorageBuffer }; enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
@ -43,7 +42,7 @@ class Type : public Castable<Type> {
/// Clones this type and all transitive types using the `CloneContext` `ctx`. /// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context /// @param ctx the clone context
/// @return the newly cloned type /// @return the newly cloned type
virtual Type* Clone(ast::CloneContext* ctx) const = 0; virtual Type* Clone(CloneContext* ctx) const = 0;
/// @returns the name for this type. The type name is unique over all types. /// @returns the name for this type. The type name is unique over all types.
virtual std::string type_name() const = 0; virtual std::string type_name() const = 0;

View File

@ -14,8 +14,8 @@
#include "src/type/u32_type.h" #include "src/type/u32_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::U32); TINT_INSTANTIATE_CLASS_ID(tint::type::U32);

View File

@ -17,8 +17,8 @@
#include <assert.h> #include <assert.h>
#include <cmath> #include <cmath>
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Vector); TINT_INSTANTIATE_CLASS_ID(tint::type::Vector);

View File

@ -14,8 +14,8 @@
#include "src/type/void_type.h" #include "src/type/void_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h" #include "src/ast/module.h"
#include "src/clone_context.h"
TINT_INSTANTIATE_CLASS_ID(tint::type::Void); TINT_INSTANTIATE_CLASS_ID(tint::type::Void);

View File

@ -74,7 +74,7 @@ namespace {
class FakeStmt : public ast::Statement { class FakeStmt : public ast::Statement {
public: public:
explicit FakeStmt(Source source) : ast::Statement(source) {} explicit FakeStmt(Source source) : ast::Statement(source) {}
FakeStmt* Clone(ast::CloneContext*) const override { return nullptr; } FakeStmt* Clone(CloneContext*) const override { return nullptr; }
bool IsValid() const override { return true; } bool IsValid() const override { return true; }
void to_str(std::ostream& out, size_t) const override { out << "Fake"; } void to_str(std::ostream& out, size_t) const override { out << "Fake"; }
}; };
@ -82,7 +82,7 @@ class FakeStmt : public ast::Statement {
class FakeExpr : public ast::Expression { class FakeExpr : public ast::Expression {
public: public:
explicit FakeExpr(Source source) : ast::Expression(source) {} explicit FakeExpr(Source source) : ast::Expression(source) {}
FakeExpr* Clone(ast::CloneContext*) const override { return nullptr; } FakeExpr* Clone(CloneContext*) const override { return nullptr; }
bool IsValid() const override { return true; } bool IsValid() const override { return true; }
void to_str(std::ostream&, size_t) const override {} void to_str(std::ostream&, size_t) const override {}
}; };