diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-05-29 11:39:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-29 11:39:55 -0700 |
| commit | e7a83323bfc4dd698ef491375a37c65c83915951 (patch) | |
| tree | 4dc8d7ac5c192817a6d3fa680b731723ff9eba27 /source/slang/syntax.cpp | |
| parent | ace9a8dc7e4353b1cf8e846abe2b8dc53ecdbc59 (diff) | |
Fix global atomic functions (#582)
Fixes #581
This change adds a new parameter passing mode `__ref` to exist alongisde `in`, `out`, and `inout`.
The `__ref` modifier indicates true by-reference parameter passing (whereas `inout` is copy-in-copy-out).
This is not intended to be something that users interact with directly, but rather a low-level feature that lets us provide a correct signature for the `Interlocked*()` operations in the standard library.
Most of the support for passing what are logically addresses around already exists in the IR, so the majority of the work here is just in introducing the new type `Ref<T>` and then using it appropriately when lowering `__ref` parameters/arguments to the IR.
Diffstat (limited to 'source/slang/syntax.cpp')
| -rw-r--r-- | source/slang/syntax.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index 5e855de29..74c817b92 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -303,6 +303,11 @@ void Type::accept(IValVisitor* visitor, void* extra) return getPtrType(valueType, "InOutType").As<InOutType>(); } + RefPtr<RefType> Session::getRefType(RefPtr<Type> valueType) + { + return getPtrType(valueType, "RefType").As<RefType>(); + } + RefPtr<PtrTypeBase> Session::getPtrType(RefPtr<Type> valueType, char const* ptrTypeName) { auto genericDecl = findMagicDecl( @@ -2085,7 +2090,11 @@ void Type::accept(IValVisitor* visitor, void* extra) { auto paramDecl = paramDeclRef.getDecl(); auto paramType = GetType(paramDeclRef); - if( paramDecl->FindModifier<OutModifier>() ) + if( paramDecl->FindModifier<RefModifier>() ) + { + paramType = session->getRefType(paramType); + } + else if( paramDecl->FindModifier<OutModifier>() ) { if(paramDecl->FindModifier<InOutModifier>() || paramDecl->FindModifier<InModifier>()) { |
