summaryrefslogtreecommitdiff
path: root/source/slang/type-defs.h
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-10 15:40:42 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-11 12:07:09 -0700
commitbd7105ff8683a680d1270eca8cd74f9002144dbd (patch)
tree2e4911b6da6573d334117a08130be5c945c31b15 /source/slang/type-defs.h
parent672332936ad7a4610ce0595493152c117476e823 (diff)
Initial work on handling resources in structs during cross-compilation
- The basic idea is that during the "lowering" pass, some types (notably: aggregate types that contain resource variables) will get turned into "tuple" types, which are pseduo-types that aren't meant to survive lowering. - An attempt to declare a variable with a tuple type expands into a tuple of declarations - An attempt to reference such a tuple-ified variable leads to a tuple of expressions - An attempt to extract a member from such a tuple expression will pick the appropriate sub-element - Dereference a tuple by dereferencing the primary expression - Expand a tuple in the argument list to a call into N arguments (by recursively flattening the tuple) - Don't create tuple types when not generating GLSL - Make sure to preserve the specialized type of a call expression through lowering, since emission of unchecked calls relies on that info. - TODO: maybe the infix/prefix/postifx/select information should come in as a side-band? Should we have modifiers on expressions? - Make sure to offset the layout for a nested field based on teh base offset of its parent variable, when generating declarations for nested fields
Diffstat (limited to 'source/slang/type-defs.h')
-rw-r--r--source/slang/type-defs.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/slang/type-defs.h b/source/slang/type-defs.h
index ae64cce2e..461a27b18 100644
--- a/source/slang/type-defs.h
+++ b/source/slang/type-defs.h
@@ -51,12 +51,12 @@ RAW(
static DeclRefType* Create(DeclRef<Decl> declRef);
-protected:
DeclRefType()
{}
DeclRefType(DeclRef<Decl> declRef)
: declRef(declRef)
{}
+protected:
virtual int GetHashCode() override;
virtual bool EqualsImpl(ExpressionType * type) override;
virtual ExpressionType* CreateCanonicalType() override;
@@ -64,7 +64,7 @@ protected:
END_SYNTAX_CLASS()
// Base class for types that can be used in arithmetic expressions
-SYNTAX_CLASS(ArithmeticExpressionType, DeclRefType)
+ABSTRACT_SYNTAX_CLASS(ArithmeticExpressionType, DeclRefType)
RAW(
virtual BasicExpressionType* GetScalarType() = 0;
)
@@ -142,6 +142,8 @@ RAW(
SlangResourceShape getShape() const { return flavor & 0xFF; }
SlangResourceAccess getAccess() const { return (flavor >> 8) & 0xFF; }
+ TextureTypeBase()
+ {}
TextureTypeBase(
Flavor flavor,
RefPtr<ExpressionType> elementType)
@@ -153,6 +155,8 @@ END_SYNTAX_CLASS()
SYNTAX_CLASS(TextureType, TextureTypeBase)
RAW(
+ TextureType()
+ {}
TextureType(
Flavor flavor,
RefPtr<ExpressionType> elementType)
@@ -165,6 +169,8 @@ END_SYNTAX_CLASS()
// as they exist in, e.g., GLSL
SYNTAX_CLASS(TextureSamplerType, TextureTypeBase)
RAW(
+ TextureSamplerType()
+ {}
TextureSamplerType(
Flavor flavor,
RefPtr<ExpressionType> elementType)
@@ -176,6 +182,8 @@ END_SYNTAX_CLASS()
// This is a base type for `image*` types, as they exist in GLSL
SYNTAX_CLASS(GLSLImageType, TextureTypeBase)
RAW(
+ GLSLImageType()
+ {}
GLSLImageType(
Flavor flavor,
RefPtr<ExpressionType> elementType)
@@ -289,6 +297,8 @@ SYNTAX_CLASS(TypeType, ExpressionType)
RAW(
public:
+ TypeType()
+ {}
TypeType(RefPtr<ExpressionType> type)
: type(type)
{}
@@ -340,6 +350,8 @@ SYNTAX_CLASS(NamedExpressionType, ExpressionType)
DECL_FIELD(DeclRef<TypeDefDecl>, declRef)
RAW(
+ NamedExpressionType()
+ {}
NamedExpressionType(DeclRef<TypeDefDecl> declRef)
: declRef(declRef)
{}
@@ -376,6 +388,8 @@ SYNTAX_CLASS(GenericDeclRefType, ExpressionType)
DECL_FIELD(DeclRef<GenericDecl>, declRef)
RAW(
+ GenericDeclRefType()
+ {}
GenericDeclRefType(DeclRef<GenericDecl> declRef)
: declRef(declRef)
{}