Remove name fields
This CL removes the name fields from the various AST nodes now that the
symbols are used everywhere.
Change-Id: I73e8fa8958aa6e6f0159b12b63176b12c418f525
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36762
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/ast/builder.cc b/src/ast/builder.cc
index 3e6863b..b46ee0e 100644
--- a/src/ast/builder.cc
+++ b/src/ast/builder.cc
@@ -40,8 +40,8 @@
type::Type* type,
Expression* constructor,
VariableDecorationList decorations) {
- auto* var = create<Variable>(mod->RegisterSymbol(name), name, storage, type,
- false, constructor, decorations);
+ auto* var = create<Variable>(mod->RegisterSymbol(name), storage, type, false,
+ constructor, decorations);
OnVariableBuilt(var);
return var;
}
@@ -52,8 +52,8 @@
type::Type* type,
Expression* constructor,
VariableDecorationList decorations) {
- auto* var = create<Variable>(source, mod->RegisterSymbol(name), name, storage,
- type, false, constructor, decorations);
+ auto* var = create<Variable>(source, mod->RegisterSymbol(name), storage, type,
+ false, constructor, decorations);
OnVariableBuilt(var);
return var;
}
@@ -69,8 +69,8 @@
type::Type* type,
Expression* constructor,
VariableDecorationList decorations) {
- auto* var = create<Variable>(mod->RegisterSymbol(name), name, storage, type,
- true, constructor, decorations);
+ auto* var = create<Variable>(mod->RegisterSymbol(name), storage, type, true,
+ constructor, decorations);
OnVariableBuilt(var);
return var;
}
@@ -81,8 +81,8 @@
type::Type* type,
Expression* constructor,
VariableDecorationList decorations) {
- auto* var = create<Variable>(source, mod->RegisterSymbol(name), name, storage,
- type, true, constructor, decorations);
+ auto* var = create<Variable>(source, mod->RegisterSymbol(name), storage, type,
+ true, constructor, decorations);
OnVariableBuilt(var);
return var;
}
diff --git a/src/ast/builder.h b/src/ast/builder.h
index 62a874c..1ebe604 100644
--- a/src/ast/builder.h
+++ b/src/ast/builder.h
@@ -166,7 +166,7 @@
/// @param type the alias type
/// @returns the alias pointer
type::Alias* alias(const std::string& name, type::Type* type) const {
- return mod_->create<type::Alias>(mod_->RegisterSymbol(name), name, type);
+ return mod_->create<type::Alias>(mod_->RegisterSymbol(name), type);
}
/// @return the tint AST pointer to type `T` with the given StorageClass.
@@ -180,7 +180,7 @@
/// @param impl the struct implementation
/// @returns a struct pointer
type::Struct* struct_(const std::string& name, ast::Struct* impl) const {
- return mod_->create<type::Struct>(mod_->RegisterSymbol(name), name, impl);
+ return mod_->create<type::Struct>(mod_->RegisterSymbol(name), impl);
}
private:
@@ -227,21 +227,20 @@
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const std::string& name) {
- return create<IdentifierExpression>(mod->RegisterSymbol(name), name);
+ return create<IdentifierExpression>(mod->RegisterSymbol(name));
}
/// @param source the source information
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const Source& source, const std::string& name) {
- return create<IdentifierExpression>(source, mod->RegisterSymbol(name),
- name);
+ return create<IdentifierExpression>(source, mod->RegisterSymbol(name));
}
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const char* name) {
- return create<IdentifierExpression>(mod->RegisterSymbol(name), name);
+ return create<IdentifierExpression>(mod->RegisterSymbol(name));
}
/// @param value the boolean value
@@ -620,9 +619,9 @@
type::Type* type,
ast::StatementList body,
ast::FunctionDecorationList decorations) {
- return mod->create<ast::Function>(
- source, mod->RegisterSymbol(name), name, params, type,
- create<ast::BlockStatement>(body), decorations);
+ return mod->create<ast::Function>(source, mod->RegisterSymbol(name), params,
+ type, create<ast::BlockStatement>(body),
+ decorations);
}
/// Creates a Function
@@ -637,7 +636,7 @@
type::Type* type,
ast::StatementList body,
ast::FunctionDecorationList decorations) {
- return create<ast::Function>(mod->RegisterSymbol(name), name, params, type,
+ return create<ast::Function>(mod->RegisterSymbol(name), params, type,
create<ast::BlockStatement>(body),
decorations);
}
@@ -650,8 +649,8 @@
StructMember* Member(const Source& source,
const std::string& name,
type::Type* type) {
- return mod->create<StructMember>(source, mod->RegisterSymbol(name), name,
- type, StructMemberDecorationList{});
+ return mod->create<StructMember>(source, mod->RegisterSymbol(name), type,
+ StructMemberDecorationList{});
}
/// Creates a StructMember
@@ -659,8 +658,8 @@
/// @param type the struct member type
/// @returns the struct member pointer
StructMember* Member(const std::string& name, type::Type* type) {
- return mod->create<StructMember>(source_, mod->RegisterSymbol(name), name,
- type, StructMemberDecorationList{});
+ return mod->create<StructMember>(source_, mod->RegisterSymbol(name), type,
+ StructMemberDecorationList{});
}
/// Creates a StructMember
@@ -671,8 +670,8 @@
StructMember* Member(const std::string& name,
type::Type* type,
StructMemberDecorationList decos) {
- return mod->create<StructMember>(source_, mod->RegisterSymbol(name), name,
- type, decos);
+ return mod->create<StructMember>(source_, mod->RegisterSymbol(name), type,
+ decos);
}
/// Creates a new Node owned by the Module, with the explicit Source.
diff --git a/src/ast/function.cc b/src/ast/function.cc
index 7e076b3..723cb85 100644
--- a/src/ast/function.cc
+++ b/src/ast/function.cc
@@ -32,14 +32,12 @@
Function::Function(const Source& source,
Symbol symbol,
- const std::string& name,
VariableList params,
type::Type* return_type,
BlockStatement* body,
FunctionDecorationList decorations)
: Base(source),
symbol_(symbol),
- name_(name),
params_(std::move(params)),
return_type_(return_type),
body_(body),
@@ -228,7 +226,7 @@
Function* Function::Clone(CloneContext* ctx) const {
return ctx->mod->create<Function>(
- ctx->Clone(source()), ctx->Clone(symbol()), name_, ctx->Clone(params_),
+ ctx->Clone(source()), ctx->Clone(symbol()), ctx->Clone(params_),
ctx->Clone(return_type_), ctx->Clone(body_), ctx->Clone(decorations_));
}
@@ -240,7 +238,7 @@
if (body_ == nullptr || !body_->IsValid()) {
return false;
}
- if (name_.length() == 0 || !symbol_.IsValid()) {
+ if (!symbol_.IsValid()) {
return false;
}
if (return_type_ == nullptr) {
diff --git a/src/ast/function.h b/src/ast/function.h
index 151794f..7dbda87 100644
--- a/src/ast/function.h
+++ b/src/ast/function.h
@@ -54,14 +54,12 @@
/// Create a function
/// @param source the variable source
/// @param symbol the function symbol
- /// @param name the function name
/// @param params the function parameters
/// @param return_type the return type
/// @param body the function body
/// @param decorations the function decorations
Function(const Source& source,
Symbol symbol,
- const std::string& name,
VariableList params,
type::Type* return_type,
BlockStatement* body,
@@ -73,8 +71,6 @@
/// @returns the function symbol
Symbol symbol() const { return symbol_; }
- /// @returns the function name
- const std::string& name_for_clone() { return name_; }
/// @returns the function params
const VariableList& params() const { return params_; }
@@ -184,7 +180,7 @@
/// @return the newly cloned node
Function* Clone(CloneContext* ctx) const override;
- /// @returns true if the name and type are both present
+ /// @returns true if the symbol and type are both present
bool IsValid() const override;
/// Writes a representation of the node to the output stream
@@ -203,7 +199,6 @@
ReferencedSampledTextureVariablesImpl(bool multisampled) const;
Symbol const symbol_;
- std::string const name_;
VariableList const params_;
type::Type* const return_type_;
BlockStatement* const body_;
diff --git a/src/ast/identifier_expression.cc b/src/ast/identifier_expression.cc
index b18ca10..9d6bafe 100644
--- a/src/ast/identifier_expression.cc
+++ b/src/ast/identifier_expression.cc
@@ -22,10 +22,8 @@
namespace tint {
namespace ast {
-IdentifierExpression::IdentifierExpression(const Source& source,
- Symbol sym,
- const std::string& name)
- : Base(source), sym_(sym), name_(name) {}
+IdentifierExpression::IdentifierExpression(const Source& source, Symbol sym)
+ : Base(source), sym_(sym) {}
IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default;
@@ -33,7 +31,7 @@
IdentifierExpression* IdentifierExpression::Clone(CloneContext* ctx) const {
return ctx->mod->create<IdentifierExpression>(ctx->Clone(source()),
- ctx->Clone(symbol()), name_);
+ ctx->Clone(symbol()));
}
bool IdentifierExpression::IsValid() const {
diff --git a/src/ast/identifier_expression.h b/src/ast/identifier_expression.h
index 82ffca0..b6b9b62 100644
--- a/src/ast/identifier_expression.h
+++ b/src/ast/identifier_expression.h
@@ -16,7 +16,6 @@
#define SRC_AST_IDENTIFIER_EXPRESSION_H_
#include <memory>
-#include <string>
#include <utility>
#include "src/ast/expression.h"
@@ -32,10 +31,7 @@
/// Constructor
/// @param source the source
/// @param sym the symbol for the identifier
- /// @param name the name
- IdentifierExpression(const Source& source,
- Symbol sym,
- const std::string& name);
+ IdentifierExpression(const Source& source, Symbol sym);
/// Move constructor
IdentifierExpression(IdentifierExpression&&);
~IdentifierExpression() override;
@@ -82,7 +78,6 @@
IdentifierExpression(const IdentifierExpression&) = delete;
Symbol const sym_;
- std::string const name_;
Intrinsic intrinsic_ = Intrinsic::kNone; // Semantic info
std::unique_ptr<intrinsic::Signature> intrinsic_sig_; // Semantic info
diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc
index 20b74c9..a387cc0 100644
--- a/src/ast/struct_member.cc
+++ b/src/ast/struct_member.cc
@@ -25,12 +25,10 @@
StructMember::StructMember(const Source& source,
const Symbol& sym,
- const std::string& name,
type::Type* type,
StructMemberDecorationList decorations)
: Base(source),
symbol_(sym),
- name_(name),
type_(type),
decorations_(std::move(decorations)) {}
@@ -57,13 +55,13 @@
}
StructMember* StructMember::Clone(CloneContext* ctx) const {
- return ctx->mod->create<StructMember>(
- ctx->Clone(source()), ctx->Clone(symbol_), name_, ctx->Clone(type_),
- ctx->Clone(decorations_));
+ return ctx->mod->create<StructMember>(ctx->Clone(source()),
+ ctx->Clone(symbol_), ctx->Clone(type_),
+ ctx->Clone(decorations_));
}
bool StructMember::IsValid() const {
- if (name_.empty() || type_ == nullptr || !symbol_.IsValid()) {
+ if (type_ == nullptr || !symbol_.IsValid()) {
return false;
}
for (auto* deco : decorations_) {
diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h
index 66d1977..52204f8 100644
--- a/src/ast/struct_member.h
+++ b/src/ast/struct_member.h
@@ -17,7 +17,6 @@
#include <memory>
#include <ostream>
-#include <string>
#include <utility>
#include <vector>
@@ -35,12 +34,10 @@
/// Create a new struct member statement
/// @param source The input source for the struct member statement
/// @param sym The struct member symbol
- /// @param name The struct member name
/// @param type The struct member type
/// @param decorations The struct member decorations
StructMember(const Source& source,
const Symbol& sym,
- const std::string& name,
type::Type* type,
StructMemberDecorationList decorations);
/// Move constructor
@@ -81,7 +78,6 @@
StructMember(const StructMember&) = delete;
Symbol const symbol_;
- std::string const name_;
type::Type* const type_;
StructMemberDecorationList const decorations_;
};
diff --git a/src/ast/type/alias_type.cc b/src/ast/type/alias_type.cc
index bef935b..b8632de 100644
--- a/src/ast/type/alias_type.cc
+++ b/src/ast/type/alias_type.cc
@@ -25,8 +25,8 @@
namespace ast {
namespace type {
-Alias::Alias(const Symbol& sym, const std::string& name, Type* subtype)
- : symbol_(sym), name_(name), subtype_(subtype) {
+Alias::Alias(const Symbol& sym, Type* subtype)
+ : symbol_(sym), subtype_(subtype) {
assert(subtype_);
}
@@ -47,8 +47,7 @@
}
Alias* Alias::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Alias>(ctx->Clone(symbol()), name_,
- ctx->Clone(subtype_));
+ return ctx->mod->create<Alias>(ctx->Clone(symbol()), ctx->Clone(subtype_));
}
} // namespace type
diff --git a/src/ast/type/alias_type.h b/src/ast/type/alias_type.h
index 7fd0a30..7bc3bc2 100644
--- a/src/ast/type/alias_type.h
+++ b/src/ast/type/alias_type.h
@@ -29,9 +29,8 @@
public:
/// Constructor
/// @param sym the symbol for the alias
- /// @param name the alias name
/// @param subtype the alias'd type
- Alias(const Symbol& sym, const std::string& name, Type* subtype);
+ Alias(const Symbol& sym, Type* subtype);
/// Move constructor
Alias(Alias&&);
/// Destructor
@@ -42,7 +41,7 @@
/// @returns the alias type
Type* type() const { return subtype_; }
- /// @returns the name for this type
+ /// @returns the type_name for this type
std::string type_name() const override;
/// @param mem_layout type of memory layout to use in calculation.
@@ -62,7 +61,6 @@
private:
Symbol const symbol_;
- std::string const name_;
Type* const subtype_;
};
diff --git a/src/ast/type/struct_type.cc b/src/ast/type/struct_type.cc
index 7a127a6..24f5640 100644
--- a/src/ast/type/struct_type.cc
+++ b/src/ast/type/struct_type.cc
@@ -30,8 +30,8 @@
namespace ast {
namespace type {
-Struct::Struct(const Symbol& sym, const std::string& name, ast::Struct* impl)
- : symbol_(sym), name_(name), struct_(impl) {}
+Struct::Struct(const Symbol& sym, ast::Struct* impl)
+ : symbol_(sym), struct_(impl) {}
Struct::Struct(Struct&&) = default;
@@ -84,8 +84,7 @@
}
Struct* Struct::Clone(CloneContext* ctx) const {
- return ctx->mod->create<Struct>(ctx->Clone(symbol()), name_,
- ctx->Clone(struct_));
+ return ctx->mod->create<Struct>(ctx->Clone(symbol()), ctx->Clone(struct_));
}
} // namespace type
diff --git a/src/ast/type/struct_type.h b/src/ast/type/struct_type.h
index 2d90a7a..e340f4bb 100644
--- a/src/ast/type/struct_type.h
+++ b/src/ast/type/struct_type.h
@@ -31,9 +31,8 @@
public:
/// Constructor
/// @param sym the symbol representing the struct
- /// @param name the name of the struct
/// @param impl the struct data
- Struct(const Symbol& sym, const std::string& name, ast::Struct* impl);
+ Struct(const Symbol& sym, ast::Struct* impl);
/// Move constructor
Struct(Struct&&);
~Struct() override;
@@ -44,7 +43,7 @@
/// @returns true if the struct has a block decoration
bool IsBlockDecorated() const { return struct_->IsBlockDecorated(); }
- /// @returns the struct name
+ /// @returns the struct
ast::Struct* impl() const { return struct_; }
/// @returns the name for the type
@@ -67,7 +66,6 @@
private:
Symbol const symbol_;
- std::string const name_;
ast::Struct* const struct_;
uint64_t LargestMemberBaseAlignment(MemoryLayout mem_layout) const;
diff --git a/src/ast/variable.cc b/src/ast/variable.cc
index 777b6e3..6ac6976 100644
--- a/src/ast/variable.cc
+++ b/src/ast/variable.cc
@@ -27,7 +27,6 @@
Variable::Variable(const Source& source,
const Symbol& sym,
- const std::string& name,
StorageClass sc,
type::Type* type,
bool is_const,
@@ -35,7 +34,6 @@
VariableDecorationList decorations)
: Base(source),
symbol_(sym),
- name_(name),
type_(type),
is_const_(is_const),
constructor_(constructor),
@@ -85,13 +83,13 @@
Variable* Variable::Clone(CloneContext* ctx) const {
return ctx->mod->create<Variable>(ctx->Clone(source()), ctx->Clone(symbol_),
- name_, storage_class(), ctx->Clone(type()),
+ storage_class(), ctx->Clone(type()),
is_const_, ctx->Clone(constructor()),
ctx->Clone(decorations_));
}
bool Variable::IsValid() const {
- if (name_.length() == 0 || !symbol_.IsValid()) {
+ if (!symbol_.IsValid()) {
return false;
}
if (type_ == nullptr) {
diff --git a/src/ast/variable.h b/src/ast/variable.h
index a805485..134b013 100644
--- a/src/ast/variable.h
+++ b/src/ast/variable.h
@@ -17,7 +17,6 @@
#include <memory>
#include <ostream>
-#include <string>
#include <utility>
#include <vector>
@@ -83,7 +82,6 @@
/// Create a variable
/// @param source the variable source
/// @param sym the variable symbol
- /// @param name the variables name
/// @param sc the variable storage class
/// @param type the value type
/// @param is_const true if the variable is const
@@ -91,7 +89,6 @@
/// @param decorations the variable decorations
Variable(const Source& source,
const Symbol& sym,
- const std::string& name,
StorageClass sc,
type::Type* type,
bool is_const,
@@ -166,7 +163,6 @@
Variable(const Variable&) = delete;
Symbol const symbol_;
- std::string const name_;
// The value type if a const or formal paramter, and the store type if a var
type::Type* const type_;
bool const is_const_;
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index ec99005..7ed54e2 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -787,7 +787,7 @@
const auto& top = statements_stack_.back();
auto* cond = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(guard_name), guard_name);
+ Source{}, ast_module_.RegisterSymbol(guard_name));
auto* builder = AddStatementBuilder<IfStatementBuilder>(cond);
PushNewStatementBlock(
@@ -862,8 +862,8 @@
auto* body = create<ast::BlockStatement>(Source{}, statements);
ast_module_.AddFunction(
create<ast::Function>(decl.source, ast_module_.RegisterSymbol(decl.name),
- decl.name, std::move(decl.params), decl.return_type,
- body, std::move(decl.decorations)));
+ std::move(decl.params), decl.return_type, body,
+ std::move(decl.decorations)));
// Maintain the invariant by repopulating the one and only element.
statements_stack_.clear();
@@ -2013,8 +2013,8 @@
auto name = namer_.Name(id);
return TypedExpression{
parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()),
- create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name)};
+ create<ast::IdentifierExpression>(Source{},
+ ast_module_.RegisterSymbol(name))};
}
if (singly_used_values_.count(id)) {
auto expr = std::move(singly_used_values_[id]);
@@ -2034,10 +2034,9 @@
case SpvOpVariable: {
// This occurs for module-scope variables.
auto name = namer_.Name(inst->result_id());
- return TypedExpression{
- parser_impl_.ConvertType(inst->type_id()),
- create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name)};
+ return TypedExpression{parser_impl_.ConvertType(inst->type_id()),
+ create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name))};
}
default:
break;
@@ -2269,7 +2268,6 @@
auto* guard_var =
create<ast::Variable>(Source{}, // source
ast_module_.RegisterSymbol(guard_name), // symbol
- guard_name, // name
ast::StorageClass::kFunction, // storage_class
parser_impl_.Bool(), // type
false, // is_const
@@ -2676,7 +2674,7 @@
return create<ast::AssignmentStatement>(
Source{},
create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(flow_guard), flow_guard),
+ Source{}, ast_module_.RegisterSymbol(flow_guard)),
MakeFalse(Source{}));
}
@@ -2798,7 +2796,6 @@
auto* var = create<ast::Variable>(
Source{}, // source
ast_module_.RegisterSymbol(phi_var_name), // symbol
- phi_var_name, // name
ast::StorageClass::kFunction, // storage_class
parser_impl_.ConvertType(def_inst->type_id()), // type
false, // is_const
@@ -2837,7 +2834,7 @@
AddStatement(create<ast::AssignmentStatement>(
Source{},
create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(var_name), var_name),
+ Source{}, ast_module_.RegisterSymbol(var_name)),
expr.expr));
}
}
@@ -2874,8 +2871,8 @@
// Emit an assignment of the expression to the hoisted variable.
AddStatement(create<ast::AssignmentStatement>(
Source{},
- create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), namer_.Name(result_id)),
+ create<ast::IdentifierExpression>(Source{},
+ ast_module_.RegisterSymbol(name)),
ast_expr.expr));
return true;
}
@@ -3014,8 +3011,7 @@
TypedExpression expr{
parser_impl_.ConvertType(inst.type_id()),
create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(def_info->phi_var),
- def_info->phi_var)};
+ Source{}, ast_module_.RegisterSymbol(def_info->phi_var))};
return EmitConstDefOrWriteToHoistedVar(inst, expr);
}
@@ -3074,8 +3070,7 @@
create<ast::CallExpression>(
Source{},
create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(unary_builtin_name),
- unary_builtin_name),
+ Source{}, ast_module_.RegisterSymbol(unary_builtin_name)),
std::move(params))};
}
@@ -3181,7 +3176,7 @@
}
auto* func = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name));
ast::ExpressionList operands;
ast::type::Type* first_operand_type = nullptr;
// All parameters to GLSL.std.450 extended instructions are IDs.
@@ -3207,20 +3202,20 @@
}
const char* names[] = {"x", "y", "z", "w"};
return create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(names[i & 3]), names[i & 3]);
+ Source{}, ast_module_.RegisterSymbol(names[i & 3]));
}
ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) {
switch (n) {
case 1:
- return create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol("x"), "x");
+ return create<ast::IdentifierExpression>(Source{},
+ ast_module_.RegisterSymbol("x"));
case 2:
return create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol("xy"), "xy");
+ Source{}, ast_module_.RegisterSymbol("xy"));
case 3:
return create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol("xyz"), "xyz");
+ Source{}, ast_module_.RegisterSymbol("xyz"));
default:
break;
}
@@ -3315,7 +3310,7 @@
auto name = namer_.Name(base_id);
current_expr.expr = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name));
current_expr.type = parser_impl_.ConvertType(ptr_ty_id);
}
}
@@ -3408,7 +3403,7 @@
auto name =
namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val));
auto* member_access = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name));
next_expr = create<ast::MemberAccessorExpression>(
Source{}, current_expr.expr, member_access);
@@ -3529,7 +3524,7 @@
}
auto name = namer_.GetMemberName(current_type_id, uint32_t(index_val));
auto* member_access = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name));
next_expr = create<ast::MemberAccessorExpression>(
Source{}, current_expr.expr, member_access);
@@ -3933,7 +3928,7 @@
// We ignore function attributes such as Inline, DontInline, Pure, Const.
auto name = namer_.Name(inst.GetSingleWordInOperand(0));
auto* function = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name));
ast::ExpressionList params;
for (uint32_t iarg = 1; iarg < inst.NumInOperands(); ++iarg) {
@@ -3962,7 +3957,7 @@
ss << intrinsic;
auto name = ss.str();
auto* ident = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name));
ident->set_intrinsic(intrinsic);
ast::ExpressionList params;
@@ -4009,7 +4004,7 @@
create<ast::CallExpression>(
Source{},
create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol("select"), "select"),
+ Source{}, ast_module_.RegisterSymbol("select")),
std::move(params))};
}
return {};
@@ -4035,7 +4030,7 @@
}
auto name = namer_.Name(image->result_id());
params.push_back(create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(name), name));
+ Source{}, ast_module_.RegisterSymbol(name)));
const auto opcode = inst.opcode();
if (IsSampledImageAccess(opcode)) {
@@ -4048,7 +4043,7 @@
}
auto param_name = namer_.Name(sampler->result_id());
params.push_back(create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(param_name), param_name));
+ Source{}, ast_module_.RegisterSymbol(param_name)));
}
ast::type::Pointer* texture_ptr_type =
@@ -4214,7 +4209,7 @@
}
auto* ident = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(builtin_name), builtin_name);
+ Source{}, ast_module_.RegisterSymbol(builtin_name));
auto* call_expr =
create<ast::CallExpression>(Source{}, ident, std::move(params));
@@ -4556,14 +4551,14 @@
}
auto* member_ident = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(field_name), field_name);
+ Source{}, ast_module_.RegisterSymbol(field_name));
auto* member_access = create<ast::MemberAccessorExpression>(
Source{}, MakeExpression(struct_ptr_id).expr, member_ident);
// Generate the intrinsic function call.
std::string call_ident_str = "arrayLength";
auto* call_ident = create<ast::IdentifierExpression>(
- Source{}, ast_module_.RegisterSymbol(call_ident_str), call_ident_str);
+ Source{}, ast_module_.RegisterSymbol(call_ident_str));
call_ident->set_intrinsic(ast::Intrinsic::kArrayLength);
ast::ExpressionList params{member_access};
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index ee91183..ebb3234 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -948,8 +948,8 @@
}
const auto member_name = namer_.GetMemberName(type_id, member_index);
auto* ast_struct_member = create<ast::StructMember>(
- Source{}, ast_module_.RegisterSymbol(member_name), member_name,
- ast_member_ty, std::move(ast_member_decorations));
+ Source{}, ast_module_.RegisterSymbol(member_name), ast_member_ty,
+ std::move(ast_member_decorations));
ast_members.push_back(ast_struct_member);
}
if (is_per_vertex_struct) {
@@ -965,7 +965,7 @@
auto name = namer_.GetName(type_id);
auto* result = ast_module_.create<ast::type::Struct>(
- ast_module_.RegisterSymbol(name), name, ast_struct);
+ ast_module_.RegisterSymbol(name), ast_struct);
id_to_type_[type_id] = result;
if (num_non_writable_members == members.size()) {
read_only_struct_types_.insert(result);
@@ -1132,7 +1132,7 @@
}
const auto name = namer_.GetName(type_id);
auto* ast_alias_type = ast_module_.create<ast::type::Alias>(
- ast_module_.RegisterSymbol(name), name, ast_underlying_type);
+ ast_module_.RegisterSymbol(name), ast_underlying_type);
// Record this new alias as the AST type for this SPIR-V ID.
id_to_type_[type_id] = ast_alias_type;
ast_module_.AddConstructedType(ast_alias_type);
@@ -1311,7 +1311,6 @@
std::string name = namer_.Name(id);
return create<ast::Variable>(Source{}, // source
ast_module_.RegisterSymbol(name), // symbol
- name, // name
sc, // storage_class
type, // type
is_const, // is_const
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index d58b153..d178cb9 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -434,7 +434,6 @@
return create<ast::Variable>(decl->source, // source
module_.RegisterSymbol(decl->name), // symbol
- decl->name, // name
decl->storage_class, // storage_class
decl->type, // type
false, // is_const
@@ -463,7 +462,6 @@
return create<ast::Variable>(decl->source, // source
module_.RegisterSymbol(decl->name), // symbol
- decl->name, // name
ast::StorageClass::kNone, // storage_class
decl->type, // type
true, // is_const
@@ -941,7 +939,7 @@
return add_error(peek(), "invalid type alias");
auto* alias = module_.create<ast::type::Alias>(
- module_.RegisterSymbol(name.value), name.value, type.value);
+ module_.RegisterSymbol(name.value), type.value);
register_constructed(name.value, alias);
return alias;
@@ -1195,7 +1193,7 @@
return Failure::kErrored;
return std::make_unique<ast::type::Struct>(
- module_.RegisterSymbol(name.value), name.value,
+ module_.RegisterSymbol(name.value),
create<ast::Struct>(source, std::move(body.value),
std::move(struct_decos.value)));
}
@@ -1249,9 +1247,9 @@
if (!expect("struct member", Token::Type::kSemicolon))
return Failure::kErrored;
- return create<ast::StructMember>(
- decl->source, module_.RegisterSymbol(decl->name), decl->name, decl->type,
- std::move(member_decos.value));
+ return create<ast::StructMember>(decl->source,
+ module_.RegisterSymbol(decl->name),
+ decl->type, std::move(member_decos.value));
}
// function_decl
@@ -1287,8 +1285,8 @@
return Failure::kErrored;
return create<ast::Function>(
- header->source, module_.RegisterSymbol(header->name), header->name,
- header->params, header->return_type, body.value, func_decos.value);
+ header->source, module_.RegisterSymbol(header->name), header->params,
+ header->return_type, body.value, func_decos.value);
}
// function_type_decl
@@ -1358,7 +1356,6 @@
auto* var =
create<ast::Variable>(decl->source, // source
module_.RegisterSymbol(decl->name), // symbol
- decl->name, // name
ast::StorageClass::kNone, // storage_class
decl->type, // type
true, // is_const
@@ -1630,7 +1627,6 @@
auto* var =
create<ast::Variable>(decl->source, // source
module_.RegisterSymbol(decl->name), // symbol
- decl->name, // name
ast::StorageClass::kNone, // storage_class
decl->type, // type
true, // is_const
@@ -1660,7 +1656,6 @@
auto* var =
create<ast::Variable>(decl->source, // source
module_.RegisterSymbol(decl->name), // symbol
- decl->name, // name
decl->storage_class, // storage_class
decl->type, // type
false, // is_const
@@ -2046,11 +2041,11 @@
return Failure::kErrored;
return create<ast::CallStatement>(
- Source{}, create<ast::CallExpression>(
- source,
- create<ast::IdentifierExpression>(
- source, module_.RegisterSymbol(name), name),
- std::move(params)));
+ Source{},
+ create<ast::CallExpression>(source,
+ create<ast::IdentifierExpression>(
+ source, module_.RegisterSymbol(name)),
+ std::move(params)));
}
// break_stmt
@@ -2122,7 +2117,7 @@
if (match(Token::Type::kIdentifier))
return create<ast::IdentifierExpression>(
- t.source(), module_.RegisterSymbol(t.to_str()), t.to_str());
+ t.source(), module_.RegisterSymbol(t.to_str()));
auto type = type_decl();
if (type.errored)
@@ -2198,7 +2193,7 @@
return postfix_expr(create<ast::MemberAccessorExpression>(
ident.source, prefix,
create<ast::IdentifierExpression>(
- ident.source, module_.RegisterSymbol(ident.value), ident.value)));
+ ident.source, module_.RegisterSymbol(ident.value))));
}
return prefix;
diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc
index f7872cf..efe51a0 100644
--- a/src/reader/wgsl/parser_impl_type_alias_test.cc
+++ b/src/reader/wgsl/parser_impl_type_alias_test.cc
@@ -45,7 +45,7 @@
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
auto p = parser("type a = B");
- ast::type::Struct str(p->get_module().RegisterSymbol("B"), "B", {});
+ ast::type::Struct str(p->get_module().RegisterSymbol("B"), {});
p->register_constructed("B", &str);
auto t = p->type_alias();
diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc
index 9251526..5bb6f9f 100644
--- a/src/reader/wgsl/parser_impl_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_type_decl_test.cc
@@ -50,7 +50,7 @@
auto* int_type = mod.create<ast::type::I32>();
auto* alias_type =
- mod.create<ast::type::Alias>(mod.RegisterSymbol("A"), "A", int_type);
+ mod.create<ast::type::Alias>(mod.RegisterSymbol("A"), int_type);
p->register_constructed("A", alias_type);
diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc
index 7e48e0a..1628d63 100644
--- a/src/transform/emit_vertex_point_size.cc
+++ b/src/transform/emit_vertex_point_size.cc
@@ -53,7 +53,6 @@
auto* pointsize_var = out.module.create<ast::Variable>(
Source{}, // source
out.module.RegisterSymbol(kPointSizeVar), // symbol
- kPointSizeVar, // name
ast::StorageClass::kOutput, // storage_class
f32, // type
false, // is_const
@@ -69,7 +68,7 @@
auto* one = out.module.create<ast::ScalarConstructorExpression>(
Source{}, out.module.create<ast::FloatLiteral>(Source{}, f32, 1.0f));
auto* pointsize_ident = out.module.create<ast::IdentifierExpression>(
- Source{}, out.module.RegisterSymbol(kPointSizeVar), kPointSizeVar);
+ Source{}, out.module.RegisterSymbol(kPointSizeVar));
auto* pointsize_assign = out.module.create<ast::AssignmentStatement>(
Source{}, pointsize_ident, one);
diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc
index 3cafccb..8158857 100644
--- a/src/transform/first_index_offset.cc
+++ b/src/transform/first_index_offset.cc
@@ -67,7 +67,6 @@
return ctx->mod->create<ast::Variable>(
ctx->Clone(in->source()), // source
ctx->mod->RegisterSymbol(new_name), // symbol
- new_name, // name
in->storage_class(), // storage_class
ctx->Clone(in->type()), // type
in->is_const(), // is_const
@@ -205,8 +204,8 @@
member_dec.push_back(
mod->create<ast::StructMemberOffsetDecoration>(Source{}, offset));
members.push_back(mod->create<ast::StructMember>(
- Source{}, mod->RegisterSymbol(kFirstVertexName), kFirstVertexName,
- u32_type, std::move(member_dec)));
+ Source{}, mod->RegisterSymbol(kFirstVertexName), u32_type,
+ std::move(member_dec)));
vertex_index_offset_ = offset;
offset += 4;
}
@@ -216,8 +215,8 @@
member_dec.push_back(
mod->create<ast::StructMemberOffsetDecoration>(Source{}, offset));
members.push_back(mod->create<ast::StructMember>(
- Source{}, mod->RegisterSymbol(kFirstInstanceName), kFirstInstanceName,
- u32_type, std::move(member_dec)));
+ Source{}, mod->RegisterSymbol(kFirstInstanceName), u32_type,
+ std::move(member_dec)));
instance_index_offset_ = offset;
offset += 4;
}
@@ -226,13 +225,12 @@
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
auto* struct_type = mod->create<ast::type::Struct>(
- mod->RegisterSymbol(kStructName), kStructName,
+ mod->RegisterSymbol(kStructName),
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
auto* idx_var = mod->create<ast::Variable>(
Source{}, // source
mod->RegisterSymbol(kBufferName), // symbol
- kBufferName, // name
ast::StorageClass::kUniform, // storage_class
struct_type, // type
false, // is_const
@@ -254,22 +252,21 @@
const std::string& field_name,
ast::Variable* buffer_var,
ast::Module* mod) {
- auto* buffer = mod->create<ast::IdentifierExpression>(
- Source{}, buffer_var->symbol(), mod->SymbolToName(buffer_var->symbol()));
+ auto* buffer =
+ mod->create<ast::IdentifierExpression>(Source{}, buffer_var->symbol());
auto lhs_name = kIndexOffsetPrefix + original_name;
auto* constructor = mod->create<ast::BinaryExpression>(
Source{}, ast::BinaryOp::kAdd,
- mod->create<ast::IdentifierExpression>(
- Source{}, mod->RegisterSymbol(lhs_name), lhs_name),
+ mod->create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol(lhs_name)),
mod->create<ast::MemberAccessorExpression>(
Source{}, buffer,
mod->create<ast::IdentifierExpression>(
- Source{}, mod->RegisterSymbol(field_name), field_name)));
+ Source{}, mod->RegisterSymbol(field_name))));
auto* var =
mod->create<ast::Variable>(Source{}, // source
mod->RegisterSymbol(original_name), // symbol
- original_name, // name
ast::StorageClass::kNone, // storage_class
mod->create<ast::type::U32>(), // type
true, // is_const
diff --git a/src/transform/transform.cc b/src/transform/transform.cc
index 3b6da17..65fadb9 100644
--- a/src/transform/transform.cc
+++ b/src/transform/transform.cc
@@ -32,7 +32,7 @@
statements.emplace_back(ctx->Clone(s));
}
return ctx->mod->create<ast::Function>(
- ctx->Clone(in->source()), ctx->Clone(in->symbol()), in->name_for_clone(),
+ ctx->Clone(in->source()), ctx->Clone(in->symbol()),
ctx->Clone(in->params()), ctx->Clone(in->return_type()),
ctx->mod->create<ast::BlockStatement>(ctx->Clone(in->body()->source()),
statements),
diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc
index 9709919..a0d9a7e 100644
--- a/src/transform/vertex_pulling.cc
+++ b/src/transform/vertex_pulling.cc
@@ -168,7 +168,6 @@
auto* var = out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(vertex_index_name), // symbol
- vertex_index_name, // name
ast::StorageClass::kInput, // storage_class
GetI32Type(), // type
false, // is_const
@@ -216,7 +215,6 @@
auto* var = out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(instance_index_name), // symbol
- instance_index_name, // name
ast::StorageClass::kInput, // storage_class
GetI32Type(), // type
false, // is_const
@@ -244,7 +242,6 @@
v = out->create<ast::Variable>(
Source{}, // source
v->symbol(), // symbol
- out->SymbolToName(v->symbol()), // name
ast::StorageClass::kPrivate, // storage_class
v->type(), // type
false, // is_const
@@ -273,14 +270,14 @@
out->create<ast::StructMemberOffsetDecoration>(Source{}, 0u));
members.push_back(out->create<ast::StructMember>(
- Source{}, out->RegisterSymbol(kStructBufferName), kStructBufferName,
- internal_array_type, std::move(member_dec)));
+ Source{}, out->RegisterSymbol(kStructBufferName), internal_array_type,
+ std::move(member_dec)));
ast::StructDecorationList decos;
decos.push_back(out->create<ast::StructBlockDecoration>(Source{}));
auto* struct_type = out->create<ast::type::Struct>(
- out->RegisterSymbol(kStructName), kStructName,
+ out->RegisterSymbol(kStructName),
out->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
@@ -289,7 +286,6 @@
auto* var = out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(name), // symbol
- name, // name
ast::StorageClass::kStorageBuffer, // storage_class
struct_type, // type
false, // is_const
@@ -315,7 +311,6 @@
Source{}, out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(kPullingPosVarName), // symbol
- kPullingPosVarName, // name
ast::StorageClass::kFunction, // storage_class
GetI32Type(), // type
false, // is_const
@@ -343,7 +338,7 @@
: instance_index_name;
// Identifier to index by
auto* index_identifier = out->create<ast::IdentifierExpression>(
- Source{}, out->RegisterSymbol(name), name);
+ Source{}, out->RegisterSymbol(name));
// An expression for the start of the read in the buffer in bytes
auto* pos_value = out->create<ast::BinaryExpression>(
@@ -362,7 +357,7 @@
stmts.emplace_back(out->create<ast::AssignmentStatement>(
Source{},
out->create<ast::IdentifierExpression>(
- Source{}, out->RegisterSymbol(ident_name), ident_name),
+ Source{}, out->RegisterSymbol(ident_name)),
AccessByFormat(i, attribute_desc.format)));
}
}
@@ -377,7 +372,7 @@
ast::Expression* VertexPulling::State::CreatePullingPositionIdent() const {
return out->create<ast::IdentifierExpression>(
- Source{}, out->RegisterSymbol(kPullingPosVarName), kPullingPosVarName);
+ Source{}, out->RegisterSymbol(kPullingPosVarName));
}
ast::Expression* VertexPulling::State::AccessByFormat(
@@ -421,10 +416,9 @@
out->create<ast::MemberAccessorExpression>(
Source{},
out->create<ast::IdentifierExpression>(
- Source{}, out->RegisterSymbol(vbuf_name), vbuf_name),
+ Source{}, out->RegisterSymbol(vbuf_name)),
out->create<ast::IdentifierExpression>(
- Source{}, out->RegisterSymbol(kStructBufferName),
- kStructBufferName)),
+ Source{}, out->RegisterSymbol(kStructBufferName))),
out->create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kDivide, pos,
GenUint(4)));
}