From 17e3b88b541ed7f45d575f0f9caaa808cd0a6619 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 1 Jun 2022 17:37:07 -0700 Subject: New language feature: basic error handling. (#2253) * New language feature: basic error handling. * Fix. * Fix `tryCall` encoding according to code review. Co-authored-by: Yong He --- source/slang/slang-emit.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source/slang/slang-emit.cpp') diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 0ed17ad7c..72ad80873 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -23,6 +23,7 @@ #include "slang-ir-com-interface.h" #include "slang-ir-lower-generics.h" #include "slang-ir-lower-tuple-types.h" +#include "slang-ir-lower-result-type.h" #include "slang-ir-lower-bit-cast.h" #include "slang-ir-lower-reinterpret.h" #include "slang-ir-metadata.h" @@ -200,6 +201,19 @@ Result linkAndOptimizeIR( // un-specialized IR. dumpIRIfEnabled(codeGenContext, irModule); + switch (target) + { + default: + break; + case CodeGenTarget::HostCPPSource: + lowerComInterfaces(irModule, sink); + generateDllImportFuncs(irModule, sink); + break; + } + + // Lower `Result` types into ordinary struct types. + lowerResultType(irModule, sink); + // Replace any global constants with their values. // replaceGlobalConstants(irModule); @@ -689,16 +703,6 @@ Result linkAndOptimizeIR( break; } - switch (target) - { - default: - break; - case CodeGenTarget::HostCPPSource: - lowerComInterfaces(irModule, sink); - generateDllImportFuncs(irModule, sink); - break; - } - // TODO: our current dynamic dispatch pass will remove all uses of witness tables. // If we are going to support function-pointer based, "real" modular dynamic dispatch, // we will need to disable this pass. -- cgit v1.2.3