tint/ast: Change Variable::symbol to Variable::name
Variable::name is an ast::Identifier. The goal here is to have all AST nodes use an identifier instead of symbols directly. This will greatly simplify the renamer transform, and gives the symbol a Source location, which is helpful for diagnostics and tooling. Change-Id: I71fe3e8df3d22b12d4a3430c41f236ddf5bc0b9e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119282 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
199440e37c
commit
651d9e2558
|
@ -25,11 +25,11 @@ namespace tint::ast {
|
|||
Const::Const(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const Identifier* n,
|
||||
const ast::Type* ty,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)) {
|
||||
: Base(pid, nid, src, n, ty, init, std::move(attrs)) {
|
||||
TINT_ASSERT(AST, init != nullptr);
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ const char* Const::Kind() const {
|
|||
|
||||
const Const* Const::Clone(CloneContext* ctx) const {
|
||||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto n = ctx->Clone(name);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Const>(src, sym, ty, init, std::move(attrs));
|
||||
return ctx->dst->create<Const>(src, n, ty, init, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -36,14 +36,14 @@ class Const final : public Castable<Const, Variable> {
|
|||
/// @param pid the identifier of the program that owns this node
|
||||
/// @param nid the unique node identifier
|
||||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param name the variable name
|
||||
/// @param type the declared variable type
|
||||
/// @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 Identifier* name,
|
||||
const ast::Type* type,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
|
|
@ -25,11 +25,11 @@ namespace tint::ast {
|
|||
Let::Let(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const Identifier* n,
|
||||
const ast::Type* ty,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)) {
|
||||
: Base(pid, nid, src, n, ty, init, std::move(attrs)) {
|
||||
TINT_ASSERT(AST, init != nullptr);
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ const char* Let::Kind() const {
|
|||
|
||||
const Let* Let::Clone(CloneContext* ctx) const {
|
||||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* n = ctx->Clone(name);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Let>(src, sym, ty, init, std::move(attrs));
|
||||
return ctx->dst->create<Let>(src, n, ty, init, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -33,14 +33,14 @@ class Let final : public Castable<Let, Variable> {
|
|||
/// @param pid the identifier of the program that owns this node
|
||||
/// @param nid the unique node identifier
|
||||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param name the variable name
|
||||
/// @param type the declared variable type
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Let(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const Identifier* name,
|
||||
const ast::Type* type,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
|
|
@ -25,11 +25,11 @@ namespace tint::ast {
|
|||
Override::Override(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const Identifier* n,
|
||||
const ast::Type* ty,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)) {}
|
||||
: Base(pid, nid, src, n, ty, init, std::move(attrs)) {}
|
||||
|
||||
Override::Override(Override&&) = default;
|
||||
|
||||
|
@ -41,11 +41,11 @@ const char* Override::Kind() const {
|
|||
|
||||
const Override* Override::Clone(CloneContext* ctx) const {
|
||||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* n = ctx->Clone(name);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Override>(src, sym, ty, init, std::move(attrs));
|
||||
return ctx->dst->create<Override>(src, n, ty, init, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -36,14 +36,14 @@ class Override final : public Castable<Override, Variable> {
|
|||
/// @param pid the identifier of the program that owns this node
|
||||
/// @param nid the unique node identifier
|
||||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param name the variable name
|
||||
/// @param type the declared variable type
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Override(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const Identifier* name,
|
||||
const ast::Type* type,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace tint::ast {
|
|||
Parameter::Parameter(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const Identifier* n,
|
||||
const ast::Type* ty,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, nullptr, std::move(attrs)) {}
|
||||
: Base(pid, nid, src, n, ty, nullptr, std::move(attrs)) {}
|
||||
|
||||
Parameter::Parameter(Parameter&&) = default;
|
||||
|
||||
|
@ -40,10 +40,10 @@ const char* Parameter::Kind() const {
|
|||
|
||||
const Parameter* Parameter::Clone(CloneContext* ctx) const {
|
||||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* n = ctx->Clone(name);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Parameter>(src, sym, ty, std::move(attrs));
|
||||
return ctx->dst->create<Parameter>(src, n, ty, std::move(attrs));
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -37,13 +37,13 @@ class Parameter final : public Castable<Parameter, Variable> {
|
|||
/// @param pid the identifier of the program that owns this node
|
||||
/// @param nid the unique node identifier
|
||||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param name the variable name
|
||||
/// @param type the declared variable type
|
||||
/// @param attributes the variable attributes
|
||||
Parameter(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const Identifier* name,
|
||||
const ast::Type* type,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ namespace tint::ast {
|
|||
Var::Var(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const Identifier* n,
|
||||
const ast::Type* ty,
|
||||
type::AddressSpace address_space,
|
||||
type::Access access,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> attrs)
|
||||
: Base(pid, nid, src, sym, ty, init, std::move(attrs)),
|
||||
: Base(pid, nid, src, n, ty, init, std::move(attrs)),
|
||||
declared_address_space(address_space),
|
||||
declared_access(access) {}
|
||||
|
||||
|
@ -43,11 +43,11 @@ const char* Var::Kind() const {
|
|||
|
||||
const Var* Var::Clone(CloneContext* ctx) const {
|
||||
auto src = ctx->Clone(source);
|
||||
auto sym = ctx->Clone(symbol);
|
||||
auto* n = ctx->Clone(name);
|
||||
auto* ty = ctx->Clone(type);
|
||||
auto* init = ctx->Clone(initializer);
|
||||
auto attrs = ctx->Clone(attributes);
|
||||
return ctx->dst->create<Var>(src, sym, ty, declared_address_space, declared_access, init,
|
||||
return ctx->dst->create<Var>(src, n, ty, declared_address_space, declared_access, init,
|
||||
std::move(attrs));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class Var final : public Castable<Var, Variable> {
|
|||
/// @param pid the identifier of the program that owns this node
|
||||
/// @param nid the unique node identifier
|
||||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param name the variable name
|
||||
/// @param type the declared variable type
|
||||
/// @param declared_address_space the declared address space
|
||||
/// @param declared_access the declared access control
|
||||
|
@ -54,7 +54,7 @@ class Var final : public Castable<Var, Variable> {
|
|||
Var(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const Identifier* name,
|
||||
const ast::Type* type,
|
||||
type::AddressSpace declared_address_space,
|
||||
type::Access declared_access,
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/ast/variable.h"
|
||||
#include "src/tint/ast/binding_attribute.h"
|
||||
#include "src/tint/ast/group_attribute.h"
|
||||
#include "src/tint/ast/templated_identifier.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::Variable);
|
||||
|
||||
|
@ -23,13 +24,15 @@ namespace tint::ast {
|
|||
Variable::Variable(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
const Symbol& sym,
|
||||
const Identifier* n,
|
||||
const ast::Type* ty,
|
||||
const Expression* init,
|
||||
utils::VectorRef<const Attribute*> 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);
|
||||
: Base(pid, nid, src), name(n), type(ty), initializer(init), attributes(std::move(attrs)) {
|
||||
TINT_ASSERT(AST, name);
|
||||
if (name) {
|
||||
TINT_ASSERT(AST, !name->Is<TemplatedIdentifier>());
|
||||
}
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, initializer, program_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
// Forward declarations
|
||||
namespace tint::ast {
|
||||
class Identifier;
|
||||
class LocationAttribute;
|
||||
class Type;
|
||||
} // namespace tint::ast
|
||||
|
@ -44,15 +45,15 @@ class Variable : public Castable<Variable, Node> {
|
|||
/// Constructor
|
||||
/// @param pid the identifier of the program that owns this node
|
||||
/// @param nid the unique node identifier
|
||||
/// @param source the variable source
|
||||
/// @param sym the variable symbol
|
||||
/// @param src the variable source
|
||||
/// @param name The struct member name
|
||||
/// @param type the declared variable type
|
||||
/// @param initializer the initializer expression
|
||||
/// @param attributes the variable attributes
|
||||
Variable(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
const Source& src,
|
||||
const Identifier* name,
|
||||
const ast::Type* type,
|
||||
const Expression* initializer,
|
||||
utils::VectorRef<const Attribute*> attributes);
|
||||
|
@ -73,8 +74,8 @@ class Variable : public Castable<Variable, Node> {
|
|||
/// e.g. "var", "let", "const", etc
|
||||
virtual const char* Kind() const = 0;
|
||||
|
||||
/// The variable symbol
|
||||
const Symbol symbol;
|
||||
/// The variable name
|
||||
const Identifier* const name;
|
||||
|
||||
/// The declared variable type. This is null if the type is inferred, e.g.:
|
||||
/// let f = 1.0;
|
||||
|
|
|
@ -27,7 +27,7 @@ using VariableTest = TestHelper;
|
|||
TEST_F(VariableTest, Creation) {
|
||||
auto* v = Var("my_var", ty.i32(), type::AddressSpace::kFunction);
|
||||
|
||||
EXPECT_EQ(v->symbol, Symbol(1, ID()));
|
||||
EXPECT_EQ(v->name->symbol, Symbol(1, ID()));
|
||||
EXPECT_EQ(v->declared_address_space, type::AddressSpace::kFunction);
|
||||
EXPECT_TRUE(v->type->Is<ast::I32>());
|
||||
EXPECT_EQ(v->source.range.begin.line, 0u);
|
||||
|
@ -40,7 +40,7 @@ TEST_F(VariableTest, CreationWithSource) {
|
|||
auto* v = Var(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}}, "i",
|
||||
ty.f32(), type::AddressSpace::kPrivate, utils::Empty);
|
||||
|
||||
EXPECT_EQ(v->symbol, Symbol(1, ID()));
|
||||
EXPECT_EQ(v->name->symbol, Symbol(1, ID()));
|
||||
EXPECT_EQ(v->declared_address_space, type::AddressSpace::kPrivate);
|
||||
EXPECT_TRUE(v->type->Is<ast::F32>());
|
||||
EXPECT_EQ(v->source.range.begin.line, 27u);
|
||||
|
@ -53,7 +53,7 @@ TEST_F(VariableTest, CreationEmpty) {
|
|||
auto* v = Var(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 7}}}, "a_var",
|
||||
ty.i32(), type::AddressSpace::kWorkgroup, utils::Empty);
|
||||
|
||||
EXPECT_EQ(v->symbol, Symbol(1, ID()));
|
||||
EXPECT_EQ(v->name->symbol, Symbol(1, ID()));
|
||||
EXPECT_EQ(v->declared_address_space, type::AddressSpace::kWorkgroup);
|
||||
EXPECT_TRUE(v->type->Is<ast::I32>());
|
||||
EXPECT_EQ(v->source.range.begin.line, 27u);
|
||||
|
@ -62,11 +62,11 @@ TEST_F(VariableTest, CreationEmpty) {
|
|||
EXPECT_EQ(v->source.range.end.column, 7u);
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, Assert_MissingSymbol) {
|
||||
TEST_F(VariableTest, Assert_Null_Name) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
b.Var("", b.ty.i32());
|
||||
b.Var(static_cast<Identifier*>(nullptr), b.ty.i32());
|
||||
},
|
||||
"internal compiler error");
|
||||
}
|
||||
|
|
|
@ -80,8 +80,9 @@ void MutationReplaceIdentifier::Apply(const NodeIdMap& node_id_map,
|
|||
const auto* replacement_var =
|
||||
tint::As<ast::Variable>(node_id_map.GetNode(message_.replacement_id()));
|
||||
|
||||
auto* cloned_replacement = clone_context->dst->Expr(
|
||||
clone_context->Clone(use_node->source), clone_context->Clone(replacement_var->symbol));
|
||||
auto* cloned_replacement =
|
||||
clone_context->dst->Expr(clone_context->Clone(use_node->source),
|
||||
clone_context->Clone(replacement_var->name->symbol));
|
||||
clone_context->Replace(use_node, cloned_replacement);
|
||||
new_node_id_map->Add(cloned_replacement, message_.use_id());
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
|
|||
}
|
||||
|
||||
for (auto* param : sem->Parameters()) {
|
||||
AddEntryPointInOutVariables(program_->Symbols().NameFor(param->Declaration()->symbol),
|
||||
AddEntryPointInOutVariables(program_->Symbols().NameFor(param->Declaration()->name->symbol),
|
||||
param->Type(), param->Declaration()->attributes,
|
||||
param->Location(), entry_point.input_variables);
|
||||
|
||||
|
@ -240,7 +240,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
|
|||
for (auto* var : sem->TransitivelyReferencedGlobals()) {
|
||||
auto* decl = var->Declaration();
|
||||
|
||||
auto name = program_->Symbols().NameFor(decl->symbol);
|
||||
auto name = program_->Symbols().NameFor(decl->name->symbol);
|
||||
|
||||
auto* global = var->As<sem::GlobalVariable>();
|
||||
if (global && global->Declaration()->Is<ast::Override>()) {
|
||||
|
@ -335,7 +335,7 @@ std::map<std::string, OverrideId> Inspector::GetNamedOverrideIds() {
|
|||
for (auto* var : program_->AST().GlobalVariables()) {
|
||||
auto* global = program_->Sem().Get<sem::GlobalVariable>(var);
|
||||
if (global && global->Declaration()->Is<ast::Override>()) {
|
||||
auto name = program_->Symbols().NameFor(var->symbol);
|
||||
auto name = program_->Symbols().NameFor(var->name->symbol);
|
||||
result[name] = global->OverrideId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1206,13 +1206,13 @@ class ProgramBuilder {
|
|||
/// @param variable the AST variable
|
||||
/// @return an ast::IdentifierExpression with the variable's symbol
|
||||
const ast::IdentifierExpression* Expr(const Source& source, const ast::Variable* variable) {
|
||||
return create<ast::IdentifierExpression>(source, Ident(source, variable->symbol));
|
||||
return create<ast::IdentifierExpression>(source, Ident(source, variable->name->symbol));
|
||||
}
|
||||
|
||||
/// @param variable the AST variable
|
||||
/// @return an ast::IdentifierExpression with the variable's symbol
|
||||
const ast::IdentifierExpression* Expr(const ast::Variable* variable) {
|
||||
return create<ast::IdentifierExpression>(Ident(variable->symbol));
|
||||
return create<ast::IdentifierExpression>(Ident(variable->name->symbol));
|
||||
}
|
||||
|
||||
/// @param ident the identifier
|
||||
|
@ -1690,9 +1690,7 @@ class ProgramBuilder {
|
|||
/// options
|
||||
template <typename NAME, typename... OPTIONS, typename = DisableIfSource<NAME>>
|
||||
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.initializer, std::move(opts.attributes));
|
||||
return Var(source_, std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
|
@ -1709,7 +1707,7 @@ class ProgramBuilder {
|
|||
template <typename NAME, typename... OPTIONS>
|
||||
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,
|
||||
return create<ast::Var>(source, Ident(std::forward<NAME>(name)), opts.type,
|
||||
opts.address_space, opts.access, opts.initializer,
|
||||
std::move(opts.attributes));
|
||||
}
|
||||
|
@ -1724,9 +1722,7 @@ class ProgramBuilder {
|
|||
/// @returns an `ast::Const` with the given name, type and additional options
|
||||
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.initializer,
|
||||
std::move(opts.attributes));
|
||||
return Const(source_, std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
|
@ -1741,7 +1737,7 @@ class ProgramBuilder {
|
|||
template <typename NAME, typename... OPTIONS>
|
||||
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,
|
||||
return create<ast::Const>(source, Ident(std::forward<NAME>(name)), opts.type,
|
||||
opts.initializer, std::move(opts.attributes));
|
||||
}
|
||||
|
||||
|
@ -1755,9 +1751,7 @@ class ProgramBuilder {
|
|||
/// @returns an `ast::Let` with the given name, type and additional options
|
||||
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.initializer,
|
||||
std::move(opts.attributes));
|
||||
return Let(source_, std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
|
@ -1772,8 +1766,8 @@ 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.initializer,
|
||||
std::move(opts.attributes));
|
||||
return create<ast::Let>(source, Ident(std::forward<NAME>(name)), opts.type,
|
||||
opts.initializer, std::move(opts.attributes));
|
||||
}
|
||||
|
||||
/// @param name the parameter name
|
||||
|
@ -1784,7 +1778,7 @@ class ProgramBuilder {
|
|||
const ast::Parameter* Param(NAME&& name,
|
||||
const ast::Type* type,
|
||||
utils::VectorRef<const ast::Attribute*> attributes = utils::Empty) {
|
||||
return create<ast::Parameter>(Sym(std::forward<NAME>(name)), type, attributes);
|
||||
return Param(source_, std::forward<NAME>(name), type, std::move(attributes));
|
||||
}
|
||||
|
||||
/// @param source the parameter source
|
||||
|
@ -1797,7 +1791,7 @@ class ProgramBuilder {
|
|||
NAME&& name,
|
||||
const ast::Type* type,
|
||||
utils::VectorRef<const ast::Attribute*> attributes = utils::Empty) {
|
||||
return create<ast::Parameter>(source, Sym(std::forward<NAME>(name)), type, attributes);
|
||||
return create<ast::Parameter>(source, Ident(std::forward<NAME>(name)), type, attributes);
|
||||
}
|
||||
|
||||
/// @param name the variable name
|
||||
|
@ -1813,9 +1807,7 @@ class ProgramBuilder {
|
|||
/// ast::Module.
|
||||
template <typename NAME, typename... OPTIONS, typename = DisableIfSource<NAME>>
|
||||
const ast::Var* GlobalVar(NAME&& name, OPTIONS&&... options) {
|
||||
auto* variable = Var(std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
AST().AddGlobalVariable(variable);
|
||||
return variable;
|
||||
return GlobalVar(source_, std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
|
@ -1848,9 +1840,7 @@ class ProgramBuilder {
|
|||
/// automatically registered as a global variable with the ast::Module.
|
||||
template <typename NAME, typename... OPTIONS, typename = DisableIfSource<NAME>>
|
||||
const ast::Const* GlobalConst(NAME&& name, OPTIONS&&... options) {
|
||||
auto* variable = Const(std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
AST().AddGlobalVariable(variable);
|
||||
return variable;
|
||||
return GlobalConst(source_, std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
|
@ -1881,11 +1871,7 @@ class ProgramBuilder {
|
|||
/// automatically registered as a global variable with the ast::Module.
|
||||
template <typename NAME, typename... OPTIONS, typename = DisableIfSource<NAME>>
|
||||
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.initializer, std::move(opts.attributes));
|
||||
AST().AddGlobalVariable(variable);
|
||||
return variable;
|
||||
return Override(source_, std::forward<NAME>(name), std::forward<OPTIONS>(options)...);
|
||||
}
|
||||
|
||||
/// @param source the variable source
|
||||
|
@ -1901,7 +1887,7 @@ class ProgramBuilder {
|
|||
template <typename NAME, typename... OPTIONS>
|
||||
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,
|
||||
auto* variable = create<ast::Override>(source, Ident(std::forward<NAME>(name)), opts.type,
|
||||
opts.initializer, std::move(opts.attributes));
|
||||
AST().AddGlobalVariable(variable);
|
||||
return variable;
|
||||
|
|
|
@ -35,8 +35,8 @@ TEST_F(ParserImplTest, FunctionDecl) {
|
|||
EXPECT_EQ(f->return_type, nullptr);
|
||||
|
||||
ASSERT_EQ(f->params.Length(), 2u);
|
||||
EXPECT_EQ(f->params[0]->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params[1]->symbol, p->builder().Symbols().Get("b"));
|
||||
EXPECT_EQ(f->params[0]->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params[1]->name->symbol, p->builder().Symbols().Get("b"));
|
||||
|
||||
EXPECT_EQ(f->return_type, nullptr);
|
||||
|
||||
|
@ -78,8 +78,8 @@ TEST_F(ParserImplTest, FunctionDecl_Unicode) {
|
|||
EXPECT_EQ(f->return_type, nullptr);
|
||||
|
||||
ASSERT_EQ(f->params.Length(), 2u);
|
||||
EXPECT_EQ(f->params[0]->symbol, p->builder().Symbols().Get(param_a_ident));
|
||||
EXPECT_EQ(f->params[1]->symbol, p->builder().Symbols().Get(param_b_ident));
|
||||
EXPECT_EQ(f->params[0]->name->symbol, p->builder().Symbols().Get(param_a_ident));
|
||||
EXPECT_EQ(f->params[1]->name->symbol, p->builder().Symbols().Get(param_b_ident));
|
||||
|
||||
EXPECT_EQ(f->return_type, nullptr);
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ TEST_F(ParserImplTest, FunctionHeader) {
|
|||
|
||||
EXPECT_EQ(f->name, "main");
|
||||
ASSERT_EQ(f->params.Length(), 2u);
|
||||
EXPECT_EQ(f->params[0]->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params[1]->symbol, p->builder().Symbols().Get("b"));
|
||||
EXPECT_EQ(f->params[0]->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params[1]->name->symbol, p->builder().Symbols().Get("b"));
|
||||
EXPECT_EQ(f->return_type, nullptr);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, FunctionHeader_TrailingComma) {
|
|||
|
||||
EXPECT_EQ(f->name, "main");
|
||||
ASSERT_EQ(f->params.Length(), 1u);
|
||||
EXPECT_EQ(f->params[0]->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params[0]->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->return_type, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(ParserImplTest, GlobalConstDecl) {
|
|||
auto* c = e.value->As<ast::Const>();
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
||||
EXPECT_EQ(c->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(c->name->symbol, p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(c->type, nullptr);
|
||||
EXPECT_TRUE(c->type->Is<ast::F32>());
|
||||
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, GlobalConstDecl_Inferred) {
|
|||
auto* c = e.value->As<ast::Const>();
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
||||
EXPECT_EQ(c->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(c->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(c->type, nullptr);
|
||||
|
||||
EXPECT_EQ(c->source.range.begin.line, 1u);
|
||||
|
@ -118,7 +118,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId) {
|
|||
auto* override = e.value->As<ast::Override>();
|
||||
ASSERT_NE(override, nullptr);
|
||||
|
||||
EXPECT_EQ(override->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(override->name->symbol, p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(override->type, nullptr);
|
||||
EXPECT_TRUE(override->type->Is<ast::F32>());
|
||||
|
||||
|
@ -148,7 +148,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) {
|
|||
auto* override = e.value->As<ast::Override>();
|
||||
ASSERT_NE(override, nullptr);
|
||||
|
||||
EXPECT_EQ(override->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(override->name->symbol, p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(override->type, nullptr);
|
||||
EXPECT_TRUE(override->type->Is<ast::F32>());
|
||||
|
||||
|
@ -178,7 +178,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithoutId) {
|
|||
auto* override = e.value->As<ast::Override>();
|
||||
ASSERT_NE(override, nullptr);
|
||||
|
||||
EXPECT_EQ(override->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(override->name->symbol, p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(override->type, nullptr);
|
||||
EXPECT_TRUE(override->type->Is<ast::F32>());
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalVariable) {
|
|||
ASSERT_EQ(program.AST().GlobalVariables().Length(), 1u);
|
||||
|
||||
auto* v = program.AST().GlobalVariables()[0];
|
||||
EXPECT_EQ(v->symbol, program.Symbols().Get("a"));
|
||||
EXPECT_EQ(v->name->symbol, program.Symbols().Get("a"));
|
||||
EXPECT_TRUE(Is<ast::Vector>(v->type));
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_Inferred) {
|
|||
ASSERT_EQ(program.AST().GlobalVariables().Length(), 1u);
|
||||
|
||||
auto* v = program.AST().GlobalVariables()[0];
|
||||
EXPECT_EQ(v->symbol, program.Symbols().Get("a"));
|
||||
EXPECT_EQ(v->name->symbol, program.Symbols().Get("a"));
|
||||
EXPECT_EQ(v->type, nullptr);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalConst) {
|
|||
ASSERT_EQ(program.AST().GlobalVariables().Length(), 1u);
|
||||
|
||||
auto* v = program.AST().GlobalVariables()[0];
|
||||
EXPECT_EQ(v->symbol, program.Symbols().Get("a"));
|
||||
EXPECT_EQ(v->name->symbol, program.Symbols().Get("a"));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConst_MissingInitializer) {
|
||||
|
|
|
@ -29,7 +29,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutInitializer) {
|
|||
auto* var = e.value->As<ast::Var>();
|
||||
ASSERT_NE(var, nullptr);
|
||||
|
||||
EXPECT_EQ(var->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(var->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(var->type->Is<ast::F32>());
|
||||
EXPECT_EQ(var->declared_address_space, type::AddressSpace::kPrivate);
|
||||
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithInitializer) {
|
|||
auto* var = e.value->As<ast::Var>();
|
||||
ASSERT_NE(var, nullptr);
|
||||
|
||||
EXPECT_EQ(var->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(var->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(var->type->Is<ast::F32>());
|
||||
EXPECT_EQ(var->declared_address_space, type::AddressSpace::kPrivate);
|
||||
|
||||
|
@ -78,7 +78,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute) {
|
|||
auto* var = e.value->As<ast::Var>();
|
||||
ASSERT_NE(var, nullptr);
|
||||
|
||||
EXPECT_EQ(var->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(var->name->symbol, p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(var->type, nullptr);
|
||||
EXPECT_TRUE(var->type->Is<ast::F32>());
|
||||
EXPECT_EQ(var->declared_address_space, type::AddressSpace::kUniform);
|
||||
|
@ -109,7 +109,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute_MulitpleGroups) {
|
|||
auto* var = e.value->As<ast::Var>();
|
||||
ASSERT_NE(var, nullptr);
|
||||
|
||||
EXPECT_EQ(var->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(var->name->symbol, p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(var->type, nullptr);
|
||||
EXPECT_TRUE(var->type->Is<ast::F32>());
|
||||
EXPECT_EQ(var->declared_address_space, type::AddressSpace::kUniform);
|
||||
|
|
|
@ -25,7 +25,7 @@ TEST_F(ParserImplTest, ParamList_Single) {
|
|||
ASSERT_FALSE(e.errored);
|
||||
EXPECT_EQ(e.value.Length(), 1u);
|
||||
|
||||
EXPECT_EQ(e.value[0]->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e.value[0]->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(e.value[0]->type->Is<ast::I32>());
|
||||
EXPECT_TRUE(e.value[0]->Is<ast::Parameter>());
|
||||
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||
ASSERT_FALSE(e.errored);
|
||||
EXPECT_EQ(e.value.Length(), 3u);
|
||||
|
||||
EXPECT_EQ(e.value[0]->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e.value[0]->name->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(e.value[0]->type->Is<ast::I32>());
|
||||
EXPECT_TRUE(e.value[0]->Is<ast::Parameter>());
|
||||
|
||||
|
@ -52,7 +52,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||
ASSERT_EQ(e.value[0]->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e.value[0]->source.range.end.column, 2u);
|
||||
|
||||
EXPECT_EQ(e.value[1]->symbol, p->builder().Symbols().Get("b"));
|
||||
EXPECT_EQ(e.value[1]->name->symbol, p->builder().Symbols().Get("b"));
|
||||
EXPECT_TRUE(e.value[1]->type->Is<ast::F32>());
|
||||
EXPECT_TRUE(e.value[1]->Is<ast::Parameter>());
|
||||
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||
ASSERT_EQ(e.value[1]->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e.value[1]->source.range.end.column, 11u);
|
||||
|
||||
EXPECT_EQ(e.value[2]->symbol, p->builder().Symbols().Get("c"));
|
||||
EXPECT_EQ(e.value[2]->name->symbol, p->builder().Symbols().Get("c"));
|
||||
ASSERT_TRUE(e.value[2]->type->Is<ast::Vector>());
|
||||
ASSERT_TRUE(e.value[2]->type->As<ast::Vector>()->type->Is<ast::F32>());
|
||||
EXPECT_EQ(e.value[2]->type->As<ast::Vector>()->width, 2u);
|
||||
|
@ -97,7 +97,7 @@ TEST_F(ParserImplTest, ParamList_Attributes) {
|
|||
ASSERT_FALSE(e.errored);
|
||||
ASSERT_EQ(e.value.Length(), 2u);
|
||||
|
||||
EXPECT_EQ(e.value[0]->symbol, p->builder().Symbols().Get("coord"));
|
||||
EXPECT_EQ(e.value[0]->name->symbol, p->builder().Symbols().Get("coord"));
|
||||
ASSERT_TRUE(e.value[0]->type->Is<ast::Vector>());
|
||||
EXPECT_TRUE(e.value[0]->type->As<ast::Vector>()->type->Is<ast::F32>());
|
||||
EXPECT_EQ(e.value[0]->type->As<ast::Vector>()->width, 4u);
|
||||
|
@ -112,7 +112,7 @@ TEST_F(ParserImplTest, ParamList_Attributes) {
|
|||
ASSERT_EQ(e.value[0]->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e.value[0]->source.range.end.column, 25u);
|
||||
|
||||
EXPECT_EQ(e.value[1]->symbol, p->builder().Symbols().Get("loc1"));
|
||||
EXPECT_EQ(e.value[1]->name->symbol, p->builder().Symbols().Get("loc1"));
|
||||
EXPECT_TRUE(e.value[1]->type->Is<ast::F32>());
|
||||
EXPECT_TRUE(e.value[1]->Is<ast::Parameter>());
|
||||
auto attrs_1 = e.value[1]->attributes;
|
||||
|
|
|
@ -26,7 +26,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e->variable->name->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
EXPECT_EQ(e->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 1u);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_WithInit) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e->variable->name->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
EXPECT_EQ(e->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 1u);
|
||||
|
@ -75,7 +75,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e->variable->name->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
|
@ -93,7 +93,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit_NoSpace) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e->variable->name->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
|
@ -111,7 +111,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e->variable->name->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
|
@ -129,7 +129,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit_NoSpace) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
ASSERT_TRUE(e->Is<ast::VariableDeclStatement>());
|
||||
ASSERT_NE(e->variable, nullptr);
|
||||
EXPECT_EQ(e->variable->symbol, p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(e->variable->name->symbol, p->builder().Symbols().Get("a"));
|
||||
|
||||
ASSERT_NE(e->variable->initializer, nullptr);
|
||||
auto* call = e->variable->initializer->As<ast::CallExpression>();
|
||||
|
|
|
@ -199,7 +199,7 @@ class DependencyScanner {
|
|||
TraverseFunction(func);
|
||||
},
|
||||
[&](const ast::Variable* var) {
|
||||
Declare(var->symbol, var);
|
||||
Declare(var->name->symbol, var);
|
||||
TraverseType(var->type);
|
||||
TraverseAttributes(var->attributes);
|
||||
if (var->initializer) {
|
||||
|
@ -237,10 +237,10 @@ class DependencyScanner {
|
|||
TINT_DEFER(scope_stack_.Pop());
|
||||
|
||||
for (auto* param : func->params) {
|
||||
if (auto* shadows = scope_stack_.Get(param->symbol)) {
|
||||
if (auto* shadows = scope_stack_.Get(param->name->symbol)) {
|
||||
graph_.shadows.Add(param, shadows);
|
||||
}
|
||||
Declare(param->symbol, param);
|
||||
Declare(param->name->symbol, param);
|
||||
}
|
||||
if (func->body) {
|
||||
TraverseStatements(func->body->statements);
|
||||
|
@ -311,12 +311,12 @@ class DependencyScanner {
|
|||
}
|
||||
},
|
||||
[&](const ast::VariableDeclStatement* v) {
|
||||
if (auto* shadows = scope_stack_.Get(v->variable->symbol)) {
|
||||
if (auto* shadows = scope_stack_.Get(v->variable->name->symbol)) {
|
||||
graph_.shadows.Add(v->variable, shadows);
|
||||
}
|
||||
TraverseType(v->variable->type);
|
||||
TraverseExpression(v->variable->initializer);
|
||||
Declare(v->variable->symbol, v->variable);
|
||||
Declare(v->variable->name->symbol, v->variable);
|
||||
},
|
||||
[&](const ast::WhileStatement* w) {
|
||||
scope_stack_.Push();
|
||||
|
@ -560,7 +560,7 @@ struct DependencyAnalysis {
|
|||
node, //
|
||||
[&](const ast::TypeDecl* td) { return td->name; },
|
||||
[&](const ast::Function* func) { return func->name->symbol; },
|
||||
[&](const ast::Variable* var) { return var->symbol; },
|
||||
[&](const ast::Variable* var) { return var->name->symbol; },
|
||||
[&](const ast::DiagnosticDirective*) { return Symbol(); },
|
||||
[&](const ast::Enable*) { return Symbol(); },
|
||||
[&](const ast::ConstAssert*) { return Symbol(); },
|
||||
|
|
|
@ -344,7 +344,8 @@ type::Type* Resolver::Type(const ast::Type* ty) {
|
|||
resolved_node, //
|
||||
[&](type::Type* type) { return type; },
|
||||
[&](sem::Variable* variable) {
|
||||
auto name = builder_->Symbols().NameFor(variable->Declaration()->symbol);
|
||||
auto name =
|
||||
builder_->Symbols().NameFor(variable->Declaration()->name->symbol);
|
||||
AddError("cannot use variable '" + name + "' as type", ty->source);
|
||||
AddNote("'" + name + "' declared here", variable->Declaration()->source);
|
||||
return nullptr;
|
||||
|
@ -381,6 +382,8 @@ type::Type* Resolver::Type(const ast::Type* ty) {
|
|||
}
|
||||
|
||||
sem::Variable* Resolver::Variable(const ast::Variable* v, bool is_global) {
|
||||
Mark(v->name);
|
||||
|
||||
return Switch(
|
||||
v, //
|
||||
[&](const ast::Var* var) { return Var(var, is_global); },
|
||||
|
@ -427,7 +430,8 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
|
|||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, const_cast<type::Type*>(ty),
|
||||
v->source)) {
|
||||
AddNote("while instantiating 'let' " + builder_->Symbols().NameFor(v->symbol), v->source);
|
||||
AddNote("while instantiating 'let' " + builder_->Symbols().NameFor(v->name->symbol),
|
||||
v->source);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -489,7 +493,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
|
|||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, const_cast<type::Type*>(ty),
|
||||
v->source)) {
|
||||
AddNote("while instantiating 'override' " + builder_->Symbols().NameFor(v->symbol),
|
||||
AddNote("while instantiating 'override' " + builder_->Symbols().NameFor(v->name->symbol),
|
||||
v->source);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -582,7 +586,8 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
|
|||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, const_cast<type::Type*>(ty),
|
||||
c->source)) {
|
||||
AddNote("while instantiating 'const' " + builder_->Symbols().NameFor(c->symbol), c->source);
|
||||
AddNote("while instantiating 'const' " + builder_->Symbols().NameFor(c->name->symbol),
|
||||
c->source);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -669,7 +674,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
|||
|
||||
if (!ApplyAddressSpaceUsageToType(address_space, var_ty,
|
||||
var->type ? var->type->source : var->source)) {
|
||||
AddNote("while instantiating 'var' " + builder_->Symbols().NameFor(var->symbol),
|
||||
AddNote("while instantiating 'var' " + builder_->Symbols().NameFor(var->name->symbol),
|
||||
var->source);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -753,8 +758,10 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
|||
}
|
||||
|
||||
sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) {
|
||||
Mark(param->name);
|
||||
|
||||
auto add_note = [&] {
|
||||
AddNote("while instantiating parameter " + builder_->Symbols().NameFor(param->symbol),
|
||||
AddNote("while instantiating parameter " + builder_->Symbols().NameFor(param->name->symbol),
|
||||
param->source);
|
||||
};
|
||||
|
||||
|
@ -1018,8 +1025,8 @@ sem::Function* Resolver::Function(const ast::Function* decl) {
|
|||
Mark(param);
|
||||
|
||||
{ // Check the parameter name is unique for the function
|
||||
if (auto added = parameter_names.Add(param->symbol, param->source); !added) {
|
||||
auto name = builder_->Symbols().NameFor(param->symbol);
|
||||
if (auto added = parameter_names.Add(param->name->symbol, param->source); !added) {
|
||||
auto name = builder_->Symbols().NameFor(param->name->symbol);
|
||||
AddError("redefinition of parameter '" + name + "'", param->source);
|
||||
AddNote("previous definition is here", *added.value);
|
||||
return nullptr;
|
||||
|
@ -2338,7 +2345,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
},
|
||||
[&](sem::Function* func) { return FunctionCall(expr, func, args, arg_behaviors); },
|
||||
[&](sem::Variable* var) {
|
||||
auto name = builder_->Symbols().NameFor(var->Declaration()->symbol);
|
||||
auto name = builder_->Symbols().NameFor(var->Declaration()->name->symbol);
|
||||
AddError("cannot call variable '" + name + "'", ident->source);
|
||||
AddNote("'" + name + "' declared here", var->Declaration()->source);
|
||||
return nullptr;
|
||||
|
|
|
@ -189,7 +189,7 @@ struct FunctionInfo {
|
|||
parameters.Resize(func->params.Length());
|
||||
for (size_t i = 0; i < func->params.Length(); i++) {
|
||||
auto* param = func->params[i];
|
||||
auto param_name = builder->Symbols().NameFor(param->symbol);
|
||||
auto param_name = builder->Symbols().NameFor(param->name->symbol);
|
||||
auto* sem = builder->Sem().Get<sem::Parameter>(param);
|
||||
parameters[i].sem = sem;
|
||||
|
||||
|
@ -621,7 +621,7 @@ class UniformityGraph {
|
|||
|
||||
// Add an edge from the variable exit node to its value at this point.
|
||||
auto* exit_node = info.var_exit_nodes.GetOrCreate(var, [&]() {
|
||||
auto name = NameFor(var->Declaration());
|
||||
auto name = NameFor(var->Declaration()->name);
|
||||
return CreateNode({name, "_value_", info.type, "_exit"});
|
||||
});
|
||||
exit_node->AddEdge(current_function_->variables.Get(var));
|
||||
|
@ -657,7 +657,7 @@ class UniformityGraph {
|
|||
|
||||
// Add an edge from the variable exit node to its value at this point.
|
||||
auto* exit_node = info.var_exit_nodes.GetOrCreate(var, [&]() {
|
||||
auto name = NameFor(var->Declaration());
|
||||
auto name = NameFor(var->Declaration()->name);
|
||||
return CreateNode({name, "_value_", info.type, "_exit"});
|
||||
});
|
||||
|
||||
|
@ -730,7 +730,8 @@ class UniformityGraph {
|
|||
|
||||
// Create input nodes for any variables declared before this loop.
|
||||
for (auto* v : current_function_->local_var_decls) {
|
||||
auto* in_node = CreateNode({NameFor(v->Declaration()), "_value_forloop_in"});
|
||||
auto* in_node =
|
||||
CreateNode({NameFor(v->Declaration()->name), "_value_forloop_in"});
|
||||
in_node->AddEdge(current_function_->variables.Get(v));
|
||||
info.var_in_nodes.Replace(v, in_node);
|
||||
current_function_->variables.Set(v, in_node);
|
||||
|
@ -747,7 +748,7 @@ class UniformityGraph {
|
|||
// Propagate assignments to the loop exit nodes.
|
||||
for (auto* var : current_function_->local_var_decls) {
|
||||
auto* exit_node = info.var_exit_nodes.GetOrCreate(var, [&]() {
|
||||
auto name = NameFor(var->Declaration());
|
||||
auto name = NameFor(var->Declaration()->name);
|
||||
return CreateNode({name, "_value_", info.type, "_exit"});
|
||||
});
|
||||
exit_node->AddEdge(current_function_->variables.Get(var));
|
||||
|
@ -805,7 +806,8 @@ class UniformityGraph {
|
|||
|
||||
// Create input nodes for any variables declared before this loop.
|
||||
for (auto* v : current_function_->local_var_decls) {
|
||||
auto* in_node = CreateNode({NameFor(v->Declaration()), "_value_forloop_in"});
|
||||
auto* in_node =
|
||||
CreateNode({NameFor(v->Declaration()->name), "_value_forloop_in"});
|
||||
in_node->AddEdge(current_function_->variables.Get(v));
|
||||
info.var_in_nodes.Replace(v, in_node);
|
||||
current_function_->variables.Set(v, in_node);
|
||||
|
@ -823,7 +825,7 @@ class UniformityGraph {
|
|||
// Propagate assignments to the loop exit nodes.
|
||||
for (auto* var : current_function_->local_var_decls) {
|
||||
auto* exit_node = info.var_exit_nodes.GetOrCreate(var, [&]() {
|
||||
auto name = NameFor(var->Declaration());
|
||||
auto name = NameFor(var->Declaration()->name);
|
||||
return CreateNode({name, "_value_", info.type, "_exit"});
|
||||
});
|
||||
exit_node->AddEdge(current_function_->variables.Get(var));
|
||||
|
@ -907,7 +909,8 @@ class UniformityGraph {
|
|||
}
|
||||
|
||||
// Create an exit node for the variable.
|
||||
auto* out_node = CreateNode({NameFor(var->Declaration()), "_value_if_exit"});
|
||||
auto* out_node =
|
||||
CreateNode({NameFor(var->Declaration()->name), "_value_if_exit"});
|
||||
|
||||
// Add edges to the assigned value or the initial value.
|
||||
// Only add edges if the behavior for that block contains 'Next'.
|
||||
|
@ -963,7 +966,7 @@ class UniformityGraph {
|
|||
|
||||
// Create input nodes for any variables declared before this loop.
|
||||
for (auto* v : current_function_->local_var_decls) {
|
||||
auto name = NameFor(v->Declaration());
|
||||
auto name = NameFor(v->Declaration()->name);
|
||||
auto* in_node = CreateNode({name, "_value_loop_in"}, v->Declaration());
|
||||
in_node->AddEdge(current_function_->variables.Get(v));
|
||||
info.var_in_nodes.Replace(v, in_node);
|
||||
|
@ -1062,7 +1065,7 @@ class UniformityGraph {
|
|||
|
||||
// Add an edge from the variable exit node to its new value.
|
||||
auto* exit_node = info.var_exit_nodes.GetOrCreate(var, [&]() {
|
||||
auto name = NameFor(var->Declaration());
|
||||
auto name = NameFor(var->Declaration()->name);
|
||||
return CreateNode({name, "_value_", info.type, "_exit"});
|
||||
});
|
||||
exit_node->AddEdge(current_function_->variables.Get(var));
|
||||
|
@ -1401,7 +1404,7 @@ class UniformityGraph {
|
|||
// Cut the analysis short, since we only need to know the originating variable
|
||||
// that is being written to.
|
||||
auto* root_ident = sem_.Get(u)->RootIdentifier();
|
||||
auto* deref = CreateNode({NameFor(root_ident->Declaration()), "_deref"});
|
||||
auto* deref = CreateNode({NameFor(root_ident->Declaration()->name), "_deref"});
|
||||
auto* old_value = current_function_->variables.Set(root_ident, deref);
|
||||
|
||||
if (old_value) {
|
||||
|
@ -1779,7 +1782,7 @@ class UniformityGraph {
|
|||
[&](const ast::Variable* v) {
|
||||
auto* var = sem_.Get(v);
|
||||
std::ostringstream ss;
|
||||
ss << "reading from " << var_type(var) << "'" << NameFor(v)
|
||||
ss << "reading from " << var_type(var) << "'" << NameFor(v->name)
|
||||
<< "' may result in a non-uniform value";
|
||||
diagnostics_.add_note(diag::System::Resolver, ss.str(), v->source);
|
||||
},
|
||||
|
@ -1796,7 +1799,8 @@ class UniformityGraph {
|
|||
auto* arg = c->args[non_uniform_source->arg_index];
|
||||
auto* var = sem_.GetVal(arg)->RootIdentifier();
|
||||
std::ostringstream ss;
|
||||
ss << "reading from " << var_type(var) << "'" << NameFor(var->Declaration())
|
||||
ss << "reading from " << var_type(var) << "'"
|
||||
<< NameFor(var->Declaration()->name)
|
||||
<< "' may result in a non-uniform value";
|
||||
diagnostics_.add_note(diag::System::Resolver, ss.str(),
|
||||
var->Declaration()->source);
|
||||
|
|
|
@ -2354,7 +2354,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co
|
|||
[&](const ast::Override*) { return "cannot assign to 'override'"; });
|
||||
if (err) {
|
||||
AddError(err, lhs->source);
|
||||
AddNote("'" + symbols_.NameFor(v->symbol) + "' is declared here:", v->source);
|
||||
AddNote("'" + symbols_.NameFor(v->name->symbol) + "' is declared here:", v->source);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2402,7 +2402,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme
|
|||
[&](const ast::Override*) { return "cannot modify 'override'"; });
|
||||
if (err) {
|
||||
AddError(err, lhs->source);
|
||||
AddNote("'" + symbols_.NameFor(v->symbol) + "' is declared here:", v->source);
|
||||
AddNote("'" + symbols_.NameFor(v->name->symbol) + "' is declared here:", v->source);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/sem/array_count.h"
|
||||
|
||||
#include "src/tint/ast/identifier.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::NamedOverrideArrayCount);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::UnnamedOverrideArrayCount);
|
||||
|
||||
|
@ -32,7 +34,7 @@ bool NamedOverrideArrayCount::Equals(const UniqueNode& other) const {
|
|||
}
|
||||
|
||||
std::string NamedOverrideArrayCount::FriendlyName(const SymbolTable& symbols) const {
|
||||
return symbols.NameFor(variable->Declaration()->symbol);
|
||||
return symbols.NameFor(variable->Declaration()->name->symbol);
|
||||
}
|
||||
|
||||
type::ArrayCount* NamedOverrideArrayCount::Clone(type::CloneContext&) const {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "src/tint/ast/block_statement.h"
|
||||
#include "src/tint/ast/identifier.h"
|
||||
#include "src/tint/ast/loop_statement.h"
|
||||
#include "src/tint/ast/statement.h"
|
||||
#include "src/tint/ast/variable.h"
|
||||
|
@ -46,7 +47,7 @@ CompoundStatement::CompoundStatement(const ast::Statement* declaration,
|
|||
CompoundStatement::~CompoundStatement() = default;
|
||||
|
||||
void CompoundStatement::AddDecl(const sem::LocalVariable* var) {
|
||||
decls_.Add(var->Declaration()->symbol, OrderedLocalVariable{decls_.Count(), var});
|
||||
decls_.Add(var->Declaration()->name->symbol, OrderedLocalVariable{decls_.Count(), var});
|
||||
}
|
||||
|
||||
} // namespace tint::sem
|
||||
|
|
|
@ -70,7 +70,7 @@ Transform::ApplyResult AddBlockAttribute::Apply(const Program* src,
|
|||
|
||||
auto* wrapper = wrapper_structs.GetOrCreate(ty, [&] {
|
||||
auto* block = b.ASTNodes().Create<BlockAttribute>(b.ID(), b.AllocateNodeID());
|
||||
auto wrapper_name = src->Symbols().NameFor(global->symbol) + "_block";
|
||||
auto wrapper_name = src->Symbols().NameFor(global->name->symbol) + "_block";
|
||||
auto* ret = b.create<ast::Struct>(
|
||||
b.Symbols().New(wrapper_name),
|
||||
utils::Vector{b.Member(kMemberName, CreateASTTypeFor(ctx, ty))},
|
||||
|
@ -84,7 +84,7 @@ Transform::ApplyResult AddBlockAttribute::Apply(const Program* src,
|
|||
// any usage of the original variable.
|
||||
for (auto* user : var->Users()) {
|
||||
ctx.Replace(user->Declaration(),
|
||||
b.MemberAccessor(ctx.Clone(global->symbol), kMemberName));
|
||||
b.MemberAccessor(ctx.Clone(global->name->symbol), kMemberName));
|
||||
}
|
||||
} else {
|
||||
// Add a block attribute to this struct directly.
|
||||
|
|
|
@ -131,7 +131,7 @@ struct ArrayLengthFromUniform::State {
|
|||
// Load the total storage buffer size from the UBO.
|
||||
uint32_t array_index = size_index / 4;
|
||||
auto* vec_expr = b.IndexAccessor(
|
||||
b.MemberAccessor(get_ubo()->symbol, kBufferSizeMemberName), u32(array_index));
|
||||
b.MemberAccessor(get_ubo()->name->symbol, kBufferSizeMemberName), u32(array_index));
|
||||
uint32_t vec_index = size_index % 4;
|
||||
auto* total_storage_buffer_size = b.IndexAccessor(vec_expr, u32(vec_index));
|
||||
|
||||
|
|
|
@ -139,9 +139,9 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src,
|
|||
}
|
||||
auto* ty = sem->Type()->UnwrapRef();
|
||||
const ast::Type* inner_ty = CreateASTTypeFor(ctx, ty);
|
||||
auto* new_var = b.Var(ctx.Clone(var->source), ctx.Clone(var->symbol), inner_ty,
|
||||
var->declared_address_space, ac, ctx.Clone(var->initializer),
|
||||
ctx.Clone(var->attributes));
|
||||
auto* new_var = b.Var(ctx.Clone(var->source), ctx.Clone(var->name->symbol),
|
||||
inner_ty, var->declared_address_space, ac,
|
||||
ctx.Clone(var->initializer), ctx.Clone(var->attributes));
|
||||
ctx.Replace(var, new_var);
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ Transform::ApplyResult CalculateArrayLength::Apply(const Program* src,
|
|||
// translated to:
|
||||
// X.GetDimensions(ARGS..) by the writer
|
||||
buffer_size, b.AddressOf(ctx.Clone(storage_buffer_expr)),
|
||||
b.AddressOf(b.Expr(buffer_size_result->variable->symbol))));
|
||||
b.AddressOf(b.Expr(buffer_size_result->variable->name->symbol))));
|
||||
|
||||
// Calculate actual array length
|
||||
// total_storage_buffer_size - array_offset
|
||||
|
|
|
@ -334,7 +334,7 @@ struct CanonicalizeEntryPointIO::State {
|
|||
}
|
||||
}
|
||||
|
||||
auto name = ctx.src->Symbols().NameFor(param->Declaration()->symbol);
|
||||
auto name = ctx.src->Symbols().NameFor(param->Declaration()->name->symbol);
|
||||
auto* input_expr = AddInput(name, param->Type(), param->Location(), std::move(attributes));
|
||||
inner_call_parameters.Push(input_expr);
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ struct CanonicalizeEntryPointIO::State {
|
|||
|
||||
// Process the original return type to determine the outputs that the
|
||||
// outer function needs to produce.
|
||||
ProcessReturnType(func_sem->ReturnType(), inner_result->symbol);
|
||||
ProcessReturnType(func_sem->ReturnType(), inner_result->name->symbol);
|
||||
}
|
||||
|
||||
// Add a fixed sample mask, if necessary.
|
||||
|
|
|
@ -185,10 +185,10 @@ struct CombineSamplers::State {
|
|||
const sem::Variable* texture_var = pair.first;
|
||||
const sem::Variable* sampler_var = pair.second;
|
||||
std::string name =
|
||||
ctx.src->Symbols().NameFor(texture_var->Declaration()->symbol);
|
||||
ctx.src->Symbols().NameFor(texture_var->Declaration()->name->symbol);
|
||||
if (sampler_var) {
|
||||
name +=
|
||||
"_" + ctx.src->Symbols().NameFor(sampler_var->Declaration()->symbol);
|
||||
name += "_" + ctx.src->Symbols().NameFor(
|
||||
sampler_var->Declaration()->name->symbol);
|
||||
}
|
||||
if (IsGlobal(pair)) {
|
||||
// Both texture and sampler are global; add a new global variable
|
||||
|
@ -263,7 +263,7 @@ struct CombineSamplers::State {
|
|||
? global_combined_texture_samplers_[new_pair]
|
||||
: function_combined_texture_samplers_[call->Stmt()->Function()]
|
||||
[new_pair];
|
||||
args.Push(ctx.dst->Expr(var->symbol));
|
||||
args.Push(ctx.dst->Expr(var->name->symbol));
|
||||
} else if (auto* sampler_type = type->As<type::Sampler>()) {
|
||||
type::SamplerKind kind = sampler_type->kind();
|
||||
int index = (kind == type::SamplerKind::kSampler) ? 0 : 1;
|
||||
|
@ -271,7 +271,7 @@ struct CombineSamplers::State {
|
|||
if (!p) {
|
||||
p = CreatePlaceholder(kind);
|
||||
}
|
||||
args.Push(ctx.dst->Expr(p->symbol));
|
||||
args.Push(ctx.dst->Expr(p->name->symbol));
|
||||
} else {
|
||||
args.Push(ctx.Clone(arg));
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ struct CombineSamplers::State {
|
|||
? global_combined_texture_samplers_[new_pair]
|
||||
: function_combined_texture_samplers_[call->Stmt()->Function()]
|
||||
[new_pair];
|
||||
auto* arg = ctx.dst->Expr(var->symbol);
|
||||
auto* arg = ctx.dst->Expr(var->name->symbol);
|
||||
args.Push(arg);
|
||||
}
|
||||
// Append all of the remaining non-texture and non-sampler
|
||||
|
|
|
@ -711,13 +711,13 @@ struct DirectVariableAccess::State {
|
|||
|
||||
PtrParamSymbols symbols;
|
||||
if (requires_base_ptr_param && requires_indices_param) {
|
||||
auto original_name = param->Declaration()->symbol;
|
||||
auto original_name = param->Declaration()->name->symbol;
|
||||
symbols.base_ptr = UniqueSymbolWithSuffix(original_name, "_base");
|
||||
symbols.indices = UniqueSymbolWithSuffix(original_name, "_indices");
|
||||
} else if (requires_base_ptr_param) {
|
||||
symbols.base_ptr = ctx.Clone(param->Declaration()->symbol);
|
||||
symbols.base_ptr = ctx.Clone(param->Declaration()->name->symbol);
|
||||
} else if (requires_indices_param) {
|
||||
symbols.indices = ctx.Clone(param->Declaration()->symbol);
|
||||
symbols.indices = ctx.Clone(param->Declaration()->name->symbol);
|
||||
}
|
||||
|
||||
// Remember this base pointer name.
|
||||
|
@ -1085,7 +1085,7 @@ struct DirectVariableAccess::State {
|
|||
if (IsPrivateOrFunction(shape.root.address_space)) {
|
||||
ss << "F";
|
||||
} else {
|
||||
ss << ctx.src->Symbols().NameFor(shape.root.variable->Declaration()->symbol);
|
||||
ss << ctx.src->Symbols().NameFor(shape.root.variable->Declaration()->name->symbol);
|
||||
}
|
||||
|
||||
for (auto& op : shape.ops) {
|
||||
|
@ -1122,7 +1122,7 @@ struct DirectVariableAccess::State {
|
|||
}
|
||||
}
|
||||
|
||||
const ast::Expression* expr = b.Expr(ctx.Clone(root.variable->Declaration()->symbol));
|
||||
const ast::Expression* expr = b.Expr(ctx.Clone(root.variable->Declaration()->name->symbol));
|
||||
if (deref) {
|
||||
if (root.variable->Type()->Is<type::Pointer>()) {
|
||||
expr = b.Deref(expr);
|
||||
|
|
|
@ -174,7 +174,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
// TODO(jrprice): Do this for all other workgroup variables too.
|
||||
|
||||
// Create a member in the workgroup parameter struct.
|
||||
auto member = ctx.Clone(var->Declaration()->symbol);
|
||||
auto member = ctx.Clone(var->Declaration()->name->symbol);
|
||||
workgroup_parameter_members.Push(ctx.dst->Member(member, store_type()));
|
||||
CloneStructTypes(var->Type()->UnwrapRef());
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ struct MultiplanarExternalTexture::State {
|
|||
// with the texture_external binding that corresponds with the new destination bindings.
|
||||
// NewBindingSymbols new_binding_syms;
|
||||
auto& syms = new_binding_symbols[sem_var];
|
||||
syms.plane_0 = ctx.Clone(global->symbol);
|
||||
syms.plane_0 = ctx.Clone(global->name->symbol);
|
||||
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
|
||||
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding)));
|
||||
|
@ -174,7 +174,7 @@ struct MultiplanarExternalTexture::State {
|
|||
// into the transform state so they can be used when transforming function
|
||||
// calls.
|
||||
auto& syms = new_binding_symbols[sem_var];
|
||||
syms.plane_0 = ctx.Clone(param->symbol);
|
||||
syms.plane_0 = ctx.Clone(param->name->symbol);
|
||||
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
|
||||
syms.params = b.Symbols().New("ext_tex_params");
|
||||
auto tex2d_f32 = [&] {
|
||||
|
|
|
@ -107,7 +107,7 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src,
|
|||
// Capture the symbols that would be used to access this member, which
|
||||
// we will replace later. We currently have no way to get from the
|
||||
// parameter directly to the member accessor expressions that use it.
|
||||
to_replace.insert({param->Declaration()->symbol, member->Name()});
|
||||
to_replace.insert({param->Declaration()->name->symbol, member->Name()});
|
||||
|
||||
// Remove the struct member.
|
||||
// The CanonicalizeEntryPointIO transform will have generated this
|
||||
|
@ -178,7 +178,8 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src,
|
|||
}
|
||||
|
||||
if (to_replace.count({ident->identifier->symbol, accessor->member->symbol})) {
|
||||
ctx.Replace(accessor, b.MemberAccessor(get_ubo()->symbol, kNumWorkgroupsMemberName));
|
||||
ctx.Replace(accessor,
|
||||
b.MemberAccessor(get_ubo()->name->symbol, kNumWorkgroupsMemberName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,8 @@ struct SimplifyPointers::State {
|
|||
// We have a sub-expression that needs to be saved.
|
||||
// Create a new variable
|
||||
auto saved_name = ctx.dst->Symbols().New(
|
||||
ctx.src->Symbols().NameFor(var->Declaration()->symbol) + "_save");
|
||||
ctx.src->Symbols().NameFor(var->Declaration()->name->symbol) +
|
||||
"_save");
|
||||
auto* decl =
|
||||
ctx.dst->Decl(ctx.dst->Let(saved_name, ctx.Clone(idx_expr)));
|
||||
saved.Push(decl);
|
||||
|
|
|
@ -529,7 +529,7 @@ struct Std140::State {
|
|||
}
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unexpected variable found walking access chain: "
|
||||
<< sym.NameFor(user->Variable()->Declaration()->symbol);
|
||||
<< sym.NameFor(user->Variable()->Declaration()->name->symbol);
|
||||
return Action::kError;
|
||||
},
|
||||
[&](const sem::StructMemberAccess* a) {
|
||||
|
@ -879,7 +879,9 @@ struct Std140::State {
|
|||
});
|
||||
// Method for generating dynamic index expressions.
|
||||
// These are passed in as arguments to the function.
|
||||
auto dynamic_index = [&](size_t idx) { return b.Expr(dynamic_index_params[idx]->symbol); };
|
||||
auto dynamic_index = [&](size_t idx) {
|
||||
return b.Expr(dynamic_index_params[idx]->name->symbol);
|
||||
};
|
||||
|
||||
// Fetch the access chain indices of the matrix access and the parameter index that
|
||||
// holds the matrix column index.
|
||||
|
@ -987,7 +989,9 @@ struct Std140::State {
|
|||
});
|
||||
// Method for generating dynamic index expressions.
|
||||
// These are passed in as arguments to the function.
|
||||
auto dynamic_index = [&](size_t idx) { return b.Expr(dynamic_index_params[idx]->symbol); };
|
||||
auto dynamic_index = [&](size_t idx) {
|
||||
return b.Expr(dynamic_index_params[idx]->name->symbol);
|
||||
};
|
||||
|
||||
const ast::Expression* expr = nullptr;
|
||||
const type::Type* ty = nullptr;
|
||||
|
@ -1073,8 +1077,9 @@ struct Std140::State {
|
|||
auto& access = chain.indices[index];
|
||||
|
||||
if (std::get_if<UniformVariable>(&access)) {
|
||||
const auto* expr = b.Expr(ctx.Clone(chain.var->Declaration()->symbol));
|
||||
const auto name = src->Symbols().NameFor(chain.var->Declaration()->symbol);
|
||||
const auto symbol = chain.var->Declaration()->name->symbol;
|
||||
const auto* expr = b.Expr(ctx.Clone(symbol));
|
||||
const auto name = src->Symbols().NameFor(symbol);
|
||||
ty = chain.var->Type()->UnwrapRef();
|
||||
return {expr, ty, name};
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ Transform::ApplyResult SubstituteOverride::Apply(const Program* src,
|
|||
auto* sem = ctx.src->Sem().Get(w);
|
||||
|
||||
auto source = ctx.Clone(w->source);
|
||||
auto sym = ctx.Clone(w->symbol);
|
||||
auto sym = ctx.Clone(w->name->symbol);
|
||||
auto* ty = ctx.Clone(w->type);
|
||||
|
||||
// No replacement provided, just clone the override node as a const.
|
||||
|
|
|
@ -85,9 +85,9 @@ struct Texture1DTo2D::State {
|
|||
|
||||
auto create_var = [&](const ast::Variable* v, ast::Type* type) -> const ast::Variable* {
|
||||
if (v->As<ast::Parameter>()) {
|
||||
return ctx.dst->Param(ctx.Clone(v->symbol), type, ctx.Clone(v->attributes));
|
||||
return ctx.dst->Param(ctx.Clone(v->name->symbol), type, ctx.Clone(v->attributes));
|
||||
} else {
|
||||
return ctx.dst->Var(ctx.Clone(v->symbol), type, ctx.Clone(v->attributes));
|
||||
return ctx.dst->Var(ctx.Clone(v->name->symbol), type, ctx.Clone(v->attributes));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ struct Unshadow::State {
|
|||
|
||||
auto rename = [&](const sem::Variable* v) -> const ast::Variable* {
|
||||
auto* decl = v->Declaration();
|
||||
auto name = src->Symbols().NameFor(decl->symbol);
|
||||
auto name = src->Symbols().NameFor(decl->name->symbol);
|
||||
auto symbol = b.Symbols().New(name);
|
||||
renamed_to.Add(v, symbol);
|
||||
|
||||
|
|
|
@ -756,7 +756,7 @@ struct VertexPulling::State {
|
|||
void ProcessNonStructParameter(const ast::Function* func, const ast::Parameter* param) {
|
||||
if (ast::HasAttribute<ast::LocationAttribute>(param->attributes)) {
|
||||
// Create a function-scope variable to replace the parameter.
|
||||
auto func_var_sym = ctx.Clone(param->symbol);
|
||||
auto func_var_sym = ctx.Clone(param->name->symbol);
|
||||
auto* func_var_type = ctx.Clone(param->type);
|
||||
auto* func_var = b.Var(func_var_sym, func_var_type);
|
||||
ctx.InsertFront(func->body->statements, b.Decl(func_var));
|
||||
|
@ -780,9 +780,13 @@ struct VertexPulling::State {
|
|||
}
|
||||
// Check for existing vertex_index and instance_index builtins.
|
||||
if (builtin->builtin == ast::BuiltinValue::kVertexIndex) {
|
||||
vertex_index_expr = [this, param]() { return b.Expr(ctx.Clone(param->symbol)); };
|
||||
vertex_index_expr = [this, param]() {
|
||||
return b.Expr(ctx.Clone(param->name->symbol));
|
||||
};
|
||||
} else if (builtin->builtin == ast::BuiltinValue::kInstanceIndex) {
|
||||
instance_index_expr = [this, param]() { return b.Expr(ctx.Clone(param->symbol)); };
|
||||
instance_index_expr = [this, param]() {
|
||||
return b.Expr(ctx.Clone(param->name->symbol));
|
||||
};
|
||||
}
|
||||
new_function_parameters.Push(ctx.Clone(param));
|
||||
}
|
||||
|
@ -799,7 +803,7 @@ struct VertexPulling::State {
|
|||
void ProcessStructParameter(const ast::Function* func,
|
||||
const ast::Parameter* param,
|
||||
const ast::Struct* struct_ty) {
|
||||
auto param_sym = ctx.Clone(param->symbol);
|
||||
auto param_sym = ctx.Clone(param->name->symbol);
|
||||
|
||||
// Process the struct members.
|
||||
bool has_locations = false;
|
||||
|
|
|
@ -141,7 +141,7 @@ struct ZeroInitWorkgroupMemory::State {
|
|||
for (auto* var : func->TransitivelyReferencedGlobals()) {
|
||||
if (var->AddressSpace() == type::AddressSpace::kWorkgroup) {
|
||||
auto get_expr = [&](uint32_t num_values) {
|
||||
auto var_name = ctx.Clone(var->Declaration()->symbol);
|
||||
auto var_name = ctx.Clone(var->Declaration()->name->symbol);
|
||||
return Expression{b.Expr(var_name), num_values, ArrayIndices{}};
|
||||
};
|
||||
if (!BuildZeroingStatements(var->Type()->UnwrapRef(), get_expr)) {
|
||||
|
@ -160,7 +160,7 @@ struct ZeroInitWorkgroupMemory::State {
|
|||
for (auto* param : fn->params) {
|
||||
if (auto* builtin = ast::GetAttribute<ast::BuiltinAttribute>(param->attributes)) {
|
||||
if (builtin->builtin == ast::BuiltinValue::kLocalInvocationIndex) {
|
||||
local_index = [=] { return b.Expr(ctx.Clone(param->symbol)); };
|
||||
local_index = [=] { return b.Expr(ctx.Clone(param->name->symbol)); };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ struct ZeroInitWorkgroupMemory::State {
|
|||
member->Declaration()->attributes)) {
|
||||
if (builtin->builtin == ast::BuiltinValue::kLocalInvocationIndex) {
|
||||
local_index = [=] {
|
||||
auto* param_expr = b.Expr(ctx.Clone(param->symbol));
|
||||
auto* param_expr = b.Expr(ctx.Clone(param->name->symbol));
|
||||
auto* member_name = ctx.Clone(member->Declaration()->name);
|
||||
return b.MemberAccessor(param_expr, member_name);
|
||||
};
|
||||
|
@ -188,7 +188,7 @@ struct ZeroInitWorkgroupMemory::State {
|
|||
b.Builtin(ast::BuiltinValue::kLocalInvocationIndex),
|
||||
});
|
||||
ctx.InsertBack(fn->params, param);
|
||||
local_index = [=] { return b.Expr(param->symbol); };
|
||||
local_index = [=] { return b.Expr(param->name->symbol); };
|
||||
}
|
||||
|
||||
// Take the zeroing statements and bin them by the number of iterations
|
||||
|
|
|
@ -1916,7 +1916,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
// correctly translate the parameter to a [RW]ByteAddressBuffer for
|
||||
// storage buffers and a uint4[N] for uniform buffers.
|
||||
if (!EmitTypeAndName(out, type, v->AddressSpace(), v->Access(),
|
||||
builder_.Symbols().NameFor(v->Declaration()->symbol))) {
|
||||
builder_.Symbols().NameFor(v->Declaration()->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1996,7 +1996,7 @@ bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable
|
|||
out << ") uniform " << UniqueIdentifier(StructName(str) + "_ubo") << " {";
|
||||
}
|
||||
EmitStructMembers(current_buffer_, str);
|
||||
auto name = builder_.Symbols().NameFor(var->symbol);
|
||||
auto name = builder_.Symbols().NameFor(var->name->symbol);
|
||||
line() << "} " << name << ";";
|
||||
line();
|
||||
|
||||
|
@ -2014,7 +2014,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable
|
|||
line() << "layout(binding = " << bp.binding << ", std430) buffer "
|
||||
<< UniqueIdentifier(StructName(str) + "_ssbo") << " {";
|
||||
EmitStructMembers(current_buffer_, str);
|
||||
auto name = builder_.Symbols().NameFor(var->symbol);
|
||||
auto name = builder_.Symbols().NameFor(var->name->symbol);
|
||||
line() << "} " << name << ";";
|
||||
line();
|
||||
|
||||
|
@ -2024,7 +2024,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable
|
|||
bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* sem) {
|
||||
auto out = line();
|
||||
|
||||
auto name = builder_.Symbols().NameFor(var->symbol);
|
||||
auto name = builder_.Symbols().NameFor(var->name->symbol);
|
||||
auto* type = sem->Type()->UnwrapRef();
|
||||
if (type->Is<type::Sampler>()) {
|
||||
// GLSL ignores Sampler variables.
|
||||
|
@ -2103,7 +2103,7 @@ bool GeneratorImpl::EmitPrivateVariable(const sem::Variable* var) {
|
|||
auto* decl = var->Declaration();
|
||||
auto out = line();
|
||||
|
||||
auto name = builder_.Symbols().NameFor(decl->symbol);
|
||||
auto name = builder_.Symbols().NameFor(decl->name->symbol);
|
||||
auto* type = var->Type()->UnwrapRef();
|
||||
if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) {
|
||||
return false;
|
||||
|
@ -2130,7 +2130,7 @@ bool GeneratorImpl::EmitWorkgroupVariable(const sem::Variable* var) {
|
|||
|
||||
out << "shared ";
|
||||
|
||||
auto name = builder_.Symbols().NameFor(decl->symbol);
|
||||
auto name = builder_.Symbols().NameFor(decl->name->symbol);
|
||||
auto* type = var->Type()->UnwrapRef();
|
||||
if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) {
|
||||
return false;
|
||||
|
@ -2163,7 +2163,7 @@ bool GeneratorImpl::EmitIOVariable(const sem::GlobalVariable* var) {
|
|||
EmitAttributes(out, var, decl->attributes);
|
||||
EmitInterpolationQualifiers(out, decl->attributes);
|
||||
|
||||
auto name = builder_.Symbols().NameFor(decl->symbol);
|
||||
auto name = builder_.Symbols().NameFor(decl->name->symbol);
|
||||
auto* type = var->Type()->UnwrapRef();
|
||||
if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) {
|
||||
return false;
|
||||
|
@ -2285,7 +2285,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||
first = false;
|
||||
|
||||
if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(),
|
||||
builder_.Symbols().NameFor(var->symbol))) {
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3096,7 +3096,7 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) {
|
|||
|
||||
auto out = line();
|
||||
if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(),
|
||||
builder_.Symbols().NameFor(var->symbol))) {
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3123,7 +3123,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
|
|||
auto out = line();
|
||||
// TODO(senorblanco): handle const
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
builder_.Symbols().NameFor(let->symbol))) {
|
||||
builder_.Symbols().NameFor(let->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3145,7 +3145,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
|
|||
auto out = line();
|
||||
out << "const ";
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
builder_.Symbols().NameFor(var->symbol))) {
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
out << " = ";
|
||||
|
|
|
@ -2934,7 +2934,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
// correctly translate the parameter to a [RW]ByteAddressBuffer for
|
||||
// storage buffers and a uint4[N] for uniform buffers.
|
||||
if (!EmitTypeAndName(out, type, address_space, access,
|
||||
builder_.Symbols().NameFor(v->Declaration()->symbol))) {
|
||||
builder_.Symbols().NameFor(v->Declaration()->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3040,7 +3040,7 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) {
|
|||
bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable* sem) {
|
||||
auto binding_point = sem->As<sem::GlobalVariable>()->BindingPoint();
|
||||
auto* type = sem->Type()->UnwrapRef();
|
||||
auto name = builder_.Symbols().NameFor(var->symbol);
|
||||
auto name = builder_.Symbols().NameFor(var->name->symbol);
|
||||
line() << "cbuffer cbuffer_" << name << RegisterAndSpace('b', binding_point) << " {";
|
||||
|
||||
{
|
||||
|
@ -3061,7 +3061,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable
|
|||
auto* type = sem->Type()->UnwrapRef();
|
||||
auto out = line();
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kStorage, sem->Access(),
|
||||
builder_.Symbols().NameFor(var->symbol))) {
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3077,7 +3077,7 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable*
|
|||
auto* unwrapped_type = sem->Type()->UnwrapRef();
|
||||
auto out = line();
|
||||
|
||||
auto name = builder_.Symbols().NameFor(var->symbol);
|
||||
auto name = builder_.Symbols().NameFor(var->name->symbol);
|
||||
auto* type = sem->Type()->UnwrapRef();
|
||||
if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), name)) {
|
||||
return false;
|
||||
|
@ -3109,7 +3109,7 @@ bool GeneratorImpl::EmitPrivateVariable(const sem::Variable* var) {
|
|||
|
||||
out << "static ";
|
||||
|
||||
auto name = builder_.Symbols().NameFor(decl->symbol);
|
||||
auto name = builder_.Symbols().NameFor(decl->name->symbol);
|
||||
auto* type = var->Type()->UnwrapRef();
|
||||
if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) {
|
||||
return false;
|
||||
|
@ -3136,7 +3136,7 @@ bool GeneratorImpl::EmitWorkgroupVariable(const sem::Variable* var) {
|
|||
|
||||
out << "groupshared ";
|
||||
|
||||
auto name = builder_.Symbols().NameFor(decl->symbol);
|
||||
auto name = builder_.Symbols().NameFor(decl->name->symbol);
|
||||
auto* type = var->Type()->UnwrapRef();
|
||||
if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) {
|
||||
return false;
|
||||
|
@ -3263,7 +3263,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||
first = false;
|
||||
|
||||
if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(),
|
||||
builder_.Symbols().NameFor(var->symbol))) {
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -4275,7 +4275,7 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) {
|
|||
|
||||
auto out = line();
|
||||
if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(),
|
||||
builder_.Symbols().NameFor(var->symbol))) {
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4302,7 +4302,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
|
|||
auto out = line();
|
||||
out << "const ";
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
builder_.Symbols().NameFor(let->symbol))) {
|
||||
builder_.Symbols().NameFor(let->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
out << " = ";
|
||||
|
|
|
@ -1884,13 +1884,13 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
|
||||
auto* type = program_->Sem().Get(v)->Type();
|
||||
|
||||
std::string param_name = "const " + program_->Symbols().NameFor(v->symbol);
|
||||
std::string param_name = "const " + program_->Symbols().NameFor(v->name->symbol);
|
||||
if (!EmitType(out, type, param_name)) {
|
||||
return false;
|
||||
}
|
||||
// Parameter name is output as part of the type for pointers.
|
||||
if (!type->Is<type::Pointer>()) {
|
||||
out << " " << program_->Symbols().NameFor(v->symbol);
|
||||
out << " " << program_->Symbols().NameFor(v->name->symbol);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2016,7 +2016,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
|
|||
|
||||
auto* type = program_->Sem().Get(param)->Type()->UnwrapRef();
|
||||
|
||||
auto param_name = program_->Symbols().NameFor(param->symbol);
|
||||
auto param_name = program_->Symbols().NameFor(param->name->symbol);
|
||||
if (!EmitType(out, type, param_name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3021,7 +3021,7 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) {
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string name = program_->Symbols().NameFor(var->symbol);
|
||||
std::string name = program_->Symbols().NameFor(var->name->symbol);
|
||||
if (!EmitType(out, type, name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3070,7 +3070,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string name = "const " + program_->Symbols().NameFor(let->symbol);
|
||||
std::string name = "const " + program_->Symbols().NameFor(let->name->symbol);
|
||||
if (!EmitType(out, type, name)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ uint32_t Builder::LookupVariableID(const sem::Variable* var) {
|
|||
auto it = var_to_id_.find(var);
|
||||
if (it == var_to_id_.end()) {
|
||||
error_ = "unable to find ID for variable: " +
|
||||
builder_.Symbols().NameFor(var->Declaration()->symbol);
|
||||
builder_.Symbols().NameFor(var->Declaration()->name->symbol);
|
||||
return 0;
|
||||
}
|
||||
return it->second;
|
||||
|
@ -514,7 +514,7 @@ bool Builder::GenerateEntryPoint(const ast::Function* func, uint32_t id) {
|
|||
uint32_t var_id = LookupVariableID(var);
|
||||
if (var_id == 0) {
|
||||
error_ = "unable to find ID for global variable: " +
|
||||
builder_.Symbols().NameFor(var->Declaration()->symbol);
|
||||
builder_.Symbols().NameFor(var->Declaration()->name->symbol);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -626,9 +626,9 @@ bool Builder::GenerateFunction(const ast::Function* func_ast) {
|
|||
return false;
|
||||
}
|
||||
|
||||
push_debug(
|
||||
spv::Op::OpName,
|
||||
{Operand(param_id), Operand(builder_.Symbols().NameFor(param->Declaration()->symbol))});
|
||||
push_debug(spv::Op::OpName,
|
||||
{Operand(param_id),
|
||||
Operand(builder_.Symbols().NameFor(param->Declaration()->name->symbol))});
|
||||
params.push_back(
|
||||
Instruction{spv::Op::OpFunctionParameter, {Operand(param_type_id), param_op}});
|
||||
|
||||
|
@ -725,7 +725,8 @@ bool Builder::GenerateFunctionVariable(const ast::Variable* v) {
|
|||
return false;
|
||||
}
|
||||
|
||||
push_debug(spv::Op::OpName, {Operand(var_id), Operand(builder_.Symbols().NameFor(v->symbol))});
|
||||
push_debug(spv::Op::OpName,
|
||||
{Operand(var_id), Operand(builder_.Symbols().NameFor(v->name->symbol))});
|
||||
|
||||
// TODO(dsinclair) We could detect if the initializer is fully const and emit
|
||||
// an initializer value for the variable instead of doing the OpLoad.
|
||||
|
@ -785,7 +786,8 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) {
|
|||
return false;
|
||||
}
|
||||
|
||||
push_debug(spv::Op::OpName, {Operand(var_id), Operand(builder_.Symbols().NameFor(v->symbol))});
|
||||
push_debug(spv::Op::OpName,
|
||||
{Operand(var_id), Operand(builder_.Symbols().NameFor(v->name->symbol))});
|
||||
|
||||
OperandList ops = {Operand(type_id), result, U32Operand(ConvertAddressSpace(sc))};
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
out << " ";
|
||||
}
|
||||
|
||||
out << program_->Symbols().NameFor(v->symbol) << " : ";
|
||||
out << program_->Symbols().NameFor(v->name->symbol) << " : ";
|
||||
|
||||
if (!EmitType(out, v->type)) {
|
||||
return false;
|
||||
|
@ -713,7 +713,7 @@ bool GeneratorImpl::EmitVariable(std::ostream& out, const ast::Variable* v) {
|
|||
return false;
|
||||
}
|
||||
|
||||
out << " " << program_->Symbols().NameFor(v->symbol);
|
||||
out << " " << program_->Symbols().NameFor(v->name->symbol);
|
||||
|
||||
if (auto* ty = v->type) {
|
||||
out << " : ";
|
||||
|
|
Loading…
Reference in New Issue