summaryrefslogtreecommitdiffstats
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp
index fa9c88051..e43dd9074 100644
--- a/source/slang/syntax.cpp
+++ b/source/slang/syntax.cpp
@@ -280,19 +280,40 @@ void Type::accept(IValVisitor* visitor, void* extra)
RefPtr<PtrType> Session::getPtrType(
RefPtr<Type> valueType)
{
+ return getPtrType(valueType, "PtrType").As<PtrType>();
+ }
+
+ // Construct the type `Out<valueType>`
+ RefPtr<OutType> Session::getOutType(RefPtr<Type> valueType)
+ {
+ return getPtrType(valueType, "OutType").As<OutType>();
+ }
+
+ RefPtr<InOutType> Session::getInOutType(RefPtr<Type> valueType)
+ {
+ return getPtrType(valueType, "InOutType").As<InOutType>();
+ }
+
+ RefPtr<PtrTypeBase> Session::getPtrType(RefPtr<Type> valueType, char const* ptrTypeName)
+ {
auto genericDecl = findMagicDecl(
- this, "PtrType").As<GenericDecl>();
+ this, ptrTypeName).As<GenericDecl>();
+ return getPtrType(valueType, genericDecl);
+ }
+
+ RefPtr<PtrTypeBase> Session::getPtrType(RefPtr<Type> valueType, GenericDecl* genericDecl)
+ {
auto typeDecl = genericDecl->inner;
-
+
auto substitutions = new GenericSubstitution();
- substitutions->genericDecl = genericDecl.Ptr();
+ substitutions->genericDecl = genericDecl;
substitutions->args.Add(valueType);
auto declRef = DeclRef<Decl>(typeDecl.Ptr(), substitutions);
return DeclRefType::Create(
this,
- declRef)->As<PtrType>();
+ declRef)->As<PtrTypeBase>();
}
RefPtr<ArrayExpressionType> Session::getArrayType(