tint/sem: Add const to StructMember 'type'.
This should be immutable once the sem tree is built. Add a hacky const_cast in Resolver for now, as this is preferable to having some things non-const in sem. Bug: tint:745 Change-Id: I67ebce76730347c9543875ab8e1c21a47d71fd56 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97584 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
8e0368e554
commit
6fb5d379c2
|
@ -361,7 +361,7 @@ const Constant* ZeroValue(ProgramBuilder& builder, const sem::Type* type) {
|
|||
return nullptr;
|
||||
},
|
||||
[&](const sem::Struct* s) -> const Constant* {
|
||||
std::unordered_map<sem::Type*, const Constant*> zero_by_type;
|
||||
std::unordered_map<const sem::Type*, const Constant*> zero_by_type;
|
||||
utils::Vector<const sem::Constant*, 4> zeros;
|
||||
zeros.Reserve(s->Members().size());
|
||||
for (auto* member : s->Members()) {
|
||||
|
|
|
@ -2803,7 +2803,7 @@ bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc,
|
|||
str->AddUsage(sc);
|
||||
|
||||
for (auto* member : str->Members()) {
|
||||
if (!ApplyStorageClassUsageToType(sc, member->Type(), usage)) {
|
||||
if (!ApplyStorageClassUsageToType(sc, const_cast<sem::Type*>(member->Type()), usage)) {
|
||||
std::stringstream err;
|
||||
err << "while analysing structure member " << sem_.TypeNameOf(str) << "."
|
||||
<< builder_->Symbols().NameFor(member->Declaration()->symbol);
|
||||
|
|
|
@ -157,7 +157,7 @@ bool Struct::IsConstructible() const {
|
|||
|
||||
StructMember::StructMember(const ast::StructMember* declaration,
|
||||
Symbol name,
|
||||
sem::Type* type,
|
||||
const sem::Type* type,
|
||||
uint32_t index,
|
||||
uint32_t offset,
|
||||
uint32_t align,
|
||||
|
|
|
@ -182,7 +182,7 @@ class StructMember final : public Castable<StructMember, Node> {
|
|||
/// @param size the byte size of the member
|
||||
StructMember(const ast::StructMember* declaration,
|
||||
Symbol name,
|
||||
sem::Type* type,
|
||||
const sem::Type* type,
|
||||
uint32_t index,
|
||||
uint32_t offset,
|
||||
uint32_t align,
|
||||
|
@ -205,7 +205,7 @@ class StructMember final : public Castable<StructMember, Node> {
|
|||
const sem::Struct* Struct() const { return struct_; }
|
||||
|
||||
/// @returns the type of the member
|
||||
sem::Type* Type() const { return type_; }
|
||||
const sem::Type* Type() const { return type_; }
|
||||
|
||||
/// @returns the member index
|
||||
uint32_t Index() const { return index_; }
|
||||
|
@ -223,7 +223,7 @@ class StructMember final : public Castable<StructMember, Node> {
|
|||
const ast::StructMember* const declaration_;
|
||||
const Symbol name_;
|
||||
const sem::Struct* struct_;
|
||||
sem::Type* const type_;
|
||||
const sem::Type* type_;
|
||||
const uint32_t index_;
|
||||
const uint32_t offset_;
|
||||
const uint32_t align_;
|
||||
|
|
|
@ -105,7 +105,8 @@ DecomposeStridedMatrix::~DecomposeStridedMatrix() = default;
|
|||
|
||||
bool DecomposeStridedMatrix::ShouldRun(const Program* program, const DataMap&) const {
|
||||
bool should_run = false;
|
||||
GatherCustomStrideMatrixMembers(program, [&](const sem::StructMember*, sem::Matrix*, uint32_t) {
|
||||
GatherCustomStrideMatrixMembers(program,
|
||||
[&](const sem::StructMember*, const sem::Matrix*, uint32_t) {
|
||||
should_run = true;
|
||||
return GatherResult::kStop;
|
||||
});
|
||||
|
@ -118,7 +119,7 @@ void DecomposeStridedMatrix::Run(CloneContext& ctx, const DataMap&, DataMap&) co
|
|||
// and populate the `decomposed` map with the members that have been replaced.
|
||||
std::unordered_map<const ast::StructMember*, MatrixInfo> decomposed;
|
||||
GatherCustomStrideMatrixMembers(
|
||||
ctx.src, [&](const sem::StructMember* member, sem::Matrix* matrix, uint32_t stride) {
|
||||
ctx.src, [&](const sem::StructMember* member, const sem::Matrix* matrix, uint32_t stride) {
|
||||
// We've got ourselves a struct member of a matrix type with a custom
|
||||
// stride. Replace this with an array of column vectors.
|
||||
MatrixInfo info{stride, matrix};
|
||||
|
|
Loading…
Reference in New Issue