Mercurial > projects > ddmd
annotate dmd/FuncLiteralDeclaration.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | df6d0f967680 |
children | e3afd1303184 |
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 { | |
21 super(loc, endloc, null, STC.STCundefined, type); | |
22 | |
23 string id; | |
24 | |
25 if (fes) | |
26 id = "__foreachbody"; | |
27 else if (tok == TOK.TOKdelegate) | |
28 id = "__dgliteral"; | |
29 else | |
30 id = "__funcliteral"; | |
31 | |
32 this.ident = Lexer.uniqueId(id); | |
33 this.tok = tok; | |
34 this.fes = fes; | |
35 | |
36 //printf("FuncLiteralDeclaration() id = '%s', type = '%s'\n", this->ident->toChars(), type->toChars()); | |
37 } | |
38 | |
72 | 39 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 40 { |
93
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
41 buf.writestring(kind()); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
42 buf.writeByte(' '); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
43 type.toCBuffer(buf, null, hgs); |
df6d0f967680
implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents:
72
diff
changeset
|
44 bodyToCBuffer(buf, hgs); |
0 | 45 } |
46 | |
72 | 47 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 48 { |
56 | 49 FuncLiteralDeclaration f; |
50 | |
51 //printf("FuncLiteralDeclaration.syntaxCopy('%s')\n", toChars()); | |
52 if (s) | |
53 f = cast(FuncLiteralDeclaration)s; | |
54 else | |
55 { | |
56 f = new FuncLiteralDeclaration(loc, endloc, type.syntaxCopy(), tok, fes); | |
57 f.ident = ident; // keep old identifier | |
58 } | |
59 FuncDeclaration.syntaxCopy(f); | |
60 return f; | |
0 | 61 } |
62 | |
72 | 63 override bool isNested() |
0 | 64 { |
65 //printf("FuncLiteralDeclaration::isNested() '%s'\n", toChars()); | |
66 return (tok == TOK.TOKdelegate); | |
67 } | |
68 | |
72 | 69 override bool isVirtual() |
0 | 70 { |
71 return false; | |
72 } | |
73 | |
72 | 74 override FuncLiteralDeclaration isFuncLiteralDeclaration() { return this; } |
0 | 75 |
72 | 76 override string kind() |
0 | 77 { |
78 return (tok == TOKdelegate) ? "delegate" : "function"; | |
79 } | |
72 | 80 } |