From 65c2e7f1ccc6cdb5daec343c7e32b4a9dc463ae4 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 12 Apr 2022 15:23:53 -0700 Subject: Support `[DllImport]` (#2181) * Support `[DllImport]` * Fix. * Fix. * Fix array type emit in cpp. * Fix. * Fix. * Fix Co-authored-by: Yong He --- source/slang/slang-lower-to-ir.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index bca8bd5b6..6cdf20af4 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1051,6 +1051,11 @@ static void addLinkageDecoration( { builder->addExternCppDecoration(inst, mangledName); } + if (auto dllImportModifier = decl->findModifier()) + { + auto libraryName = dllImportModifier->modulePath; + builder->addDllImportDecoration(inst, libraryName.getUnownedSlice(), decl->getName()->text.getUnownedSlice()); + } } static void addLinkageDecoration( @@ -3173,6 +3178,11 @@ struct ExprLoweringVisitorBase : ExprVisitor return LoweredValInfo::simple(context->irBuilder->getBoolValue(expr->value)); } + LoweredValInfo visitNullPtrLiteralExpr(NullPtrLiteralExpr*) + { + return LoweredValInfo::simple(context->irBuilder->getPtrValue(nullptr)); + } + LoweredValInfo visitIntegerLiteralExpr(IntegerLiteralExpr* expr) { auto type = lowerType(context, expr->type); -- cgit v1.2.3