mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
ast: Add type nodes
Copy all of the type classes from src/type into ast. Required the merging of: * type::Struct into the existing ast::Struct - ast::Struct now has a name. * type::AccessControl into the existing ast::AccessControl enumerator - The old ast::AccessControl enumerator is now ast::AccessControl::Access Bug: tint:724 Change-Id: Ibb950036ed551ec769c6d3d2c8fb411809cf6931 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48383 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
ba6f260629
commit
8a8d26bbd9
@@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::AccessControl);
|
||||
namespace tint {
|
||||
namespace sem {
|
||||
|
||||
AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
|
||||
AccessControl::AccessControl(ast::AccessControl::Access access, Type* subtype)
|
||||
: access_(access), subtype_(subtype) {
|
||||
TINT_ASSERT(subtype_);
|
||||
TINT_ASSERT(!subtype_->Is<AccessControl>());
|
||||
|
||||
@@ -29,7 +29,7 @@ class AccessControl : public Castable<AccessControl, Type> {
|
||||
/// Constructor
|
||||
/// @param access the access control setting
|
||||
/// @param subtype the access controlled type
|
||||
AccessControl(ast::AccessControl access, Type* subtype);
|
||||
AccessControl(ast::AccessControl::Access access, Type* subtype);
|
||||
/// Move constructor
|
||||
AccessControl(AccessControl&&);
|
||||
~AccessControl() override;
|
||||
@@ -42,7 +42,7 @@ class AccessControl : public Castable<AccessControl, Type> {
|
||||
bool IsReadWrite() const { return access_ == ast::AccessControl::kReadWrite; }
|
||||
|
||||
/// @returns the access control value
|
||||
ast::AccessControl access_control() const { return access_; }
|
||||
ast::AccessControl::Access access_control() const { return access_; }
|
||||
/// @returns the subtype type
|
||||
Type* type() const { return subtype_; }
|
||||
|
||||
@@ -60,7 +60,7 @@ class AccessControl : public Castable<AccessControl, Type> {
|
||||
AccessControl* Clone(CloneContext* ctx) const override;
|
||||
|
||||
private:
|
||||
ast::AccessControl const access_;
|
||||
ast::AccessControl::Access const access_;
|
||||
Type* const subtype_;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
namespace tint {
|
||||
namespace sem {
|
||||
|
||||
/// An external texture type
|
||||
class ExternalTexture : public Castable<ExternalTexture, Texture> {
|
||||
public:
|
||||
/// Constructor
|
||||
@@ -46,4 +48,5 @@ class ExternalTexture : public Castable<ExternalTexture, Texture> {
|
||||
|
||||
} // namespace sem
|
||||
} // namespace tint
|
||||
|
||||
#endif // SRC_SEM_EXTERNAL_TEXTURE_TYPE_H_
|
||||
|
||||
@@ -23,17 +23,19 @@ namespace {
|
||||
using StructTypeTest = TestHelper;
|
||||
|
||||
TEST_F(StructTypeTest, Creation) {
|
||||
auto name = Sym("S");
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
create<ast::Struct>(name, ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* ptr = impl;
|
||||
auto* s = ty.struct_("S", impl);
|
||||
auto* s = ty.struct_(name, impl);
|
||||
EXPECT_EQ(s->impl(), ptr);
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, Is) {
|
||||
auto name = Sym("S");
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_("S", impl);
|
||||
create<ast::Struct>(name, ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_(name, impl);
|
||||
sem::Type* ty = s;
|
||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||
EXPECT_FALSE(ty->Is<Alias>());
|
||||
@@ -51,16 +53,18 @@ TEST_F(StructTypeTest, Is) {
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, TypeName) {
|
||||
auto name = Sym("my_struct");
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_("my_struct", impl);
|
||||
create<ast::Struct>(name, ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_(name, impl);
|
||||
EXPECT_EQ(s->type_name(), "__struct_$1");
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, FriendlyName) {
|
||||
auto name = Sym("my_struct");
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_("my_struct", impl);
|
||||
create<ast::Struct>(name, ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_(name, impl);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user