Mercurial > projects > ddmd
comparison dmd/StaticAssert.d @ 20:1628b221808d
Fleshed out more unimplemented methods.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Wed, 07 Apr 2010 00:29:13 +0100 |
parents | 10317f0c89a5 |
children | 460959608115 |
comparison
equal
deleted
inserted
replaced
19:01cadcfa4842 | 20:1628b221808d |
---|---|
12 import dmd.Global; | 12 import dmd.Global; |
13 import dmd.Util; | 13 import dmd.Util; |
14 | 14 |
15 class StaticAssert : Dsymbol | 15 class StaticAssert : Dsymbol |
16 { | 16 { |
17 Expression exp; | 17 Expression exp; |
18 Expression msg; | 18 Expression msg; |
19 | 19 |
20 this(Loc loc, Expression exp, Expression msg) | 20 this(Loc loc, Expression exp, Expression msg) |
21 { | 21 { |
22 super(Id.empty); | 22 super(Id.empty); |
23 | 23 |
24 this.loc = loc; | 24 this.loc = loc; |
25 this.exp = exp; | 25 this.exp = exp; |
26 this.msg = msg; | 26 this.msg = msg; |
27 } | 27 } |
28 | 28 |
29 Dsymbol syntaxCopy(Dsymbol s) | 29 Dsymbol syntaxCopy(Dsymbol s) |
30 { | 30 { |
31 assert(false); | 31 StaticAssert sa; |
32 | |
33 assert(!s); | |
34 sa = new StaticAssert(loc, exp.syntaxCopy(), msg ? msg.syntaxCopy() : null); | |
35 return sa; | |
32 } | 36 } |
33 | 37 |
34 bool addMember(Scope sc, ScopeDsymbol sd, int memnum) | 38 bool addMember(Scope sc, ScopeDsymbol sd, int memnum) |
35 { | 39 { |
36 return false; // we didn't add anything | 40 return false; // we didn't add anything |
37 } | 41 } |
38 | 42 |
39 void semantic(Scope sc) | 43 void semantic(Scope sc) |
40 { | 44 { |
41 } | 45 } |
42 | 46 |
43 void semantic2(Scope sc) | 47 void semantic2(Scope sc) |
44 { | 48 { |
45 Expression e; | 49 Expression e; |
46 | 50 |
47 //printf("StaticAssert::semantic2() %s\n", toChars()); | 51 //printf("StaticAssert::semantic2() %s\n", toChars()); |
48 e = exp.semantic(sc); | 52 e = exp.semantic(sc); |
73 else if (!e.isBool(true)) | 77 else if (!e.isBool(true)) |
74 { | 78 { |
75 error("(%s) is not evaluatable at compile time", exp.toChars()); | 79 error("(%s) is not evaluatable at compile time", exp.toChars()); |
76 } | 80 } |
77 } | 81 } |
78 | 82 |
79 void inlineScan() | 83 void inlineScan() |
80 { | 84 { |
81 assert(false); | |
82 } | 85 } |
83 | 86 |
84 bool oneMember(Dsymbol* ps) | 87 bool oneMember(Dsymbol* ps) |
85 { | 88 { |
86 assert(false); | 89 //printf("StaticAssert::oneMember())\n"); |
90 *ps = null; | |
91 return true; | |
87 } | 92 } |
88 | 93 |
89 void toObjFile(int multiobj) | 94 void toObjFile(int multiobj) |
90 { | 95 { |
91 assert(false); | |
92 } | 96 } |
93 | 97 |
94 string kind() | 98 string kind() |
95 { | 99 { |
96 return "static assert"; | 100 return "static assert"; |
97 } | 101 } |
98 | 102 |
99 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 103 void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
100 { | 104 { |
101 assert(false); | 105 buf.writestring(kind()); |
106 buf.writeByte('('); | |
107 exp.toCBuffer(buf, hgs); | |
108 if (msg) | |
109 { | |
110 buf.writeByte(','); | |
111 msg.toCBuffer(buf, hgs); | |
112 } | |
113 buf.writestring(");"); | |
114 buf.writenl(); | |
102 } | 115 } |
103 } | 116 } |