summaryrefslogtreecommitdiff
path: root/source/slang/syntax-base-defs.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-02-02 11:58:54 -0500
committerTim Foley <tfoleyNV@users.noreply.github.com>2019-02-02 08:58:54 -0800
commit3726194fbe3da234eb30b6371e5b4ab1ea388f93 (patch)
tree815bb6162f76aeb2bd517126b802cc511cd0322a /source/slang/syntax-base-defs.h
parent6f2c03430afdf963eed53c08d0b63342af722868 (diff)
Feature/as refactor review (#821)
* Replace dynamicCast with as where does not change behavior (ie not Type derived). Use free function where scoping is clear. * Replace uses of dynamicCast with as when there is no difference in behavior. * Remove the IsXXXX methods from Type. * Don't have separate smart pointer to store canonicalType on Type. * Simplify Slang.FilteredMemberRefList.Adjust, such does the cast directly. * Use free as where appropriate. * Use free function version of casts where appropriate. * Fix text in casting.md * Fix typos in decl-refs.md * Remove the uses of free function as on RefDecl. Add 'canAs' to RefDecl as a way to test if a cast is possible. Moved 'as' into RefDeclBase. * Use 'is' to test for as cast on smart pointers. Fix small scope issue. * * Cache stringType and enumTypeType on the Session * Make DeclRefType::Create return a RefPtr * Make casting of result use the *method* .as (cos using free function would mean objects being wrongly destroyed) * Make results from createInstance ref'd to avoid possible leaks. * Fix typo in template parameter for is on RefPtr.
Diffstat (limited to 'source/slang/syntax-base-defs.h')
-rw-r--r--source/slang/syntax-base-defs.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/source/slang/syntax-base-defs.h b/source/slang/syntax-base-defs.h
index 7f49bb607..93fe687fd 100644
--- a/source/slang/syntax-base-defs.h
+++ b/source/slang/syntax-base-defs.h
@@ -80,27 +80,22 @@ public:
Session* getSession() { return this->session; }
void setSession(Session* s) { this->session = s; }
- bool Equals(Type * type);
- bool Equals(RefPtr<Type> type);
-
- bool IsTextureOrSampler();
- bool IsTexture() { return as<TextureType>(this) != nullptr; }
- bool IsSampler() { return as<SamplerStateType>(this) != nullptr; }
- bool IsStruct();
- //bool IsClass();
-
+ bool Equals(Type* type);
+
Type* GetCanonicalType();
virtual RefPtr<Val> SubstituteImpl(SubstitutionSet subst, int* ioDiff) override;
virtual bool EqualsVal(Val* val) override;
+
+ ~Type();
+
protected:
- virtual bool EqualsImpl(Type * type) = 0;
+ virtual bool EqualsImpl(Type* type) = 0;
virtual RefPtr<Type> CreateCanonicalType() = 0;
Type* canonicalType = nullptr;
- RefPtr<Type> canonicalTypeRefPtr;
-
+
Session* session = nullptr;
)
END_SYNTAX_CLASS()