changeset 171:f0385c044065

Make function overloads work in the codegen
author Anders Halager <halager@gmail.com>
date Thu, 24 Jul 2008 12:27:34 +0200
parents 09150374ddf9
children 01c2c49775ef
files gen/CodeGen.d
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gen/CodeGen.d	Thu Jul 24 12:18:58 2008 +0200
+++ b/gen/CodeGen.d	Thu Jul 24 12:27:34 2008 +0200
@@ -342,15 +342,23 @@
                 // if struct/class check for opCall
                 DType type = callExp.exp.type;
                 assert (type.isFunction(), "Can only call functions");
-                auto sym = callExp.exp.getSymbol();
                 scope args = new Value[callExp.args.length];
                 foreach (i, arg; callExp.args)
                     args[i] = genExpression(arg).value;
                 llvm(type);
-                auto f = m.getNamedFunction(symbolName(callExp.exp));
+                Function f = null;
+                if (callExp.callSym is null)
+                {
+                    // Do a virtual function call
+                    f = m.getNamedFunction(symbolName(callExp.exp));
+                }
+                else
+                {
+                    auto sym = callExp.callSym;
+                    f = m.getNamedFunction(sym.getMangledFQN());
+                }
                 DFunction f_type = type.asFunction();
                 bool isVoid = f_type.returnType is DType.Void;
-                // BUG: doesn't do implicit type-conversion on args
                 auto r = b.buildCall(f, args, isVoid? "" : "call");
                 return RValue(r);
             case ExpType.CastExp:
@@ -857,7 +865,7 @@
         else if (auto c = t.asClass)
         {
             SmallArray!(Type) members;
-            if (c.members.length > 0 && false)
+            if (c.members.length > 0)
             {
                 DType[] array;
                 array.length = c.members.length;