mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 14:13:39 +00:00
semantic::Struct: Add FindMember
Change-Id: Ie7b76ad8b7dbac1303ed73ba6962e584fed76238 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46628 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
f23696ddda
commit
3bfb6817df
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/semantic/struct.h"
|
#include "src/semantic/struct.h"
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::semantic::Struct);
|
TINT_INSTANTIATE_TYPEINFO(tint::semantic::Struct);
|
||||||
@ -37,6 +38,15 @@ Struct::Struct(type::Struct* type,
|
|||||||
|
|
||||||
Struct::~Struct() = default;
|
Struct::~Struct() = default;
|
||||||
|
|
||||||
|
const StructMember* Struct::FindMember(Symbol name) const {
|
||||||
|
for (auto* member : members_) {
|
||||||
|
if (member->Declaration()->symbol() == name) {
|
||||||
|
return member;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
StructMember::StructMember(ast::StructMember* declaration,
|
StructMember::StructMember(ast::StructMember* declaration,
|
||||||
uint32_t offset,
|
uint32_t offset,
|
||||||
uint32_t align,
|
uint32_t align,
|
||||||
|
@ -79,6 +79,10 @@ class Struct : public Castable<Struct, Node> {
|
|||||||
/// @returns the members of the structure
|
/// @returns the members of the structure
|
||||||
const StructMemberList& Members() const { return members_; }
|
const StructMemberList& Members() const { return members_; }
|
||||||
|
|
||||||
|
/// @param name the member name to look for
|
||||||
|
/// @returns the member with the given name, or nullptr if it was not found.
|
||||||
|
const StructMember* FindMember(Symbol name) const;
|
||||||
|
|
||||||
/// @returns the byte alignment of the structure
|
/// @returns the byte alignment of the structure
|
||||||
/// @note this may differ from the alignment of a structure member of this
|
/// @note this may differ from the alignment of a structure member of this
|
||||||
/// structure type, if the member is annotated with the `[[align(n)]]`
|
/// structure type, if the member is annotated with the `[[align(n)]]`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user