From 332f60c19336252d907b83882aa70665ca93a9d2 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Fri, 12 May 2023 04:33:21 +0800 Subject: MVP for higher order functions (#2849) * MVP for higher order functions * Add shader subgroup partitioned glsl intrinsics * Implement parsing and checking for tuple types Currently there is no way to do anything useful with them from the source language however * neaten * Correct precedence of function type parsing * neaten * higher order function tests * function types of any arity * Inference for higher order functions * Add second test for unsynchronized params * regenerate vs projects * dx11 -> dx12 for saturated cooperations tests * Disable saturated cooperation tests on vulkan They fail on release builds in CI, not essential for the higher order function work however * remove saturated-cooperation tests * Remove unnecessary assert and clarify control flow in AddDeclRefOverloadCandidates * Add Tuple type name mangling * Use functype keyword to introduce function types * Add more inference tests for hof --------- Co-authored-by: Yong He --- source/slang/slang-mangle.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-mangle.cpp') diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index a8ab98254..ef9bf4938 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -177,7 +177,7 @@ namespace Slang break; default: - SLANG_UNEXPECTED("unimplemented case in mangling"); + SLANG_UNEXPECTED("unimplemented case in base type mangling"); break; } } @@ -238,9 +238,31 @@ namespace Slang { emitRaw(context, "E"); } + else if (const auto bottomType = dynamicCast(type)) + { + emitRaw(context, "B"); + } + else if (auto funcType = dynamicCast(type)) + { + emitRaw(context, "F"); + auto n = funcType->getParamCount(); + emit(context, n); + for(Index i = 0; i < n; ++i) + emitType(context, funcType->getParamType(i)); + emitType(context, funcType->getResultType()); + emitType(context, funcType->getErrorType()); + } + else if (auto tupleType = dynamicCast(type)) + { + emitRaw(context, "Tu"); + auto n = tupleType->getMemberCount(); + emit(context, n); + for(Index i = 0; i < n; ++i) + emitType(context, tupleType->getMember(i)); + } else { - SLANG_UNEXPECTED("unimplemented case in mangling"); + SLANG_UNEXPECTED("unimplemented case in type mangling"); } } @@ -307,7 +329,7 @@ namespace Slang } else { - SLANG_UNEXPECTED("unimplemented case in mangling"); + SLANG_UNEXPECTED("unimplemented case in val mangling"); } } -- cgit v1.2.3