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
|
|
38 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
|
39 {
|
|
40 assert(false);
|
|
41 }
|
|
42
|
|
43 Dsymbol syntaxCopy(Dsymbol)
|
|
44 {
|
|
45 assert(false);
|
|
46 }
|
|
47
|
|
48 bool isNested()
|
|
49 {
|
|
50 //printf("FuncLiteralDeclaration::isNested() '%s'\n", toChars());
|
|
51 return (tok == TOK.TOKdelegate);
|
|
52 }
|
|
53
|
|
54 bool isVirtual()
|
|
55 {
|
|
56 return false;
|
|
57 }
|
|
58
|
|
59 FuncLiteralDeclaration isFuncLiteralDeclaration() { return this; }
|
|
60
|
|
61 string kind()
|
|
62 {
|
|
63 return (tok == TOKdelegate) ? "delegate" : "function";
|
|
64 }
|
|
65 } |