Mercurial > projects > dang
comparison gen/CodeGen.d @ 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 | 9cfa33517526 |
children | 50b98a06a200 |
comparison
equal
deleted
inserted
replaced
170:09150374ddf9 | 171:f0385c044065 |
---|---|
340 // if function ptr: do something else | 340 // if function ptr: do something else |
341 // if delegate do a third thing | 341 // if delegate do a third thing |
342 // if struct/class check for opCall | 342 // if struct/class check for opCall |
343 DType type = callExp.exp.type; | 343 DType type = callExp.exp.type; |
344 assert (type.isFunction(), "Can only call functions"); | 344 assert (type.isFunction(), "Can only call functions"); |
345 auto sym = callExp.exp.getSymbol(); | |
346 scope args = new Value[callExp.args.length]; | 345 scope args = new Value[callExp.args.length]; |
347 foreach (i, arg; callExp.args) | 346 foreach (i, arg; callExp.args) |
348 args[i] = genExpression(arg).value; | 347 args[i] = genExpression(arg).value; |
349 llvm(type); | 348 llvm(type); |
350 auto f = m.getNamedFunction(symbolName(callExp.exp)); | 349 Function f = null; |
350 if (callExp.callSym is null) | |
351 { | |
352 // Do a virtual function call | |
353 f = m.getNamedFunction(symbolName(callExp.exp)); | |
354 } | |
355 else | |
356 { | |
357 auto sym = callExp.callSym; | |
358 f = m.getNamedFunction(sym.getMangledFQN()); | |
359 } | |
351 DFunction f_type = type.asFunction(); | 360 DFunction f_type = type.asFunction(); |
352 bool isVoid = f_type.returnType is DType.Void; | 361 bool isVoid = f_type.returnType is DType.Void; |
353 // BUG: doesn't do implicit type-conversion on args | |
354 auto r = b.buildCall(f, args, isVoid? "" : "call"); | 362 auto r = b.buildCall(f, args, isVoid? "" : "call"); |
355 return RValue(r); | 363 return RValue(r); |
356 case ExpType.CastExp: | 364 case ExpType.CastExp: |
357 auto castExp = cast(CastExp)exp; | 365 auto castExp = cast(CastExp)exp; |
358 exp = castExp.exp; | 366 exp = castExp.exp; |
855 return res; | 863 return res; |
856 } | 864 } |
857 else if (auto c = t.asClass) | 865 else if (auto c = t.asClass) |
858 { | 866 { |
859 SmallArray!(Type) members; | 867 SmallArray!(Type) members; |
860 if (c.members.length > 0 && false) | 868 if (c.members.length > 0) |
861 { | 869 { |
862 DType[] array; | 870 DType[] array; |
863 array.length = c.members.length; | 871 array.length = c.members.length; |
864 | 872 |
865 foreach (m; c.members) | 873 foreach (m; c.members) |