summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-04-28 12:00:52 +0800
committerGitHub <noreply@github.com>2023-04-28 12:00:52 +0800
commitb07f4effda2f87ac9b3229e588121d224fd8cf52 (patch)
tree95d4602ba4a3fffe9a879a4960602e8b8d887017
parent53793612e3a2f1cadc4f7cbf703bcd94b7121414 (diff)
Use Index for FuncType param count (#2853)
-rw-r--r--source/slang/slang-ast-type.cpp6
-rw-r--r--source/slang/slang-ast-type.h4
-rw-r--r--source/slang/slang-check-decl.cpp2
-rw-r--r--source/slang/slang-check-expr.cpp4
-rw-r--r--source/slang/slang-check-impl.h4
-rw-r--r--source/slang/slang-check-overload.cpp6
-rw-r--r--source/slang/slang-lower-to-ir.cpp6
7 files changed, 16 insertions, 16 deletions
diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp
index 987d73994..27cc7800b 100644
--- a/source/slang/slang-ast-type.cpp
+++ b/source/slang/slang-ast-type.cpp
@@ -548,7 +548,7 @@ bool FuncType::_equalsImplOverride(Type * type)
if (paramCount != otherParamCount)
return false;
- for (UInt pp = 0; pp < paramCount; ++pp)
+ for (Index pp = 0; pp < paramCount; ++pp)
{
auto paramType = getParamType(pp);
auto otherParamType = funcType->getParamType(pp);
@@ -622,9 +622,9 @@ Type* FuncType::_createCanonicalTypeOverride()
HashCode FuncType::_getHashCodeOverride()
{
HashCode hashCode = getResultType()->getHashCode();
- UInt paramCount = getParamCount();
+ Index paramCount = getParamCount();
hashCode = combineHash(hashCode, Slang::getHashCode(paramCount));
- for (UInt pp = 0; pp < paramCount; ++pp)
+ for (Index pp = 0; pp < paramCount; ++pp)
{
hashCode = combineHash(
hashCode,
diff --git a/source/slang/slang-ast-type.h b/source/slang/slang-ast-type.h
index cb3fde9f9..67288a59d 100644
--- a/source/slang/slang-ast-type.h
+++ b/source/slang/slang-ast-type.h
@@ -674,8 +674,8 @@ class FuncType : public Type
Type* resultType = nullptr;
Type* errorType = nullptr;
- UInt getParamCount() { return paramTypes.getCount(); }
- Type* getParamType(UInt index) { return paramTypes[index]; }
+ Index getParamCount() { return paramTypes.getCount(); }
+ Type* getParamType(Index index) { return paramTypes[index]; }
Type* getResultType() { return resultType; }
Type* getErrorType() { return errorType; }
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index bbbbaae2f..99939afde 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -5587,7 +5587,7 @@ namespace Slang
return;
decl->returnType.type = funcType->getResultType();
decl->errorType.type = funcType->getErrorType();
- for (UInt i = 0; i < funcType->getParamCount(); i++)
+ for (Index i = 0; i < funcType->getParamCount(); i++)
{
auto paramType = funcType->getParamType(i);
if (auto dirType = as<ParamDirectionType>(paramType))
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index dd0cd4eab..7b8be7a33 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -2253,7 +2253,7 @@ namespace Slang
SLANG_ASSERT(originalType->errorType->equals(m_astBuilder->getBottomType()));
jvpType->errorType = originalType->errorType;
- for (UInt i = 0; i < originalType->getParamCount(); i++)
+ for (Index i = 0; i < originalType->getParamCount(); i++)
{
if(auto jvpParamType = _toDifferentialParamType(originalType->getParamType(i)))
jvpType->paramTypes.add(jvpParamType);
@@ -2278,7 +2278,7 @@ namespace Slang
SLANG_ASSERT(originalType->errorType->equals(m_astBuilder->getBottomType()));
type->errorType = originalType->errorType;
- for (UInt i = 0; i < originalType->getParamCount(); i++)
+ for (Index i = 0; i < originalType->getParamCount(); i++)
{
if (auto outType = as<OutType>(originalType->getParamType(i)))
{
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index b4a779a66..2a78fa999 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -1574,8 +1574,8 @@ namespace Slang
struct ParamCounts
{
- UInt required;
- UInt allowed;
+ Count required;
+ Count allowed;
};
// count the number of parameters required/allowed for a callable
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp
index fbd8fb288..f2947a55d 100644
--- a/source/slang/slang-check-overload.cpp
+++ b/source/slang/slang-check-overload.cpp
@@ -98,7 +98,7 @@ namespace Slang
OverloadResolveContext& context,
OverloadCandidate const& candidate)
{
- UInt argCount = context.getArgCount();
+ Count argCount = context.getArgCount();
ParamCounts paramCounts = { 0, 0 };
switch (candidate.flavor)
{
@@ -1559,7 +1559,7 @@ namespace Slang
// Extract parameter list from processed type.
List<Type*> paramTypes;
- for (UIndex ii = 0; ii < diffFuncType->getParamCount(); ii++)
+ for (Index ii = 0; ii < diffFuncType->getParamCount(); ii++)
paramTypes.add(removeParamDirType(diffFuncType->getParamType(ii)));
// Try to infer generic arguments, based on the updated context.
@@ -1682,7 +1682,7 @@ namespace Slang
for (Index i = 0; i < expr->arguments.getCount(); i++)
{
auto& arg = expr->arguments[i];
- if (funcType && i < (Index)funcType->getParamCount())
+ if (funcType && i < funcType->getParamCount())
{
if (funcType->getParamDirection(i) == kParameterDirection_Out)
continue;
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index 14ed8ea54..1511615ed 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -1897,9 +1897,9 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower
IRFuncType* visitFuncType(FuncType* type)
{
IRType* resultType = lowerType(context, type->getResultType());
- UInt paramCount = type->getParamCount();
+ Index paramCount = type->getParamCount();
List<IRType*> paramTypes;
- for (UInt pp = 0; pp < paramCount; ++pp)
+ for (Index pp = 0; pp < paramCount; ++pp)
{
paramTypes.add(lowerType(context, type->getParamType(pp)));
}
@@ -3930,7 +3930,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
List<OutArgumentFixup>* ioFixups)
{
Count argCount = expr->arguments.getCount();
- SLANG_ASSERT(argCount == static_cast<Count>(funcType->getParamCount()));
+ SLANG_ASSERT(argCount == funcType->getParamCount());
for(Index i = 0; i < argCount; ++i)
{