changeset 837:331a176c1f4f

Removed error on naked, not fully complete, but I'll be doing more work on it during this Christmas, and some things do work. Fixed taking delegate of final class method. see mini/delegate3.d.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 09 Dec 2008 14:07:30 +0100
parents 14c3319ac1bb
children 94ba810ea2b0
files gen/classes.cpp gen/functions.cpp gen/toir.cpp tests/mini/delegate3.d
diffstat 4 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gen/classes.cpp	Tue Dec 09 03:01:19 2008 +0100
+++ b/gen/classes.cpp	Tue Dec 09 14:07:30 2008 +0100
@@ -1260,6 +1260,7 @@
 {
     // sanity checks
     assert(fdecl->isVirtual());
+    assert(!fdecl->isFinal());
     assert(fdecl->vtblIndex > 0); // 0 is always ClassInfo/Interface*
     assert(inst->getType()->toBasetype()->ty == Tclass);
 
--- a/gen/functions.cpp	Tue Dec 09 03:01:19 2008 +0100
+++ b/gen/functions.cpp	Tue Dec 09 14:07:30 2008 +0100
@@ -628,13 +628,6 @@
     Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars());
     LOG_SCOPE;
 
-    // error on naked
-    if (fd->naked)
-    {
-        fd->error("naked is not supported");
-        fatal();
-    }
-
     // debug info
     if (global.params.symdebug) {
         Module* mo = fd->getModule();
--- a/gen/toir.cpp	Tue Dec 09 03:01:19 2008 +0100
+++ b/gen/toir.cpp	Tue Dec 09 14:07:30 2008 +0100
@@ -1970,7 +1970,7 @@
     Logger::println("func: '%s'", func->toPrettyChars());
 
     LLValue* castfptr;
-    if (func->isVirtual())
+    if (func->isVirtual() && !func->isFinal())
         castfptr = DtoVirtualFunctionPointer(u, func);
     else if (func->isAbstract())
         assert(0 && "TODO delegate to abstract method");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mini/delegate3.d	Tue Dec 09 14:07:30 2008 +0100
@@ -0,0 +1,18 @@
+module bar;
+
+class S
+{
+    int i;
+    final int foo()
+    {
+        return i;
+    }
+}
+
+void main()
+{
+    auto s = new S;
+    s.i = 42;
+    auto dg = &s.foo;
+    assert(dg() == 42);
+}