summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-05-29 11:39:55 -0700
committerGitHub <noreply@github.com>2018-05-29 11:39:55 -0700
commite7a83323bfc4dd698ef491375a37c65c83915951 (patch)
tree4dc8d7ac5c192817a6d3fa680b731723ff9eba27 /source/slang/check.cpp
parentace9a8dc7e4353b1cf8e846abe2b8dc53ecdbc59 (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/check.cpp')
-rw-r--r--source/slang/check.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index 19e349807..c3eb44cfd 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -3011,6 +3011,11 @@ namespace Slang
// because there is no way for overload resolution to pick between them.
if (fstParam.getDecl()->HasModifier<OutModifier>() != sndParam.getDecl()->HasModifier<OutModifier>())
return false;
+
+ // If one parameter is `ref` and the other isn't, then they don't match.
+ //
+ if(fstParam.getDecl()->HasModifier<RefModifier>() != sndParam.getDecl()->HasModifier<RefModifier>())
+ return false;
}
// Note(tfoley): return type doesn't enter into it, because we can't take
@@ -7046,8 +7051,15 @@ namespace Slang
for (UInt pp = 0; pp < paramCount; ++pp)
{
auto paramType = funcType->getParamType(pp);
- if (auto outParamType = paramType->As<OutTypeBase>())
+ if (paramType->As<OutTypeBase>() || paramType->As<RefType>())
{
+ // `out`, `inout`, and `ref` parameters currently require
+ // an *exact* match on the type of the argument.
+ //
+ // TODO: relax this requirement by allowing an argument
+ // for an `inout` parameter to be converted in both
+ // directions.
+ //
if( pp < expr->Arguments.Count() )
{
auto argExpr = expr->Arguments[pp];