Mercurial > projects > ddmd
annotate dmd/FuncLiteralDeclaration.d @ 178:e3afd1303184
Many small bugs fixed
Made all classes derive from TObject to detect memory leaks (functionality is disabled for now)
Began work on overriding backend memory allocations (to avoid memory leaks)
author | korDen |
---|---|
date | Sun, 17 Oct 2010 07:42:00 +0400 |
parents | e28b18c23469 |
children | b0d41ff5e0df |
rev | line source |
---|---|
0 | 1 module dmd.FuncLiteralDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.FuncDeclaration; |
5 import dmd.TOK; | |
6 import dmd.Loc; | |
7 import dmd.Type; | |
8 import dmd.ForeachStatement; | |
9 import dmd.OutBuffer; | |
10 import dmd.HdrGenState; | |
11 import dmd.Dsymbol; | |
12 import dmd.STC; | |
13 import dmd.Lexer; | |
14 | |
15 class FuncLiteralDeclaration : FuncDeclaration | |
16 { | |
17 TOK tok; // TOKfunction or TOKdelegate | |
18 | |
19 this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes) | |
20 { | |
178 | 21 register(); |
0 | 22 super(loc, endloc, null, STC.STCundefined, type); |
23 | |
24 string id; | |
25 | |
26 if (fes) | |
27 id = "__foreachbody"; | |
28 else if (tok == TOK.TOKdelegate) | |
29 id = "__dgliteral"; | |
30 else | |
31 id = "__funcliteral"; | |
32 | |
33 this.ident = Lexer.uniqueId(id); | |
34 this.tok = tok; | |
35 this.fes = fes; | |
36 | |
37 //printf("FuncLiteralDeclaration() id = '%s', type = '%s'\n", this->ident->toChars(), type->toChars()); | |
38 } | |
39 | |
72 | 40 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 41 { |
93
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
42 buf.writestring(kind()); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
43 buf.writeByte(' '); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
44 type.toCBuffer(buf, null, hgs); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
45 bodyToCBuffer(buf, hgs); |
0 | 46 } |
47 | |
72 | 48 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 49 { |
56 | 50 FuncLiteralDeclaration f; |
51 | |
52 //printf("FuncLiteralDeclaration.syntaxCopy('%s')\n", toChars()); | |
53 if (s) | |
54 f = cast(FuncLiteralDeclaration)s; | |
55 else | |
56 { | |
57 f = new FuncLiteralDeclaration(loc, endloc, type.syntaxCopy(), tok, fes); | |
58 f.ident = ident; // keep old identifier | |
59 } | |
60 FuncDeclaration.syntaxCopy(f); | |
61 return f; | |
0 | 62 } |
63 | |
72 | 64 override bool isNested() |
0 | 65 { |
66 //printf("FuncLiteralDeclaration::isNested() '%s'\n", toChars()); | |
67 return (tok == TOK.TOKdelegate); | |
68 } | |
69 | |
72 | 70 override bool isVirtual() |
0 | 71 { |
72 return false; | |
73 } | |
74 | |
72 | 75 override FuncLiteralDeclaration isFuncLiteralDeclaration() { return this; } |
0 | 76 |
72 | 77 override string kind() |
0 | 78 { |
79 return (tok == TOKdelegate) ? "delegate" : "function"; | |
80 } | |
72 | 81 } |