Mercurial > projects > ldc
annotate tests/mini/dgs.d @ 1605:1d5721f9ae18
[WIP] Merge DMD r251: bugzilla 111 (appending a dchar to a char[])
This patch needs some work in the code generation, because of the runtime
changes (functions "_d_arrayappendcd" and "_d_arrayappendwd" are added).
This doesn't affect existing code though, it just makes with patch
a little useless, because something like this:
char [] s;
s ~= '\u6211';
That failed to compile with a nice error message previously to this
change, now fails with and ugly error message (a failed assertion).
Apparently there is a regression introduced by this patch too, when
compiling Dil I get this assertion message:
ldc: /home/luca/tesis/ldc/gen/statements.cpp:132: virtual void ReturnStatement::toIR(IRState*): Assertion `p->topfunc()->getReturnType() == llvm::Type::getVoidTy(gIR->context())' failed.
0 ldc 0x08a91628
Thank god we have bisecting capabilities in VCSs now ;)
---
dmd/expression.c | 47 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 41 insertions(+), 6 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:19 -0300 |
parents | 1bb99290e03a |
children |
rev | line source |
---|---|
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
1 |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
2 extern(C) int printf(char*, ...); |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
3 |
1 | 4 struct S |
5 { | |
6 int i; | |
7 int square() | |
8 { | |
9 return i*i; | |
10 } | |
11 int plus(int a) | |
12 { | |
13 return i + a; | |
14 } | |
15 int minus(int a) | |
16 { | |
17 return i - a; | |
18 } | |
19 int delegate(int) get(char op) | |
20 { | |
21 int delegate(int) rval; | |
22 if (op == '+') | |
23 rval = + | |
24 else if (op == '-') | |
25 rval = − | |
26 return rval; | |
27 } | |
28 } | |
29 | |
30 int calldg1(int delegate(int) dg, int i) | |
31 { | |
32 return dg(i); | |
33 } | |
34 | |
35 void delegate() retdg() | |
36 { | |
37 void delegate() dg; | |
38 return dg; | |
39 } | |
40 | |
41 void getretdg() | |
42 { | |
43 void delegate() dg; | |
44 dg = retdg(); | |
45 } | |
46 | |
47 class C | |
48 { | |
49 int i; | |
50 void m() | |
51 { | |
52 i = 42; | |
53 } | |
54 } | |
55 | |
56 void getclassdg() | |
57 { | |
58 scope c = new C; | |
59 void delegate() dg = &c.m; | |
60 assert(c.i != 42); | |
61 dg(); | |
62 assert(c.i == 42); | |
63 } | |
64 | |
65 void main() | |
66 { | |
67 printf("Delegate test\n"); | |
68 S s = S(4); | |
69 | |
70 auto dg = &s.square; | |
71 //assert(dg() == 16); | |
72 //dg(); | |
73 | |
74 /*auto dg1 = &s.plus; | |
75 assert(dg1(6) == 10); | |
76 | |
77 auto dg2 = &s.minus; | |
78 assert(calldg1(dg2,30) == -26); | |
79 | |
80 auto dg3 = s.get('+'); | |
81 assert(dg3(16) == 20); | |
82 | |
83 getretdg(); | |
84 getclassdg();*/ | |
85 | |
86 printf(" SUCCESS\n"); | |
87 } |