Mercurial > projects > ddmd
annotate dmd/FuncLiteralDeclaration.d @ 93:df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
and some additional ones I came across
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 22:50:30 +0200 |
parents | 2e2a5c3f943a |
children | e28b18c23469 |
rev | line source |
---|---|
0 | 1 module dmd.FuncLiteralDeclaration; |
2 | |
3 import dmd.FuncDeclaration; | |
4 import dmd.TOK; | |
5 import dmd.Loc; | |
6 import dmd.Type; | |
7 import dmd.ForeachStatement; | |
8 import dmd.OutBuffer; | |
9 import dmd.HdrGenState; | |
10 import dmd.Dsymbol; | |
11 import dmd.STC; | |
12 import dmd.Lexer; | |
13 | |
14 class FuncLiteralDeclaration : FuncDeclaration | |
15 { | |
16 TOK tok; // TOKfunction or TOKdelegate | |
17 | |
18 this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes) | |
19 { | |
20 super(loc, endloc, null, STC.STCundefined, type); | |
21 | |
22 string id; | |
23 | |
24 if (fes) | |
25 id = "__foreachbody"; | |
26 else if (tok == TOK.TOKdelegate) | |
27 id = "__dgliteral"; | |
28 else | |
29 id = "__funcliteral"; | |
30 | |
31 this.ident = Lexer.uniqueId(id); | |
32 this.tok = tok; | |
33 this.fes = fes; | |
34 | |
35 //printf("FuncLiteralDeclaration() id = '%s', type = '%s'\n", this->ident->toChars(), type->toChars()); | |
36 } | |
37 | |
72 | 38 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 39 { |
93
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
40 buf.writestring(kind()); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
41 buf.writeByte(' '); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
42 type.toCBuffer(buf, null, hgs); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
43 bodyToCBuffer(buf, hgs); |
0 | 44 } |
45 | |
72 | 46 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 47 { |
56 | 48 FuncLiteralDeclaration f; |
49 | |
50 //printf("FuncLiteralDeclaration.syntaxCopy('%s')\n", toChars()); | |
51 if (s) | |
52 f = cast(FuncLiteralDeclaration)s; | |
53 else | |
54 { | |
55 f = new FuncLiteralDeclaration(loc, endloc, type.syntaxCopy(), tok, fes); | |
56 f.ident = ident; // keep old identifier | |
57 } | |
58 FuncDeclaration.syntaxCopy(f); | |
59 return f; | |
0 | 60 } |
61 | |
72 | 62 override bool isNested() |
0 | 63 { |
64 //printf("FuncLiteralDeclaration::isNested() '%s'\n", toChars()); | |
65 return (tok == TOK.TOKdelegate); | |
66 } | |
67 | |
72 | 68 override bool isVirtual() |
0 | 69 { |
70 return false; | |
71 } | |
72 | |
72 | 73 override FuncLiteralDeclaration isFuncLiteralDeclaration() { return this; } |
0 | 74 |
72 | 75 override string kind() |
0 | 76 { |
77 return (tok == TOKdelegate) ? "delegate" : "function"; | |
78 } | |
72 | 79 } |