summaryrefslogtreecommitdiff
path: root/source/slang/val-defs.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-05-31 17:20:37 -0400
committerGitHub <noreply@github.com>2019-05-31 17:20:37 -0400
commit6cbc3929a54d37bd23cb5efa8e3320ba02f78b2f (patch)
tree5a23cb47782e9e2a77762c90dd35da1005eba8d0 /source/slang/val-defs.h
parentb81ff3ef968d1cc4e954b31a1812b3c391d17b02 (diff)
Use slang- prefix on slang compiler and core source (#973)
* Prefixing source files in source/slang with slang- * Prefix source in source/slang with slang- prefix. * Rename core source files with slang- prefix. * Update project files. * Fix problems from automatic merge.
Diffstat (limited to 'source/slang/val-defs.h')
-rw-r--r--source/slang/val-defs.h155
1 files changed, 0 insertions, 155 deletions
diff --git a/source/slang/val-defs.h b/source/slang/val-defs.h
deleted file mode 100644
index f5b099079..000000000
--- a/source/slang/val-defs.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// val-defs.h
-
-// Syntax class definitions for compile-time values.
-
-// A compile-time integer (may not have a specific concrete value)
-ABSTRACT_SYNTAX_CLASS(IntVal, Val)
-END_SYNTAX_CLASS()
-
-// Trivial case of a value that is just a constant integer
-SYNTAX_CLASS(ConstantIntVal, IntVal)
- FIELD(IntegerLiteralValue, value)
-
- RAW(
- ConstantIntVal()
- {}
- 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()
- {}
- GenericParamIntVal(DeclRef<VarDeclBase> declRef)
- : declRef(declRef)
- {}
-
- virtual bool EqualsVal(Val* val) override;
- virtual String ToString() override;
- virtual int GetHashCode() override;
- virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int* ioDiff) override;
-)
-END_SYNTAX_CLASS()
-
-// A witness to the fact that some proposition is true, encoded
-// at the level of the type system.
-//
-// Given a generic like:
-//
-// void example<L>(L light)
-// where L : ILight
-// { ... }
-//
-// a call to `example()` needs two things for us to be sure
-// it is valid:
-//
-// 1. We need a type `X` to use as the argument for the
-// parameter `L`. We might supply this explicitly, or
-// via inference.
-//
-// 2. We need a *proof* that whatever `X` we chose conforms
-// to the `ILight` interface.
-//
-// The easiest way to make such a proof is by construction,
-// and a `Witness` represents such a constructive proof.
-// Conceptually a proposition like `X : ILight` can be
-// seen as a type, and witness prooving that proposition
-// is a value of that type.
-//
-// We construct and store witnesses explicitly during
-// semantic checking because they can help us with
-// generating downstream code. By following the structure
-// of a witness (the structure of a proof) we can, e.g.,
-// navigate from the knowledge that `X : ILight` to
-// the concrete declarations that provide the implementation
-// of `ILight` for `X`.
-//
-ABSTRACT_SYNTAX_CLASS(Witness, Val)
-END_SYNTAX_CLASS()
-
-// A witness that one type is a subtype of another
-// (where by "subtype" we include both inheritance
-// relationships and type-conforms-to-interface relationships)
-//
-// TODO: we may need to tease those apart.
-ABSTRACT_SYNTAX_CLASS(SubtypeWitness, Witness)
- FIELD(RefPtr<Type>, sub)
- FIELD(RefPtr<Type>, sup)
-END_SYNTAX_CLASS()
-
-SYNTAX_CLASS(TypeEqualityWitness, SubtypeWitness)
-RAW(
- virtual bool EqualsVal(Val* val) override;
- virtual String ToString() override;
- virtual int GetHashCode() override;
- virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int * ioDiff) override;
-)
-END_SYNTAX_CLASS()
-// A witness that one type is a subtype of another
-// because some in-scope declaration says so
-SYNTAX_CLASS(DeclaredSubtypeWitness, SubtypeWitness)
- FIELD(DeclRef<Decl>, declRef);
-RAW(
- virtual bool EqualsVal(Val* val) override;
- virtual String ToString() override;
- virtual int GetHashCode() override;
- virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int * ioDiff) override;
-)
-END_SYNTAX_CLASS()
-
-// A witness that `sub : sup` because `sub : mid` and `mid : sup`
-SYNTAX_CLASS(TransitiveSubtypeWitness, SubtypeWitness)
- // Witness that `sub : mid`
- FIELD(RefPtr<SubtypeWitness>, subToMid);
-
- // Witness that `mid : sup`
- FIELD(DeclRef<Decl>, midToSup);
-RAW(
- virtual bool EqualsVal(Val* val) override;
- virtual String ToString() override;
- virtual int GetHashCode() override;
- virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int * ioDiff) override;
-)
-END_SYNTAX_CLASS()
-
-// A witness taht `sub : sup` because `sub` was wrapped into
-// an existential of type `sup`.
-SYNTAX_CLASS(ExtractExistentialSubtypeWitness, SubtypeWitness)
-RAW(
- // The declaration of the existential value that has been opened
- DeclRef<VarDeclBase> declRef;
-
- virtual bool EqualsVal(Val* val) override;
- virtual String ToString() override;
- virtual int GetHashCode() override;
- virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int * ioDiff) override;
-)
-END_SYNTAX_CLASS()
-
-// A witness that `sub : sup`, because `sub` is a tagged union
-// of the form `A | B | C | ...` and each of `A : sup`,
-// `B : sup`, `C : sup`, etc.
-//
-SYNTAX_CLASS(TaggedUnionSubtypeWitness, SubtypeWitness)
-RAW(
- // Witnesses that each of the "case" types in the union
- // is a subtype of `sup`.
- //
- List<RefPtr<Val>> caseWitnesses;
-
- virtual bool EqualsVal(Val* val) override;
- virtual String ToString() override;
- virtual int GetHashCode() override;
- virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int * ioDiff) override;
-)
-END_SYNTAX_CLASS()