Update internals to initializer instead of constructor.
This CL catches up the internals (along with a few error messages) to say `initializer` instead of `constructor. Bug: tint:1600 Change-Id: I8e56572c310d77da1130380bdd32b334f27c8e46 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106462 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
56ce1a2155
commit
6e77b47ed9
|
@ -67,7 +67,7 @@ void Initialize(Napi::Env env);
|
|||
class {{$.Name}} {{- if $.Inherits }} : public {{$.Inherits}}{{end}} {
|
||||
public:
|
||||
{{ range $m := $.Members}}
|
||||
{{- if IsConstructor $m}} {{$.Name}}();
|
||||
{{- if IsInitializer $m}} {{$.Name}}();
|
||||
{{ else if IsMember $m}} {{template "DictionaryMember" $m}}
|
||||
{{ end}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -115,7 +115,7 @@ func run() error {
|
|||
"HasAnnotation": hasAnnotation,
|
||||
"Include": g.include,
|
||||
"IsBasicLiteral": is(ast.BasicLiteral{}),
|
||||
"IsConstructor": isConstructor,
|
||||
"IsInitializer": isInitializer,
|
||||
"IsDefaultDictionaryLiteral": is(ast.DefaultDictionaryLiteral{}),
|
||||
"IsDictionary": is(ast.Dictionary{}),
|
||||
"IsEnum": is(ast.Enum{}),
|
||||
|
@ -489,8 +489,8 @@ func is(prototypes ...interface{}) func(interface{}) bool {
|
|||
}
|
||||
}
|
||||
|
||||
// isConstructor returns true if the object is a constructor ast.Member.
|
||||
func isConstructor(v interface{}) bool {
|
||||
// isInitializer returns true if the object is a constructor ast.Member.
|
||||
func isInitializer(v interface{}) bool {
|
||||
if member, ok := v.(*ast.Member); ok {
|
||||
if ty, ok := member.Type.(*ast.TypeName); ok {
|
||||
return ty.Name == "constructor"
|
||||
|
@ -555,7 +555,7 @@ func methodsOf(obj interface{}) []*Method {
|
|||
out := []*Method{}
|
||||
for _, member := range iface.Members {
|
||||
member := member.(*ast.Member)
|
||||
if !member.Const && !member.Attribute && !isConstructor(member) {
|
||||
if !member.Const && !member.Attribute && !isInitializer(member) {
|
||||
if method, ok := byName[member.Name]; ok {
|
||||
method.Overloads = append(method.Overloads, member)
|
||||
} else {
|
||||
|
|
|
@ -397,10 +397,10 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"reflection.h",
|
||||
"resolver/const_eval.cc",
|
||||
"resolver/const_eval.h",
|
||||
"resolver/ctor_conv_intrinsic.cc",
|
||||
"resolver/ctor_conv_intrinsic.h",
|
||||
"resolver/dependency_graph.cc",
|
||||
"resolver/dependency_graph.h",
|
||||
"resolver/init_conv_intrinsic.cc",
|
||||
"resolver/init_conv_intrinsic.h",
|
||||
"resolver/intrinsic_table.cc",
|
||||
"resolver/intrinsic_table.h",
|
||||
"resolver/intrinsic_table.inl",
|
||||
|
@ -455,8 +455,8 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"sem/switch_statement.h",
|
||||
"sem/texture.h",
|
||||
"sem/type.h",
|
||||
"sem/type_constructor.h",
|
||||
"sem/type_conversion.h",
|
||||
"sem/type_initializer.h",
|
||||
"sem/type_manager.h",
|
||||
"sem/type_mappings.h",
|
||||
"sem/u32.h",
|
||||
|
@ -554,8 +554,8 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"transform/var_for_dynamic_index.h",
|
||||
"transform/vectorize_matrix_conversions.cc",
|
||||
"transform/vectorize_matrix_conversions.h",
|
||||
"transform/vectorize_scalar_matrix_constructors.cc",
|
||||
"transform/vectorize_scalar_matrix_constructors.h",
|
||||
"transform/vectorize_scalar_matrix_initializers.cc",
|
||||
"transform/vectorize_scalar_matrix_initializers.h",
|
||||
"transform/vertex_pulling.cc",
|
||||
"transform/vertex_pulling.h",
|
||||
"transform/while_to_loop.cc",
|
||||
|
@ -698,10 +698,10 @@ libtint_source_set("libtint_sem_src") {
|
|||
"sem/texture.h",
|
||||
"sem/type.cc",
|
||||
"sem/type.h",
|
||||
"sem/type_constructor.cc",
|
||||
"sem/type_constructor.h",
|
||||
"sem/type_conversion.cc",
|
||||
"sem/type_conversion.h",
|
||||
"sem/type_initializer.cc",
|
||||
"sem/type_initializer.h",
|
||||
"sem/type_manager.cc",
|
||||
"sem/type_manager.h",
|
||||
"sem/type_mappings.h",
|
||||
|
@ -1153,7 +1153,7 @@ if (tint_build_unittests) {
|
|||
"resolver/struct_address_space_use_test.cc",
|
||||
"resolver/struct_layout_test.cc",
|
||||
"resolver/struct_pipeline_stage_use_test.cc",
|
||||
"resolver/type_constructor_validation_test.cc",
|
||||
"resolver/type_initializer_validation_test.cc",
|
||||
"resolver/type_validation_test.cc",
|
||||
"resolver/uniformity_test.cc",
|
||||
"resolver/validation_test.cc",
|
||||
|
@ -1241,7 +1241,7 @@ if (tint_build_unittests) {
|
|||
"transform/utils/hoist_to_decl_before_test.cc",
|
||||
"transform/var_for_dynamic_index_test.cc",
|
||||
"transform/vectorize_matrix_conversions_test.cc",
|
||||
"transform/vectorize_scalar_matrix_constructors_test.cc",
|
||||
"transform/vectorize_scalar_matrix_initializers_test.cc",
|
||||
"transform/vertex_pulling_test.cc",
|
||||
"transform/while_to_loop_test.cc",
|
||||
"transform/zero_init_workgroup_memory_test.cc",
|
||||
|
@ -1335,7 +1335,6 @@ if (tint_build_unittests) {
|
|||
"writer/spirv/builder_builtin_test.cc",
|
||||
"writer/spirv/builder_builtin_texture_test.cc",
|
||||
"writer/spirv/builder_call_test.cc",
|
||||
"writer/spirv/builder_constructor_expression_test.cc",
|
||||
"writer/spirv/builder_discard_test.cc",
|
||||
"writer/spirv/builder_entry_point_test.cc",
|
||||
"writer/spirv/builder_format_conversion_test.cc",
|
||||
|
@ -1345,6 +1344,7 @@ if (tint_build_unittests) {
|
|||
"writer/spirv/builder_global_variable_test.cc",
|
||||
"writer/spirv/builder_ident_expression_test.cc",
|
||||
"writer/spirv/builder_if_test.cc",
|
||||
"writer/spirv/builder_initializer_expression_test.cc",
|
||||
"writer/spirv/builder_literal_test.cc",
|
||||
"writer/spirv/builder_loop_test.cc",
|
||||
"writer/spirv/builder_return_test.cc",
|
||||
|
@ -1464,7 +1464,6 @@ if (tint_build_unittests) {
|
|||
"writer/wgsl/generator_impl_call_test.cc",
|
||||
"writer/wgsl/generator_impl_case_test.cc",
|
||||
"writer/wgsl/generator_impl_cast_test.cc",
|
||||
"writer/wgsl/generator_impl_constructor_test.cc",
|
||||
"writer/wgsl/generator_impl_continue_test.cc",
|
||||
"writer/wgsl/generator_impl_discard_test.cc",
|
||||
"writer/wgsl/generator_impl_enable_test.cc",
|
||||
|
@ -1473,6 +1472,7 @@ if (tint_build_unittests) {
|
|||
"writer/wgsl/generator_impl_global_decl_test.cc",
|
||||
"writer/wgsl/generator_impl_identifier_test.cc",
|
||||
"writer/wgsl/generator_impl_if_test.cc",
|
||||
"writer/wgsl/generator_impl_initializer_test.cc",
|
||||
"writer/wgsl/generator_impl_literal_test.cc",
|
||||
"writer/wgsl/generator_impl_loop_test.cc",
|
||||
"writer/wgsl/generator_impl_member_accessor_test.cc",
|
||||
|
@ -1506,13 +1506,13 @@ if (tint_build_unittests) {
|
|||
"writer/msl/generator_impl_call_test.cc",
|
||||
"writer/msl/generator_impl_case_test.cc",
|
||||
"writer/msl/generator_impl_cast_test.cc",
|
||||
"writer/msl/generator_impl_constructor_test.cc",
|
||||
"writer/msl/generator_impl_continue_test.cc",
|
||||
"writer/msl/generator_impl_discard_test.cc",
|
||||
"writer/msl/generator_impl_function_test.cc",
|
||||
"writer/msl/generator_impl_identifier_test.cc",
|
||||
"writer/msl/generator_impl_if_test.cc",
|
||||
"writer/msl/generator_impl_import_test.cc",
|
||||
"writer/msl/generator_impl_initializer_test.cc",
|
||||
"writer/msl/generator_impl_loop_test.cc",
|
||||
"writer/msl/generator_impl_member_accessor_test.cc",
|
||||
"writer/msl/generator_impl_module_constant_test.cc",
|
||||
|
@ -1546,13 +1546,13 @@ if (tint_build_unittests) {
|
|||
"writer/hlsl/generator_impl_call_test.cc",
|
||||
"writer/hlsl/generator_impl_case_test.cc",
|
||||
"writer/hlsl/generator_impl_cast_test.cc",
|
||||
"writer/hlsl/generator_impl_constructor_test.cc",
|
||||
"writer/hlsl/generator_impl_continue_test.cc",
|
||||
"writer/hlsl/generator_impl_discard_test.cc",
|
||||
"writer/hlsl/generator_impl_function_test.cc",
|
||||
"writer/hlsl/generator_impl_identifier_test.cc",
|
||||
"writer/hlsl/generator_impl_if_test.cc",
|
||||
"writer/hlsl/generator_impl_import_test.cc",
|
||||
"writer/hlsl/generator_impl_initializer_test.cc",
|
||||
"writer/hlsl/generator_impl_loop_test.cc",
|
||||
"writer/hlsl/generator_impl_member_accessor_test.cc",
|
||||
"writer/hlsl/generator_impl_module_constant_test.cc",
|
||||
|
@ -1587,13 +1587,13 @@ if (tint_build_unittests) {
|
|||
"writer/glsl/generator_impl_call_test.cc",
|
||||
"writer/glsl/generator_impl_case_test.cc",
|
||||
"writer/glsl/generator_impl_cast_test.cc",
|
||||
"writer/glsl/generator_impl_constructor_test.cc",
|
||||
"writer/glsl/generator_impl_continue_test.cc",
|
||||
"writer/glsl/generator_impl_discard_test.cc",
|
||||
"writer/glsl/generator_impl_function_test.cc",
|
||||
"writer/glsl/generator_impl_identifier_test.cc",
|
||||
"writer/glsl/generator_impl_if_test.cc",
|
||||
"writer/glsl/generator_impl_import_test.cc",
|
||||
"writer/glsl/generator_impl_initializer_test.cc",
|
||||
"writer/glsl/generator_impl_loop_test.cc",
|
||||
"writer/glsl/generator_impl_member_accessor_test.cc",
|
||||
"writer/glsl/generator_impl_module_constant_test.cc",
|
||||
|
|
|
@ -259,10 +259,10 @@ set(TINT_LIB_SRCS
|
|||
reader/reader.h
|
||||
resolver/const_eval.cc
|
||||
resolver/const_eval.h
|
||||
resolver/ctor_conv_intrinsic.cc
|
||||
resolver/ctor_conv_intrinsic.h
|
||||
resolver/dependency_graph.cc
|
||||
resolver/dependency_graph.h
|
||||
resolver/init_conv_intrinsic.cc
|
||||
resolver/init_conv_intrinsic.h
|
||||
resolver/intrinsic_table.cc
|
||||
resolver/intrinsic_table.h
|
||||
resolver/intrinsic_table.inl
|
||||
|
@ -359,8 +359,8 @@ set(TINT_LIB_SRCS
|
|||
sem/switch_statement.h
|
||||
sem/texture.cc
|
||||
sem/texture.h
|
||||
sem/type_constructor.cc
|
||||
sem/type_constructor.h
|
||||
sem/type_initializer.cc
|
||||
sem/type_initializer.h
|
||||
sem/type_conversion.cc
|
||||
sem/type_conversion.h
|
||||
sem/type_manager.cc
|
||||
|
@ -466,8 +466,8 @@ set(TINT_LIB_SRCS
|
|||
transform/var_for_dynamic_index.h
|
||||
transform/vectorize_matrix_conversions.cc
|
||||
transform/vectorize_matrix_conversions.h
|
||||
transform/vectorize_scalar_matrix_constructors.cc
|
||||
transform/vectorize_scalar_matrix_constructors.h
|
||||
transform/vectorize_scalar_matrix_initializers.cc
|
||||
transform/vectorize_scalar_matrix_initializers.h
|
||||
transform/vertex_pulling.cc
|
||||
transform/vertex_pulling.h
|
||||
transform/while_to_loop.cc
|
||||
|
@ -834,7 +834,7 @@ if(TINT_BUILD_TESTS)
|
|||
resolver/struct_layout_test.cc
|
||||
resolver/struct_pipeline_stage_use_test.cc
|
||||
resolver/struct_address_space_use_test.cc
|
||||
resolver/type_constructor_validation_test.cc
|
||||
resolver/type_initializer_validation_test.cc
|
||||
resolver/type_validation_test.cc
|
||||
resolver/validation_test.cc
|
||||
resolver/validator_is_storeable_test.cc
|
||||
|
@ -1050,7 +1050,7 @@ if(TINT_BUILD_TESTS)
|
|||
writer/spirv/builder_builtin_test.cc
|
||||
writer/spirv/builder_builtin_texture_test.cc
|
||||
writer/spirv/builder_call_test.cc
|
||||
writer/spirv/builder_constructor_expression_test.cc
|
||||
writer/spirv/builder_initializer_expression_test.cc
|
||||
writer/spirv/builder_discard_test.cc
|
||||
writer/spirv/builder_entry_point_test.cc
|
||||
writer/spirv/builder_format_conversion_test.cc
|
||||
|
@ -1090,7 +1090,7 @@ if(TINT_BUILD_TESTS)
|
|||
writer/wgsl/generator_impl_call_test.cc
|
||||
writer/wgsl/generator_impl_case_test.cc
|
||||
writer/wgsl/generator_impl_cast_test.cc
|
||||
writer/wgsl/generator_impl_constructor_test.cc
|
||||
writer/wgsl/generator_impl_initializer_test.cc
|
||||
writer/wgsl/generator_impl_continue_test.cc
|
||||
writer/wgsl/generator_impl_discard_test.cc
|
||||
writer/wgsl/generator_impl_enable_test.cc
|
||||
|
@ -1155,7 +1155,7 @@ if(TINT_BUILD_TESTS)
|
|||
transform/unwind_discard_functions_test.cc
|
||||
transform/var_for_dynamic_index_test.cc
|
||||
transform/vectorize_matrix_conversions_test.cc
|
||||
transform/vectorize_scalar_matrix_constructors_test.cc
|
||||
transform/vectorize_scalar_matrix_initializers_test.cc
|
||||
transform/vertex_pulling_test.cc
|
||||
transform/while_to_loop_test.cc
|
||||
transform/zero_init_workgroup_memory_test.cc
|
||||
|
@ -1177,7 +1177,7 @@ if(TINT_BUILD_TESTS)
|
|||
writer/msl/generator_impl_call_test.cc
|
||||
writer/msl/generator_impl_case_test.cc
|
||||
writer/msl/generator_impl_cast_test.cc
|
||||
writer/msl/generator_impl_constructor_test.cc
|
||||
writer/msl/generator_impl_initializer_test.cc
|
||||
writer/msl/generator_impl_continue_test.cc
|
||||
writer/msl/generator_impl_discard_test.cc
|
||||
writer/msl/generator_impl_function_test.cc
|
||||
|
@ -1212,7 +1212,7 @@ if(TINT_BUILD_TESTS)
|
|||
writer/glsl/generator_impl_call_test.cc
|
||||
writer/glsl/generator_impl_case_test.cc
|
||||
writer/glsl/generator_impl_cast_test.cc
|
||||
writer/glsl/generator_impl_constructor_test.cc
|
||||
writer/glsl/generator_impl_initializer_test.cc
|
||||
writer/glsl/generator_impl_continue_test.cc
|
||||
writer/glsl/generator_impl_discard_test.cc
|
||||
writer/glsl/generator_impl_function_test.cc
|
||||
|
@ -1249,7 +1249,7 @@ if(TINT_BUILD_TESTS)
|
|||
writer/hlsl/generator_impl_call_test.cc
|
||||
writer/hlsl/generator_impl_case_test.cc
|
||||
writer/hlsl/generator_impl_cast_test.cc
|
||||
writer/hlsl/generator_impl_constructor_test.cc
|
||||
writer/hlsl/generator_impl_initializer_test.cc
|
||||
writer/hlsl/generator_impl_continue_test.cc
|
||||
writer/hlsl/generator_impl_discard_test.cc
|
||||
writer/hlsl/generator_impl_function_test.cc
|
||||
|
|
|
@ -27,10 +27,10 @@ Const::Const(ProgramID pid,
|
|||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const ast::Type* ty,
|
||||
const Expression* ctor,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, ctor, std::move(attrs)) {
|
||||
TINT_ASSERT(AST, ctor != nullptr);
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)) {
|
||||
TINT_ASSERT(AST, init != nullptr);
|
||||
}
|
||||
|
||||
Const::Const(Const&&) = default;
|
||||
|
@ -45,9 +45,9 @@ const Const* Const::Clone(CloneContext* ctx) const {
|
|||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* ctor = ctx->Clone(constructor);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Const>(src, sym, ty, ctor, std::move(attrs));
|
||||
return ctx->dst->create<Const>(src, sym, ty, init, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace tint::ast {
|
||||
|
||||
/// A "const" declaration is a name for a module-scoped or function-scoped creation-time value.
|
||||
/// const must have a constructor expression.
|
||||
/// const must have a initializer expression.
|
||||
///
|
||||
/// Examples:
|
||||
///
|
||||
|
@ -38,14 +38,14 @@ class Const final : public Castable<Const, Variable> {
|
|||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param type the declared variable type
|
||||
/// @param constructor the constructor expression. Must not be nullptr.
|
||||
/// @param initializer the initializer expression. Must not be nullptr.
|
||||
/// @param attributes the variable attributes
|
||||
Const(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const ast::Type* type,
|
||||
const Expression* constructor,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
||||
/// Move constructor
|
||||
|
|
|
@ -27,10 +27,10 @@ Let::Let(ProgramID pid,
|
|||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const ast::Type* ty,
|
||||
const Expression* ctor,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, ctor, std::move(attrs)) {
|
||||
TINT_ASSERT(AST, ctor != nullptr);
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)) {
|
||||
TINT_ASSERT(AST, init != nullptr);
|
||||
}
|
||||
|
||||
Let::Let(Let&&) = default;
|
||||
|
@ -45,9 +45,9 @@ const Let* Let::Clone(CloneContext* ctx) const {
|
|||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* ctor = ctx->Clone(constructor);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Let>(src, sym, ty, ctor, std::move(attrs));
|
||||
return ctx->dst->create<Let>(src, sym, ty, init, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -35,14 +35,14 @@ class Let final : public Castable<Let, Variable> {
|
|||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param type the declared variable type
|
||||
/// @param constructor the constructor expression
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Let(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const ast::Type* type,
|
||||
const Expression* constructor,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
||||
/// Move constructor
|
||||
|
|
|
@ -29,8 +29,8 @@ class Matrix final : public Castable<Matrix, Type> {
|
|||
/// @param nid the unique node identifier
|
||||
/// @param src the source of this node
|
||||
/// @param subtype the declared type of the matrix components. May be null for
|
||||
/// matrix constructors, where the element type will be inferred from
|
||||
/// the constructor arguments
|
||||
/// matrix initializers, where the element type will be inferred from
|
||||
/// the initializer arguments
|
||||
/// @param rows the number of rows in the matrix
|
||||
/// @param columns the number of columns in the matrix
|
||||
Matrix(ProgramID pid,
|
||||
|
@ -54,7 +54,7 @@ class Matrix final : public Castable<Matrix, Type> {
|
|||
const Matrix* Clone(CloneContext* ctx) const override;
|
||||
|
||||
/// The declared type of the matrix components. May be null for matrix
|
||||
/// constructors, where the element type will be inferred from the constructor
|
||||
/// initializers, where the element type will be inferred from the initializer
|
||||
/// arguments
|
||||
const Type* const type;
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ Override::Override(ProgramID pid,
|
|||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const ast::Type* ty,
|
||||
const Expression* ctor,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, ctor, std::move(attrs)) {}
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)) {}
|
||||
|
||||
Override::Override(Override&&) = default;
|
||||
|
||||
|
@ -43,9 +43,9 @@ const Override* Override::Clone(CloneContext* ctx) const {
|
|||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* ctor = ctx->Clone(constructor);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Override>(src, sym, ty, ctor, std::move(attrs));
|
||||
return ctx->dst->create<Override>(src, sym, ty, init, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -38,14 +38,14 @@ class Override final : public Castable<Override, Variable> {
|
|||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param type the declared variable type
|
||||
/// @param constructor the constructor expression
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Override(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const ast::Type* type,
|
||||
const Expression* constructor,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
||||
/// Move constructor
|
||||
|
|
|
@ -27,9 +27,9 @@ Var::Var(ProgramID pid,
|
|||
const ast::Type* ty,
|
||||
AddressSpace address_space,
|
||||
Access access,
|
||||
const Expression* ctor,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, ctor, std::move(attrs)),
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)),
|
||||
declared_address_space(address_space),
|
||||
declared_access(access) {}
|
||||
|
||||
|
@ -45,9 +45,9 @@ const Var* Var::Clone(CloneContext* ctx) const {
|
|||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* ctor = ctx->Clone(constructor);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Var>(src, sym, ty, declared_address_space, declared_access, ctor,
|
||||
return ctx->dst->create<Var>(src, sym, ty, declared_address_space, declared_access, init,
|
||||
std::move(attrs));
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class Var final : public Castable<Var, Variable> {
|
|||
/// @param type the declared variable type
|
||||
/// @param declared_address_space the declared address space
|
||||
/// @param declared_access the declared access control
|
||||
/// @param constructor the constructor expression
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Var(ProgramID pid,
|
||||
NodeID nid,
|
||||
|
@ -58,7 +58,7 @@ class Var final : public Castable<Var, Variable> {
|
|||
const ast::Type* type,
|
||||
AddressSpace declared_address_space,
|
||||
Access declared_access,
|
||||
const Expression* constructor,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
||||
/// Move constructor
|
||||
|
|
|
@ -25,12 +25,12 @@ Variable::Variable(ProgramID pid,
|
|||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const ast::Type* ty,
|
||||
const Expression* ctor,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src), symbol(sym), type(ty), constructor(ctor), attributes(std::move(attrs)) {
|
||||
: Base(pid, nid, src), symbol(sym), type(ty), initializer(init), attributes(std::move(attrs)) {
|
||||
TINT_ASSERT(AST, symbol.IsValid());
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, symbol, program_id);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, constructor, program_id);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, initializer, program_id);
|
||||
}
|
||||
|
||||
Variable::Variable(Variable&&) = default;
|
||||
|
|
|
@ -47,14 +47,14 @@ class Variable : public Castable<Variable, Node> {
|
|||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param type the declared variable type
|
||||
/// @param constructor the constructor expression
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Variable(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const ast::Type* type,
|
||||
const Expression* constructor,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
||||
/// Move constructor
|
||||
|
@ -81,8 +81,8 @@ class Variable : public Castable<Variable, Node> {
|
|||
/// var i = 1;
|
||||
const ast::Type* const type;
|
||||
|
||||
/// The constructor expression or nullptr if none set
|
||||
const Expression* const constructor;
|
||||
/// The initializer expression or nullptr if none set
|
||||
const Expression* const initializer;
|
||||
|
||||
/// The attributes attached to this variable
|
||||
const utils::Vector<const Attribute*, 2> attributes;
|
||||
|
|
|
@ -81,7 +81,7 @@ TEST_F(VariableTest, Assert_DifferentProgramID_Symbol) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, Assert_DifferentProgramID_Constructor) {
|
||||
TEST_F(VariableTest, Assert_DifferentProgramID_Initializer) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b1;
|
||||
|
|
|
@ -29,8 +29,8 @@ class Vector final : public Castable<Vector, Type> {
|
|||
/// @param nid the unique node identifier
|
||||
/// @param src the source of this node
|
||||
/// @param subtype the declared type of the vector components. May be null
|
||||
/// for vector constructors, where the element type will be inferred
|
||||
/// from the constructor arguments
|
||||
/// for vector initializers, where the element type will be inferred
|
||||
/// from the initializer arguments
|
||||
/// @param width the number of elements in the vector
|
||||
Vector(ProgramID pid, NodeID nid, Source const& src, const Type* subtype, uint32_t width);
|
||||
/// Move constructor
|
||||
|
@ -48,7 +48,7 @@ class Vector final : public Castable<Vector, Type> {
|
|||
const Vector* Clone(CloneContext* ctx) const override;
|
||||
|
||||
/// The declared type of the vector components. May be null for vector
|
||||
/// constructors, where the element type will be inferred from the constructor
|
||||
/// initializers, where the element type will be inferred from the initializer
|
||||
/// arguments
|
||||
const Type* const type;
|
||||
|
||||
|
|
|
@ -710,7 +710,7 @@ TEST(Castable, SwitchNullNoDefault) {
|
|||
EXPECT_TRUE(default_called);
|
||||
}
|
||||
|
||||
TEST(Castable, SwitchReturnNoDefaultConstructor) {
|
||||
TEST(Castable, SwitchReturnNoDefaultInitializer) {
|
||||
struct Object {
|
||||
explicit Object(int v) : value(v) {}
|
||||
int value;
|
||||
|
|
|
@ -92,7 +92,7 @@ TEST(ChangeBinaryOperatorTest, NotApplicable_Simple) {
|
|||
|
||||
auto a_var_id = node_id_map.GetId(a_var);
|
||||
|
||||
const auto* sum_expr = a_var->constructor->As<ast::BinaryExpression>();
|
||||
const auto* sum_expr = a_var->initializer->As<ast::BinaryExpression>();
|
||||
ASSERT_NE(sum_expr, nullptr);
|
||||
|
||||
auto sum_expr_id = node_id_map.GetId(sum_expr);
|
||||
|
@ -131,7 +131,7 @@ TEST(ChangeBinaryOperatorTest, Applicable_Simple) {
|
|||
const auto* a_var = main_fn_stmts[0]->As<ast::VariableDeclStatement>()->variable;
|
||||
ASSERT_NE(a_var, nullptr);
|
||||
|
||||
const auto* sum_expr = a_var->constructor->As<ast::BinaryExpression>();
|
||||
const auto* sum_expr = a_var->initializer->As<ast::BinaryExpression>();
|
||||
ASSERT_NE(sum_expr, nullptr);
|
||||
|
||||
auto sum_expr_id = node_id_map.GetId(sum_expr);
|
||||
|
@ -194,7 +194,7 @@ void CheckMutations(const std::string& lhs_type,
|
|||
const auto* r_var = stmts[0]->As<ast::VariableDeclStatement>()->variable;
|
||||
ASSERT_NE(r_var, nullptr);
|
||||
|
||||
const auto* binary_expr = r_var->constructor->As<ast::BinaryExpression>();
|
||||
const auto* binary_expr = r_var->initializer->As<ast::BinaryExpression>();
|
||||
ASSERT_NE(binary_expr, nullptr);
|
||||
|
||||
auto binary_expr_id = node_id_map.GetId(binary_expr);
|
||||
|
|
|
@ -64,16 +64,16 @@ TEST(ChangeUnaryOperatorTest, Operator_Not_Applicable) {
|
|||
ASSERT_NE(neg_d_var, nullptr);
|
||||
|
||||
// Get the expression from variable declaration.
|
||||
const auto* neg_a_expr = neg_a_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* neg_a_expr = neg_a_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(neg_a_expr, nullptr);
|
||||
|
||||
const auto* not_b_expr = not_b_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* not_b_expr = not_b_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(not_b_expr, nullptr);
|
||||
|
||||
const auto* not_c_expr = not_c_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* not_c_expr = not_c_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(not_c_expr, nullptr);
|
||||
|
||||
const auto* neg_d_expr = neg_d_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* neg_d_expr = neg_d_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(neg_d_expr, nullptr);
|
||||
|
||||
// The following mutations are not applicable.
|
||||
|
@ -147,7 +147,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable1) {
|
|||
ASSERT_NE(comp_a_var, nullptr);
|
||||
|
||||
// Get the expression from variable declaration.
|
||||
const auto* comp_a_expr = comp_a_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* comp_a_expr = comp_a_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(comp_a_expr, nullptr);
|
||||
|
||||
// Assert mutation to be applicable and apply mutation.
|
||||
|
@ -188,7 +188,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable2) {
|
|||
ASSERT_NE(comp_b_var, nullptr);
|
||||
|
||||
// Get the expression from variable declaration.
|
||||
const auto* comp_b_expr = comp_b_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* comp_b_expr = comp_b_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(comp_b_expr, nullptr);
|
||||
|
||||
// Assert mutation to be applicable and apply mutation.
|
||||
|
@ -231,7 +231,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable3) {
|
|||
ASSERT_NE(neg_a_var, nullptr);
|
||||
|
||||
// Get the expression from variable declaration.
|
||||
const auto* neg_a_expr = neg_a_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* neg_a_expr = neg_a_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(neg_a_expr, nullptr);
|
||||
|
||||
// Assert mutation to be applicable and apply mutation.
|
||||
|
@ -273,7 +273,7 @@ TEST(ChangeUnaryOperatorTest, Signed_Integer_Types_Applicable4) {
|
|||
ASSERT_NE(neg_b_var, nullptr);
|
||||
|
||||
// Get the expression from variable declaration.
|
||||
const auto* neg_b_expr = neg_b_var->constructor->As<ast::UnaryOpExpression>();
|
||||
const auto* neg_b_expr = neg_b_var->initializer->As<ast::UnaryOpExpression>();
|
||||
ASSERT_NE(neg_b_expr, nullptr);
|
||||
|
||||
// Assert mutation to be applicable and apply mutation.
|
||||
|
|
|
@ -62,7 +62,7 @@ TEST(ReplaceIdentifierTest, NotApplicable_Simple) {
|
|||
auto b_var_id = node_id_map.GetId(b_var);
|
||||
ASSERT_NE(b_var_id, 0);
|
||||
|
||||
const auto* sum_expr = b_var->constructor->As<ast::BinaryExpression>();
|
||||
const auto* sum_expr = b_var->initializer->As<ast::BinaryExpression>();
|
||||
ASSERT_NE(sum_expr, nullptr);
|
||||
|
||||
auto a_ident_id = node_id_map.GetId(sum_expr->lhs);
|
||||
|
@ -75,7 +75,7 @@ TEST(ReplaceIdentifierTest, NotApplicable_Simple) {
|
|||
ASSERT_NE(e_var_id, 0);
|
||||
|
||||
auto vec_member_access_id =
|
||||
node_id_map.GetId(e_var->constructor->As<ast::MemberAccessorExpression>()->member);
|
||||
node_id_map.GetId(e_var->initializer->As<ast::MemberAccessorExpression>()->member);
|
||||
ASSERT_NE(vec_member_access_id, 0);
|
||||
|
||||
// use_id is invalid.
|
||||
|
@ -596,7 +596,7 @@ fn f() {
|
|||
.Functions()[0]
|
||||
->body->statements[1]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::IndexAccessorExpression>()
|
||||
->variable->initializer->As<ast::IndexAccessorExpression>()
|
||||
->object->As<ast::UnaryOpExpression>()
|
||||
->expr->As<ast::UnaryOpExpression>()
|
||||
->expr);
|
||||
|
@ -631,7 +631,7 @@ fn f() {
|
|||
.Functions()[0]
|
||||
->body->statements[3]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::IndexAccessorExpression>()
|
||||
->variable->initializer->As<ast::IndexAccessorExpression>()
|
||||
->object->As<ast::UnaryOpExpression>()
|
||||
->expr);
|
||||
ASSERT_NE(use_id, 0);
|
||||
|
|
|
@ -84,7 +84,7 @@ TEST(WrapUnaryOperatorTest, Applicable2) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -162,7 +162,7 @@ TEST(WrapUnaryOperatorTest, Applicable4) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::BinaryExpression>()
|
||||
->variable->initializer->As<ast::BinaryExpression>()
|
||||
->lhs;
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
|
@ -203,7 +203,7 @@ TEST(WrapUnaryOperatorTest, Applicable5) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::UnaryOpExpression>()
|
||||
->variable->initializer->As<ast::UnaryOpExpression>()
|
||||
->expr;
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
|
@ -243,7 +243,7 @@ TEST(WrapUnaryOperatorTest, Applicable6) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -286,7 +286,7 @@ TEST(WrapUnaryOperatorTest, Applicable7) {
|
|||
const auto* expr = main_fn_statements[1]
|
||||
->As<ast::ForLoopStatement>()
|
||||
->initializer->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -328,7 +328,7 @@ TEST(WrapUnaryOperatorTest, Applicable8) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -367,7 +367,7 @@ TEST(WrapUnaryOperatorTest, NotApplicable1) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -396,7 +396,7 @@ TEST(WrapUnaryOperatorTest, NotApplicable2) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -424,7 +424,7 @@ TEST(WrapUnaryOperatorTest, NotApplicable3) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -453,7 +453,7 @@ TEST(WrapUnaryOperatorTest, NotApplicable4) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
@ -482,7 +482,7 @@ TEST(WrapUnaryOperatorTest, NotApplicable5) {
|
|||
|
||||
const auto* expr = main_fn_statements[0]
|
||||
->As<ast::VariableDeclStatement>()
|
||||
->variable->constructor->As<ast::Expression>();
|
||||
->variable->initializer->As<ast::Expression>();
|
||||
|
||||
const auto expression_id = node_id_map.GetId(expr);
|
||||
ASSERT_NE(expression_id, 0);
|
||||
|
|
|
@ -36,7 +36,7 @@ class WgslMutatorTest : public WgslMutator {
|
|||
using WgslMutator::GetIntLiterals;
|
||||
using WgslMutator::GetLoopBodyPositions;
|
||||
using WgslMutator::GetSwizzles;
|
||||
using WgslMutator::GetVectorConstructors;
|
||||
using WgslMutator::GetVectorInitializers;
|
||||
using WgslMutator::ReplaceRegion;
|
||||
using WgslMutator::SwapIntervals;
|
||||
};
|
||||
|
@ -660,7 +660,7 @@ u.rgba.rrg.b)";
|
|||
ASSERT_EQ(ground_truth, swizzles);
|
||||
}
|
||||
|
||||
TEST(TestAddSwizzle, FindVectorConstructors) {
|
||||
TEST(TestAddSwizzle, FindVectorInitializers) {
|
||||
RandomGenerator generator(0);
|
||||
WgslMutatorTest mutator(generator);
|
||||
std::string code = R"(
|
||||
|
@ -668,7 +668,7 @@ vec4<f32>(vec2<f32>(1, 2), vec2<f32>(3))
|
|||
|
||||
vec2<i32>(1, abs(abs(2)))
|
||||
)";
|
||||
std::vector<std::pair<size_t, size_t>> swizzles = mutator.GetVectorConstructors(code);
|
||||
std::vector<std::pair<size_t, size_t>> swizzles = mutator.GetVectorInitializers(code);
|
||||
std::vector<std::pair<size_t, size_t>> ground_truth{{1, 40}, {11, 15}, {28, 12}, {43, 25}};
|
||||
ASSERT_EQ(ground_truth, swizzles);
|
||||
}
|
||||
|
|
|
@ -692,15 +692,15 @@ bool WgslMutator::AddSwizzle(std::string& wgsl_code) {
|
|||
auto identifiers = GetIdentifiers(function_body);
|
||||
// - existing swizzles, e.g. to turn v.xy into v.xy.xx
|
||||
auto swizzles = GetSwizzles(function_body);
|
||||
// - vector constructors, e.g. to turn vec3<f32>(...) into vec3<f32>(...).yyz
|
||||
auto vector_constructors = GetVectorConstructors(function_body);
|
||||
// - vector initializers, e.g. to turn vec3<f32>(...) into vec3<f32>(...).yyz
|
||||
auto vector_initializers = GetVectorInitializers(function_body);
|
||||
|
||||
// Create a combined vector of all the possibilities for swizzling, so that they can be sampled
|
||||
// from as a whole.
|
||||
std::vector<std::pair<size_t, size_t>> combined;
|
||||
combined.insert(combined.end(), identifiers.begin(), identifiers.end());
|
||||
combined.insert(combined.end(), swizzles.begin(), swizzles.end());
|
||||
combined.insert(combined.end(), vector_constructors.begin(), vector_constructors.end());
|
||||
combined.insert(combined.end(), vector_initializers.begin(), vector_initializers.end());
|
||||
|
||||
if (combined.empty()) {
|
||||
// No opportunities for swizzling: give up.
|
||||
|
@ -709,7 +709,7 @@ bool WgslMutator::AddSwizzle(std::string& wgsl_code) {
|
|||
|
||||
// Randomly create a swizzle operation. This is done without checking the potential length of
|
||||
// the target vector. For identifiers this isn't possible without proper context. For existing
|
||||
// swizzles and vector constructors it would be possible to check the length, but it is anyway
|
||||
// swizzles and vector initializers it would be possible to check the length, but it is anyway
|
||||
// good to stress-test swizzle validation code paths.
|
||||
std::string swizzle = ".";
|
||||
{
|
||||
|
@ -758,28 +758,28 @@ std::vector<std::pair<size_t, size_t>> WgslMutator::GetSwizzles(const std::strin
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<size_t, size_t>> WgslMutator::GetVectorConstructors(
|
||||
std::vector<std::pair<size_t, size_t>> WgslMutator::GetVectorInitializers(
|
||||
const std::string& wgsl_code) {
|
||||
// This regex recognises the prefixes of vector constructors, which have the form:
|
||||
// This regex recognises the prefixes of vector initializers, which have the form:
|
||||
// "vecn<type>(", with possible whitespace between tokens.
|
||||
std::regex vector_constructor_prefix_regex("vec\\d[ \\n]*<[ \\n]*[a-z0-9_]+[ \\n]*>[^\\(]*\\(");
|
||||
std::regex vector_initializer_prefix_regex("vec\\d[ \\n]*<[ \\n]*[a-z0-9_]+[ \\n]*>[^\\(]*\\(");
|
||||
std::vector<std::pair<size_t, size_t>> result;
|
||||
|
||||
auto vector_constructor_prefixes_begin =
|
||||
std::sregex_iterator(wgsl_code.begin(), wgsl_code.end(), vector_constructor_prefix_regex);
|
||||
auto vector_constructor_prefixes_end = std::sregex_iterator();
|
||||
auto vector_initializer_prefixes_begin =
|
||||
std::sregex_iterator(wgsl_code.begin(), wgsl_code.end(), vector_initializer_prefix_regex);
|
||||
auto vector_initializer_prefixes_end = std::sregex_iterator();
|
||||
|
||||
// Look through all of the vector constructor prefixes and see whether each one appears to
|
||||
// Look through all of the vector initializer prefixes and see whether each one appears to
|
||||
// correspond to a complete vector construction.
|
||||
for (std::sregex_iterator i = vector_constructor_prefixes_begin;
|
||||
i != vector_constructor_prefixes_end; ++i) {
|
||||
for (std::sregex_iterator i = vector_initializer_prefixes_begin;
|
||||
i != vector_initializer_prefixes_end; ++i) {
|
||||
// A prefix is deemed to correspond to a complete vector construction if it is possible to
|
||||
// find a corresponding closing bracket for the "(" at the end of the prefix.
|
||||
size_t closing_bracket = FindClosingBracket(
|
||||
static_cast<size_t>(i->suffix().first - wgsl_code.cbegin()), wgsl_code, '(', ')');
|
||||
if (closing_bracket != 0) {
|
||||
// A closing bracket was found, so record the start and size of the entire vector
|
||||
// constructor.
|
||||
// initializer.
|
||||
size_t start = static_cast<size_t>(i->prefix().second - wgsl_code.cbegin());
|
||||
result.push_back({start, closing_bracket - start + 1});
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class WgslMutator {
|
|||
bool ReplaceFunctionCallWithBuiltin(std::string& wgsl_code);
|
||||
|
||||
/// Given a WGSL-like string, adds a swizzle operation to either (a) an identifier, (b) a vector
|
||||
/// constructor, or (c) an existing swizzle.
|
||||
/// initializer, or (c) an existing swizzle.
|
||||
/// @param wgsl_code - the initial WGSL-like string that will be mutated.
|
||||
/// @return true if a swizzle operation is added or false otherwise.
|
||||
bool AddSwizzle(std::string& wgsl_code);
|
||||
|
@ -212,10 +212,10 @@ class WgslMutator {
|
|||
/// @return a vector with the positions and lengths of all the swizzles in wgsl_code.
|
||||
std::vector<std::pair<size_t, size_t>> GetSwizzles(const std::string& wgsl_code);
|
||||
|
||||
/// Finds all the vector constructors in a WGSL-like string.
|
||||
/// @param wgsl_code - the WGSL-like string where the vector constructors will be found.
|
||||
/// @return a vector with the positions and lengths of all the vector constructors in wgsl_code.
|
||||
std::vector<std::pair<size_t, size_t>> GetVectorConstructors(const std::string& wgsl_code);
|
||||
/// Finds all the vector initializers in a WGSL-like string.
|
||||
/// @param wgsl_code - the WGSL-like string where the vector initializers will be found.
|
||||
/// @return a vector with the positions and lengths of all the vector initializers in wgsl_code.
|
||||
std::vector<std::pair<size_t, size_t>> GetVectorInitializers(const std::string& wgsl_code);
|
||||
|
||||
private:
|
||||
/// A function that given a delimiter, returns a vector that contains
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace tint::fuzzers::spvtools_fuzzer {
|
||||
|
||||
// We need to define constructor here so that vtable is produced in this
|
||||
// We need to define destructor here so that vtable is produced in this
|
||||
// translation unit (see -Wweak-vtables clang flag).
|
||||
Mutator::~Mutator() = default;
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
|
|||
TINT_UNREACHABLE(Inspector, diagnostics_);
|
||||
}
|
||||
|
||||
override.is_initialized = global->Declaration()->constructor;
|
||||
override.is_initialized = global->Declaration()->initializer;
|
||||
override.is_id_specified =
|
||||
ast::HasAttribute<ast::IdAttribute>(global->Declaration()->attributes);
|
||||
|
||||
|
@ -302,8 +302,8 @@ std::map<OverrideId, Scalar> Inspector::GetOverrideDefaultValues() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (global->Constructor()) {
|
||||
if (auto* value = global->Constructor()->ConstantValue()) {
|
||||
if (global->Initializer()) {
|
||||
if (auto* value = global->Initializer()->ConstantValue()) {
|
||||
result[override_id] = Switch(
|
||||
value->Type(), //
|
||||
[&](const sem::I32*) { return Scalar(value->As<i32>()); },
|
||||
|
|
|
@ -711,124 +711,124 @@ fn textureLoad(texture: texture_external, coords: vec2<i32>) -> vec4<f32>
|
|||
@stage("fragment", "compute") fn atomicCompareExchangeWeak<T: iu32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, T, T) -> __atomic_compare_exchange_result<T>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Type constructors //
|
||||
// Type initializers //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Zero value constructors
|
||||
@const("Zero") ctor i32() -> i32
|
||||
@const("Zero") ctor u32() -> u32
|
||||
@const("Zero") ctor f32() -> f32
|
||||
@const("Zero") ctor f16() -> f16
|
||||
@const("Zero") ctor bool() -> bool
|
||||
@const("Zero") ctor vec2<T: concrete_scalar>() -> vec2<T>
|
||||
@const("Zero") ctor vec3<T: concrete_scalar>() -> vec3<T>
|
||||
@const("Zero") ctor vec4<T: concrete_scalar>() -> vec4<T>
|
||||
@const("Zero") ctor mat2x2<T: f32_f16>() -> mat2x2<T>
|
||||
@const("Zero") ctor mat2x3<T: f32_f16>() -> mat2x3<T>
|
||||
@const("Zero") ctor mat2x4<T: f32_f16>() -> mat2x4<T>
|
||||
@const("Zero") ctor mat3x2<T: f32_f16>() -> mat3x2<T>
|
||||
@const("Zero") ctor mat3x3<T: f32_f16>() -> mat3x3<T>
|
||||
@const("Zero") ctor mat3x4<T: f32_f16>() -> mat3x4<T>
|
||||
@const("Zero") ctor mat4x2<T: f32_f16>() -> mat4x2<T>
|
||||
@const("Zero") ctor mat4x3<T: f32_f16>() -> mat4x3<T>
|
||||
@const("Zero") ctor mat4x4<T: f32_f16>() -> mat4x4<T>
|
||||
// Zero value initializers
|
||||
@const("Zero") init i32() -> i32
|
||||
@const("Zero") init u32() -> u32
|
||||
@const("Zero") init f32() -> f32
|
||||
@const("Zero") init f16() -> f16
|
||||
@const("Zero") init bool() -> bool
|
||||
@const("Zero") init vec2<T: concrete_scalar>() -> vec2<T>
|
||||
@const("Zero") init vec3<T: concrete_scalar>() -> vec3<T>
|
||||
@const("Zero") init vec4<T: concrete_scalar>() -> vec4<T>
|
||||
@const("Zero") init mat2x2<T: f32_f16>() -> mat2x2<T>
|
||||
@const("Zero") init mat2x3<T: f32_f16>() -> mat2x3<T>
|
||||
@const("Zero") init mat2x4<T: f32_f16>() -> mat2x4<T>
|
||||
@const("Zero") init mat3x2<T: f32_f16>() -> mat3x2<T>
|
||||
@const("Zero") init mat3x3<T: f32_f16>() -> mat3x3<T>
|
||||
@const("Zero") init mat3x4<T: f32_f16>() -> mat3x4<T>
|
||||
@const("Zero") init mat4x2<T: f32_f16>() -> mat4x2<T>
|
||||
@const("Zero") init mat4x3<T: f32_f16>() -> mat4x3<T>
|
||||
@const("Zero") init mat4x4<T: f32_f16>() -> mat4x4<T>
|
||||
|
||||
// Identity constructors
|
||||
@const("Identity") ctor i32(i32) -> i32
|
||||
@const("Identity") ctor u32(u32) -> u32
|
||||
@const("Identity") ctor f32(f32) -> f32
|
||||
@const("Identity") ctor f16(f16) -> f16
|
||||
@const("Identity") ctor bool(bool) -> bool
|
||||
@const("Identity") ctor vec2<T: concrete_scalar>(vec2<T>) -> vec2<T>
|
||||
@const("Identity") ctor vec3<T: concrete_scalar>(vec3<T>) -> vec3<T>
|
||||
@const("Identity") ctor vec4<T: concrete_scalar>(vec4<T>) -> vec4<T>
|
||||
@const("Identity") ctor mat2x2<T: f32_f16>(mat2x2<T>) -> mat2x2<T>
|
||||
@const("Identity") ctor mat2x3<T: f32_f16>(mat2x3<T>) -> mat2x3<T>
|
||||
@const("Identity") ctor mat2x4<T: f32_f16>(mat2x4<T>) -> mat2x4<T>
|
||||
@const("Identity") ctor mat3x2<T: f32_f16>(mat3x2<T>) -> mat3x2<T>
|
||||
@const("Identity") ctor mat3x3<T: f32_f16>(mat3x3<T>) -> mat3x3<T>
|
||||
@const("Identity") ctor mat3x4<T: f32_f16>(mat3x4<T>) -> mat3x4<T>
|
||||
@const("Identity") ctor mat4x2<T: f32_f16>(mat4x2<T>) -> mat4x2<T>
|
||||
@const("Identity") ctor mat4x3<T: f32_f16>(mat4x3<T>) -> mat4x3<T>
|
||||
@const("Identity") ctor mat4x4<T: f32_f16>(mat4x4<T>) -> mat4x4<T>
|
||||
// Identity initializers
|
||||
@const("Identity") init i32(i32) -> i32
|
||||
@const("Identity") init u32(u32) -> u32
|
||||
@const("Identity") init f32(f32) -> f32
|
||||
@const("Identity") init f16(f16) -> f16
|
||||
@const("Identity") init bool(bool) -> bool
|
||||
@const("Identity") init vec2<T: concrete_scalar>(vec2<T>) -> vec2<T>
|
||||
@const("Identity") init vec3<T: concrete_scalar>(vec3<T>) -> vec3<T>
|
||||
@const("Identity") init vec4<T: concrete_scalar>(vec4<T>) -> vec4<T>
|
||||
@const("Identity") init mat2x2<T: f32_f16>(mat2x2<T>) -> mat2x2<T>
|
||||
@const("Identity") init mat2x3<T: f32_f16>(mat2x3<T>) -> mat2x3<T>
|
||||
@const("Identity") init mat2x4<T: f32_f16>(mat2x4<T>) -> mat2x4<T>
|
||||
@const("Identity") init mat3x2<T: f32_f16>(mat3x2<T>) -> mat3x2<T>
|
||||
@const("Identity") init mat3x3<T: f32_f16>(mat3x3<T>) -> mat3x3<T>
|
||||
@const("Identity") init mat3x4<T: f32_f16>(mat3x4<T>) -> mat3x4<T>
|
||||
@const("Identity") init mat4x2<T: f32_f16>(mat4x2<T>) -> mat4x2<T>
|
||||
@const("Identity") init mat4x3<T: f32_f16>(mat4x3<T>) -> mat4x3<T>
|
||||
@const("Identity") init mat4x4<T: f32_f16>(mat4x4<T>) -> mat4x4<T>
|
||||
|
||||
// Vector constructors (splat)
|
||||
@const("VecSplat") ctor vec2<T: scalar>(T) -> vec2<T>
|
||||
@const("VecSplat") ctor vec3<T: scalar>(T) -> vec3<T>
|
||||
@const("VecSplat") ctor vec4<T: scalar>(T) -> vec4<T>
|
||||
// Vector initializers (splat)
|
||||
@const("VecSplat") init vec2<T: scalar>(T) -> vec2<T>
|
||||
@const("VecSplat") init vec3<T: scalar>(T) -> vec3<T>
|
||||
@const("VecSplat") init vec4<T: scalar>(T) -> vec4<T>
|
||||
|
||||
// Vector constructors (scalar)
|
||||
@const("VecCtorS") ctor vec2<T: scalar>(x: T, y: T) -> vec2<T>
|
||||
@const("VecCtorS") ctor vec3<T: scalar>(x: T, y: T, z: T) -> vec3<T>
|
||||
@const("VecCtorS") ctor vec4<T: scalar>(x: T, y: T, z: T, w: T) -> vec4<T>
|
||||
// Vector initializers (scalar)
|
||||
@const("VecInitS") init vec2<T: scalar>(x: T, y: T) -> vec2<T>
|
||||
@const("VecInitS") init vec3<T: scalar>(x: T, y: T, z: T) -> vec3<T>
|
||||
@const("VecInitS") init vec4<T: scalar>(x: T, y: T, z: T, w: T) -> vec4<T>
|
||||
|
||||
// Vector constructors (mixed)
|
||||
@const("VecCtorM") ctor vec3<T: scalar>(xy: vec2<T>, z: T) -> vec3<T>
|
||||
@const("VecCtorM") ctor vec3<T: scalar>(x: T, yz: vec2<T>) -> vec3<T>
|
||||
@const("VecCtorM") ctor vec4<T: scalar>(xy: vec2<T>, z: T, w: T) -> vec4<T>
|
||||
@const("VecCtorM") ctor vec4<T: scalar>(x: T, yz: vec2<T>, w: T) -> vec4<T>
|
||||
@const("VecCtorM") ctor vec4<T: scalar>(x: T, y: T, zw: vec2<T>) -> vec4<T>
|
||||
@const("VecCtorM") ctor vec4<T: scalar>(xy: vec2<T>, zw: vec2<T>) -> vec4<T>
|
||||
@const("VecCtorM") ctor vec4<T: scalar>(xyz: vec3<T>, w: T) -> vec4<T>
|
||||
@const("VecCtorM") ctor vec4<T: scalar>(x: T, zyw: vec3<T>) -> vec4<T>
|
||||
// Vector initializers (mixed)
|
||||
@const("VecInitM") init vec3<T: scalar>(xy: vec2<T>, z: T) -> vec3<T>
|
||||
@const("VecInitM") init vec3<T: scalar>(x: T, yz: vec2<T>) -> vec3<T>
|
||||
@const("VecInitM") init vec4<T: scalar>(xy: vec2<T>, z: T, w: T) -> vec4<T>
|
||||
@const("VecInitM") init vec4<T: scalar>(x: T, yz: vec2<T>, w: T) -> vec4<T>
|
||||
@const("VecInitM") init vec4<T: scalar>(x: T, y: T, zw: vec2<T>) -> vec4<T>
|
||||
@const("VecInitM") init vec4<T: scalar>(xy: vec2<T>, zw: vec2<T>) -> vec4<T>
|
||||
@const("VecInitM") init vec4<T: scalar>(xyz: vec3<T>, w: T) -> vec4<T>
|
||||
@const("VecInitM") init vec4<T: scalar>(x: T, zyw: vec3<T>) -> vec4<T>
|
||||
|
||||
// Matrix constructors (scalar)
|
||||
@const("MatCtorS")
|
||||
ctor mat2x2<T: fa_f32_f16>(T, T,
|
||||
// Matrix initializers (scalar)
|
||||
@const("MatInitS")
|
||||
init mat2x2<T: fa_f32_f16>(T, T,
|
||||
T, T) -> mat2x2<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat2x3<T: fa_f32_f16>(T, T, T,
|
||||
@const("MatInitS")
|
||||
init mat2x3<T: fa_f32_f16>(T, T, T,
|
||||
T, T, T) -> mat2x3<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat2x4<T: fa_f32_f16>(T, T, T, T,
|
||||
@const("MatInitS")
|
||||
init mat2x4<T: fa_f32_f16>(T, T, T, T,
|
||||
T, T, T, T) -> mat2x4<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat3x2<T: fa_f32_f16>(T, T,
|
||||
@const("MatInitS")
|
||||
init mat3x2<T: fa_f32_f16>(T, T,
|
||||
T, T,
|
||||
T, T) -> mat3x2<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat3x3<T: fa_f32_f16>(T, T, T,
|
||||
@const("MatInitS")
|
||||
init mat3x3<T: fa_f32_f16>(T, T, T,
|
||||
T, T, T,
|
||||
T, T, T) -> mat3x3<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat3x4<T: fa_f32_f16>(T, T, T, T,
|
||||
@const("MatInitS")
|
||||
init mat3x4<T: fa_f32_f16>(T, T, T, T,
|
||||
T, T, T, T,
|
||||
T, T, T, T) -> mat3x4<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat4x2<T: fa_f32_f16>(T, T,
|
||||
@const("MatInitS")
|
||||
init mat4x2<T: fa_f32_f16>(T, T,
|
||||
T, T,
|
||||
T, T,
|
||||
T, T) -> mat4x2<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat4x3<T: fa_f32_f16>(T, T, T,
|
||||
@const("MatInitS")
|
||||
init mat4x3<T: fa_f32_f16>(T, T, T,
|
||||
T, T, T,
|
||||
T, T, T,
|
||||
T, T, T) -> mat4x3<T>
|
||||
@const("MatCtorS")
|
||||
ctor mat4x4<T: fa_f32_f16>(T, T, T, T,
|
||||
@const("MatInitS")
|
||||
init mat4x4<T: fa_f32_f16>(T, T, T, T,
|
||||
T, T, T, T,
|
||||
T, T, T, T,
|
||||
T, T, T, T) -> mat4x4<T>
|
||||
|
||||
// Matrix constructors (column vectors)
|
||||
@const("MatCtorV")
|
||||
ctor mat2x2<T: fa_f32_f16>(vec2<T>, vec2<T>) -> mat2x2<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat2x3<T: fa_f32_f16>(vec3<T>, vec3<T>) -> mat2x3<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat2x4<T: fa_f32_f16>(vec4<T>, vec4<T>) -> mat2x4<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat3x2<T: fa_f32_f16>(vec2<T>, vec2<T>, vec2<T>) -> mat3x2<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat3x3<T: fa_f32_f16>(vec3<T>, vec3<T>, vec3<T>) -> mat3x3<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat3x4<T: fa_f32_f16>(vec4<T>, vec4<T>, vec4<T>) -> mat3x4<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat4x2<T: fa_f32_f16>(vec2<T>, vec2<T>, vec2<T>, vec2<T>) -> mat4x2<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat4x3<T: fa_f32_f16>(vec3<T>, vec3<T>, vec3<T>, vec3<T>) -> mat4x3<T>
|
||||
@const("MatCtorV")
|
||||
ctor mat4x4<T: fa_f32_f16>(vec4<T>, vec4<T>, vec4<T>, vec4<T>) -> mat4x4<T>
|
||||
// Matrix initializers (column vectors)
|
||||
@const("MatInitV")
|
||||
init mat2x2<T: fa_f32_f16>(vec2<T>, vec2<T>) -> mat2x2<T>
|
||||
@const("MatInitV")
|
||||
init mat2x3<T: fa_f32_f16>(vec3<T>, vec3<T>) -> mat2x3<T>
|
||||
@const("MatInitV")
|
||||
init mat2x4<T: fa_f32_f16>(vec4<T>, vec4<T>) -> mat2x4<T>
|
||||
@const("MatInitV")
|
||||
init mat3x2<T: fa_f32_f16>(vec2<T>, vec2<T>, vec2<T>) -> mat3x2<T>
|
||||
@const("MatInitV")
|
||||
init mat3x3<T: fa_f32_f16>(vec3<T>, vec3<T>, vec3<T>) -> mat3x3<T>
|
||||
@const("MatInitV")
|
||||
init mat3x4<T: fa_f32_f16>(vec4<T>, vec4<T>, vec4<T>) -> mat3x4<T>
|
||||
@const("MatInitV")
|
||||
init mat4x2<T: fa_f32_f16>(vec2<T>, vec2<T>, vec2<T>, vec2<T>) -> mat4x2<T>
|
||||
@const("MatInitV")
|
||||
init mat4x3<T: fa_f32_f16>(vec3<T>, vec3<T>, vec3<T>, vec3<T>) -> mat4x3<T>
|
||||
@const("MatInitV")
|
||||
init mat4x4<T: fa_f32_f16>(vec4<T>, vec4<T>, vec4<T>, vec4<T>) -> mat4x4<T>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Type conversions //
|
||||
|
@ -981,4 +981,4 @@ op >> <T: iu32, N: num> (vec<N, T>, vec<N, u32>) -> vec<N, T>
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Tint internal builtins //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@const("Identity") fn _tint_materialize<T>(T) -> T
|
||||
@const("Identity") fn _tint_materialize<T>(T) -> T
|
||||
|
|
|
@ -175,14 +175,14 @@ class ProgramBuilder {
|
|||
const ast::Type* type = nullptr;
|
||||
ast::AddressSpace address_space = ast::AddressSpace::kNone;
|
||||
ast::Access access = ast::Access::kUndefined;
|
||||
const ast::Expression* constructor = nullptr;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
utils::Vector<const ast::Attribute*, 4> attributes;
|
||||
|
||||
private:
|
||||
void Set(const ast::Type* t) { type = t; }
|
||||
void Set(ast::AddressSpace addr_space) { address_space = addr_space; }
|
||||
void Set(ast::Access ac) { access = ac; }
|
||||
void Set(const ast::Expression* c) { constructor = c; }
|
||||
void Set(const ast::Expression* c) { initializer = c; }
|
||||
void Set(utils::VectorRef<const ast::Attribute*> l) { attributes = std::move(l); }
|
||||
void Set(const ast::Attribute* a) { attributes.Push(a); }
|
||||
};
|
||||
|
@ -202,12 +202,12 @@ class ProgramBuilder {
|
|||
~LetOptions();
|
||||
|
||||
const ast::Type* type = nullptr;
|
||||
const ast::Expression* constructor = nullptr;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
utils::Vector<const ast::Attribute*, 4> attributes;
|
||||
|
||||
private:
|
||||
void Set(const ast::Type* t) { type = t; }
|
||||
void Set(const ast::Expression* c) { constructor = c; }
|
||||
void Set(const ast::Expression* c) { initializer = c; }
|
||||
void Set(utils::VectorRef<const ast::Attribute*> l) { attributes = std::move(l); }
|
||||
void Set(const ast::Attribute* a) { attributes.Push(a); }
|
||||
};
|
||||
|
@ -227,12 +227,12 @@ class ProgramBuilder {
|
|||
~ConstOptions();
|
||||
|
||||
const ast::Type* type = nullptr;
|
||||
const ast::Expression* constructor = nullptr;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
utils::Vector<const ast::Attribute*, 4> attributes;
|
||||
|
||||
private:
|
||||
void Set(const ast::Type* t) { type = t; }
|
||||
void Set(const ast::Expression* c) { constructor = c; }
|
||||
void Set(const ast::Expression* c) { initializer = c; }
|
||||
void Set(utils::VectorRef<const ast::Attribute*> l) { attributes = std::move(l); }
|
||||
void Set(const ast::Attribute* a) { attributes.Push(a); }
|
||||
};
|
||||
|
@ -247,12 +247,12 @@ class ProgramBuilder {
|
|||
~OverrideOptions();
|
||||
|
||||
const ast::Type* type = nullptr;
|
||||
const ast::Expression* constructor = nullptr;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
utils::Vector<const ast::Attribute*, 4> attributes;
|
||||
|
||||
private:
|
||||
void Set(const ast::Type* t) { type = t; }
|
||||
void Set(const ast::Expression* c) { constructor = c; }
|
||||
void Set(const ast::Expression* c) { initializer = c; }
|
||||
void Set(utils::VectorRef<const ast::Attribute*> l) { attributes = std::move(l); }
|
||||
void Set(const ast::Attribute* a) { attributes.Push(a); }
|
||||
};
|
||||
|
@ -1378,7 +1378,7 @@ class ProgramBuilder {
|
|||
return create<ast::BitcastExpression>(source, type, Expr(std::forward<EXPR>(expr)));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @param type the vector type
|
||||
/// @param size the vector size
|
||||
/// @return an `ast::CallExpression` of a `size`-element vector of
|
||||
|
@ -1388,7 +1388,7 @@ class ProgramBuilder {
|
|||
return Construct(ty.vec(type, size), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @return an `ast::CallExpression` of a 2-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1397,7 +1397,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the vector source
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @return an `ast::CallExpression` of a 2-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1405,7 +1405,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.vec2<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @return an `ast::CallExpression` of a 3-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1414,7 +1414,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the vector source
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @return an `ast::CallExpression` of a 3-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1422,7 +1422,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.vec3<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @return an `ast::CallExpression` of a 4-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1431,7 +1431,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the vector source
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @param args the arguments for the vector initializer
|
||||
/// @return an `ast::CallExpression` of a 4-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1439,7 +1439,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.vec4<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 2x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1448,7 +1448,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 2x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1456,7 +1456,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat2x2<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 2x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1465,7 +1465,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 2x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1473,7 +1473,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat2x3<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 2x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1482,7 +1482,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 2x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1490,7 +1490,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat2x4<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 3x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1499,7 +1499,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 3x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1507,7 +1507,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat3x2<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 3x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1516,7 +1516,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 3x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1524,7 +1524,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat3x3<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 3x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1533,7 +1533,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 3x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1541,7 +1541,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat3x4<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 4x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1550,7 +1550,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 4x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1558,7 +1558,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat4x2<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 4x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1567,7 +1567,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 4x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1575,7 +1575,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat4x3<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 4x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS, typename _ = DisableIfSource<ARGS...>>
|
||||
|
@ -1584,7 +1584,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the matrix source
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @param args the arguments for the matrix initializer
|
||||
/// @return an `ast::CallExpression` of a 4x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -1592,7 +1592,7 @@ class ProgramBuilder {
|
|||
return Construct(source, ty.mat4x4<T>(), std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the array constructor
|
||||
/// @param args the arguments for the array initializer
|
||||
/// @return an `ast::CallExpression` of an array with element type
|
||||
/// `T` and size `N`, constructed with the values `args`.
|
||||
template <typename T, int N, typename... ARGS>
|
||||
|
@ -1601,7 +1601,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param source the array source
|
||||
/// @param args the arguments for the array constructor
|
||||
/// @param args the arguments for the array initializer
|
||||
/// @return an `ast::CallExpression` of an array with element type
|
||||
/// `T` and size `N`, constructed with the values `args`.
|
||||
template <typename T, int N, typename... ARGS>
|
||||
|
@ -1611,7 +1611,7 @@ class ProgramBuilder {
|
|||
|
||||
/// @param subtype the array element type
|
||||
/// @param n the array size. nullptr represents a runtime-array.
|
||||
/// @param args the arguments for the array constructor
|
||||
/// @param args the arguments for the array initializer
|
||||
/// @return an `ast::CallExpression` of an array with element type
|
||||
/// `subtype`, constructed with the values `args`.
|
||||
template <typename EXPR, typename... ARGS>
|
||||
|
@ -1622,7 +1622,7 @@ class ProgramBuilder {
|
|||
/// @param source the array source
|
||||
/// @param subtype the array element type
|
||||
/// @param n the array size. nullptr represents a runtime-array.
|
||||
/// @param args the arguments for the array constructor
|
||||
/// @param args the arguments for the array initializer
|
||||
/// @return an `ast::CallExpression` of an array with element type
|
||||
/// `subtype`, constructed with the values `args`.
|
||||
template <typename EXPR, typename... ARGS>
|
||||
|
@ -1654,7 +1654,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Type* - specifies the variable type
|
||||
/// * ast::AddressSpace - specifies the variable address space
|
||||
|
@ -1668,12 +1668,12 @@ class ProgramBuilder {
|
|||
const ast::Var* Var(NAME&& name, OPTIONS&&... options) {
|
||||
VarOptions opts(std::forward<OPTIONS>(options)...);
|
||||
return create<ast::Var>(Sym(std::forward<NAME>(name)), opts.type, opts.address_space,
|
||||
opts.access, opts.constructor, std::move(opts.attributes));
|
||||
opts.access, opts.initializer, std::move(opts.attributes));
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Type* - specifies the variable type
|
||||
/// * ast::AddressSpace - specifies the variable address space
|
||||
|
@ -1686,12 +1686,12 @@ class ProgramBuilder {
|
|||
const ast::Var* Var(const Source& source, NAME&& name, OPTIONS&&... options) {
|
||||
VarOptions opts(std::forward<OPTIONS>(options)...);
|
||||
return create<ast::Var>(source, Sym(std::forward<NAME>(name)), opts.type,
|
||||
opts.address_space, opts.access, opts.constructor,
|
||||
opts.address_space, opts.access, opts.initializer,
|
||||
std::move(opts.attributes));
|
||||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1701,13 +1701,13 @@ class ProgramBuilder {
|
|||
template <typename NAME, typename... OPTIONS, typename = DisableIfSource<NAME>>
|
||||
const ast::Const* Const(NAME&& name, OPTIONS&&... options) {
|
||||
ConstOptions opts(std::forward<OPTIONS>(options)...);
|
||||
return create<ast::Const>(Sym(std::forward<NAME>(name)), opts.type, opts.constructor,
|
||||
return create<ast::Const>(Sym(std::forward<NAME>(name)), opts.type, opts.initializer,
|
||||
std::move(opts.attributes));
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1718,11 +1718,11 @@ class ProgramBuilder {
|
|||
const ast::Const* Const(const Source& source, NAME&& name, OPTIONS&&... options) {
|
||||
ConstOptions opts(std::forward<OPTIONS>(options)...);
|
||||
return create<ast::Const>(source, Sym(std::forward<NAME>(name)), opts.type,
|
||||
opts.constructor, std::move(opts.attributes));
|
||||
opts.initializer, std::move(opts.attributes));
|
||||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1732,13 +1732,13 @@ class ProgramBuilder {
|
|||
template <typename NAME, typename... OPTIONS, typename = DisableIfSource<NAME>>
|
||||
const ast::Let* Let(NAME&& name, OPTIONS&&... options) {
|
||||
LetOptions opts(std::forward<OPTIONS>(options)...);
|
||||
return create<ast::Let>(Sym(std::forward<NAME>(name)), opts.type, opts.constructor,
|
||||
return create<ast::Let>(Sym(std::forward<NAME>(name)), opts.type, opts.initializer,
|
||||
std::move(opts.attributes));
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1748,7 +1748,7 @@ class ProgramBuilder {
|
|||
template <typename NAME, typename... OPTIONS>
|
||||
const ast::Let* Let(const Source& source, NAME&& name, OPTIONS&&... options) {
|
||||
LetOptions opts(std::forward<OPTIONS>(options)...);
|
||||
return create<ast::Let>(source, Sym(std::forward<NAME>(name)), opts.type, opts.constructor,
|
||||
return create<ast::Let>(source, Sym(std::forward<NAME>(name)), opts.type, opts.initializer,
|
||||
std::move(opts.attributes));
|
||||
}
|
||||
|
||||
|
@ -1777,7 +1777,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Type* - specifies the variable type
|
||||
/// * ast::AddressSpace - specifies the variable address space
|
||||
|
@ -1796,7 +1796,7 @@ class ProgramBuilder {
|
|||
|
||||
/// @param source the variable source
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Var constructor
|
||||
/// @param options the extra options passed to the ast::Var initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Type* - specifies the variable type
|
||||
/// * ast::AddressSpace - specifies the variable address space
|
||||
|
@ -1814,7 +1814,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Const constructor
|
||||
/// @param options the extra options passed to the ast::Const initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1831,7 +1831,7 @@ class ProgramBuilder {
|
|||
|
||||
/// @param source the variable source
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Const constructor
|
||||
/// @param options the extra options passed to the ast::Const initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1847,7 +1847,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Override constructor
|
||||
/// @param options the extra options passed to the ast::Override initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1859,14 +1859,14 @@ class ProgramBuilder {
|
|||
const ast::Override* Override(NAME&& name, OPTIONS&&... options) {
|
||||
OverrideOptions opts(std::forward<OPTIONS>(options)...);
|
||||
auto* variable = create<ast::Override>(Sym(std::forward<NAME>(name)), opts.type,
|
||||
opts.constructor, std::move(opts.attributes));
|
||||
opts.initializer, std::move(opts.attributes));
|
||||
AST().AddGlobalVariable(variable);
|
||||
return variable;
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
/// @param name the variable name
|
||||
/// @param options the extra options passed to the ast::Override constructor
|
||||
/// @param options the extra options passed to the ast::Override initializer
|
||||
/// Can be any of the following, in any order:
|
||||
/// * ast::Expression* - specifies the variable's initializer expression (required)
|
||||
/// * ast::Type* - specifies the variable type
|
||||
|
@ -1878,7 +1878,7 @@ class ProgramBuilder {
|
|||
const ast::Override* Override(const Source& source, NAME&& name, OPTIONS&&... options) {
|
||||
OverrideOptions opts(std::forward<OPTIONS>(options)...);
|
||||
auto* variable = create<ast::Override>(source, Sym(std::forward<NAME>(name)), opts.type,
|
||||
opts.constructor, std::move(opts.attributes));
|
||||
opts.initializer, std::move(opts.attributes));
|
||||
AST().AddGlobalVariable(variable);
|
||||
return variable;
|
||||
}
|
||||
|
|
|
@ -2492,18 +2492,18 @@ bool FunctionEmitter::EmitFunctionVariables() {
|
|||
if (failed()) {
|
||||
return false;
|
||||
}
|
||||
const ast::Expression* constructor = nullptr;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
if (inst.NumInOperands() > 1) {
|
||||
// SPIR-V initializers are always constants.
|
||||
// (OpenCL also allows the ID of an OpVariable, but we don't handle that
|
||||
// here.)
|
||||
constructor = parser_impl_.MakeConstantExpression(inst.GetSingleWordInOperand(1)).expr;
|
||||
if (!constructor) {
|
||||
initializer = parser_impl_.MakeConstantExpression(inst.GetSingleWordInOperand(1)).expr;
|
||||
if (!initializer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
auto* var = parser_impl_.MakeVar(inst.result_id(), ast::AddressSpace::kNone, var_store_type,
|
||||
constructor, AttributeList{});
|
||||
initializer, AttributeList{});
|
||||
auto* var_decl_stmt = create<ast::VariableDeclStatement>(Source{}, var);
|
||||
AddStatement(var_decl_stmt);
|
||||
auto* var_type = ty_.Reference(var_store_type, ast::AddressSpace::kNone);
|
||||
|
@ -3967,7 +3967,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst
|
|||
|
||||
if (ext_opcode == GLSLstd450Ldexp) {
|
||||
// WGSL requires the second argument to be signed.
|
||||
// Use a type constructor to convert it, which is the same as a bitcast.
|
||||
// Use a type initializer to convert it, which is the same as a bitcast.
|
||||
// If the value would go from very large positive to negative, then the
|
||||
// original result would have been infinity. And since WGSL
|
||||
// implementations may assume that infinities are not present, then we
|
||||
|
@ -4705,7 +4705,7 @@ TypedExpression FunctionEmitter::MakeVectorShuffle(const spvtools::opt::Instruct
|
|||
|
||||
// Idiomatic vector accessors.
|
||||
|
||||
// Generate an ast::TypeConstructor expression.
|
||||
// Generate an ast::TypeInitializer expression.
|
||||
// Assume the literal indices are valid, and there is a valid number of them.
|
||||
auto source = GetSourceForInst(inst);
|
||||
const Vector* result_type = As<Vector>(parser_impl_.ConvertType(inst.type_id()));
|
||||
|
|
|
@ -957,7 +957,7 @@ class FunctionEmitter {
|
|||
const spvtools::opt::Instruction& image_access);
|
||||
|
||||
/// Returns the given value as an I32. If it's already an I32 then this
|
||||
/// return the given value. Otherwise, wrap the value in a TypeConstructor
|
||||
/// return the given value. Otherwise, wrap the value in a TypeInitializer
|
||||
/// expression.
|
||||
/// @param value the value to pass through or convert
|
||||
/// @returns the value as an I32 value.
|
||||
|
@ -965,7 +965,7 @@ class FunctionEmitter {
|
|||
|
||||
/// Returns the given value as a signed integer type of the same shape
|
||||
/// if the value is unsigned scalar or vector, by wrapping the value
|
||||
/// with a TypeConstructor expression. Returns the value itself if the
|
||||
/// with a TypeInitializer expression. Returns the value itself if the
|
||||
/// value otherwise.
|
||||
/// @param value the value to pass through or convert
|
||||
/// @returns the value itself, or converted to signed integral
|
||||
|
@ -1277,7 +1277,7 @@ class FunctionEmitter {
|
|||
TypedExpression Dereference(TypedExpression expr);
|
||||
|
||||
/// Creates a new `ast::Node` owned by the ProgramBuilder.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @param args the arguments to pass to the type initializer
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
T* create(ARGS&&... args) const {
|
||||
|
|
|
@ -977,7 +977,7 @@ TEST_F(SpvParserTest, DISABLED_WorkgroupSize_Overridable) {
|
|||
none
|
||||
__u32
|
||||
{
|
||||
ScalarConstructor[not set]{2}
|
||||
ScalarInitializer[not set]{2}
|
||||
}
|
||||
}
|
||||
VariableConst{
|
||||
|
@ -988,7 +988,7 @@ TEST_F(SpvParserTest, DISABLED_WorkgroupSize_Overridable) {
|
|||
none
|
||||
__u32
|
||||
{
|
||||
ScalarConstructor[not set]{4}
|
||||
ScalarInitializer[not set]{4}
|
||||
}
|
||||
}
|
||||
VariableConst{
|
||||
|
@ -999,7 +999,7 @@ TEST_F(SpvParserTest, DISABLED_WorkgroupSize_Overridable) {
|
|||
none
|
||||
__u32
|
||||
{
|
||||
ScalarConstructor[not set]{8}
|
||||
ScalarInitializer[not set]{8}
|
||||
}
|
||||
}
|
||||
)")) << got;
|
||||
|
@ -1010,11 +1010,11 @@ TEST_F(SpvParserTest, DISABLED_WorkgroupSize_Overridable) {
|
|||
none
|
||||
__vec_3__u32
|
||||
{
|
||||
TypeConstructor[not set]{
|
||||
TypeInitializer[not set]{
|
||||
__vec_3__u32
|
||||
ScalarConstructor[not set]{2}
|
||||
ScalarConstructor[not set]{4}
|
||||
ScalarConstructor[not set]{8}
|
||||
ScalarInitializer[not set]{2}
|
||||
ScalarInitializer[not set]{4}
|
||||
ScalarInitializer[not set]{8}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1485,16 +1485,16 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
|||
|
||||
auto* ast_store_type = ast_type->As<Pointer>()->type;
|
||||
auto ast_address_space = ast_type->As<Pointer>()->address_space;
|
||||
const ast::Expression* ast_constructor = nullptr;
|
||||
const ast::Expression* ast_initializer = nullptr;
|
||||
if (var.NumInOperands() > 1) {
|
||||
// SPIR-V initializers are always constants.
|
||||
// (OpenCL also allows the ID of an OpVariable, but we don't handle that
|
||||
// here.)
|
||||
ast_constructor = MakeConstantExpression(var.GetSingleWordInOperand(1)).expr;
|
||||
ast_initializer = MakeConstantExpression(var.GetSingleWordInOperand(1)).expr;
|
||||
}
|
||||
auto* ast_var = MakeVar(var.result_id(), ast_address_space, ast_store_type, ast_constructor,
|
||||
auto* ast_var = MakeVar(var.result_id(), ast_address_space, ast_store_type, ast_initializer,
|
||||
utils::Empty);
|
||||
// TODO(dneto): initializers (a.k.a. constructor expression)
|
||||
// TODO(dneto): initializers (a.k.a. initializer expression)
|
||||
if (ast_var) {
|
||||
builder_.AST().AddGlobalVariable(ast_var);
|
||||
module_variable_.GetOrCreate(var.result_id(), [ast_var] { return ast_var; });
|
||||
|
@ -1505,14 +1505,14 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
|||
if (builtin_position_.per_vertex_var_id) {
|
||||
// Make sure the variable has a name.
|
||||
namer_.SuggestSanitizedName(builtin_position_.per_vertex_var_id, "gl_Position");
|
||||
const ast::Expression* ast_constructor = nullptr;
|
||||
const ast::Expression* ast_initializer = nullptr;
|
||||
if (builtin_position_.per_vertex_var_init_id) {
|
||||
// The initializer is complex.
|
||||
const auto* init = def_use_mgr_->GetDef(builtin_position_.per_vertex_var_init_id);
|
||||
switch (init->opcode()) {
|
||||
case SpvOpConstantComposite:
|
||||
case SpvOpSpecConstantComposite:
|
||||
ast_constructor =
|
||||
ast_initializer =
|
||||
MakeConstantExpression(
|
||||
init->GetSingleWordInOperand(builtin_position_.position_member_index))
|
||||
.expr;
|
||||
|
@ -1527,7 +1527,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
|||
auto* ast_var =
|
||||
MakeVar(builtin_position_.per_vertex_var_id,
|
||||
enum_converter_.ToAddressSpace(builtin_position_.storage_class),
|
||||
ConvertType(builtin_position_.position_member_type_id), ast_constructor, {});
|
||||
ConvertType(builtin_position_.position_member_type_id), ast_initializer, {});
|
||||
|
||||
builder_.AST().AddGlobalVariable(ast_var);
|
||||
module_variable_.GetOrCreate(builtin_position_.per_vertex_var_id,
|
||||
|
@ -1562,7 +1562,7 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize(uint32_t va
|
|||
ast::Var* ParserImpl::MakeVar(uint32_t id,
|
||||
ast::AddressSpace address_space,
|
||||
const Type* storage_type,
|
||||
const ast::Expression* constructor,
|
||||
const ast::Expression* initializer,
|
||||
AttributeList decorations) {
|
||||
if (storage_type == nullptr) {
|
||||
Fail() << "internal error: can't make ast::Variable for null type";
|
||||
|
@ -1593,23 +1593,23 @@ ast::Var* ParserImpl::MakeVar(uint32_t id,
|
|||
|
||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||
return create<ast::Var>(Source{}, sym, storage_type->Build(builder_), address_space, access,
|
||||
constructor, decorations);
|
||||
initializer, decorations);
|
||||
}
|
||||
|
||||
ast::Let* ParserImpl::MakeLet(uint32_t id, const Type* type, const ast::Expression* constructor) {
|
||||
ast::Let* ParserImpl::MakeLet(uint32_t id, const Type* type, const ast::Expression* initializer) {
|
||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||
return create<ast::Let>(Source{}, sym, type->Build(builder_), constructor, utils::Empty);
|
||||
return create<ast::Let>(Source{}, sym, type->Build(builder_), initializer, utils::Empty);
|
||||
}
|
||||
|
||||
ast::Override* ParserImpl::MakeOverride(uint32_t id,
|
||||
const Type* type,
|
||||
const ast::Expression* constructor,
|
||||
const ast::Expression* initializer,
|
||||
AttributeList decorations) {
|
||||
if (!ConvertDecorationsForVariable(id, &type, &decorations, false)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||
return create<ast::Override>(Source{}, sym, type->Build(builder_), constructor, decorations);
|
||||
return create<ast::Override>(Source{}, sym, type->Build(builder_), initializer, decorations);
|
||||
}
|
||||
|
||||
ast::Parameter* ParserImpl::MakeParameter(uint32_t id,
|
||||
|
@ -1965,7 +1965,7 @@ TypedExpression ParserImpl::MakeConstantExpressionForScalarSpirvConstant(
|
|||
}
|
||||
|
||||
const ast::Expression* ParserImpl::MakeNullValue(const Type* type) {
|
||||
// TODO(dneto): Use the no-operands constructor syntax when it becomes
|
||||
// TODO(dneto): Use the no-operands initializer syntax when it becomes
|
||||
// available in Tint.
|
||||
// https://github.com/gpuweb/gpuweb/issues/685
|
||||
// https://bugs.chromium.org/p/tint/issues/detail?id=34
|
||||
|
|
|
@ -427,32 +427,32 @@ class ParserImpl : Reader {
|
|||
/// @param id the SPIR-V result ID
|
||||
/// @param address_space the address space, which cannot be ast::AddressSpace::kNone
|
||||
/// @param storage_type the storage type of the variable
|
||||
/// @param constructor the variable constructor
|
||||
/// @param initializer the variable initializer
|
||||
/// @param decorations the variable decorations
|
||||
/// @returns a new Variable node, or null in the ignorable variable case and
|
||||
/// in the error case
|
||||
ast::Var* MakeVar(uint32_t id,
|
||||
ast::AddressSpace address_space,
|
||||
const Type* storage_type,
|
||||
const ast::Expression* constructor,
|
||||
const ast::Expression* initializer,
|
||||
AttributeList decorations);
|
||||
|
||||
/// Creates an AST 'let' node for a SPIR-V ID, including any attached decorations,.
|
||||
/// @param id the SPIR-V result ID
|
||||
/// @param type the type of the variable
|
||||
/// @param constructor the variable constructor
|
||||
/// @param initializer the variable initializer
|
||||
/// @returns the AST 'let' node
|
||||
ast::Let* MakeLet(uint32_t id, const Type* type, const ast::Expression* constructor);
|
||||
ast::Let* MakeLet(uint32_t id, const Type* type, const ast::Expression* initializer);
|
||||
|
||||
/// Creates an AST 'override' node for a SPIR-V ID, including any attached decorations.
|
||||
/// @param id the SPIR-V result ID
|
||||
/// @param type the type of the variable
|
||||
/// @param constructor the variable constructor
|
||||
/// @param initializer the variable initializer
|
||||
/// @param decorations the variable decorations
|
||||
/// @returns the AST 'override' node
|
||||
ast::Override* MakeOverride(uint32_t id,
|
||||
const Type* type,
|
||||
const ast::Expression* constructor,
|
||||
const ast::Expression* initializer,
|
||||
AttributeList decorations);
|
||||
|
||||
/// Creates an AST parameter node for a SPIR-V ID, including any attached decorations, unless
|
||||
|
@ -780,7 +780,7 @@ class ParserImpl : Reader {
|
|||
uint32_t* array_stride);
|
||||
|
||||
/// Creates a new `ast::Node` owned by the ProgramBuilder.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @param args the arguments to pass to the type initializer
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
T* create(ARGS&&... args) {
|
||||
|
|
|
@ -2939,7 +2939,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
// When SPIR-V wants the result type to be unsigned, we have to
|
||||
// insert a type constructor or bitcast for WGSL to do the type
|
||||
// insert a type initializer or bitcast for WGSL to do the type
|
||||
// coercion. But the algorithm already does that as a matter
|
||||
// of course.
|
||||
ImageQuerySizeLod_NonArrayed_UnsignedResult_SignedLevel,
|
||||
|
|
|
@ -2555,7 +2555,7 @@ Maybe<const ast::Expression*> ParserImpl::primary_expression() {
|
|||
return Failure::kErrored;
|
||||
}
|
||||
if (call.matched) {
|
||||
auto params = expect_argument_expression_list("type constructor");
|
||||
auto params = expect_argument_expression_list("type initializer");
|
||||
if (params.errored) {
|
||||
return Failure::kErrored;
|
||||
}
|
||||
|
|
|
@ -186,17 +186,17 @@ fn f() { f() }
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, ConstructorExprMissingLParen) {
|
||||
TEST_F(ParserImplErrorTest, InitializerExprMissingLParen) {
|
||||
EXPECT("fn f() { x = vec2<u32>1,2); }",
|
||||
R"(test.wgsl:1:23 error: expected '(' for type constructor
|
||||
R"(test.wgsl:1:23 error: expected '(' for type initializer
|
||||
fn f() { x = vec2<u32>1,2); }
|
||||
^
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, ConstructorExprMissingRParen) {
|
||||
TEST_F(ParserImplErrorTest, InitializerExprMissingRParen) {
|
||||
EXPECT("fn f() { x = vec2<u32>(1,2; }",
|
||||
R"(test.wgsl:1:27 error: expected ')' for type constructor
|
||||
R"(test.wgsl:1:27 error: expected ')' for type initializer
|
||||
fn f() { x = vec2<u32>(1,2; }
|
||||
^
|
||||
)");
|
||||
|
@ -218,7 +218,7 @@ fn f() { let a : i32; }
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, ConstVarStmtMissingConstructor) {
|
||||
TEST_F(ParserImplErrorTest, ConstVarStmtMissingInitializer) {
|
||||
EXPECT("fn f() { let a : i32 = >; }",
|
||||
R"(test.wgsl:1:24 error: missing initializer for 'let' declaration
|
||||
fn f() { let a : i32 = >; }
|
||||
|
@ -530,7 +530,7 @@ const i : i32 = 1
|
|||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclConstMissingLParen) {
|
||||
EXPECT("const i : vec2<i32> = vec2<i32>;",
|
||||
R"(test.wgsl:1:32 error: expected '(' for type constructor
|
||||
R"(test.wgsl:1:32 error: expected '(' for type initializer
|
||||
const i : vec2<i32> = vec2<i32>;
|
||||
^
|
||||
)");
|
||||
|
@ -538,7 +538,7 @@ const i : vec2<i32> = vec2<i32>;
|
|||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclConstMissingRParen) {
|
||||
EXPECT("const i : vec2<i32> = vec2<i32>(1., 2.;",
|
||||
R"(test.wgsl:1:39 error: expected ')' for type constructor
|
||||
R"(test.wgsl:1:39 error: expected ')' for type initializer
|
||||
const i : vec2<i32> = vec2<i32>(1., 2.;
|
||||
^
|
||||
)");
|
||||
|
@ -581,7 +581,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclConstExprMaxDepth) {
|
|||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMissingLParen) {
|
||||
EXPECT("const i : vec2<i32> = vec2<i32> 1, 2);",
|
||||
R"(test.wgsl:1:33 error: expected '(' for type constructor
|
||||
R"(test.wgsl:1:33 error: expected '(' for type initializer
|
||||
const i : vec2<i32> = vec2<i32> 1, 2);
|
||||
^
|
||||
)");
|
||||
|
@ -589,7 +589,7 @@ const i : vec2<i32> = vec2<i32> 1, 2);
|
|||
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMissingRParen) {
|
||||
EXPECT("const i : vec2<i32> = vec2<i32>(1, 2;",
|
||||
R"(test.wgsl:1:37 error: expected ')' for type constructor
|
||||
R"(test.wgsl:1:37 error: expected ')' for type initializer
|
||||
const i : vec2<i32> = vec2<i32>(1, 2;
|
||||
^
|
||||
)");
|
||||
|
@ -628,7 +628,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclLetMissingLParen) {
|
|||
let i : vec2<i32> = vec2<i32>;
|
||||
^^^
|
||||
|
||||
test.wgsl:1:30 error: expected '(' for type constructor
|
||||
test.wgsl:1:30 error: expected '(' for type initializer
|
||||
let i : vec2<i32> = vec2<i32>;
|
||||
^
|
||||
)");
|
||||
|
@ -641,7 +641,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclLetMissingRParen) {
|
|||
let i : vec2<i32> = vec2<i32>(1., 2.;
|
||||
^^^
|
||||
|
||||
test.wgsl:1:37 error: expected ')' for type constructor
|
||||
test.wgsl:1:37 error: expected ')' for type initializer
|
||||
let i : vec2<i32> = vec2<i32>(1., 2.;
|
||||
^
|
||||
)");
|
||||
|
@ -667,7 +667,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclLetExprMissingLParen) {
|
|||
let i : vec2<i32> = vec2<i32> 1, 2);
|
||||
^^^
|
||||
|
||||
test.wgsl:1:31 error: expected '(' for type constructor
|
||||
test.wgsl:1:31 error: expected '(' for type initializer
|
||||
let i : vec2<i32> = vec2<i32> 1, 2);
|
||||
^
|
||||
)");
|
||||
|
@ -680,7 +680,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclLetExprMissingRParen) {
|
|||
let i : vec2<i32> = vec2<i32>(1, 2;
|
||||
^^^
|
||||
|
||||
test.wgsl:1:35 error: expected ')' for type constructor
|
||||
test.wgsl:1:35 error: expected ')' for type initializer
|
||||
let i : vec2<i32> = vec2<i32>(1, 2;
|
||||
^
|
||||
)");
|
||||
|
|
|
@ -58,7 +58,7 @@ TEST_F(ForStmtTest, InitializerStatementDecl) {
|
|||
ASSERT_TRUE(Is<ast::VariableDeclStatement>(fl->initializer));
|
||||
auto* var = fl->initializer->As<ast::VariableDeclStatement>()->variable;
|
||||
EXPECT_TRUE(var->Is<ast::Var>());
|
||||
EXPECT_EQ(var->constructor, nullptr);
|
||||
EXPECT_EQ(var->initializer, nullptr);
|
||||
EXPECT_EQ(fl->condition, nullptr);
|
||||
EXPECT_EQ(fl->continuing, nullptr);
|
||||
EXPECT_TRUE(fl->body->Empty());
|
||||
|
@ -75,7 +75,7 @@ TEST_F(ForStmtTest, InitializerStatementDeclEqual) {
|
|||
ASSERT_TRUE(Is<ast::VariableDeclStatement>(fl->initializer));
|
||||
auto* var = fl->initializer->As<ast::VariableDeclStatement>()->variable;
|
||||
EXPECT_TRUE(var->Is<ast::Var>());
|
||||
EXPECT_NE(var->constructor, nullptr);
|
||||
EXPECT_NE(var->initializer, nullptr);
|
||||
EXPECT_EQ(fl->condition, nullptr);
|
||||
EXPECT_EQ(fl->continuing, nullptr);
|
||||
EXPECT_TRUE(fl->body->Empty());
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ForStmtTest, InitializerStatementConstDecl) {
|
|||
ASSERT_TRUE(Is<ast::VariableDeclStatement>(fl->initializer));
|
||||
auto* var = fl->initializer->As<ast::VariableDeclStatement>()->variable;
|
||||
EXPECT_TRUE(var->Is<ast::Let>());
|
||||
EXPECT_NE(var->constructor, nullptr);
|
||||
EXPECT_NE(var->initializer, nullptr);
|
||||
EXPECT_EQ(fl->condition, nullptr);
|
||||
EXPECT_EQ(fl->continuing, nullptr);
|
||||
EXPECT_TRUE(fl->body->Empty());
|
||||
|
|
|
@ -39,8 +39,8 @@ TEST_F(ParserImplTest, GlobalLetDecl) {
|
|||
EXPECT_EQ(const_->source.range.end.line, 1u);
|
||||
EXPECT_EQ(const_->source.range.end.column, 6u);
|
||||
|
||||
ASSERT_NE(const_->constructor, nullptr);
|
||||
EXPECT_TRUE(const_->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(const_->initializer, nullptr);
|
||||
EXPECT_TRUE(const_->initializer->Is<ast::LiteralExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalLetDecl_Inferred) {
|
||||
|
@ -63,8 +63,8 @@ TEST_F(ParserImplTest, GlobalLetDecl_Inferred) {
|
|||
EXPECT_EQ(const_->source.range.end.line, 1u);
|
||||
EXPECT_EQ(const_->source.range.end.column, 6u);
|
||||
|
||||
ASSERT_NE(const_->constructor, nullptr);
|
||||
EXPECT_TRUE(const_->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(const_->initializer, nullptr);
|
||||
EXPECT_TRUE(const_->initializer->Is<ast::LiteralExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalLetDecl_InvalidExpression) {
|
||||
|
@ -120,8 +120,8 @@ TEST_F(ParserImplTest, GlobalConstDecl) {
|
|||
EXPECT_EQ(c->source.range.end.line, 1u);
|
||||
EXPECT_EQ(c->source.range.end.column, 8u);
|
||||
|
||||
ASSERT_NE(c->constructor, nullptr);
|
||||
EXPECT_TRUE(c->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(c->initializer, nullptr);
|
||||
EXPECT_TRUE(c->initializer->Is<ast::LiteralExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstDecl_Inferred) {
|
||||
|
@ -144,8 +144,8 @@ TEST_F(ParserImplTest, GlobalConstDecl_Inferred) {
|
|||
EXPECT_EQ(c->source.range.end.line, 1u);
|
||||
EXPECT_EQ(c->source.range.end.column, 8u);
|
||||
|
||||
ASSERT_NE(c->constructor, nullptr);
|
||||
EXPECT_TRUE(c->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(c->initializer, nullptr);
|
||||
EXPECT_TRUE(c->initializer->Is<ast::LiteralExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstDecl_InvalidExpression) {
|
||||
|
@ -196,8 +196,8 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId) {
|
|||
EXPECT_EQ(override->source.range.end.line, 1u);
|
||||
EXPECT_EQ(override->source.range.end.column, 18u);
|
||||
|
||||
ASSERT_NE(override->constructor, nullptr);
|
||||
EXPECT_TRUE(override->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(override->initializer, nullptr);
|
||||
EXPECT_TRUE(override->initializer->Is<ast::LiteralExpression>());
|
||||
|
||||
auto* override_attr = ast::GetAttribute<ast::IdAttribute>(override->attributes);
|
||||
ASSERT_NE(override_attr, nullptr);
|
||||
|
@ -226,8 +226,8 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) {
|
|||
EXPECT_EQ(override->source.range.end.line, 1u);
|
||||
EXPECT_EQ(override->source.range.end.column, 19u);
|
||||
|
||||
ASSERT_NE(override->constructor, nullptr);
|
||||
EXPECT_TRUE(override->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(override->initializer, nullptr);
|
||||
EXPECT_TRUE(override->initializer->Is<ast::LiteralExpression>());
|
||||
|
||||
auto* override_attr = ast::GetAttribute<ast::IdAttribute>(override->attributes);
|
||||
ASSERT_NE(override_attr, nullptr);
|
||||
|
@ -256,8 +256,8 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithoutId) {
|
|||
EXPECT_EQ(override->source.range.end.line, 1u);
|
||||
EXPECT_EQ(override->source.range.end.column, 11u);
|
||||
|
||||
ASSERT_NE(override->constructor, nullptr);
|
||||
EXPECT_TRUE(override->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(override->initializer, nullptr);
|
||||
EXPECT_TRUE(override->initializer->Is<ast::LiteralExpression>());
|
||||
|
||||
auto* id_attr = ast::GetAttribute<ast::IdAttribute>(override->attributes);
|
||||
ASSERT_EQ(id_attr, nullptr);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint::reader::wgsl {
|
||||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithoutInitializer) {
|
||||
auto p = parser("var<private> a : f32");
|
||||
auto attrs = p->attribute_list();
|
||||
EXPECT_FALSE(attrs.errored);
|
||||
|
@ -38,10 +38,10 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
|||
EXPECT_EQ(var->source.range.end.line, 1u);
|
||||
EXPECT_EQ(var->source.range.end.column, 15u);
|
||||
|
||||
ASSERT_EQ(var->constructor, nullptr);
|
||||
ASSERT_EQ(var->initializer, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithInitializer) {
|
||||
auto p = parser("var<private> a : f32 = 1.");
|
||||
auto attrs = p->attribute_list();
|
||||
EXPECT_FALSE(attrs.errored);
|
||||
|
@ -62,8 +62,8 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
|||
EXPECT_EQ(var->source.range.end.line, 1u);
|
||||
EXPECT_EQ(var->source.range.end.column, 15u);
|
||||
|
||||
ASSERT_NE(var->constructor, nullptr);
|
||||
ASSERT_TRUE(var->constructor->Is<ast::FloatLiteralExpression>());
|
||||
ASSERT_NE(var->initializer, nullptr);
|
||||
ASSERT_TRUE(var->initializer->Is<ast::FloatLiteralExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute) {
|
||||
|
@ -88,7 +88,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute) {
|
|||
EXPECT_EQ(var->source.range.end.line, 1u);
|
||||
EXPECT_EQ(var->source.range.end.column, 37u);
|
||||
|
||||
ASSERT_EQ(var->constructor, nullptr);
|
||||
ASSERT_EQ(var->initializer, nullptr);
|
||||
|
||||
auto& attributes = var->attributes;
|
||||
ASSERT_EQ(attributes.Length(), 2u);
|
||||
|
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute_MulitpleGroups) {
|
|||
EXPECT_EQ(var->source.range.end.line, 1u);
|
||||
EXPECT_EQ(var->source.range.end.column, 37u);
|
||||
|
||||
ASSERT_EQ(var->constructor, nullptr);
|
||||
ASSERT_EQ(var->initializer, nullptr);
|
||||
|
||||
auto& attributes = var->attributes;
|
||||
ASSERT_EQ(attributes.Length(), 2u);
|
||||
|
|
|
@ -65,7 +65,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
|||
ast::IntLiteralExpression::Suffix::kNone);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_ZeroConstructor) {
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_ZeroInitializer) {
|
||||
auto p = parser("vec4<i32>()");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -96,7 +96,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingLeftParen) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:11: expected '(' for type constructor");
|
||||
EXPECT_EQ(p->error(), "1:11: expected '(' for type initializer");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingRightParen) {
|
||||
|
@ -106,7 +106,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingRightParen) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:25: expected ')' for type constructor");
|
||||
EXPECT_EQ(p->error(), "1:25: expected ')' for type initializer");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidValue) {
|
||||
|
@ -116,10 +116,10 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidValue) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:5: expected ')' for type constructor");
|
||||
EXPECT_EQ(p->error(), "1:5: expected ')' for type initializer");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructConstructor_Empty) {
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructInitializer_Empty) {
|
||||
auto p = parser(R"(
|
||||
struct S { a : i32, b : f32, }
|
||||
S()
|
||||
|
@ -143,7 +143,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructConstructor_Empty) {
|
|||
ASSERT_EQ(call->args.Length(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructConstructor_NotEmpty) {
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructInitializer_NotEmpty) {
|
||||
auto p = parser(R"(
|
||||
struct S { a : i32, b : f32, }
|
||||
S(1u, 2.0)
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl) {
|
|||
ASSERT_EQ(e->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e->source.range.end.column, 6u);
|
||||
|
||||
EXPECT_EQ(e->variable->constructor, nullptr);
|
||||
EXPECT_EQ(e->variable->initializer, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_WithInit) {
|
||||
|
@ -52,11 +52,11 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_WithInit) {
|
|||
ASSERT_EQ(e->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e->source.range.end.column, 6u);
|
||||
|
||||
ASSERT_NE(e->variable->constructor, nullptr);
|
||||
EXPECT_TRUE(e->variable->constructor->Is<ast::LiteralExpression>());
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
EXPECT_TRUE(e->variable->initializer->Is<ast::LiteralExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_ConstructorInvalid) {
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_InitializerInvalid) {
|
||||
auto p = parser("var a : i32 = if(a) {}");
|
||||
auto e = p->variable_statement();
|
||||
EXPECT_FALSE(e.matched);
|
||||
|
@ -77,8 +77,8 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit) {
|
|||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->constructor, nullptr);
|
||||
auto* call = e->variable->constructor->As<ast::CallExpression>();
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
ASSERT_NE(call, nullptr);
|
||||
EXPECT_EQ(call->target.name, nullptr);
|
||||
EXPECT_NE(call->target.type, nullptr);
|
||||
|
@ -95,8 +95,8 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit_NoSpace) {
|
|||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->constructor, nullptr);
|
||||
auto* call = e->variable->constructor->As<ast::CallExpression>();
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
ASSERT_NE(call, nullptr);
|
||||
EXPECT_EQ(call->target.name, nullptr);
|
||||
EXPECT_NE(call->target.type, nullptr);
|
||||
|
@ -113,8 +113,8 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit) {
|
|||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->constructor, nullptr);
|
||||
auto* call = e->variable->constructor->As<ast::CallExpression>();
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
ASSERT_NE(call, nullptr);
|
||||
EXPECT_EQ(call->target.name, nullptr);
|
||||
EXPECT_NE(call->target.type, nullptr);
|
||||
|
@ -131,8 +131,8 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit_NoSpace) {
|
|||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->constructor, nullptr);
|
||||
auto* call = e->variable->constructor->As<ast::CallExpression>();
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
ASSERT_NE(call, nullptr);
|
||||
EXPECT_EQ(call->target.name, nullptr);
|
||||
EXPECT_NE(call->target.type, nullptr);
|
||||
|
@ -164,10 +164,10 @@ TEST_F(ParserImplTest, VariableStmt_Let_ComplexExpression) {
|
|||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
|
||||
auto* decl = e->As<ast::VariableDeclStatement>();
|
||||
ASSERT_NE(decl->variable->constructor, nullptr);
|
||||
ASSERT_NE(decl->variable->initializer, nullptr);
|
||||
|
||||
ASSERT_TRUE(decl->variable->constructor->Is<ast::BinaryExpression>());
|
||||
auto* expr = decl->variable->constructor->As<ast::BinaryExpression>();
|
||||
ASSERT_TRUE(decl->variable->initializer->Is<ast::BinaryExpression>());
|
||||
auto* expr = decl->variable->initializer->As<ast::BinaryExpression>();
|
||||
EXPECT_EQ(expr->op, ast::BinaryOp::kAdd);
|
||||
|
||||
ASSERT_TRUE(expr->lhs->Is<ast::IdentifierExpression>());
|
||||
|
@ -189,7 +189,7 @@ TEST_F(ParserImplTest, VariableStmt_Let_MissingEqual) {
|
|||
EXPECT_EQ(p->error(), "1:13: expected '=' for 'let' declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Let_MissingConstructor) {
|
||||
TEST_F(ParserImplTest, VariableStmt_Let_MissingInitializer) {
|
||||
auto p = parser("let a : i32 =");
|
||||
auto e = p->variable_statement();
|
||||
EXPECT_FALSE(e.matched);
|
||||
|
@ -199,7 +199,7 @@ TEST_F(ParserImplTest, VariableStmt_Let_MissingConstructor) {
|
|||
EXPECT_EQ(p->error(), "1:14: missing initializer for 'let' declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Let_InvalidConstructor) {
|
||||
TEST_F(ParserImplTest, VariableStmt_Let_InvalidInitializer) {
|
||||
auto p = parser("let a : i32 = if (a) {}");
|
||||
auto e = p->variable_statement();
|
||||
EXPECT_FALSE(e.matched);
|
||||
|
|
|
@ -94,7 +94,7 @@ class WhileStmtErrorTest : public ParserImplTest {
|
|||
// Test a while loop with missing left parenthesis is invalid.
|
||||
TEST_F(WhileStmtErrorTest, MissingLeftParen) {
|
||||
std::string while_str = "while bool) { }";
|
||||
std::string error_str = "1:11: expected '(' for type constructor";
|
||||
std::string error_str = "1:11: expected '(' for type initializer";
|
||||
|
||||
TestWhileWithError(while_str, error_str);
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, Immediate) {
|
|||
auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back();
|
||||
|
||||
// BuildTextureVariable() uses a Literal for scalars, and a CallExpression for
|
||||
// a vector constructor.
|
||||
// a vector initializer.
|
||||
bool is_vector = arg_to_replace->Is<ast::CallExpression>();
|
||||
|
||||
// Make the expression to be replaced, reachable. This keeps the resolver happy.
|
||||
|
@ -310,7 +310,7 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalConst) {
|
|||
auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back();
|
||||
|
||||
// BuildTextureVariable() uses a Literal for scalars, and a CallExpression for
|
||||
// a vector constructor.
|
||||
// a vector initializer.
|
||||
bool is_vector = arg_to_replace->Is<ast::CallExpression>();
|
||||
|
||||
// Make the expression to be replaced, reachable. This keeps the resolver happy.
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "src/tint/sem/i32.h"
|
||||
#include "src/tint/sem/matrix.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/sem/u32.h"
|
||||
#include "src/tint/sem/vector.h"
|
||||
#include "src/tint/utils/compiler_macros.h"
|
||||
|
@ -286,7 +286,7 @@ struct Element : ImplConstant {
|
|||
};
|
||||
|
||||
/// Splat holds a single Constant value, duplicated as all children.
|
||||
/// Splat is used for zero-initializers, 'splat' constructors, or constructors where each element is
|
||||
/// Splat is used for zero-initializers, 'splat' initializers, or initializers where each element is
|
||||
/// identical. Splat may be of a vector, matrix or array type.
|
||||
/// Splat implements the Constant interface.
|
||||
struct Splat : ImplConstant {
|
||||
|
@ -815,18 +815,18 @@ ConstEval::Result ConstEval::Literal(const sem::Type* ty, const ast::LiteralExpr
|
|||
});
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::ArrayOrStructCtor(const sem::Type* ty,
|
||||
ConstEval::Result ConstEval::ArrayOrStructInit(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Expression*> args) {
|
||||
if (args.IsEmpty()) {
|
||||
return ZeroValue(builder, ty);
|
||||
}
|
||||
|
||||
if (args.Length() == 1 && args[0]->Type() == ty) {
|
||||
// Identity constructor.
|
||||
// Identity initializer.
|
||||
return args[0]->ConstantValue();
|
||||
}
|
||||
|
||||
// Multiple arguments. Must be a type constructor.
|
||||
// Multiple arguments. Must be a type initializer.
|
||||
utils::Vector<const sem::Constant*, 4> els;
|
||||
els.Reserve(args.Length());
|
||||
for (auto* arg : args) {
|
||||
|
@ -872,13 +872,13 @@ ConstEval::Result ConstEval::VecSplat(const sem::Type* ty,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::VecCtorS(const sem::Type* ty,
|
||||
ConstEval::Result ConstEval::VecInitS(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source&) {
|
||||
return CreateComposite(builder, ty, args);
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::VecCtorM(const sem::Type* ty,
|
||||
ConstEval::Result ConstEval::VecInitM(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source&) {
|
||||
utils::Vector<const sem::Constant*, 4> els;
|
||||
|
@ -904,7 +904,7 @@ ConstEval::Result ConstEval::VecCtorM(const sem::Type* ty,
|
|||
return CreateComposite(builder, ty, std::move(els));
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::MatCtorS(const sem::Type* ty,
|
||||
ConstEval::Result ConstEval::MatInitS(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source&) {
|
||||
auto* m = static_cast<const sem::Matrix*>(ty);
|
||||
|
@ -921,7 +921,7 @@ ConstEval::Result ConstEval::MatCtorS(const sem::Type* ty,
|
|||
return CreateComposite(builder, ty, std::move(els));
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::MatCtorV(const sem::Type* ty,
|
||||
ConstEval::Result ConstEval::MatInitV(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source&) {
|
||||
return CreateComposite(builder, ty, args);
|
||||
|
|
|
@ -68,10 +68,10 @@ class ConstEval {
|
|||
// Constant value evaluation methods, to be called directly from Resolver
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// @param ty the target type - must be an array or constructor
|
||||
/// @param ty the target type - must be an array or initializer
|
||||
/// @param args the input arguments
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result ArrayOrStructCtor(const sem::Type* ty, utils::VectorRef<const sem::Expression*> args);
|
||||
Result ArrayOrStructInit(const sem::Type* ty, utils::VectorRef<const sem::Expression*> args);
|
||||
|
||||
/// @param ty the target type
|
||||
/// @param expr the input expression
|
||||
|
@ -122,7 +122,7 @@ class ConstEval {
|
|||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Zero value type constructor
|
||||
/// Zero value type initializer
|
||||
/// @param ty the result type
|
||||
/// @param args the input arguments (no arguments provided)
|
||||
/// @param source the source location of the conversion
|
||||
|
@ -131,7 +131,7 @@ class ConstEval {
|
|||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Identity value type constructor
|
||||
/// Identity value type initializer
|
||||
/// @param ty the result type
|
||||
/// @param args the input arguments
|
||||
/// @param source the source location of the conversion
|
||||
|
@ -140,7 +140,7 @@ class ConstEval {
|
|||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Vector splat constructor
|
||||
/// Vector splat initializer
|
||||
/// @param ty the vector type
|
||||
/// @param args the input arguments
|
||||
/// @param source the source location of the conversion
|
||||
|
@ -149,39 +149,39 @@ class ConstEval {
|
|||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Vector constructor using scalars
|
||||
/// Vector initializer using scalars
|
||||
/// @param ty the vector type
|
||||
/// @param args the input arguments
|
||||
/// @param source the source location of the conversion
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result VecCtorS(const sem::Type* ty,
|
||||
Result VecInitS(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Vector constructor using a mix of scalars and smaller vectors
|
||||
/// Vector initializer using a mix of scalars and smaller vectors
|
||||
/// @param ty the vector type
|
||||
/// @param args the input arguments
|
||||
/// @param source the source location of the conversion
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result VecCtorM(const sem::Type* ty,
|
||||
Result VecInitM(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Matrix constructor using scalar values
|
||||
/// Matrix initializer using scalar values
|
||||
/// @param ty the matrix type
|
||||
/// @param args the input arguments
|
||||
/// @param source the source location of the conversion
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result MatCtorS(const sem::Type* ty,
|
||||
Result MatInitS(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
/// Matrix constructor using column vectors
|
||||
/// Matrix initializer using column vectors
|
||||
/// @param ty the matrix type
|
||||
/// @param args the input arguments
|
||||
/// @param source the source location of the conversion
|
||||
/// @return the constructed value, or null if the value cannot be calculated
|
||||
Result MatCtorV(const sem::Type* ty,
|
||||
Result MatInitV(const sem::Type* ty,
|
||||
utils::VectorRef<const sem::Constant*> args,
|
||||
const Source& source);
|
||||
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
{{- /*
|
||||
--------------------------------------------------------------------------------
|
||||
Template file for use with tools/src/cmd/gen to generate ctor_conv_intrinsic.h
|
||||
|
||||
To update the generated file, run:
|
||||
./tools/run gen
|
||||
|
||||
See:
|
||||
* tools/src/cmd/gen for structures used by this template
|
||||
* https://golang.org/pkg/text/template/ for documentation on the template syntax
|
||||
--------------------------------------------------------------------------------
|
||||
*/ -}}
|
||||
|
||||
#ifndef SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_
|
||||
#define SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
/// CtorConvIntrinsic is an enumerator of types that have a constructor or converter overload
|
||||
/// declared in the intrinsic table.
|
||||
enum class CtorConvIntrinsic {
|
||||
kNone = -1,
|
||||
{{- range Sem.ConstructorsAndConverters }}
|
||||
k{{Title .Name}},
|
||||
{{- end }}
|
||||
};
|
||||
|
||||
/// @returns the name of the type.
|
||||
const char* str(CtorConvIntrinsic i);
|
||||
|
||||
/// @param n the width of the vector
|
||||
/// @return the CtorConvIntrinsic for a vector of width `n`
|
||||
inline CtorConvIntrinsic VectorCtorConvIntrinsic(uint32_t n) {
|
||||
switch (n) {
|
||||
case 2:
|
||||
return CtorConvIntrinsic::kVec2;
|
||||
case 3:
|
||||
return CtorConvIntrinsic::kVec3;
|
||||
case 4:
|
||||
return CtorConvIntrinsic::kVec4;
|
||||
}
|
||||
return CtorConvIntrinsic::kNone;
|
||||
}
|
||||
|
||||
/// @param c the number of columns in the matrix
|
||||
/// @param r the number of rows in the matrix
|
||||
/// @return the CtorConvIntrinsic for a matrix with `c` columns and `r` rows
|
||||
inline CtorConvIntrinsic MatrixCtorConvIntrinsic(uint32_t c, uint32_t r) {
|
||||
switch ((c - 2) * 3 + (r - 2)) {
|
||||
case 0:
|
||||
return CtorConvIntrinsic::kMat2x2;
|
||||
case 1:
|
||||
return CtorConvIntrinsic::kMat2x3;
|
||||
case 2:
|
||||
return CtorConvIntrinsic::kMat2x4;
|
||||
case 3:
|
||||
return CtorConvIntrinsic::kMat3x2;
|
||||
case 4:
|
||||
return CtorConvIntrinsic::kMat3x3;
|
||||
case 5:
|
||||
return CtorConvIntrinsic::kMat3x4;
|
||||
case 6:
|
||||
return CtorConvIntrinsic::kMat4x2;
|
||||
case 7:
|
||||
return CtorConvIntrinsic::kMat4x3;
|
||||
case 8:
|
||||
return CtorConvIntrinsic::kMat4x4;
|
||||
}
|
||||
return CtorConvIntrinsic::kNone;
|
||||
}
|
||||
|
||||
} // namespace tint::resolver
|
||||
|
||||
#endif // SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_
|
|
@ -199,8 +199,8 @@ class DependencyScanner {
|
|||
Declare(var->symbol, var);
|
||||
TraverseType(var->type);
|
||||
TraverseAttributes(var->attributes);
|
||||
if (var->constructor) {
|
||||
TraverseExpression(var->constructor);
|
||||
if (var->initializer) {
|
||||
TraverseExpression(var->initializer);
|
||||
}
|
||||
},
|
||||
[&](const ast::Enable*) {
|
||||
|
@ -309,7 +309,7 @@ class DependencyScanner {
|
|||
graph_.shadows.emplace(v->variable, shadows);
|
||||
}
|
||||
TraverseType(v->variable->type);
|
||||
TraverseExpression(v->variable->constructor);
|
||||
TraverseExpression(v->variable->initializer);
|
||||
Declare(v->variable->symbol, v->variable);
|
||||
},
|
||||
[&](const ast::WhileStatement* w) {
|
||||
|
|
|
@ -40,7 +40,7 @@ TEST_F(ResolverEvaluationStageTest, Literal_f32) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kConstant);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Vector_Ctor) {
|
||||
TEST_F(ResolverEvaluationStageTest, Vector_Init) {
|
||||
auto* expr = vec3<f32>();
|
||||
WrapInFunction(expr);
|
||||
|
||||
|
@ -48,7 +48,7 @@ TEST_F(ResolverEvaluationStageTest, Vector_Ctor) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kConstant);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Vector_Ctor_Const_Const) {
|
||||
TEST_F(ResolverEvaluationStageTest, Vector_Init_Const_Const) {
|
||||
// const f = 1.f;
|
||||
// vec2<f32>(f, f);
|
||||
auto* f = Const("f", Expr(1_f));
|
||||
|
@ -60,7 +60,7 @@ TEST_F(ResolverEvaluationStageTest, Vector_Ctor_Const_Const) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kConstant);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Vector_Ctor_Runtime_Runtime) {
|
||||
TEST_F(ResolverEvaluationStageTest, Vector_Init_Runtime_Runtime) {
|
||||
// var f = 1.f;
|
||||
// vec2<f32>(f, f);
|
||||
auto* f = Var("f", Expr(1_f));
|
||||
|
@ -96,7 +96,7 @@ TEST_F(ResolverEvaluationStageTest, Vector_Conv_Runtime) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kRuntime);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Matrix_Ctor) {
|
||||
TEST_F(ResolverEvaluationStageTest, Matrix_Init) {
|
||||
auto* expr = mat2x2<f32>();
|
||||
WrapInFunction(expr);
|
||||
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ResolverEvaluationStageTest, Matrix_Ctor) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kConstant);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Ctor) {
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Init) {
|
||||
auto* expr = array<f32, 3>();
|
||||
WrapInFunction(expr);
|
||||
|
||||
|
@ -112,7 +112,7 @@ TEST_F(ResolverEvaluationStageTest, Array_Ctor) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kConstant);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Ctor_Const_Const) {
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Init_Const_Const) {
|
||||
// const f = 1.f;
|
||||
// array<f32, 2>(f, f);
|
||||
auto* f = Const("f", Expr(1_f));
|
||||
|
@ -124,7 +124,7 @@ TEST_F(ResolverEvaluationStageTest, Array_Ctor_Const_Const) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kConstant);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Ctor_Const_Override) {
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Init_Const_Override) {
|
||||
// const f1 = 1.f;
|
||||
// override f2 = 2.f;
|
||||
// array<f32, 2>(f1, f2);
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ResolverEvaluationStageTest, Array_Ctor_Const_Override) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kOverride);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Ctor_Override_Runtime) {
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Init_Override_Runtime) {
|
||||
// override f1 = 1.f;
|
||||
// var f2 = 2.f;
|
||||
// array<f32, 2>(f1, f2);
|
||||
|
@ -154,7 +154,7 @@ TEST_F(ResolverEvaluationStageTest, Array_Ctor_Override_Runtime) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kRuntime);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Ctor_Const_Runtime) {
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Init_Const_Runtime) {
|
||||
// const f1 = 1.f;
|
||||
// var f2 = 2.f;
|
||||
// array<f32, 2>(f1, f2);
|
||||
|
@ -169,7 +169,7 @@ TEST_F(ResolverEvaluationStageTest, Array_Ctor_Const_Runtime) {
|
|||
EXPECT_EQ(Sem().Get(expr)->Stage(), sem::EvaluationStage::kRuntime);
|
||||
}
|
||||
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Ctor_Runtime_Runtime) {
|
||||
TEST_F(ResolverEvaluationStageTest, Array_Init_Runtime_Runtime) {
|
||||
// var f = 1.f;
|
||||
// array<f32, 2>(f, f);
|
||||
auto* f = Var("f", Expr(1_f));
|
||||
|
|
|
@ -805,7 +805,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Zero) {
|
|||
EXPECT_EQ(r()->error(), "12:34 error: workgroup_size argument must be at least 1");
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_NestedZeroValueConstructor) {
|
||||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_NestedZeroValueInitializer) {
|
||||
// const x = i32(i32(i32()));
|
||||
// @compute @workgroup_size(x)
|
||||
// fn main() {}
|
||||
|
|
|
@ -82,7 +82,7 @@ TEST_P(ResolverInferredTypeParamTest, GlobalConst_Pass) {
|
|||
|
||||
auto* expected_type = params.create_expected_type(*this);
|
||||
|
||||
// const a = <type constructor>;
|
||||
// const a = <type initializer>;
|
||||
auto* ctor_expr = params.create_value(*this, 0);
|
||||
auto* a = GlobalConst("a", ctor_expr);
|
||||
|
||||
|
@ -95,7 +95,7 @@ TEST_P(ResolverInferredTypeParamTest, GlobalVar_Pass) {
|
|||
|
||||
auto* expected_type = params.create_expected_type(*this);
|
||||
|
||||
// var a = <type constructor>;
|
||||
// var a = <type initializer>;
|
||||
auto* ctor_expr = params.create_value(*this, 0);
|
||||
auto* var = GlobalVar("a", ast::AddressSpace::kPrivate, ctor_expr);
|
||||
|
||||
|
@ -108,7 +108,7 @@ TEST_P(ResolverInferredTypeParamTest, LocalLet_Pass) {
|
|||
|
||||
auto* expected_type = params.create_expected_type(*this);
|
||||
|
||||
// let a = <type constructor>;
|
||||
// let a = <type initializer>;
|
||||
auto* ctor_expr = params.create_value(*this, 0);
|
||||
auto* var = Let("a", ctor_expr);
|
||||
WrapInFunction(var);
|
||||
|
@ -122,7 +122,7 @@ TEST_P(ResolverInferredTypeParamTest, LocalVar_Pass) {
|
|||
|
||||
auto* expected_type = params.create_expected_type(*this);
|
||||
|
||||
// var a = <type constructor>;
|
||||
// var a = <type initializer>;
|
||||
auto* ctor_expr = params.create_value(*this, 0);
|
||||
auto* var = Var("a", ast::AddressSpace::kFunction, ctor_expr);
|
||||
WrapInFunction(var);
|
||||
|
|
|
@ -15,52 +15,52 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// File generated by tools/src/cmd/gen
|
||||
// using the template:
|
||||
// src/tint/resolver/ctor_conv_intrinsic.cc.tmpl
|
||||
// src/tint/resolver/init_conv_intrinsic.cc.tmpl
|
||||
//
|
||||
// Do not modify this file directly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "src/tint/resolver/ctor_conv_intrinsic.h"
|
||||
#include "src/tint/resolver/init_conv_intrinsic.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
const char* str(CtorConvIntrinsic i) {
|
||||
const char* str(InitConvIntrinsic i) {
|
||||
switch (i) {
|
||||
case CtorConvIntrinsic::kNone:
|
||||
case InitConvIntrinsic::kNone:
|
||||
return "<none>";
|
||||
case CtorConvIntrinsic::kI32:
|
||||
case InitConvIntrinsic::kI32:
|
||||
return "i32";
|
||||
case CtorConvIntrinsic::kU32:
|
||||
case InitConvIntrinsic::kU32:
|
||||
return "u32";
|
||||
case CtorConvIntrinsic::kF32:
|
||||
case InitConvIntrinsic::kF32:
|
||||
return "f32";
|
||||
case CtorConvIntrinsic::kF16:
|
||||
case InitConvIntrinsic::kF16:
|
||||
return "f16";
|
||||
case CtorConvIntrinsic::kBool:
|
||||
case InitConvIntrinsic::kBool:
|
||||
return "bool";
|
||||
case CtorConvIntrinsic::kVec2:
|
||||
case InitConvIntrinsic::kVec2:
|
||||
return "vec2";
|
||||
case CtorConvIntrinsic::kVec3:
|
||||
case InitConvIntrinsic::kVec3:
|
||||
return "vec3";
|
||||
case CtorConvIntrinsic::kVec4:
|
||||
case InitConvIntrinsic::kVec4:
|
||||
return "vec4";
|
||||
case CtorConvIntrinsic::kMat2x2:
|
||||
case InitConvIntrinsic::kMat2x2:
|
||||
return "mat2x2";
|
||||
case CtorConvIntrinsic::kMat2x3:
|
||||
case InitConvIntrinsic::kMat2x3:
|
||||
return "mat2x3";
|
||||
case CtorConvIntrinsic::kMat2x4:
|
||||
case InitConvIntrinsic::kMat2x4:
|
||||
return "mat2x4";
|
||||
case CtorConvIntrinsic::kMat3x2:
|
||||
case InitConvIntrinsic::kMat3x2:
|
||||
return "mat3x2";
|
||||
case CtorConvIntrinsic::kMat3x3:
|
||||
case InitConvIntrinsic::kMat3x3:
|
||||
return "mat3x3";
|
||||
case CtorConvIntrinsic::kMat3x4:
|
||||
case InitConvIntrinsic::kMat3x4:
|
||||
return "mat3x4";
|
||||
case CtorConvIntrinsic::kMat4x2:
|
||||
case InitConvIntrinsic::kMat4x2:
|
||||
return "mat4x2";
|
||||
case CtorConvIntrinsic::kMat4x3:
|
||||
case InitConvIntrinsic::kMat4x3:
|
||||
return "mat4x3";
|
||||
case CtorConvIntrinsic::kMat4x4:
|
||||
case InitConvIntrinsic::kMat4x4:
|
||||
return "mat4x4";
|
||||
}
|
||||
return "<unknown>";
|
|
@ -1,6 +1,6 @@
|
|||
{{- /*
|
||||
--------------------------------------------------------------------------------
|
||||
Template file for use with tools/src/cmd/gen to generate ctor_conv_intrinsic.cc
|
||||
Template file for use with tools/src/cmd/gen to generate init_conv_intrinsic.cc
|
||||
|
||||
To update the generated file, run:
|
||||
./tools/run gen
|
||||
|
@ -11,16 +11,16 @@ See:
|
|||
--------------------------------------------------------------------------------
|
||||
*/ -}}
|
||||
|
||||
#include "src/tint/resolver/ctor_conv_intrinsic.h"
|
||||
#include "src/tint/resolver/init_conv_intrinsic.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
const char* str(CtorConvIntrinsic i) {
|
||||
const char* str(InitConvIntrinsic i) {
|
||||
switch (i) {
|
||||
case CtorConvIntrinsic::kNone:
|
||||
case InitConvIntrinsic::kNone:
|
||||
return "<none>";
|
||||
{{- range Sem.ConstructorsAndConverters }}
|
||||
case CtorConvIntrinsic::k{{Title .Name}}:
|
||||
{{- range Sem.InitializersAndConverters }}
|
||||
case InitConvIntrinsic::k{{Title .Name}}:
|
||||
return "{{.Name}}";
|
||||
{{- end }}
|
||||
}
|
|
@ -15,21 +15,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// File generated by tools/src/cmd/gen
|
||||
// using the template:
|
||||
// src/tint/resolver/ctor_conv_intrinsic.h.tmpl
|
||||
// src/tint/resolver/init_conv_intrinsic.h.tmpl
|
||||
//
|
||||
// Do not modify this file directly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_
|
||||
#define SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_
|
||||
#ifndef SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_
|
||||
#define SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
/// CtorConvIntrinsic is an enumerator of types that have a constructor or converter overload
|
||||
/// InitConvIntrinsic is an enumerator of types that have a initializer or converter overload
|
||||
/// declared in the intrinsic table.
|
||||
enum class CtorConvIntrinsic {
|
||||
enum class InitConvIntrinsic {
|
||||
kNone = -1,
|
||||
kI32,
|
||||
kU32,
|
||||
|
@ -51,49 +51,49 @@ enum class CtorConvIntrinsic {
|
|||
};
|
||||
|
||||
/// @returns the name of the type.
|
||||
const char* str(CtorConvIntrinsic i);
|
||||
const char* str(InitConvIntrinsic i);
|
||||
|
||||
/// @param n the width of the vector
|
||||
/// @return the CtorConvIntrinsic for a vector of width `n`
|
||||
inline CtorConvIntrinsic VectorCtorConvIntrinsic(uint32_t n) {
|
||||
/// @return the InitConvIntrinsic for a vector of width `n`
|
||||
inline InitConvIntrinsic VectorInitConvIntrinsic(uint32_t n) {
|
||||
switch (n) {
|
||||
case 2:
|
||||
return CtorConvIntrinsic::kVec2;
|
||||
return InitConvIntrinsic::kVec2;
|
||||
case 3:
|
||||
return CtorConvIntrinsic::kVec3;
|
||||
return InitConvIntrinsic::kVec3;
|
||||
case 4:
|
||||
return CtorConvIntrinsic::kVec4;
|
||||
return InitConvIntrinsic::kVec4;
|
||||
}
|
||||
return CtorConvIntrinsic::kNone;
|
||||
return InitConvIntrinsic::kNone;
|
||||
}
|
||||
|
||||
/// @param c the number of columns in the matrix
|
||||
/// @param r the number of rows in the matrix
|
||||
/// @return the CtorConvIntrinsic for a matrix with `c` columns and `r` rows
|
||||
inline CtorConvIntrinsic MatrixCtorConvIntrinsic(uint32_t c, uint32_t r) {
|
||||
/// @return the InitConvIntrinsic for a matrix with `c` columns and `r` rows
|
||||
inline InitConvIntrinsic MatrixInitConvIntrinsic(uint32_t c, uint32_t r) {
|
||||
switch ((c - 2) * 3 + (r - 2)) {
|
||||
case 0:
|
||||
return CtorConvIntrinsic::kMat2x2;
|
||||
return InitConvIntrinsic::kMat2x2;
|
||||
case 1:
|
||||
return CtorConvIntrinsic::kMat2x3;
|
||||
return InitConvIntrinsic::kMat2x3;
|
||||
case 2:
|
||||
return CtorConvIntrinsic::kMat2x4;
|
||||
return InitConvIntrinsic::kMat2x4;
|
||||
case 3:
|
||||
return CtorConvIntrinsic::kMat3x2;
|
||||
return InitConvIntrinsic::kMat3x2;
|
||||
case 4:
|
||||
return CtorConvIntrinsic::kMat3x3;
|
||||
return InitConvIntrinsic::kMat3x3;
|
||||
case 5:
|
||||
return CtorConvIntrinsic::kMat3x4;
|
||||
return InitConvIntrinsic::kMat3x4;
|
||||
case 6:
|
||||
return CtorConvIntrinsic::kMat4x2;
|
||||
return InitConvIntrinsic::kMat4x2;
|
||||
case 7:
|
||||
return CtorConvIntrinsic::kMat4x3;
|
||||
return InitConvIntrinsic::kMat4x3;
|
||||
case 8:
|
||||
return CtorConvIntrinsic::kMat4x4;
|
||||
return InitConvIntrinsic::kMat4x4;
|
||||
}
|
||||
return CtorConvIntrinsic::kNone;
|
||||
return InitConvIntrinsic::kNone;
|
||||
}
|
||||
|
||||
} // namespace tint::resolver
|
||||
|
||||
#endif // SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_
|
||||
#endif // SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_
|
|
@ -0,0 +1,76 @@
|
|||
{{- /*
|
||||
--------------------------------------------------------------------------------
|
||||
Template file for use with tools/src/cmd/gen to generate init_conv_intrinsic.h
|
||||
|
||||
To update the generated file, run:
|
||||
./tools/run gen
|
||||
|
||||
See:
|
||||
* tools/src/cmd/gen for structures used by this template
|
||||
* https://golang.org/pkg/text/template/ for documentation on the template syntax
|
||||
--------------------------------------------------------------------------------
|
||||
*/ -}}
|
||||
|
||||
#ifndef SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_
|
||||
#define SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace tint::resolver {
|
||||
|
||||
/// InitConvIntrinsic is an enumerator of types that have a initializer or converter overload
|
||||
/// declared in the intrinsic table.
|
||||
enum class InitConvIntrinsic {
|
||||
kNone = -1,
|
||||
{{- range Sem.InitializersAndConverters }}
|
||||
k{{Title .Name}},
|
||||
{{- end }}
|
||||
};
|
||||
|
||||
/// @returns the name of the type.
|
||||
const char* str(InitConvIntrinsic i);
|
||||
|
||||
/// @param n the width of the vector
|
||||
/// @return the InitConvIntrinsic for a vector of width `n`
|
||||
inline InitConvIntrinsic VectorInitConvIntrinsic(uint32_t n) {
|
||||
switch (n) {
|
||||
case 2:
|
||||
return InitConvIntrinsic::kVec2;
|
||||
case 3:
|
||||
return InitConvIntrinsic::kVec3;
|
||||
case 4:
|
||||
return InitConvIntrinsic::kVec4;
|
||||
}
|
||||
return InitConvIntrinsic::kNone;
|
||||
}
|
||||
|
||||
/// @param c the number of columns in the matrix
|
||||
/// @param r the number of rows in the matrix
|
||||
/// @return the InitConvIntrinsic for a matrix with `c` columns and `r` rows
|
||||
inline InitConvIntrinsic MatrixInitConvIntrinsic(uint32_t c, uint32_t r) {
|
||||
switch ((c - 2) * 3 + (r - 2)) {
|
||||
case 0:
|
||||
return InitConvIntrinsic::kMat2x2;
|
||||
case 1:
|
||||
return InitConvIntrinsic::kMat2x3;
|
||||
case 2:
|
||||
return InitConvIntrinsic::kMat2x4;
|
||||
case 3:
|
||||
return InitConvIntrinsic::kMat3x2;
|
||||
case 4:
|
||||
return InitConvIntrinsic::kMat3x3;
|
||||
case 5:
|
||||
return InitConvIntrinsic::kMat3x4;
|
||||
case 6:
|
||||
return InitConvIntrinsic::kMat4x2;
|
||||
case 7:
|
||||
return InitConvIntrinsic::kMat4x3;
|
||||
case 8:
|
||||
return InitConvIntrinsic::kMat4x4;
|
||||
}
|
||||
return InitConvIntrinsic::kNone;
|
||||
}
|
||||
|
||||
} // namespace tint::resolver
|
||||
|
||||
#endif // SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_
|
|
@ -33,8 +33,8 @@
|
|||
#include "src/tint/sem/pipeline_stage_set.h"
|
||||
#include "src/tint/sem/sampled_texture.h"
|
||||
#include "src/tint/sem/storage_texture.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
#include "src/tint/utils/math.h"
|
||||
|
@ -338,7 +338,7 @@ using PipelineStage = ast::PipelineStage;
|
|||
enum class OverloadFlag {
|
||||
kIsBuiltin, // The overload is a builtin ('fn')
|
||||
kIsOperator, // The overload is an operator ('op')
|
||||
kIsConstructor, // The overload is a type constructor ('ctor')
|
||||
kIsInitializer, // The overload is a type initializer ('ctor')
|
||||
kIsConverter, // The overload is a type converter ('conv')
|
||||
kSupportsVertexPipeline, // The overload can be used in vertex shaders
|
||||
kSupportsFragmentPipeline, // The overload can be used in fragment shaders
|
||||
|
@ -1003,7 +1003,7 @@ class Impl : public IntrinsicTable {
|
|||
const Source& source,
|
||||
bool is_compound) override;
|
||||
|
||||
CtorOrConv Lookup(CtorConvIntrinsic type,
|
||||
InitOrConv Lookup(InitConvIntrinsic type,
|
||||
const sem::Type* template_arg,
|
||||
utils::VectorRef<const sem::Type*> args,
|
||||
const Source& source) override;
|
||||
|
@ -1110,8 +1110,8 @@ class Impl : public IntrinsicTable {
|
|||
ProgramBuilder& builder;
|
||||
Matchers matchers;
|
||||
std::unordered_map<IntrinsicPrototype, sem::Builtin*, IntrinsicPrototype::Hasher> builtins;
|
||||
std::unordered_map<IntrinsicPrototype, sem::TypeConstructor*, IntrinsicPrototype::Hasher>
|
||||
constructors;
|
||||
std::unordered_map<IntrinsicPrototype, sem::TypeInitializer*, IntrinsicPrototype::Hasher>
|
||||
initializers;
|
||||
std::unordered_map<IntrinsicPrototype, sem::TypeConversion*, IntrinsicPrototype::Hasher>
|
||||
converters;
|
||||
};
|
||||
|
@ -1330,7 +1330,7 @@ IntrinsicTable::BinaryOperator Impl::Lookup(ast::BinaryOp op,
|
|||
};
|
||||
}
|
||||
|
||||
IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type,
|
||||
IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type,
|
||||
const sem::Type* template_arg,
|
||||
utils::VectorRef<const sem::Type*> args,
|
||||
const Source& source) {
|
||||
|
@ -1339,11 +1339,11 @@ IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type,
|
|||
// Generates an error when no overloads match the provided arguments
|
||||
auto on_no_match = [&](utils::VectorRef<Candidate> candidates) {
|
||||
std::stringstream ss;
|
||||
ss << "no matching constructor for " << CallSignature(builder, name, args, template_arg)
|
||||
ss << "no matching initializer for " << CallSignature(builder, name, args, template_arg)
|
||||
<< std::endl;
|
||||
Candidates ctor, conv;
|
||||
for (auto candidate : candidates) {
|
||||
if (candidate.overload->flags.Contains(OverloadFlag::kIsConstructor)) {
|
||||
if (candidate.overload->flags.Contains(OverloadFlag::kIsInitializer)) {
|
||||
ctor.Push(candidate);
|
||||
} else {
|
||||
conv.Push(candidate);
|
||||
|
@ -1351,7 +1351,7 @@ IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type,
|
|||
}
|
||||
if (!ctor.IsEmpty()) {
|
||||
ss << std::endl
|
||||
<< ctor.Length() << " candidate constructor" << (ctor.Length() > 1 ? "s:" : ":")
|
||||
<< ctor.Length() << " candidate initializer" << (ctor.Length() > 1 ? "s:" : ":")
|
||||
<< std::endl;
|
||||
PrintCandidates(ss, ctor, name);
|
||||
}
|
||||
|
@ -1371,14 +1371,14 @@ IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type,
|
|||
}
|
||||
|
||||
// Resolve the intrinsic overload
|
||||
auto match = MatchIntrinsic(kConstructorsAndConverters[static_cast<size_t>(type)], name, args,
|
||||
auto match = MatchIntrinsic(kInitializersAndConverters[static_cast<size_t>(type)], name, args,
|
||||
sem::EvaluationStage::kConstant, templates, on_no_match);
|
||||
if (!match.overload) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// Was this overload a constructor or conversion?
|
||||
if (match.overload->flags.Contains(OverloadFlag::kIsConstructor)) {
|
||||
// Was this overload a initializer or conversion?
|
||||
if (match.overload->flags.Contains(OverloadFlag::kIsInitializer)) {
|
||||
utils::Vector<const sem::Parameter*, 8> params;
|
||||
params.Reserve(match.parameters.Length());
|
||||
for (auto& p : match.parameters) {
|
||||
|
@ -1388,11 +1388,11 @@ IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type,
|
|||
}
|
||||
auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant
|
||||
: sem::EvaluationStage::kRuntime;
|
||||
auto* target = utils::GetOrCreate(constructors, match, [&]() {
|
||||
return builder.create<sem::TypeConstructor>(match.return_type, std::move(params),
|
||||
auto* target = utils::GetOrCreate(initializers, match, [&]() {
|
||||
return builder.create<sem::TypeInitializer>(match.return_type, std::move(params),
|
||||
eval_stage);
|
||||
});
|
||||
return CtorOrConv{target, match.overload->const_eval_fn};
|
||||
return InitOrConv{target, match.overload->const_eval_fn};
|
||||
}
|
||||
|
||||
// Conversion.
|
||||
|
@ -1404,7 +1404,7 @@ IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type,
|
|||
: sem::EvaluationStage::kRuntime;
|
||||
return builder.create<sem::TypeConversion>(match.return_type, param, eval_stage);
|
||||
});
|
||||
return CtorOrConv{target, match.overload->const_eval_fn};
|
||||
return InitOrConv{target, match.overload->const_eval_fn};
|
||||
}
|
||||
|
||||
IntrinsicPrototype Impl::MatchIntrinsic(const IntrinsicInfo& intrinsic,
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "src/tint/ast/binary_expression.h"
|
||||
#include "src/tint/ast/unary_op.h"
|
||||
#include "src/tint/resolver/const_eval.h"
|
||||
#include "src/tint/resolver/ctor_conv_intrinsic.h"
|
||||
#include "src/tint/resolver/init_conv_intrinsic.h"
|
||||
#include "src/tint/sem/builtin.h"
|
||||
#include "src/tint/utils/vector.h"
|
||||
|
||||
|
@ -72,9 +72,9 @@ class IntrinsicTable {
|
|||
ConstEval::Function const_eval_fn = nullptr;
|
||||
};
|
||||
|
||||
/// CtorOrConv describes a resolved type constructor or type conversion
|
||||
struct CtorOrConv {
|
||||
/// The result type of the type constructor or type conversion
|
||||
/// InitOrConv describes a resolved type initializer or type conversion
|
||||
struct InitOrConv {
|
||||
/// The result type of the type initializer or type conversion
|
||||
const sem::CallTarget* target = nullptr;
|
||||
/// The constant evaluation function
|
||||
ConstEval::Function const_eval_fn = nullptr;
|
||||
|
@ -121,14 +121,14 @@ class IntrinsicTable {
|
|||
const Source& source,
|
||||
bool is_compound) = 0;
|
||||
|
||||
/// Lookup looks for the type constructor or conversion overload for the given
|
||||
/// CtorConvIntrinsic.
|
||||
/// Lookup looks for the type initializer or conversion overload for the given
|
||||
/// InitConvIntrinsic.
|
||||
/// @param type the type being constructed or converted
|
||||
/// @param template_arg the optional template argument
|
||||
/// @param args the argument types passed to the constructor / conversion call
|
||||
/// @param args the argument types passed to the initializer / conversion call
|
||||
/// @param source the source of the call
|
||||
/// @return a sem::TypeConstructor, sem::TypeConversion or nullptr if nothing matched
|
||||
virtual CtorOrConv Lookup(CtorConvIntrinsic type,
|
||||
/// @return a sem::TypeInitializer, sem::TypeConversion or nullptr if nothing matched
|
||||
virtual InitOrConv Lookup(InitConvIntrinsic type,
|
||||
const sem::Type* template_arg,
|
||||
utils::VectorRef<const sem::Type*> args,
|
||||
const Source& source) = 0;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -160,8 +160,8 @@ constexpr IntrinsicInfo kBinaryOperators[] = {
|
|||
constexpr uint8_t kBinaryOperator{{ template "ExpandName" $o.Name}} = {{$i}};
|
||||
{{- end }}
|
||||
|
||||
constexpr IntrinsicInfo kConstructorsAndConverters[] = {
|
||||
{{- range $i, $o := .ConstructorsAndConverters }}
|
||||
constexpr IntrinsicInfo kInitializersAndConverters[] = {
|
||||
{{- range $i, $o := .InitializersAndConverters }}
|
||||
{
|
||||
/* [{{$i}}] */
|
||||
{{- range $o.OverloadDescriptions }}
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#include "src/tint/sem/sampled_texture.h"
|
||||
#include "src/tint/sem/storage_texture.h"
|
||||
#include "src/tint/sem/test_helper.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
@ -745,14 +745,14 @@ TEST_F(IntrinsicTableTest, MismatchCompoundOp) {
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeConstructorImplicit) {
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) {
|
||||
auto* i32 = create<sem::I32>();
|
||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||
auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32},
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32},
|
||||
Source{{12, 34}});
|
||||
ASSERT_NE(result.target, nullptr);
|
||||
EXPECT_EQ(result.target->ReturnType(), vec3_i32);
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeConstructor>());
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeInitializer>());
|
||||
ASSERT_EQ(result.target->Parameters().Length(), 3u);
|
||||
EXPECT_EQ(result.target->Parameters()[0]->Type(), i32);
|
||||
EXPECT_EQ(result.target->Parameters()[1]->Type(), i32);
|
||||
|
@ -760,14 +760,14 @@ TEST_F(IntrinsicTableTest, MatchTypeConstructorImplicit) {
|
|||
EXPECT_NE(result.const_eval_fn, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeConstructorExplicit) {
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) {
|
||||
auto* i32 = create<sem::I32>();
|
||||
auto* vec3_i32 = create<sem::Vector>(i32, 3u);
|
||||
auto result = table->Lookup(CtorConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32},
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32},
|
||||
Source{{12, 34}});
|
||||
ASSERT_NE(result.target, nullptr);
|
||||
EXPECT_EQ(result.target->ReturnType(), vec3_i32);
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeConstructor>());
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeInitializer>());
|
||||
ASSERT_EQ(result.target->Parameters().Length(), 3u);
|
||||
EXPECT_EQ(result.target->Parameters()[0]->Type(), i32);
|
||||
EXPECT_EQ(result.target->Parameters()[1]->Type(), i32);
|
||||
|
@ -775,16 +775,16 @@ TEST_F(IntrinsicTableTest, MatchTypeConstructorExplicit) {
|
|||
EXPECT_NE(result.const_eval_fn, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MismatchTypeConstructorImplicit) {
|
||||
TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) {
|
||||
auto* i32 = create<sem::I32>();
|
||||
auto* f32 = create<sem::F32>();
|
||||
auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32},
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32},
|
||||
Source{{12, 34}});
|
||||
ASSERT_EQ(result.target, nullptr);
|
||||
EXPECT_EQ(Diagnostics().str(),
|
||||
R"(12:34 error: no matching constructor for vec3(i32, f32, i32)
|
||||
R"(12:34 error: no matching initializer for vec3(i32, f32, i32)
|
||||
|
||||
6 candidate constructors:
|
||||
6 candidate initializers:
|
||||
vec3(x: T, y: T, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
|
@ -801,16 +801,16 @@ TEST_F(IntrinsicTableTest, MismatchTypeConstructorImplicit) {
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MismatchTypeConstructorExplicit) {
|
||||
TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
|
||||
auto* i32 = create<sem::I32>();
|
||||
auto* f32 = create<sem::F32>();
|
||||
auto result = table->Lookup(CtorConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32},
|
||||
auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32},
|
||||
Source{{12, 34}});
|
||||
ASSERT_EQ(result.target, nullptr);
|
||||
EXPECT_EQ(Diagnostics().str(),
|
||||
R"(12:34 error: no matching constructor for vec3<i32>(i32, f32, i32)
|
||||
R"(12:34 error: no matching initializer for vec3<i32>(i32, f32, i32)
|
||||
|
||||
6 candidate constructors:
|
||||
6 candidate initializers:
|
||||
vec3(x: T, y: T, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
|
@ -827,16 +827,16 @@ TEST_F(IntrinsicTableTest, MismatchTypeConstructorExplicit) {
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, MatchTypeConstructorImplicitMatFromVec) {
|
||||
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
|
||||
auto* af = create<sem::AbstractFloat>();
|
||||
auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u);
|
||||
auto* vec2_af = create<sem::Vector>(af, 2u);
|
||||
auto* mat2x2_af = create<sem::Matrix>(vec2_af, 2u);
|
||||
auto result = table->Lookup(CtorConvIntrinsic::kMat2x2, nullptr,
|
||||
auto result = table->Lookup(InitConvIntrinsic::kMat2x2, nullptr,
|
||||
utils::Vector{vec2_ai, vec2_ai}, Source{{12, 34}});
|
||||
ASSERT_NE(result.target, nullptr);
|
||||
EXPECT_TYPE(result.target->ReturnType(), mat2x2_af);
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeConstructor>());
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeInitializer>());
|
||||
ASSERT_EQ(result.target->Parameters().Length(), 2u);
|
||||
EXPECT_TYPE(result.target->Parameters()[0]->Type(), vec2_af);
|
||||
EXPECT_TYPE(result.target->Parameters()[1]->Type(), vec2_af);
|
||||
|
@ -849,7 +849,7 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion) {
|
|||
auto* f32 = create<sem::F32>();
|
||||
auto* vec3_f32 = create<sem::Vector>(f32, 3u);
|
||||
auto result =
|
||||
table->Lookup(CtorConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32}, Source{{12, 34}});
|
||||
table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32}, Source{{12, 34}});
|
||||
ASSERT_NE(result.target, nullptr);
|
||||
EXPECT_EQ(result.target->ReturnType(), vec3_i32);
|
||||
EXPECT_TRUE(result.target->Is<sem::TypeConversion>());
|
||||
|
@ -861,12 +861,12 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
|
|||
auto* arr = create<sem::Array>(create<sem::U32>(), sem::RuntimeArrayCount{}, 4u, 4u, 4u, 4u);
|
||||
auto* f32 = create<sem::F32>();
|
||||
auto result =
|
||||
table->Lookup(CtorConvIntrinsic::kVec3, f32, utils::Vector{arr}, Source{{12, 34}});
|
||||
table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr}, Source{{12, 34}});
|
||||
ASSERT_EQ(result.target, nullptr);
|
||||
EXPECT_EQ(Diagnostics().str(),
|
||||
R"(12:34 error: no matching constructor for vec3<f32>(array<u32>)
|
||||
R"(12:34 error: no matching initializer for vec3<f32>(array<u32>)
|
||||
|
||||
6 candidate constructors:
|
||||
6 candidate initializers:
|
||||
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool
|
||||
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
|
||||
vec3() -> vec3<T> where: T is f32, f16, i32, u32 or bool
|
||||
|
@ -900,7 +900,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) {
|
|||
// The first should win overload resolution.
|
||||
auto* ai = create<sem::AbstractInt>();
|
||||
auto* i32 = create<sem::I32>();
|
||||
auto result = table->Lookup(CtorConvIntrinsic::kI32, nullptr, utils::Vector{ai}, Source{});
|
||||
auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai}, Source{});
|
||||
ASSERT_NE(result.target, nullptr);
|
||||
EXPECT_EQ(result.target->ReturnType(), i32);
|
||||
EXPECT_EQ(result.target->Parameters().Length(), 1u);
|
||||
|
|
|
@ -1215,7 +1215,7 @@ namespace materialize_abstract_numeric_to_unrelated_type {
|
|||
|
||||
using MaterializeAbstractNumericToUnrelatedType = resolver::ResolverTest;
|
||||
|
||||
TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarCtor) {
|
||||
TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarInit) {
|
||||
Structure("S", utils::Vector{Member("a", ty.i32())});
|
||||
WrapInFunction(Decl(Var("v", ty.type_name("S"), Expr(Source{{12, 34}}, 1_a))));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1224,7 +1224,7 @@ TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarCtor) {
|
|||
testing::HasSubstr("error: cannot convert value of type 'abstract-int' to type 'S'"));
|
||||
}
|
||||
|
||||
TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructLetCtor) {
|
||||
TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructLetInit) {
|
||||
Structure("S", utils::Vector{Member("a", ty.i32())});
|
||||
WrapInFunction(Decl(Let("v", ty.type_name("S"), Expr(Source{{12, 34}}, 1_a))));
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
|
|
@ -77,8 +77,8 @@
|
|||
#include "src/tint/sem/storage_texture.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/sem/while_statement.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
|
@ -358,12 +358,12 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!v->constructor) {
|
||||
if (!v->initializer) {
|
||||
AddError("'let' declaration must have an initializer", v->source);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* rhs = Materialize(Expression(v->constructor), ty);
|
||||
auto* rhs = Materialize(Expression(v->initializer), ty);
|
||||
if (!rhs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
|
|||
/* constant_value */ nullptr);
|
||||
}
|
||||
|
||||
sem->SetConstructor(rhs);
|
||||
sem->SetInitializer(rhs);
|
||||
builder_->Sem().Add(v, sem);
|
||||
return sem;
|
||||
}
|
||||
|
@ -414,11 +414,11 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
|
|||
|
||||
const sem::Expression* rhs = nullptr;
|
||||
|
||||
// Does the variable have a constructor?
|
||||
if (v->constructor) {
|
||||
// Does the variable have a initializer?
|
||||
if (v->initializer) {
|
||||
ExprEvalStageConstraint constraint{sem::EvaluationStage::kOverride, "override initializer"};
|
||||
TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint);
|
||||
rhs = Materialize(Expression(v->constructor), ty);
|
||||
rhs = Materialize(Expression(v->initializer), ty);
|
||||
if (!rhs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
|
|||
auto* sem = builder_->create<sem::GlobalVariable>(
|
||||
v, ty, sem::EvaluationStage::kOverride, ast::AddressSpace::kNone, ast::Access::kUndefined,
|
||||
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
|
||||
sem->SetConstructor(rhs);
|
||||
sem->SetInitializer(rhs);
|
||||
|
||||
if (auto* id_attr = ast::GetAttribute<ast::IdAttribute>(v->attributes)) {
|
||||
ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "@id"};
|
||||
|
@ -496,7 +496,7 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!c->constructor) {
|
||||
if (!c->initializer) {
|
||||
AddError("'const' declaration must have an initializer", c->source);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
|
|||
{
|
||||
ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "const initializer"};
|
||||
TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint);
|
||||
rhs = Expression(c->constructor);
|
||||
rhs = Expression(c->initializer);
|
||||
if (!rhs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
|
|||
c, ty, sem::EvaluationStage::kConstant, ast::AddressSpace::kNone,
|
||||
ast::Access::kUndefined, current_statement_, value));
|
||||
|
||||
sem->SetConstructor(rhs);
|
||||
sem->SetInitializer(rhs);
|
||||
builder_->Sem().Add(c, sem);
|
||||
return sem;
|
||||
}
|
||||
|
@ -558,15 +558,15 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
|||
|
||||
const sem::Expression* rhs = nullptr;
|
||||
|
||||
// Does the variable have a constructor?
|
||||
if (var->constructor) {
|
||||
// Does the variable have a initializer?
|
||||
if (var->initializer) {
|
||||
ExprEvalStageConstraint constraint{
|
||||
is_global ? sem::EvaluationStage::kOverride : sem::EvaluationStage::kRuntime,
|
||||
"var initializer",
|
||||
};
|
||||
TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint);
|
||||
|
||||
rhs = Materialize(Expression(var->constructor), storage_ty);
|
||||
rhs = Materialize(Expression(var->initializer), storage_ty);
|
||||
if (!rhs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
|||
/* constant_value */ nullptr);
|
||||
}
|
||||
|
||||
sem->SetConstructor(rhs);
|
||||
sem->SetInitializer(rhs);
|
||||
builder_->Sem().Add(var, sem);
|
||||
return sem;
|
||||
}
|
||||
|
@ -1750,7 +1750,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
// A CallExpression can resolve to one of:
|
||||
// * A function call.
|
||||
// * A builtin call.
|
||||
// * A type constructor.
|
||||
// * A type initializer.
|
||||
// * A type conversion.
|
||||
|
||||
// Resolve all of the arguments, their types and the set of behaviors.
|
||||
|
@ -1773,9 +1773,9 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
bool has_side_effects =
|
||||
std::any_of(args.begin(), args.end(), [](auto* e) { return e->HasSideEffects(); });
|
||||
|
||||
// ct_ctor_or_conv is a helper for building either a sem::TypeConstructor or sem::TypeConversion
|
||||
// call for a CtorConvIntrinsic with an optional template argument type.
|
||||
auto ct_ctor_or_conv = [&](CtorConvIntrinsic ty, const sem::Type* template_arg) -> sem::Call* {
|
||||
// ct_init_or_conv is a helper for building either a sem::TypeInitializer or sem::TypeConversion
|
||||
// call for a InitConvIntrinsic with an optional template argument type.
|
||||
auto ct_init_or_conv = [&](InitConvIntrinsic ty, const sem::Type* template_arg) -> sem::Call* {
|
||||
auto arg_tys = utils::Transform(args, [](auto* arg) { return arg->Type(); });
|
||||
auto ctor_or_conv = intrinsic_table_->Lookup(ty, template_arg, arg_tys, expr->source);
|
||||
if (!ctor_or_conv.target) {
|
||||
|
@ -1802,9 +1802,9 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
current_statement_, value, has_side_effects);
|
||||
};
|
||||
|
||||
// arr_or_str_ctor is a helper for building a sem::TypeConstructor for an array or structure
|
||||
// constructor call target.
|
||||
auto arr_or_str_ctor = [&](const sem::Type* ty,
|
||||
// arr_or_str_init is a helper for building a sem::TypeInitializer for an array or structure
|
||||
// initializer call target.
|
||||
auto arr_or_str_init = [&](const sem::Type* ty,
|
||||
const sem::CallTarget* call_target) -> sem::Call* {
|
||||
if (!MaybeMaterializeArguments(args, call_target)) {
|
||||
return nullptr;
|
||||
|
@ -1813,7 +1813,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
auto stage = args_stage; // The evaluation stage of the call
|
||||
const sem::Constant* value = nullptr; // The constant value for the call
|
||||
if (stage == sem::EvaluationStage::kConstant) {
|
||||
if (auto r = const_eval_.ArrayOrStructCtor(ty, args)) {
|
||||
if (auto r = const_eval_.ArrayOrStructInit(ty, args)) {
|
||||
value = r.Get();
|
||||
} else {
|
||||
return nullptr;
|
||||
|
@ -1822,7 +1822,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
// Constant evaluation failed.
|
||||
// Can happen for expressions that will fail validation (later).
|
||||
// Use the kRuntime EvaluationStage, as kConstant will trigger an assertion in the
|
||||
// sem::Expression constructor, which checks that kConstant is paired with a
|
||||
// sem::Expression initializer, which checks that kConstant is paired with a
|
||||
// constant value.
|
||||
stage = sem::EvaluationStage::kRuntime;
|
||||
}
|
||||
|
@ -1832,26 +1832,26 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
current_statement_, value, has_side_effects);
|
||||
};
|
||||
|
||||
// ty_ctor_or_conv is a helper for building either a sem::TypeConstructor or sem::TypeConversion
|
||||
// ty_init_or_conv is a helper for building either a sem::TypeInitializer or sem::TypeConversion
|
||||
// call for the given semantic type.
|
||||
auto ty_ctor_or_conv = [&](const sem::Type* ty) {
|
||||
auto ty_init_or_conv = [&](const sem::Type* ty) {
|
||||
return Switch(
|
||||
ty, //
|
||||
[&](const sem::Vector* v) {
|
||||
return ct_ctor_or_conv(VectorCtorConvIntrinsic(v->Width()), v->type());
|
||||
return ct_init_or_conv(VectorInitConvIntrinsic(v->Width()), v->type());
|
||||
},
|
||||
[&](const sem::Matrix* m) {
|
||||
return ct_ctor_or_conv(MatrixCtorConvIntrinsic(m->columns(), m->rows()), m->type());
|
||||
return ct_init_or_conv(MatrixInitConvIntrinsic(m->columns(), m->rows()), m->type());
|
||||
},
|
||||
[&](const sem::I32*) { return ct_ctor_or_conv(CtorConvIntrinsic::kI32, nullptr); },
|
||||
[&](const sem::U32*) { return ct_ctor_or_conv(CtorConvIntrinsic::kU32, nullptr); },
|
||||
[&](const sem::F16*) { return ct_ctor_or_conv(CtorConvIntrinsic::kF16, nullptr); },
|
||||
[&](const sem::F32*) { return ct_ctor_or_conv(CtorConvIntrinsic::kF32, nullptr); },
|
||||
[&](const sem::Bool*) { return ct_ctor_or_conv(CtorConvIntrinsic::kBool, nullptr); },
|
||||
[&](const sem::I32*) { return ct_init_or_conv(InitConvIntrinsic::kI32, nullptr); },
|
||||
[&](const sem::U32*) { return ct_init_or_conv(InitConvIntrinsic::kU32, nullptr); },
|
||||
[&](const sem::F16*) { return ct_init_or_conv(InitConvIntrinsic::kF16, nullptr); },
|
||||
[&](const sem::F32*) { return ct_init_or_conv(InitConvIntrinsic::kF32, nullptr); },
|
||||
[&](const sem::Bool*) { return ct_init_or_conv(InitConvIntrinsic::kBool, nullptr); },
|
||||
[&](const sem::Array* arr) -> sem::Call* {
|
||||
auto* call_target = utils::GetOrCreate(
|
||||
array_ctors_, ArrayConstructorSig{{arr, args.Length(), args_stage}},
|
||||
[&]() -> sem::TypeConstructor* {
|
||||
array_inits_, ArrayInitializerSig{{arr, args.Length(), args_stage}},
|
||||
[&]() -> sem::TypeInitializer* {
|
||||
auto params = utils::Transform(args, [&](auto, size_t i) {
|
||||
return builder_->create<sem::Parameter>(
|
||||
nullptr, // declaration
|
||||
|
@ -1860,25 +1860,25 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
ast::AddressSpace::kNone, // address_space
|
||||
ast::Access::kUndefined);
|
||||
});
|
||||
return builder_->create<sem::TypeConstructor>(arr, std::move(params),
|
||||
return builder_->create<sem::TypeInitializer>(arr, std::move(params),
|
||||
args_stage);
|
||||
});
|
||||
|
||||
auto* call = arr_or_str_ctor(arr, call_target);
|
||||
auto* call = arr_or_str_init(arr, call_target);
|
||||
if (!call) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Validation must occur after argument materialization in arr_or_str_ctor().
|
||||
if (!validator_.ArrayConstructor(expr, arr)) {
|
||||
// Validation must occur after argument materialization in arr_or_str_init().
|
||||
if (!validator_.ArrayInitializer(expr, arr)) {
|
||||
return nullptr;
|
||||
}
|
||||
return call;
|
||||
},
|
||||
[&](const sem::Struct* str) -> sem::Call* {
|
||||
auto* call_target = utils::GetOrCreate(
|
||||
struct_ctors_, StructConstructorSig{{str, args.Length(), args_stage}},
|
||||
[&]() -> sem::TypeConstructor* {
|
||||
struct_inits_, StructInitializerSig{{str, args.Length(), args_stage}},
|
||||
[&]() -> sem::TypeInitializer* {
|
||||
utils::Vector<const sem::Parameter*, 8> params;
|
||||
params.Resize(std::min(args.Length(), str->Members().size()));
|
||||
for (size_t i = 0, n = params.Length(); i < n; i++) {
|
||||
|
@ -1889,17 +1889,17 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
ast::AddressSpace::kNone, // address_space
|
||||
ast::Access::kUndefined); // access
|
||||
}
|
||||
return builder_->create<sem::TypeConstructor>(str, std::move(params),
|
||||
return builder_->create<sem::TypeInitializer>(str, std::move(params),
|
||||
args_stage);
|
||||
});
|
||||
|
||||
auto* call = arr_or_str_ctor(str, call_target);
|
||||
auto* call = arr_or_str_init(str, call_target);
|
||||
if (!call) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Validation must occur after argument materialization in arr_or_str_ctor().
|
||||
if (!validator_.StructureConstructor(expr, str)) {
|
||||
// Validation must occur after argument materialization in arr_or_str_init().
|
||||
if (!validator_.StructureInitializer(expr, str)) {
|
||||
return nullptr;
|
||||
}
|
||||
return call;
|
||||
|
@ -1914,7 +1914,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
sem::Call* call = nullptr;
|
||||
if (expr->target.type) {
|
||||
// ast::CallExpression has an ast::Type as the target.
|
||||
// This call is either a type constructor or type conversion.
|
||||
// This call is either a type initializer or type conversion.
|
||||
call = Switch(
|
||||
expr->target.type,
|
||||
[&](const ast::Vector* v) -> sem::Call* {
|
||||
|
@ -1927,7 +1927,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (auto* c = ct_ctor_or_conv(VectorCtorConvIntrinsic(v->width), template_arg)) {
|
||||
if (auto* c = ct_init_or_conv(VectorInitConvIntrinsic(v->width), template_arg)) {
|
||||
builder_->Sem().Add(expr->target.type, c->Target()->ReturnType());
|
||||
return c;
|
||||
}
|
||||
|
@ -1943,7 +1943,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (auto* c = ct_ctor_or_conv(MatrixCtorConvIntrinsic(m->columns, m->rows),
|
||||
if (auto* c = ct_init_or_conv(MatrixInitConvIntrinsic(m->columns, m->rows),
|
||||
template_arg)) {
|
||||
builder_->Sem().Add(expr->target.type, c->Target()->ReturnType());
|
||||
return c;
|
||||
|
@ -1971,14 +1971,14 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
return nullptr;
|
||||
}
|
||||
// Note: validation later will detect any mismatches between explicit array
|
||||
// size and number of constructor expressions.
|
||||
// size and number of initializer expressions.
|
||||
} else {
|
||||
auto arg_tys =
|
||||
utils::Transform(args, [](auto* arg) { return arg->Type()->UnwrapRef(); });
|
||||
el_ty = sem::Type::Common(arg_tys);
|
||||
if (!el_ty) {
|
||||
AddError(
|
||||
"cannot infer common array element type from constructor arguments",
|
||||
"cannot infer common array element type from initializer arguments",
|
||||
expr->source);
|
||||
std::unordered_set<const sem::Type*> types;
|
||||
for (size_t i = 0; i < args.Length(); i++) {
|
||||
|
@ -2004,12 +2004,12 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
}
|
||||
builder_->Sem().Add(a, arr);
|
||||
|
||||
return ty_ctor_or_conv(arr);
|
||||
return ty_init_or_conv(arr);
|
||||
},
|
||||
[&](const ast::Type* ast) -> sem::Call* {
|
||||
// Handler for AST types that do not have an optional element type.
|
||||
if (auto* ty = Type(ast)) {
|
||||
return ty_ctor_or_conv(ty);
|
||||
return ty_init_or_conv(ty);
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
|
@ -2022,18 +2022,18 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
});
|
||||
} else {
|
||||
// ast::CallExpression has an ast::IdentifierExpression as the target.
|
||||
// This call is either a function call, builtin call, type constructor or type conversion.
|
||||
// This call is either a function call, builtin call, type initializer or type conversion.
|
||||
auto* ident = expr->target.name;
|
||||
Mark(ident);
|
||||
auto* resolved = sem_.ResolvedSymbol(ident);
|
||||
call = Switch<sem::Call*>(
|
||||
resolved, //
|
||||
[&](sem::Type* ty) {
|
||||
// A type constructor or conversions.
|
||||
// A type initializer or conversions.
|
||||
// Note: Unlike the code path where we're resolving the call target from an
|
||||
// ast::Type, all types must already have the element type explicitly specified, so
|
||||
// there's no need to infer element types.
|
||||
return ty_ctor_or_conv(ty);
|
||||
return ty_init_or_conv(ty);
|
||||
},
|
||||
[&](sem::Function* func) { return FunctionCall(expr, func, args, arg_behaviors); },
|
||||
[&](sem::Variable* var) {
|
||||
|
@ -2349,7 +2349,7 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) {
|
|||
}
|
||||
|
||||
if (resolved->Is<sem::Type>()) {
|
||||
AddError("missing '(' for type constructor or cast", expr->source.End());
|
||||
AddError("missing '(' for type initializer or cast", expr->source.End());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -3170,7 +3170,7 @@ sem::Statement* Resolver::VariableDeclStatement(const ast::VariableDeclStatement
|
|||
|
||||
current_compound_statement_->AddDecl(variable->As<sem::LocalVariable>());
|
||||
|
||||
if (auto* ctor = variable->Constructor()) {
|
||||
if (auto* ctor = variable->Initializer()) {
|
||||
sem->Behaviors() = ctor->Behaviors();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class LoopStatement;
|
|||
class Statement;
|
||||
class StructMember;
|
||||
class SwitchStatement;
|
||||
class TypeConstructor;
|
||||
class TypeInitializer;
|
||||
class WhileStatement;
|
||||
} // namespace tint::sem
|
||||
|
||||
|
@ -400,15 +400,15 @@ class Resolver {
|
|||
/// @returns true if the symbol is the name of a builtin function.
|
||||
bool IsBuiltin(Symbol) const;
|
||||
|
||||
// ArrayConstructorSig represents a unique array constructor signature.
|
||||
// ArrayInitializerSig represents a unique array initializer signature.
|
||||
// It is a tuple of the array type, number of arguments provided and earliest evaluation stage.
|
||||
using ArrayConstructorSig =
|
||||
using ArrayInitializerSig =
|
||||
utils::UnorderedKeyWrapper<std::tuple<const sem::Array*, size_t, sem::EvaluationStage>>;
|
||||
|
||||
// StructConstructorSig represents a unique structure constructor signature.
|
||||
// StructInitializerSig represents a unique structure initializer signature.
|
||||
// It is a tuple of the structure type, number of arguments provided and earliest evaluation
|
||||
// stage.
|
||||
using StructConstructorSig =
|
||||
using StructInitializerSig =
|
||||
utils::UnorderedKeyWrapper<std::tuple<const sem::Struct*, size_t, sem::EvaluationStage>>;
|
||||
|
||||
/// ExprEvalStageConstraint describes a constraint on when expressions can be evaluated.
|
||||
|
@ -433,8 +433,8 @@ class Resolver {
|
|||
utils::Bitset<0> marked_;
|
||||
ExprEvalStageConstraint expr_eval_stage_constraint_;
|
||||
std::unordered_map<OverrideId, const sem::Variable*> override_ids_;
|
||||
std::unordered_map<ArrayConstructorSig, sem::CallTarget*> array_ctors_;
|
||||
std::unordered_map<StructConstructorSig, sem::CallTarget*> struct_ctors_;
|
||||
std::unordered_map<ArrayInitializerSig, sem::CallTarget*> array_inits_;
|
||||
std::unordered_map<StructInitializerSig, sem::CallTarget*> struct_inits_;
|
||||
sem::Function* current_function_ = nullptr;
|
||||
sem::Statement* current_statement_ = nullptr;
|
||||
sem::CompoundStatement* current_compound_statement_ = nullptr;
|
||||
|
|
|
@ -287,7 +287,7 @@ TEST_F(ResolverTest, Stmt_Call) {
|
|||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||
auto* var = Var("my_var", ty.i32(), Expr(2_i));
|
||||
auto* init = var->constructor;
|
||||
auto* init = var->initializer;
|
||||
|
||||
auto* decl = Decl(var);
|
||||
WrapInFunction(decl);
|
||||
|
@ -301,7 +301,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) {
|
|||
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||
auto* my_int = Alias("MyInt", ty.i32());
|
||||
auto* var = Var("my_var", ty.Of(my_int), Expr(2_i));
|
||||
auto* init = var->constructor;
|
||||
auto* init = var->initializer;
|
||||
|
||||
auto* decl = Decl(var);
|
||||
WrapInFunction(decl);
|
||||
|
@ -335,24 +335,24 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
|||
|
||||
// Declare i32 "foo" inside a block
|
||||
auto* foo_i32 = Var("foo", ty.i32(), Expr(2_i));
|
||||
auto* foo_i32_init = foo_i32->constructor;
|
||||
auto* foo_i32_init = foo_i32->initializer;
|
||||
auto* foo_i32_decl = Decl(foo_i32);
|
||||
|
||||
// Reference "foo" inside the block
|
||||
auto* bar_i32 = Var("bar", ty.i32(), Expr("foo"));
|
||||
auto* bar_i32_init = bar_i32->constructor;
|
||||
auto* bar_i32_init = bar_i32->initializer;
|
||||
auto* bar_i32_decl = Decl(bar_i32);
|
||||
|
||||
auto* inner = Block(foo_i32_decl, bar_i32_decl);
|
||||
|
||||
// Declare f32 "foo" at function scope
|
||||
auto* foo_f32 = Var("foo", ty.f32(), Expr(2_f));
|
||||
auto* foo_f32_init = foo_f32->constructor;
|
||||
auto* foo_f32_init = foo_f32->initializer;
|
||||
auto* foo_f32_decl = Decl(foo_f32);
|
||||
|
||||
// Reference "foo" at function scope
|
||||
auto* bar_f32 = Var("bar", ty.f32(), Expr("foo"));
|
||||
auto* bar_f32_init = bar_f32->constructor;
|
||||
auto* bar_f32_init = bar_f32->initializer;
|
||||
auto* bar_f32_decl = Decl(bar_f32);
|
||||
|
||||
Func("func", utils::Empty, ty.void_(), utils::Vector{inner, foo_f32_decl, bar_f32_decl});
|
||||
|
@ -370,12 +370,12 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
|||
EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl);
|
||||
EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl);
|
||||
EXPECT_EQ(StmtOf(bar_f32_init), bar_f32_decl);
|
||||
EXPECT_TRUE(CheckVarUsers(foo_i32, utils::Vector{bar_i32->constructor}));
|
||||
EXPECT_TRUE(CheckVarUsers(foo_f32, utils::Vector{bar_f32->constructor}));
|
||||
ASSERT_NE(VarOf(bar_i32->constructor), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_i32->constructor)->Declaration(), foo_i32);
|
||||
ASSERT_NE(VarOf(bar_f32->constructor), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_f32->constructor)->Declaration(), foo_f32);
|
||||
EXPECT_TRUE(CheckVarUsers(foo_i32, utils::Vector{bar_i32->initializer}));
|
||||
EXPECT_TRUE(CheckVarUsers(foo_f32, utils::Vector{bar_f32->initializer}));
|
||||
ASSERT_NE(VarOf(bar_i32->initializer), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_i32->initializer)->Declaration(), foo_i32);
|
||||
ASSERT_NE(VarOf(bar_f32->initializer), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_f32->initializer)->Declaration(), foo_f32);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||
|
@ -389,18 +389,18 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
|||
|
||||
// Declare i32 "foo" inside a function
|
||||
auto* fn_i32 = Var("foo", ty.i32(), Expr(2_i));
|
||||
auto* fn_i32_init = fn_i32->constructor;
|
||||
auto* fn_i32_init = fn_i32->initializer;
|
||||
auto* fn_i32_decl = Decl(fn_i32);
|
||||
Func("func_i32", utils::Empty, ty.void_(), utils::Vector{fn_i32_decl});
|
||||
|
||||
// Declare f32 "foo" at module scope
|
||||
auto* mod_f32 = Var("foo", ty.f32(), ast::AddressSpace::kPrivate, Expr(2_f));
|
||||
auto* mod_init = mod_f32->constructor;
|
||||
auto* mod_init = mod_f32->initializer;
|
||||
AST().AddGlobalVariable(mod_f32);
|
||||
|
||||
// Reference "foo" in another function
|
||||
auto* fn_f32 = Var("bar", ty.f32(), Expr("foo"));
|
||||
auto* fn_f32_init = fn_f32->constructor;
|
||||
auto* fn_f32_init = fn_f32->initializer;
|
||||
auto* fn_f32_decl = Decl(fn_f32);
|
||||
Func("func_f32", utils::Empty, ty.void_(), utils::Vector{fn_f32_decl});
|
||||
|
||||
|
@ -415,9 +415,9 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
|||
EXPECT_EQ(StmtOf(mod_init), nullptr);
|
||||
EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl);
|
||||
EXPECT_TRUE(CheckVarUsers(fn_i32, utils::Empty));
|
||||
EXPECT_TRUE(CheckVarUsers(mod_f32, utils::Vector{fn_f32->constructor}));
|
||||
ASSERT_NE(VarOf(fn_f32->constructor), nullptr);
|
||||
EXPECT_EQ(VarOf(fn_f32->constructor)->Declaration(), mod_f32);
|
||||
EXPECT_TRUE(CheckVarUsers(mod_f32, utils::Vector{fn_f32->initializer}));
|
||||
ASSERT_NE(VarOf(fn_f32->initializer), nullptr);
|
||||
EXPECT_EQ(VarOf(fn_f32->initializer)->Declaration(), mod_f32);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
|
||||
|
@ -595,7 +595,7 @@ TEST_F(ResolverTest, Expr_Cast) {
|
|||
EXPECT_TRUE(TypeOf(cast)->Is<sem::F32>());
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_Constructor_Scalar) {
|
||||
TEST_F(ResolverTest, Expr_Initializer_Scalar) {
|
||||
auto* s = Expr(1_f);
|
||||
WrapInFunction(s);
|
||||
|
||||
|
@ -605,7 +605,7 @@ TEST_F(ResolverTest, Expr_Constructor_Scalar) {
|
|||
EXPECT_TRUE(TypeOf(s)->Is<sem::F32>());
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
|
||||
TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) {
|
||||
auto* tc = vec2<f32>(1_f, 1_f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
|
@ -617,7 +617,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
|
|||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
|
||||
TEST_F(ResolverTest, Expr_Initializer_Type_Vec3) {
|
||||
auto* tc = vec3<f32>(1_f, 1_f, 1_f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
|
@ -629,7 +629,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
|
|||
EXPECT_EQ(TypeOf(tc)->As<sem::Vector>()->Width(), 3u);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) {
|
||||
TEST_F(ResolverTest, Expr_Initializer_Type_Vec4) {
|
||||
auto* tc = vec4<f32>(1_f, 1_f, 1_f, 1_f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
|
|
|
@ -383,7 +383,7 @@ TEST_F(SideEffectsTest, Call_TypeConversion_SE) {
|
|||
EXPECT_TRUE(sem->HasSideEffects());
|
||||
}
|
||||
|
||||
TEST_F(SideEffectsTest, Call_TypeConstructor_NoSE) {
|
||||
TEST_F(SideEffectsTest, Call_TypeInitializer_NoSE) {
|
||||
auto* var = Decl(Var("a", ty.f32()));
|
||||
auto* expr = Construct(ty.f32(), "a");
|
||||
WrapInFunction(var, expr);
|
||||
|
@ -395,7 +395,7 @@ TEST_F(SideEffectsTest, Call_TypeConstructor_NoSE) {
|
|||
EXPECT_FALSE(sem->HasSideEffects());
|
||||
}
|
||||
|
||||
TEST_F(SideEffectsTest, Call_TypeConstructor_SE) {
|
||||
TEST_F(SideEffectsTest, Call_TypeInitializer_SE) {
|
||||
MakeSideEffectFunc<f32>("se");
|
||||
auto* expr = Construct(ty.f32(), Call("se"));
|
||||
WrapInFunction(expr);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -55,7 +55,7 @@ using alias3 = builder::alias3<T>;
|
|||
|
||||
class ResolverTypeValidationTest : public resolver::TestHelper, public testing::Test {};
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, VariableDeclNoConstructor_Pass) {
|
||||
TEST_F(ResolverTypeValidationTest, VariableDeclNoInitializer_Pass) {
|
||||
// {
|
||||
// var a :i32;
|
||||
// a = 2;
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ResolverTypeValidationTest, VariableDeclNoConstructor_Pass) {
|
|||
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, GlobalOverrideNoConstructor_Pass) {
|
||||
TEST_F(ResolverTypeValidationTest, GlobalOverrideNoInitializer_Pass) {
|
||||
// @id(0) override a :i32;
|
||||
Override(Source{{12, 34}}, "a", ty.i32(), Id(0_u));
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include "src/tint/sem/loop_statement.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/sem/while_statement.h"
|
||||
#include "src/tint/utils/block_allocator.h"
|
||||
|
@ -965,14 +965,14 @@ class UniformityGraph {
|
|||
[&](const ast::VariableDeclStatement* decl) {
|
||||
Node* node;
|
||||
auto* sem_var = sem_.Get(decl->variable);
|
||||
if (decl->variable->constructor) {
|
||||
auto [cf1, v] = ProcessExpression(cf, decl->variable->constructor);
|
||||
if (decl->variable->initializer) {
|
||||
auto [cf1, v] = ProcessExpression(cf, decl->variable->initializer);
|
||||
cf = cf1;
|
||||
node = v;
|
||||
|
||||
// Store if lhs is a partial pointer
|
||||
if (sem_var->Type()->Is<sem::Pointer>()) {
|
||||
auto* init = sem_.Get(decl->variable->constructor);
|
||||
auto* init = sem_.Get(decl->variable->initializer);
|
||||
if (auto* unary_init = init->Declaration()->As<ast::UnaryOpExpression>()) {
|
||||
auto* e = UnwrapIndirectAndAddressOfChain(unary_init);
|
||||
if (e->IsAnyOf<ast::IndexAccessorExpression,
|
||||
|
@ -1333,7 +1333,7 @@ class UniformityGraph {
|
|||
function_tag = info.function_tag;
|
||||
func_info = &info;
|
||||
},
|
||||
[&](const sem::TypeConstructor*) {
|
||||
[&](const sem::TypeInitializer*) {
|
||||
callsite_tag = CallSiteNoRestriction;
|
||||
function_tag = NoRestriction;
|
||||
},
|
||||
|
@ -1404,7 +1404,7 @@ class UniformityGraph {
|
|||
}
|
||||
} else {
|
||||
// All builtin function parameters are RequiredToBeUniformForReturnValue, as are
|
||||
// parameters for type constructors and type conversions.
|
||||
// parameters for type initializers and type conversions.
|
||||
// The arrayLength() builtin is a special case, as there is currently no way for it
|
||||
// to have a non-uniform return value.
|
||||
auto* builtin = sem->Target()->As<sem::Builtin>();
|
||||
|
|
|
@ -7194,7 +7194,7 @@ fn main() {
|
|||
RunTest(src, true);
|
||||
}
|
||||
|
||||
TEST_F(UniformityAnalysisTest, TypeConstructor) {
|
||||
TEST_F(UniformityAnalysisTest, TypeInitializer) {
|
||||
std::string src = R"(
|
||||
@group(0) @binding(0) var<storage, read_write> non_uniform_global : i32;
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ TEST_F(ResolverValidationTest, Expr_DontCall_Type) {
|
|||
WrapInFunction(Expr(Source{{{3, 3}, {3, 8}}}, "T"));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "3:8 error: missing '(' for type constructor or cast");
|
||||
EXPECT_EQ(r()->error(), "3:8 error: missing '(' for type initializer or cast");
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, AssignmentStmt_InvalidLHS_BuiltinFunctionName) {
|
||||
|
@ -1303,7 +1303,7 @@ TEST_F(ResolverValidationTest, OffsetAndAlignAndSizeAttribute) {
|
|||
EXPECT_EQ(r()->error(), "12:34 error: @offset cannot be used with @align or @size");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_Constructor_Cast_Pointer) {
|
||||
TEST_F(ResolverTest, Expr_Initializer_Cast_Pointer) {
|
||||
auto* vf = Var("vf", ty.f32());
|
||||
auto* c =
|
||||
Construct(Source{{12, 34}}, ty.pointer<i32>(ast::AddressSpace::kFunction), ExprList(vf));
|
||||
|
|
|
@ -69,8 +69,8 @@
|
|||
#include "src/tint/sem/storage_texture.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_conversion.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/sem/while_statement.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
|
@ -551,7 +551,7 @@ bool Validator::LocalVariable(const sem::Variable* local) const {
|
|||
auto* decl = local->Declaration();
|
||||
if (IsArrayWithOverrideCount(local->Type())) {
|
||||
RaiseArrayWithOverrideCountError(decl->type ? decl->type->source
|
||||
: decl->constructor->source);
|
||||
: decl->initializer->source);
|
||||
return false;
|
||||
}
|
||||
return Switch(
|
||||
|
@ -585,13 +585,13 @@ bool Validator::GlobalVariable(
|
|||
if (global->AddressSpace() != ast::AddressSpace::kWorkgroup &&
|
||||
IsArrayWithOverrideCount(global->Type())) {
|
||||
RaiseArrayWithOverrideCountError(decl->type ? decl->type->source
|
||||
: decl->constructor->source);
|
||||
: decl->initializer->source);
|
||||
return false;
|
||||
}
|
||||
bool ok = Switch(
|
||||
decl, //
|
||||
[&](const ast::Var* var) {
|
||||
if (auto* init = global->Constructor();
|
||||
if (auto* init = global->Initializer();
|
||||
init && init->Stage() > sem::EvaluationStage::kOverride) {
|
||||
AddError("module-scope 'var' initializer must be a constant or override-expression",
|
||||
init->Declaration()->source);
|
||||
|
@ -794,7 +794,7 @@ bool Validator::Override(
|
|||
auto* decl = v->Declaration();
|
||||
auto* storage_ty = v->Type()->UnwrapRef();
|
||||
|
||||
if (auto* init = v->Constructor(); init && init->Stage() > sem::EvaluationStage::kOverride) {
|
||||
if (auto* init = v->Initializer(); init && init->Stage() > sem::EvaluationStage::kOverride) {
|
||||
AddError("'override' initializer must be an override-expression",
|
||||
init->Declaration()->source);
|
||||
return false;
|
||||
|
@ -1549,8 +1549,8 @@ bool Validator::Call(const sem::Call* call, sem::Statement* current_statement) c
|
|||
AddError("type conversion evaluated but not used", call->Declaration()->source);
|
||||
return false;
|
||||
},
|
||||
[&](const sem::TypeConstructor*) {
|
||||
AddError("type constructor evaluated but not used", call->Declaration()->source);
|
||||
[&](const sem::TypeInitializer*) {
|
||||
AddError("type initializer evaluated but not used", call->Declaration()->source);
|
||||
return false;
|
||||
},
|
||||
[&](Default) { return true; });
|
||||
|
@ -1852,17 +1852,17 @@ bool Validator::FunctionCall(const sem::Call* call, sem::Statement* current_stat
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Validator::StructureConstructor(const ast::CallExpression* ctor,
|
||||
bool Validator::StructureInitializer(const ast::CallExpression* ctor,
|
||||
const sem::Struct* struct_type) const {
|
||||
if (!struct_type->IsConstructible()) {
|
||||
AddError("struct constructor has non-constructible type", ctor->source);
|
||||
AddError("struct initializer has non-constructible type", ctor->source);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ctor->args.Length() > 0) {
|
||||
if (ctor->args.Length() != struct_type->Members().size()) {
|
||||
std::string fm = ctor->args.Length() < struct_type->Members().size() ? "few" : "many";
|
||||
AddError("struct constructor has too " + fm + " inputs: expected " +
|
||||
AddError("struct initializer has too " + fm + " inputs: expected " +
|
||||
std::to_string(struct_type->Members().size()) + ", found " +
|
||||
std::to_string(ctor->args.Length()),
|
||||
ctor->source);
|
||||
|
@ -1873,7 +1873,7 @@ bool Validator::StructureConstructor(const ast::CallExpression* ctor,
|
|||
auto* value_ty = sem_.TypeOf(value);
|
||||
if (member->Type() != value_ty->UnwrapRef()) {
|
||||
AddError(
|
||||
"type in struct constructor does not match struct member type: expected '" +
|
||||
"type in struct initializer does not match struct member type: expected '" +
|
||||
sem_.TypeNameOf(member->Type()) + "', found '" + sem_.TypeNameOf(value_ty) +
|
||||
"'",
|
||||
value->source);
|
||||
|
@ -1884,7 +1884,7 @@ bool Validator::StructureConstructor(const ast::CallExpression* ctor,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Validator::ArrayConstructor(const ast::CallExpression* ctor,
|
||||
bool Validator::ArrayInitializer(const ast::CallExpression* ctor,
|
||||
const sem::Array* array_type) const {
|
||||
auto& values = ctor->args;
|
||||
auto* elem_ty = array_type->ElemType();
|
||||
|
@ -1910,14 +1910,14 @@ bool Validator::ArrayConstructor(const ast::CallExpression* ctor,
|
|||
}
|
||||
|
||||
if (!elem_ty->IsConstructible()) {
|
||||
AddError("array constructor has non-constructible element type", ctor->source);
|
||||
AddError("array initializer has non-constructible element type", ctor->source);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto count = std::get<sem::ConstantArrayCount>(array_type->Count()).value;
|
||||
if (!values.IsEmpty() && (values.Length() != count)) {
|
||||
std::string fm = values.Length() < count ? "few" : "many";
|
||||
AddError("array constructor has too " + fm + " elements: expected " +
|
||||
AddError("array initializer has too " + fm + " elements: expected " +
|
||||
std::to_string(count) + ", found " + std::to_string(values.Length()),
|
||||
ctor->source);
|
||||
return false;
|
||||
|
|
|
@ -60,7 +60,7 @@ class LoopStatement;
|
|||
class Materialize;
|
||||
class Statement;
|
||||
class SwitchStatement;
|
||||
class TypeConstructor;
|
||||
class TypeInitializer;
|
||||
class WhileStatement;
|
||||
} // namespace tint::sem
|
||||
|
||||
|
@ -363,11 +363,11 @@ class Validator {
|
|||
/// @returns true on success, false otherwise.
|
||||
bool Structure(const sem::Struct* str, ast::PipelineStage stage) const;
|
||||
|
||||
/// Validates a structure constructor
|
||||
/// Validates a structure initializer
|
||||
/// @param ctor the call expression to validate
|
||||
/// @param struct_type the type of the structure
|
||||
/// @returns true on success, false otherwise
|
||||
bool StructureConstructor(const ast::CallExpression* ctor,
|
||||
bool StructureInitializer(const ast::CallExpression* ctor,
|
||||
const sem::Struct* struct_type) const;
|
||||
|
||||
/// Validates a switch statement
|
||||
|
@ -414,11 +414,11 @@ class Validator {
|
|||
/// @returns true on success, false otherwise
|
||||
bool Vector(const sem::Vector* ty, const Source& source) const;
|
||||
|
||||
/// Validates an array constructor
|
||||
/// Validates an array initializer
|
||||
/// @param ctor the call expresion to validate
|
||||
/// @param arr_type the type of the array
|
||||
/// @returns true on success, false otherwise
|
||||
bool ArrayConstructor(const ast::CallExpression* ctor, const sem::Array* arr_type) const;
|
||||
bool ArrayInitializer(const ast::CallExpression* ctor, const sem::Array* arr_type) const;
|
||||
|
||||
/// Validates a texture builtin function
|
||||
/// @param call the builtin call to validate
|
||||
|
|
|
@ -28,7 +28,7 @@ struct ResolverVariableTest : public resolver::TestHelper, public testing::Test
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function-scope 'var'
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TEST_F(ResolverVariableTest, LocalVar_NoConstructor) {
|
||||
TEST_F(ResolverVariableTest, LocalVar_NoInitializer) {
|
||||
// struct S { i : i32; }
|
||||
// alias A = S;
|
||||
// fn F(){
|
||||
|
@ -84,16 +84,16 @@ TEST_F(ResolverVariableTest, LocalVar_NoConstructor) {
|
|||
EXPECT_TRUE(TypeOf(s)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||
EXPECT_TRUE(TypeOf(a)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||
|
||||
EXPECT_EQ(Sem().Get(i)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(u)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(f)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(h)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(b)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(s)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(a)->Constructor(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(i)->Initializer(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(u)->Initializer(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(f)->Initializer(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(h)->Initializer(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(b)->Initializer(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(s)->Initializer(), nullptr);
|
||||
EXPECT_EQ(Sem().Get(a)->Initializer(), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableTest, LocalVar_WithConstructor) {
|
||||
TEST_F(ResolverVariableTest, LocalVar_WithInitializer) {
|
||||
// struct S { i : i32; }
|
||||
// alias A = S;
|
||||
// fn F(){
|
||||
|
@ -164,13 +164,13 @@ TEST_F(ResolverVariableTest, LocalVar_WithConstructor) {
|
|||
EXPECT_TRUE(TypeOf(s)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||
EXPECT_TRUE(TypeOf(a)->As<sem::Reference>()->StoreType()->Is<sem::Struct>());
|
||||
|
||||
EXPECT_EQ(Sem().Get(i)->Constructor()->Declaration(), i_c);
|
||||
EXPECT_EQ(Sem().Get(u)->Constructor()->Declaration(), u_c);
|
||||
EXPECT_EQ(Sem().Get(f)->Constructor()->Declaration(), f_c);
|
||||
EXPECT_EQ(Sem().Get(h)->Constructor()->Declaration(), h_c);
|
||||
EXPECT_EQ(Sem().Get(b)->Constructor()->Declaration(), b_c);
|
||||
EXPECT_EQ(Sem().Get(s)->Constructor()->Declaration(), s_c);
|
||||
EXPECT_EQ(Sem().Get(a)->Constructor()->Declaration(), a_c);
|
||||
EXPECT_EQ(Sem().Get(i)->Initializer()->Declaration(), i_c);
|
||||
EXPECT_EQ(Sem().Get(u)->Initializer()->Declaration(), u_c);
|
||||
EXPECT_EQ(Sem().Get(f)->Initializer()->Declaration(), f_c);
|
||||
EXPECT_EQ(Sem().Get(h)->Initializer()->Declaration(), h_c);
|
||||
EXPECT_EQ(Sem().Get(b)->Initializer()->Declaration(), b_c);
|
||||
EXPECT_EQ(Sem().Get(s)->Initializer()->Declaration(), s_c);
|
||||
EXPECT_EQ(Sem().Get(a)->Initializer()->Declaration(), a_c);
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableTest, LocalVar_ShadowsAlias) {
|
||||
|
@ -249,7 +249,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalVar) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), global);
|
||||
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user_v, nullptr);
|
||||
EXPECT_EQ(user_v->Variable(), global);
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalConst) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), global);
|
||||
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user_v, nullptr);
|
||||
EXPECT_EQ(user_v->Variable(), global);
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsLocalVar) {
|
|||
ASSERT_NE(local_y, nullptr);
|
||||
EXPECT_EQ(local_y->Shadows(), local_x);
|
||||
|
||||
auto* user_y = Sem().Get<sem::VariableUser>(local_y->Declaration()->constructor);
|
||||
auto* user_y = Sem().Get<sem::VariableUser>(local_y->Declaration()->initializer);
|
||||
ASSERT_NE(user_y, nullptr);
|
||||
EXPECT_EQ(user_y->Variable(), local_x);
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsLocalConst) {
|
|||
ASSERT_NE(local_v, nullptr);
|
||||
EXPECT_EQ(local_v->Shadows(), local_c);
|
||||
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local_v->Declaration()->constructor);
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local_v->Declaration()->initializer);
|
||||
ASSERT_NE(user_v, nullptr);
|
||||
EXPECT_EQ(user_v->Variable(), local_c);
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsLocalLet) {
|
|||
ASSERT_NE(local_v, nullptr);
|
||||
EXPECT_EQ(local_v->Shadows(), local_l);
|
||||
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local_v->Declaration()->constructor);
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local_v->Declaration()->initializer);
|
||||
ASSERT_NE(user_v, nullptr);
|
||||
EXPECT_EQ(user_v->Variable(), local_l);
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsParam) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), param);
|
||||
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user_v = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user_v, nullptr);
|
||||
EXPECT_EQ(user_v->Variable(), param);
|
||||
}
|
||||
|
@ -447,14 +447,14 @@ TEST_F(ResolverVariableTest, LocalLet) {
|
|||
ASSERT_TRUE(TypeOf(p)->Is<sem::Pointer>());
|
||||
ASSERT_TRUE(TypeOf(p)->As<sem::Pointer>()->StoreType()->Is<sem::I32>());
|
||||
|
||||
EXPECT_EQ(Sem().Get(i)->Constructor()->Declaration(), i_c);
|
||||
EXPECT_EQ(Sem().Get(u)->Constructor()->Declaration(), u_c);
|
||||
EXPECT_EQ(Sem().Get(f)->Constructor()->Declaration(), f_c);
|
||||
EXPECT_EQ(Sem().Get(h)->Constructor()->Declaration(), h_c);
|
||||
EXPECT_EQ(Sem().Get(b)->Constructor()->Declaration(), b_c);
|
||||
EXPECT_EQ(Sem().Get(s)->Constructor()->Declaration(), s_c);
|
||||
EXPECT_EQ(Sem().Get(a)->Constructor()->Declaration(), a_c);
|
||||
EXPECT_EQ(Sem().Get(p)->Constructor()->Declaration(), p_c);
|
||||
EXPECT_EQ(Sem().Get(i)->Initializer()->Declaration(), i_c);
|
||||
EXPECT_EQ(Sem().Get(u)->Initializer()->Declaration(), u_c);
|
||||
EXPECT_EQ(Sem().Get(f)->Initializer()->Declaration(), f_c);
|
||||
EXPECT_EQ(Sem().Get(h)->Initializer()->Declaration(), h_c);
|
||||
EXPECT_EQ(Sem().Get(b)->Initializer()->Declaration(), b_c);
|
||||
EXPECT_EQ(Sem().Get(s)->Initializer()->Declaration(), s_c);
|
||||
EXPECT_EQ(Sem().Get(a)->Initializer()->Declaration(), a_c);
|
||||
EXPECT_EQ(Sem().Get(p)->Initializer()->Declaration(), p_c);
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
|
||||
|
@ -563,7 +563,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalVar) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), global);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), global);
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalConst) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), global);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), global);
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsLocalVar) {
|
|||
ASSERT_NE(local_l, nullptr);
|
||||
EXPECT_EQ(local_l->Shadows(), local_v);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_l->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_l->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), local_v);
|
||||
}
|
||||
|
@ -638,7 +638,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsLocalConst) {
|
|||
ASSERT_NE(local_y, nullptr);
|
||||
EXPECT_EQ(local_y->Shadows(), local_x);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_y->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_y->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), local_x);
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsLocalLet) {
|
|||
ASSERT_NE(local_y, nullptr);
|
||||
EXPECT_EQ(local_y->Shadows(), local_x);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_y->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_y->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), local_x);
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsParam) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), param);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), param);
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ TEST_F(ResolverVariableTest, LocalConst_ShadowsGlobalConst) {
|
|||
ASSERT_NE(local, nullptr);
|
||||
EXPECT_EQ(local->Shadows(), global);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), global);
|
||||
}
|
||||
|
@ -840,7 +840,7 @@ TEST_F(ResolverVariableTest, LocalConst_ShadowsLocalConst) {
|
|||
ASSERT_NE(local_y, nullptr);
|
||||
EXPECT_EQ(local_y->Shadows(), local_x);
|
||||
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_y->Declaration()->constructor);
|
||||
auto* user = Sem().Get<sem::VariableUser>(local_y->Declaration()->initializer);
|
||||
ASSERT_NE(user, nullptr);
|
||||
EXPECT_EQ(user->Variable(), local_x);
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ TEST_F(ResolverVariableValidationTest, OverrideInferedTypeNotScalar) {
|
|||
EXPECT_EQ(r()->error(), "56:78 error: vec3<f32> cannot be used as the type of a 'override'");
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableValidationTest, ConstConstructorWrongType) {
|
||||
TEST_F(ResolverVariableValidationTest, ConstInitializerWrongType) {
|
||||
// const c : i32 = 2u
|
||||
WrapInFunction(Const(Source{{3, 3}}, "c", ty.i32(), Expr(2_u)));
|
||||
|
||||
|
@ -157,7 +157,7 @@ TEST_F(ResolverVariableValidationTest, ConstConstructorWrongType) {
|
|||
R"(3:3 error: cannot initialize const of type 'i32' with value of type 'u32')");
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableValidationTest, LetConstructorWrongType) {
|
||||
TEST_F(ResolverVariableValidationTest, LetInitializerWrongType) {
|
||||
// var v : i32 = 2u
|
||||
WrapInFunction(Let(Source{{3, 3}}, "v", ty.i32(), Expr(2_u)));
|
||||
|
||||
|
@ -166,7 +166,7 @@ TEST_F(ResolverVariableValidationTest, LetConstructorWrongType) {
|
|||
R"(3:3 error: cannot initialize let of type 'i32' with value of type 'u32')");
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableValidationTest, VarConstructorWrongType) {
|
||||
TEST_F(ResolverVariableValidationTest, VarInitializerWrongType) {
|
||||
// var v : i32 = 2u
|
||||
WrapInFunction(Var(Source{{3, 3}}, "v", ty.i32(), Expr(2_u)));
|
||||
|
||||
|
@ -175,7 +175,7 @@ TEST_F(ResolverVariableValidationTest, VarConstructorWrongType) {
|
|||
R"(3:3 error: cannot initialize var of type 'i32' with value of type 'u32')");
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableValidationTest, ConstConstructorWrongTypeViaAlias) {
|
||||
TEST_F(ResolverVariableValidationTest, ConstInitializerWrongTypeViaAlias) {
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(Const(Source{{3, 3}}, "v", ty.Of(a), Expr(2_u)));
|
||||
|
||||
|
@ -184,7 +184,7 @@ TEST_F(ResolverVariableValidationTest, ConstConstructorWrongTypeViaAlias) {
|
|||
R"(3:3 error: cannot initialize const of type 'i32' with value of type 'u32')");
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableValidationTest, LetConstructorWrongTypeViaAlias) {
|
||||
TEST_F(ResolverVariableValidationTest, LetInitializerWrongTypeViaAlias) {
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(Let(Source{{3, 3}}, "v", ty.Of(a), Expr(2_u)));
|
||||
|
||||
|
@ -193,7 +193,7 @@ TEST_F(ResolverVariableValidationTest, LetConstructorWrongTypeViaAlias) {
|
|||
R"(3:3 error: cannot initialize let of type 'i32' with value of type 'u32')");
|
||||
}
|
||||
|
||||
TEST_F(ResolverVariableValidationTest, VarConstructorWrongTypeViaAlias) {
|
||||
TEST_F(ResolverVariableValidationTest, VarInitializerWrongTypeViaAlias) {
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(Var(Source{{3, 3}}, "v", ty.Of(a), Expr(2_u)));
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ struct CallTargetSignature {
|
|||
}
|
||||
};
|
||||
|
||||
/// CallTarget is the base for callable functions, builtins, type constructors
|
||||
/// CallTarget is the base for callable functions, builtins, type initializers
|
||||
/// and type casts.
|
||||
class CallTarget : public Castable<CallTarget, Node> {
|
||||
public:
|
||||
|
|
|
@ -12,19 +12,19 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeConstructor);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeInitializer);
|
||||
|
||||
namespace tint::sem {
|
||||
|
||||
TypeConstructor::TypeConstructor(const sem::Type* type,
|
||||
TypeInitializer::TypeInitializer(const sem::Type* type,
|
||||
utils::VectorRef<const Parameter*> parameters,
|
||||
EvaluationStage stage)
|
||||
: Base(type, std::move(parameters), stage) {}
|
||||
|
||||
TypeConstructor::~TypeConstructor() = default;
|
||||
TypeInitializer::~TypeInitializer() = default;
|
||||
|
||||
} // namespace tint::sem
|
|
@ -12,29 +12,29 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TINT_SEM_TYPE_CONSTRUCTOR_H_
|
||||
#define SRC_TINT_SEM_TYPE_CONSTRUCTOR_H_
|
||||
#ifndef SRC_TINT_SEM_TYPE_INITIALIZER_H_
|
||||
#define SRC_TINT_SEM_TYPE_INITIALIZER_H_
|
||||
|
||||
#include "src/tint/sem/call_target.h"
|
||||
#include "src/tint/utils/vector.h"
|
||||
|
||||
namespace tint::sem {
|
||||
|
||||
/// TypeConstructor is the CallTarget for a type constructor.
|
||||
class TypeConstructor final : public Castable<TypeConstructor, CallTarget> {
|
||||
/// TypeInitializer is the CallTarget for a type initializer.
|
||||
class TypeInitializer final : public Castable<TypeInitializer, CallTarget> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param type the type that's being constructed
|
||||
/// @param parameters the type constructor parameters
|
||||
/// @param parameters the type initializer parameters
|
||||
/// @param stage the earliest evaluation stage for the expression
|
||||
TypeConstructor(const sem::Type* type,
|
||||
TypeInitializer(const sem::Type* type,
|
||||
utils::VectorRef<const Parameter*> parameters,
|
||||
EvaluationStage stage);
|
||||
|
||||
/// Destructor
|
||||
~TypeConstructor() override;
|
||||
~TypeInitializer() override;
|
||||
};
|
||||
|
||||
} // namespace tint::sem
|
||||
|
||||
#endif // SRC_TINT_SEM_TYPE_CONSTRUCTOR_H_
|
||||
#endif // SRC_TINT_SEM_TYPE_INITIALIZER_H_
|
|
@ -96,8 +96,8 @@ VariableUser::VariableUser(const ast::IdentifierExpression* declaration,
|
|||
/* has_side_effects */ false),
|
||||
variable_(variable) {
|
||||
auto* type = variable->Type();
|
||||
if (type->Is<sem::Pointer>() && variable->Constructor()) {
|
||||
source_variable_ = variable->Constructor()->SourceVariable();
|
||||
if (type->Is<sem::Pointer>() && variable->Initializer()) {
|
||||
source_variable_ = variable->Initializer()->SourceVariable();
|
||||
} else {
|
||||
source_variable_ = variable;
|
||||
}
|
||||
|
|
|
@ -80,13 +80,13 @@ class Variable : public Castable<Variable, Node> {
|
|||
/// @return the constant value of this expression
|
||||
const Constant* ConstantValue() const { return constant_value_; }
|
||||
|
||||
/// @returns the variable constructor expression, or nullptr if the variable
|
||||
/// @returns the variable initializer expression, or nullptr if the variable
|
||||
/// does not have one.
|
||||
const Expression* Constructor() const { return constructor_; }
|
||||
const Expression* Initializer() const { return initializer_; }
|
||||
|
||||
/// Sets the variable constructor expression.
|
||||
/// @param constructor the constructor expression to assign to this variable.
|
||||
void SetConstructor(const Expression* constructor) { constructor_ = constructor; }
|
||||
/// Sets the variable initializer expression.
|
||||
/// @param initializer the initializer expression to assign to this variable.
|
||||
void SetInitializer(const Expression* initializer) { initializer_ = initializer; }
|
||||
|
||||
/// @returns the expressions that use the variable
|
||||
const std::vector<const VariableUser*>& Users() const { return users_; }
|
||||
|
@ -101,7 +101,7 @@ class Variable : public Castable<Variable, Node> {
|
|||
const ast::AddressSpace address_space_;
|
||||
const ast::Access access_;
|
||||
const Constant* constant_value_;
|
||||
const Expression* constructor_ = nullptr;
|
||||
const Expression* initializer_ = nullptr;
|
||||
std::vector<const VariableUser*> users_;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ line three)";
|
|||
|
||||
using SourceFileContentTest = testing::Test;
|
||||
|
||||
TEST_F(SourceFileContentTest, Ctor) {
|
||||
TEST_F(SourceFileContentTest, Init) {
|
||||
Source::FileContent fc(kSource);
|
||||
EXPECT_EQ(fc.data, kSource);
|
||||
EXPECT_EQ(fc.data_view, kSource);
|
||||
|
@ -38,7 +38,7 @@ TEST_F(SourceFileContentTest, Ctor) {
|
|||
EXPECT_EQ(fc.lines[2], "line three");
|
||||
}
|
||||
|
||||
TEST_F(SourceFileContentTest, CopyCtor) {
|
||||
TEST_F(SourceFileContentTest, CopyInit) {
|
||||
auto src = std::make_unique<Source::FileContent>(kSource);
|
||||
Source::FileContent fc{*src};
|
||||
src.reset();
|
||||
|
@ -50,7 +50,7 @@ TEST_F(SourceFileContentTest, CopyCtor) {
|
|||
EXPECT_EQ(fc.lines[2], "line three");
|
||||
}
|
||||
|
||||
TEST_F(SourceFileContentTest, MoveCtor) {
|
||||
TEST_F(SourceFileContentTest, MoveInit) {
|
||||
auto src = std::make_unique<Source::FileContent>(kSource);
|
||||
Source::FileContent fc{std::move(*src)};
|
||||
src.reset();
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<!--=================================================================-->
|
||||
<!-- ast -->
|
||||
<!--=================================================================-->
|
||||
|
||||
|
||||
<Type Name="tint::ast::AssignmentStatement">
|
||||
<DisplayString>{*lhs} = {*rhs};</DisplayString>
|
||||
<Expand>
|
||||
|
@ -126,15 +126,15 @@
|
|||
</Type>
|
||||
|
||||
<Type Name="tint::ast::Let">
|
||||
<DisplayString Condition="!!type">let {symbol} : {*type} = {*constructor}</DisplayString>
|
||||
<DisplayString Condition=" !type">let {symbol} = {*constructor}</DisplayString>
|
||||
<DisplayString Condition="!!type">let {symbol} : {*type} = {*initializer}</DisplayString>
|
||||
<DisplayString Condition=" !type">let {symbol} = {*initializer}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="tint::ast::Variable">
|
||||
<DisplayString Condition="!!type & !!constructor">var {symbol} : {*type} = {*constructor}</DisplayString>
|
||||
<DisplayString Condition="!!type & !constructor">var {symbol} : {*type}</DisplayString>
|
||||
<DisplayString Condition=" !type & !!constructor">var {symbol} = {*constructor}</DisplayString>
|
||||
<DisplayString Condition=" !type & !constructor">var {symbol}</DisplayString>
|
||||
<DisplayString Condition="!!type & !!initializer">var {symbol} : {*type} = {*initializer}</DisplayString>
|
||||
<DisplayString Condition="!!type & !initializer">var {symbol} : {*type}</DisplayString>
|
||||
<DisplayString Condition=" !type & !!initializer">var {symbol} = {*initializer}</DisplayString>
|
||||
<DisplayString Condition=" !type & !initializer">var {symbol}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="tint::ast::VariableDeclStatement">
|
||||
|
|
|
@ -139,7 +139,7 @@ void BindingRemapper::Run(CloneContext& ctx, const DataMap& inputs, DataMap&) co
|
|||
const ast::Type* inner_ty = CreateASTTypeFor(ctx, ty);
|
||||
auto* new_var =
|
||||
ctx.dst->Var(ctx.Clone(var->source), ctx.Clone(var->symbol), inner_ty,
|
||||
var->declared_address_space, ac, ctx.Clone(var->constructor),
|
||||
var->declared_address_space, ac, ctx.Clone(var->initializer),
|
||||
ctx.Clone(var->attributes));
|
||||
ctx.Replace(var, new_var);
|
||||
}
|
||||
|
|
|
@ -161,17 +161,17 @@ void ClampFragDepth::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
|
|||
auto fn_sym = b.Symbols().New("clamp_frag_depth_" +
|
||||
sym.NameFor(return_ty->As<ast::TypeName>()->name));
|
||||
|
||||
utils::Vector<const ast::Expression*, 8u> constructor_args;
|
||||
utils::Vector<const ast::Expression*, 8u> initializer_args;
|
||||
for (auto* member : struct_ty->members) {
|
||||
const ast::Expression* arg = b.MemberAccessor("s", ctx.Clone(member->symbol));
|
||||
if (ContainsFragDepth(member->attributes)) {
|
||||
arg = b.Call(base_fn_sym, arg);
|
||||
}
|
||||
constructor_args.Push(arg);
|
||||
initializer_args.Push(arg);
|
||||
}
|
||||
utils::Vector params{b.Param("s", ctx.Clone(return_ty))};
|
||||
utils::Vector body{
|
||||
b.Return(b.Construct(ctx.Clone(return_ty), std::move(constructor_args))),
|
||||
b.Return(b.Construct(ctx.Clone(return_ty), std::move(initializer_args))),
|
||||
};
|
||||
b.Func(fn_sym, params, ctx.Clone(return_ty), body);
|
||||
return fn_sym;
|
||||
|
|
|
@ -832,7 +832,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) con
|
|||
//
|
||||
// Inner-most expression nodes are guaranteed to be visited first because AST
|
||||
// nodes are fully immutable and require their children to be constructed
|
||||
// first so their pointer can be passed to the parent's constructor.
|
||||
// first so their pointer can be passed to the parent's initializer.
|
||||
for (auto* node : ctx.src->ASTNodes().Objects()) {
|
||||
if (auto* ident = node->As<ast::IdentifierExpression>()) {
|
||||
// X
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/transform/simplify_pointers.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
@ -107,9 +107,9 @@ void DecomposeStridedArray::Run(CloneContext& ctx, const DataMap&, DataMap&) con
|
|||
return nullptr;
|
||||
});
|
||||
|
||||
// Find all array type constructor expressions for array types that have had
|
||||
// their element changed to a single field structure. These constructors are
|
||||
// adjusted to wrap each of the arguments with an additional constructor for
|
||||
// Find all array type initializer expressions for array types that have had
|
||||
// their element changed to a single field structure. These initializers are
|
||||
// adjusted to wrap each of the arguments with an additional initializer for
|
||||
// the new element structure type.
|
||||
// Example:
|
||||
// `@stride(32) array<i32, 3>(1, 2, 3)`
|
||||
|
@ -118,9 +118,9 @@ void DecomposeStridedArray::Run(CloneContext& ctx, const DataMap&, DataMap&) con
|
|||
ctx.ReplaceAll([&](const ast::CallExpression* expr) -> const ast::Expression* {
|
||||
if (!expr->args.IsEmpty()) {
|
||||
if (auto* call = sem.Get(expr)->UnwrapMaterialize()->As<sem::Call>()) {
|
||||
if (auto* ctor = call->Target()->As<sem::TypeConstructor>()) {
|
||||
if (auto* ctor = call->Target()->As<sem::TypeInitializer>()) {
|
||||
if (auto* arr = ctor->ReturnType()->As<sem::Array>()) {
|
||||
// Begin by cloning the array constructor type or name
|
||||
// Begin by cloning the array initializer type or name
|
||||
// If this is an unaliased array, this may add a new entry to
|
||||
// decomposed.
|
||||
// If this is an aliased array, decomposed should already be
|
||||
|
|
|
@ -41,7 +41,7 @@ class Manager final : public Castable<Manager, Transform> {
|
|||
|
||||
/// Add pass to the manager of type `T`, constructed with the provided
|
||||
/// arguments.
|
||||
/// @param args the arguments to forward to the `T` constructor
|
||||
/// @param args the arguments to forward to the `T` initializer
|
||||
template <typename T, typename... ARGS>
|
||||
void Add(ARGS&&... args) {
|
||||
transforms_.emplace_back(std::make_unique<T>(std::forward<ARGS>(args)...));
|
||||
|
|
|
@ -187,8 +187,8 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
// scope. Disable address space validation on this variable.
|
||||
auto* disable_validation =
|
||||
ctx.dst->Disable(ast::DisabledValidation::kIgnoreAddressSpace);
|
||||
auto* constructor = ctx.Clone(var->Declaration()->constructor);
|
||||
auto* local_var = ctx.dst->Var(new_var_symbol, store_type(), sc, constructor,
|
||||
auto* initializer = ctx.Clone(var->Declaration()->initializer);
|
||||
auto* local_var = ctx.dst->Var(new_var_symbol, store_type(), sc, initializer,
|
||||
utils::Vector{disable_validation});
|
||||
ctx.InsertFront(func->body->statements, ctx.dst->Decl(local_var));
|
||||
|
||||
|
@ -400,10 +400,10 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
// Redeclare the variable at function scope.
|
||||
auto* disable_validation =
|
||||
ctx.dst->Disable(ast::DisabledValidation::kIgnoreAddressSpace);
|
||||
auto* constructor = ctx.Clone(var->Declaration()->constructor);
|
||||
auto* initializer = ctx.Clone(var->Declaration()->initializer);
|
||||
auto* local_var = ctx.dst->Var(new_var_symbol,
|
||||
CreateASTTypeFor(ctx, var->Type()->UnwrapRef()),
|
||||
ast::AddressSpace::kPrivate, constructor,
|
||||
ast::AddressSpace::kPrivate, initializer,
|
||||
utils::Vector{disable_validation});
|
||||
ctx.InsertFront(func_ast->body->statements, ctx.dst->Decl(local_var));
|
||||
local_private_vars_.insert(var);
|
||||
|
|
|
@ -213,7 +213,7 @@ fn zoo(@internal(disable_validation__ignore_address_space) @internal(disable_val
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, Constructors) {
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, Initializers) {
|
||||
auto* src = R"(
|
||||
var<private> a : f32 = 1.0;
|
||||
var<private> b : f32 = f32();
|
||||
|
@ -238,7 +238,7 @@ fn main() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, Constructors_OutOfOrder) {
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, Initializers_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
@compute @workgroup_size(1)
|
||||
fn main() {
|
||||
|
|
|
@ -138,11 +138,11 @@ struct MultiplanarExternalTexture::State {
|
|||
|
||||
// Replace the original texture_external binding with a texture_2d<f32> binding.
|
||||
auto cloned_attributes = ctx.Clone(global->attributes);
|
||||
const ast::Expression* cloned_constructor = ctx.Clone(global->constructor);
|
||||
const ast::Expression* cloned_initializer = ctx.Clone(global->initializer);
|
||||
|
||||
auto* replacement =
|
||||
b.Var(syms.plane_0, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
cloned_constructor, cloned_attributes);
|
||||
cloned_initializer, cloned_attributes);
|
||||
ctx.Replace(global, replacement);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/module.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -112,7 +112,7 @@ void PadStructs::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
|
|||
if (!call) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* cons = call->Target()->As<sem::TypeConstructor>();
|
||||
auto* cons = call->Target()->As<sem::TypeInitializer>();
|
||||
if (!cons) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -521,8 +521,8 @@ fn main() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PadStructsTest, Constructor) {
|
||||
// Calls to a constructor of a padded struct must be modified to initialize the padding.
|
||||
TEST_F(PadStructsTest, Initializer) {
|
||||
// Calls to a initializer of a padded struct must be modified to initialize the padding.
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
a : f32,
|
||||
|
@ -557,8 +557,8 @@ fn main() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PadStructsTest, ConstructorZeroArgs) {
|
||||
// Calls to a zero-argument constructor of a padded struct should not be modified.
|
||||
TEST_F(PadStructsTest, InitializerZeroArgs) {
|
||||
// Calls to a zero-argument initializer of a padded struct should not be modified.
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
a : f32,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/type_constructor.h"
|
||||
#include "src/tint/sem/type_initializer.h"
|
||||
#include "src/tint/transform/utils/hoist_to_decl_before.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::PromoteInitializersToLet);
|
||||
|
@ -45,9 +45,9 @@ void PromoteInitializersToLet::Run(CloneContext& ctx, const DataMap&, DataMap&)
|
|||
auto* stmt = sem_stmt->Declaration();
|
||||
|
||||
if (auto* src_var_decl = stmt->As<ast::VariableDeclStatement>()) {
|
||||
if (src_var_decl->variable->constructor == expr->Declaration()) {
|
||||
if (src_var_decl->variable->initializer == expr->Declaration()) {
|
||||
// This statement is just a variable declaration with the
|
||||
// initializer as the constructor value. This is what we're
|
||||
// initializer as the initializer value. This is what we're
|
||||
// attempting to transform to, and so ignore.
|
||||
return true;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void PromoteInitializersToLet::Run(CloneContext& ctx, const DataMap&, DataMap&)
|
|||
[&](const ast::CallExpression* expr) {
|
||||
if (auto* sem = ctx.src->Sem().Get(expr)) {
|
||||
auto* ctor = sem->UnwrapMaterialize()->As<sem::Call>();
|
||||
if (ctor->Target()->Is<sem::TypeConstructor>()) {
|
||||
if (ctor->Target()->Is<sem::TypeInitializer>()) {
|
||||
return promote(sem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace tint::transform {
|
||||
|
||||
/// A transform that hoists array and structure constructors, and identifiers resolving to a
|
||||
/// A transform that hoists array and structure initializers, and identifiers resolving to a
|
||||
/// 'const' array to a 'let' variable, declared just before the statement of usage.
|
||||
/// This transform is used by backends that do not support expressions that operate on an immediate
|
||||
/// array or structure. For example, the following is not immediately expressable for HLSL:
|
||||
|
|
|
@ -396,7 +396,7 @@ class DecomposeSideEffects::CollectHoistsState : public StateBase {
|
|||
},
|
||||
[&](const ast::SwitchStatement* s) { ProcessStatement(s->condition); },
|
||||
[&](const ast::VariableDeclStatement* s) {
|
||||
ProcessStatement(s->variable->constructor);
|
||||
ProcessStatement(s->variable->initializer);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -625,11 +625,11 @@ class DecomposeSideEffects::DecomposeState : public StateBase {
|
|||
},
|
||||
[&](const ast::VariableDeclStatement* s) -> const ast::Statement* {
|
||||
auto* var = s->variable;
|
||||
if (!var->constructor || !sem.Get(var->constructor)->HasSideEffects()) {
|
||||
if (!var->initializer || !sem.Get(var->initializer)->HasSideEffects()) {
|
||||
return nullptr;
|
||||
}
|
||||
tint::utils::Vector<const ast::Statement*, 8> stmts;
|
||||
ctx.Replace(var->constructor, Decompose(var->constructor, &stmts));
|
||||
ctx.Replace(var->initializer, Decompose(var->initializer, &stmts));
|
||||
InsertBefore(stmts, s);
|
||||
return b.Decl(ctx.CloneWithoutTransform(var));
|
||||
},
|
||||
|
|
|
@ -614,7 +614,7 @@ fn f() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteSideEffectsToDeclTest, Binary_Arith_InTypeCtor) {
|
||||
TEST_F(PromoteSideEffectsToDeclTest, Binary_Arith_InTypeInit) {
|
||||
auto* src = R"(
|
||||
|
||||
fn a(i : i32) -> i32 {
|
||||
|
@ -1860,7 +1860,7 @@ fn f() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteSideEffectsToDeclTest, Binary_Logical_InTypeCtor) {
|
||||
TEST_F(PromoteSideEffectsToDeclTest, Binary_Logical_InTypeInit) {
|
||||
auto* src = R"(
|
||||
|
||||
fn a(i : i32) -> bool {
|
||||
|
@ -3030,7 +3030,7 @@ fn f() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeConstructor_Struct) {
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeInitializer_Struct) {
|
||||
auto* src = R"(
|
||||
fn a(i : i32) -> i32 {
|
||||
return 1;
|
||||
|
@ -3072,7 +3072,7 @@ fn f() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeConstructor_Array1D) {
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeInitializer_Array1D) {
|
||||
auto* src = R"(
|
||||
fn a(i : i32) -> i32 {
|
||||
return 1;
|
||||
|
@ -3102,7 +3102,7 @@ fn f() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeConstructor_Array2D) {
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeInitializer_Array2D) {
|
||||
auto* src = R"(
|
||||
fn a(i : i32) -> i32 {
|
||||
return 1;
|
||||
|
@ -3809,7 +3809,7 @@ fn f() {
|
|||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeCtor_VarPlusI32CtorPlusVar) {
|
||||
TEST_F(PromoteSideEffectsToDeclTest, TypeInit_VarPlusI32InitPlusVar) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b = 0;
|
||||
|
|
|
@ -70,7 +70,7 @@ void RemovePhonies::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
|
|||
stmt->rhs, ctx.dst->Diagnostics(),
|
||||
[&](const ast::CallExpression* expr) {
|
||||
// ast::CallExpression may map to a function or builtin call
|
||||
// (both may have side-effects), or a type constructor or
|
||||
// (both may have side-effects), or a type initializer or
|
||||
// type conversion (both do not have side effects).
|
||||
auto* call = sem.Get<sem::Call>(expr);
|
||||
if (!call) {
|
||||
|
|
|
@ -112,7 +112,7 @@ struct SimplifyPointers::State {
|
|||
if (var->Is<sem::LocalVariable>() && //
|
||||
var->Declaration()->Is<ast::Let>() && //
|
||||
var->Type()->Is<sem::Pointer>()) {
|
||||
op.expr = var->Declaration()->constructor;
|
||||
op.expr = var->Declaration()->initializer;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ struct SimplifyPointers::State {
|
|||
// to be hoist to temporary "saved" variables.
|
||||
std::vector<const ast::VariableDeclStatement*> saved;
|
||||
CollectSavedArrayIndices(
|
||||
var->Declaration()->constructor, [&](const ast::Expression* idx_expr) {
|
||||
var->Declaration()->initializer, [&](const ast::Expression* idx_expr) {
|
||||
// We have a sub-expression that needs to be saved.
|
||||
// Create a new variable
|
||||
auto saved_name = ctx.dst->Symbols().New(
|
||||
|
|
|
@ -163,7 +163,7 @@ struct SpirvAtomic::State {
|
|||
if (v->type && atomic_variables.emplace(user->Variable()).second) {
|
||||
ctx.Replace(v->type, AtomicTypeFor(user->Variable()->Type()));
|
||||
}
|
||||
if (auto* ctor = user->Variable()->Constructor()) {
|
||||
if (auto* ctor = user->Variable()->Initializer()) {
|
||||
atomic_expressions.Add(ctor);
|
||||
}
|
||||
},
|
||||
|
@ -266,10 +266,10 @@ struct SpirvAtomic::State {
|
|||
},
|
||||
[&](const ast::VariableDeclStatement* decl) {
|
||||
auto* var = decl->variable;
|
||||
if (auto* sem_ctor = ctx.src->Sem().Get(var->constructor)) {
|
||||
if (is_ref_to_atomic_var(sem_ctor)) {
|
||||
ctx.Replace(var->constructor, [=] {
|
||||
auto* rhs = ctx.CloneWithoutTransform(var->constructor);
|
||||
if (auto* sem_init = ctx.src->Sem().Get(var->initializer)) {
|
||||
if (is_ref_to_atomic_var(sem_init)) {
|
||||
ctx.Replace(var->initializer, [=] {
|
||||
auto* rhs = ctx.CloneWithoutTransform(var->initializer);
|
||||
return b.Call(sem::str(sem::BuiltinType::kAtomicLoad),
|
||||
b.AddressOf(rhs));
|
||||
});
|
||||
|
|
|
@ -513,7 +513,7 @@ struct Std140::State {
|
|||
// Found a pointer. As the source variable is a uniform buffer variable,
|
||||
// this must be a pointer-let. Continue traversing from the let
|
||||
// initializer.
|
||||
expr = user->Variable()->Constructor();
|
||||
expr = user->Variable()->Initializer();
|
||||
return Action::kContinue;
|
||||
}
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
|
|
|
@ -57,13 +57,13 @@ void SubstituteOverride::Run(CloneContext& ctx, const DataMap& config, DataMap&)
|
|||
// No replacement provided, just clone the override node as a const.
|
||||
auto iter = data->map.find(sem->OverrideId());
|
||||
if (iter == data->map.end()) {
|
||||
if (!w->constructor) {
|
||||
if (!w->initializer) {
|
||||
ctx.dst->Diagnostics().add_error(
|
||||
diag::System::Transform,
|
||||
"Initializer not provided for override, and override not overridden.");
|
||||
return nullptr;
|
||||
}
|
||||
return ctx.dst->Const(src, sym, ty, ctx.Clone(w->constructor));
|
||||
return ctx.dst->Const(src, sym, ty, ctx.Clone(w->initializer));
|
||||
}
|
||||
|
||||
auto value = iter->second;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue