summaryrefslogtreecommitdiff
path: root/source/slang/val-defs.h
diff options
context:
space:
mode:
authorTim Foley <tim.foley.is@gmail.com>2017-06-30 13:12:50 -0700
committerGitHub <noreply@github.com>2017-06-30 13:12:50 -0700
commitf313df379dd9e0d4395f072ffb87016a6f20d5a1 (patch)
tree6c2c07c3930ff68b5518e562b0b507d5ec54d0bf /source/slang/val-defs.h
parentb2b08679a32506d629df84730f36639dab9f9593 (diff)
parentcab694dcead92a554654d7fa3f08909d519425f0 (diff)
Merge pull request #52 from tfoleyNV/syntax-meta
Add meta-definitions for AST types
Diffstat (limited to 'source/slang/val-defs.h')
-rw-r--r--source/slang/val-defs.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/slang/val-defs.h b/source/slang/val-defs.h
new file mode 100644
index 000000000..316981842
--- /dev/null
+++ b/source/slang/val-defs.h
@@ -0,0 +1,37 @@
+// val-defs.h
+
+// Syntax class definitions for compile-time values.
+
+// A compile-time integer (may not have a specific concrete value)
+SIMPLE_SYNTAX_CLASS(IntVal, Val)
+
+// Trivial case of a value that is just a constant integer
+SYNTAX_CLASS(ConstantIntVal, IntVal)
+ FIELD(IntegerLiteralValue, value)
+
+ RAW(
+ ConstantIntVal(IntegerLiteralValue value)
+ : value(value)
+ {}
+
+ virtual bool EqualsVal(Val* val) override;
+ virtual String ToString() override;
+ virtual int GetHashCode() override;
+ )
+END_SYNTAX_CLASS()
+
+// The logical "value" of a rererence to a generic value parameter
+SYNTAX_CLASS(GenericParamIntVal, IntVal)
+ DECL_FIELD(DeclRef<VarDeclBase>, declRef)
+
+ RAW(
+ GenericParamIntVal(DeclRef<VarDeclBase> declRef)
+ : declRef(declRef)
+ {}
+
+ virtual bool EqualsVal(Val* val) override;
+ virtual String ToString() override;
+ virtual int GetHashCode() override;
+ virtual RefPtr<Val> SubstituteImpl(Substitutions* subst, int* ioDiff) override;
+)
+END_SYNTAX_CLASS()