Mercurial > projects > ddmd
annotate dmd/FuncLiteralDeclaration.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
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 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
15 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
16 |
0 | 17 class FuncLiteralDeclaration : FuncDeclaration |
18 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
19 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
20 |
0 | 21 TOK tok; // TOKfunction or TOKdelegate |
22 | |
23 this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes) | |
24 { | |
178 | 25 register(); |
0 | 26 super(loc, endloc, null, STC.STCundefined, type); |
27 | |
28 string id; | |
29 | |
30 if (fes) | |
31 id = "__foreachbody"; | |
32 else if (tok == TOK.TOKdelegate) | |
33 id = "__dgliteral"; | |
34 else | |
35 id = "__funcliteral"; | |
36 | |
37 this.ident = Lexer.uniqueId(id); | |
38 this.tok = tok; | |
39 this.fes = fes; | |
40 | |
41 //printf("FuncLiteralDeclaration() id = '%s', type = '%s'\n", this->ident->toChars(), type->toChars()); | |
42 } | |
43 | |
72 | 44 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 45 { |
93
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
46 buf.writestring(kind()); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
47 buf.writeByte(' '); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
48 type.toCBuffer(buf, null, hgs); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
49 bodyToCBuffer(buf, hgs); |
0 | 50 } |
51 | |
72 | 52 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 53 { |
56 | 54 FuncLiteralDeclaration f; |
55 | |
56 //printf("FuncLiteralDeclaration.syntaxCopy('%s')\n", toChars()); | |
57 if (s) | |
58 f = cast(FuncLiteralDeclaration)s; | |
59 else | |
60 { | |
61 f = new FuncLiteralDeclaration(loc, endloc, type.syntaxCopy(), tok, fes); | |
62 f.ident = ident; // keep old identifier | |
63 } | |
64 FuncDeclaration.syntaxCopy(f); | |
65 return f; | |
0 | 66 } |
67 | |
72 | 68 override bool isNested() |
0 | 69 { |
70 //printf("FuncLiteralDeclaration::isNested() '%s'\n", toChars()); | |
71 return (tok == TOK.TOKdelegate); | |
72 } | |
73 | |
72 | 74 override bool isVirtual() |
0 | 75 { |
76 return false; | |
77 } | |
78 | |
72 | 79 override FuncLiteralDeclaration isFuncLiteralDeclaration() { return this; } |
0 | 80 |
72 | 81 override string kind() |
0 | 82 { |
83 return (tok == TOKdelegate) ? "delegate" : "function"; | |
84 } | |
72 | 85 } |