// A bunch of methods for casting this type to a given type. Returns this if the
// cast can be done, nullptr otherwise.
#define DeclareCastMethod(target) \
- virtual target* As##target() { return nullptr; }
+ virtual target* As##target() { return nullptr; } \
+ virtual const target* As##target() const { return nullptr; }
DeclareCastMethod(Void);
DeclareCastMethod(Bool);
DeclareCastMethod(Integer);
std::string str() const override;
Integer* AsInteger() override { return this; }
+ const Integer* AsInteger() const override { return this; }
private:
uint32_t width_; // bit width
std::string str() const override;
Float* AsFloat() override { return this; }
+ const Float* AsFloat() const override { return this; }
private:
uint32_t width_; // bit width
std::string str() const override;
Vector* AsVector() override { return this; }
+ const Vector* AsVector() const override { return this; }
private:
Type* element_type_;
std::string str() const override;
Matrix* AsMatrix() override { return this; }
+ const Matrix* AsMatrix() const override { return this; }
private:
Type* element_type_;
std::string str() const override;
Image* AsImage() override { return this; }
+ const Image* AsImage() const override { return this; }
private:
Type* sampled_type_;
std::string str() const override;
SampledImage* AsSampledImage() override { return this; }
+ const SampledImage* AsSampledImage() const override { return this; }
private:
Type* image_type_;
std::string str() const override;
Array* AsArray() override { return this; }
+ const Array* AsArray() const override { return this; }
private:
Type* element_type_;
std::string str() const override;
RuntimeArray* AsRuntimeArray() override { return this; }
+ const RuntimeArray* AsRuntimeArray() const override { return this; }
private:
Type* element_type_;
std::string str() const override;
Struct* AsStruct() override { return this; }
+ const Struct* AsStruct() const override { return this; }
private:
std::vector<Type*> element_types_;
std::string str() const override;
Opaque* AsOpaque() override { return this; }
+ const Opaque* AsOpaque() const override { return this; }
private:
std::string name_;
std::string str() const override;
Pointer* AsPointer() override { return this; }
+ const Pointer* AsPointer() const override { return this; }
private:
Type* pointee_type_;
std::string str() const override;
Function* AsFunction() override { return this; }
+ const Function* AsFunction() const override { return this; }
private:
Type* return_type_;
std::string str() const override;
Pipe* AsPipe() override { return this; }
+ const Pipe* AsPipe() const override { return this; }
private:
SpvAccessQualifier access_qualifier_;
std::string str() const override;
ForwardPointer* AsForwardPointer() override { return this; }
+ const ForwardPointer* AsForwardPointer() const override { return this; }
private:
uint32_t target_id_;
std::string str() const override { return #name; } \
\
type* As##type() override { return this; } \
+ const type* As##type() const override { return this; } \
};
DefineParameterlessType(Void, void);
DefineParameterlessType(Bool, bool);