From 8c48f86f0a62275817204cfa57ff4585f09a06c5 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Fri, 11 Jul 2008 01:34:04 +0200 Subject: [PATCH] [svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should. --- gen/functions.cpp | 11 +++++++++++ tangotests/lazy1.d | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tangotests/lazy1.d diff --git a/gen/functions.cpp b/gen/functions.cpp index 8d641a14..cddaaac6 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -141,6 +141,17 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, bo paramvec.push_back(at); } + // handle lazy args + if (arg->storageClass & STClazy) + { + Logger::cout() << "for lazy got: " << *paramvec.back() << '\n'; + TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd); + TypeDelegate *ltd = new TypeDelegate(ltf); + at = getPtrToType(DtoType(ltd)); + Logger::cout() << "lazy updated to: " << *at << '\n'; + paramvec.back() = at; + } + if (arg->llvmByVal) nbyval++; } diff --git a/tangotests/lazy1.d b/tangotests/lazy1.d new file mode 100644 index 00000000..aed64581 --- /dev/null +++ b/tangotests/lazy1.d @@ -0,0 +1,13 @@ +module tangotests.lazy1; + +extern(C) int printf(char*, ...); + +void main() +{ + lazystr("whee\n"); +} + +void lazystr(lazy char[] msg) +{ + printf("%.*s", msg.length, msg.ptr); +}