Mercurial > projects > ddmd
comparison dmd/AssertExp.d @ 179:cd48cb899aee
Updated to dmd2.040
author | korDen |
---|---|
date | Sun, 17 Oct 2010 20:56:07 +0400 |
parents | e3afd1303184 |
children | b0d41ff5e0df |
comparison
equal
deleted
inserted
replaced
178:e3afd1303184 | 179:cd48cb899aee |
---|---|
16 import dmd.Type; | 16 import dmd.Type; |
17 import dmd.Global; | 17 import dmd.Global; |
18 import dmd.InvariantDeclaration; | 18 import dmd.InvariantDeclaration; |
19 import dmd.TOK; | 19 import dmd.TOK; |
20 import dmd.PREC; | 20 import dmd.PREC; |
21 import dmd.AddrExp; | |
22 import dmd.DotVarExp; | |
21 import dmd.TY; | 23 import dmd.TY; |
22 import dmd.TypeClass; | 24 import dmd.TypeClass; |
25 import dmd.GlobalExpressions; | |
23 import dmd.Module; | 26 import dmd.Module; |
24 import dmd.WANT; | 27 import dmd.WANT; |
25 import dmd.FuncDeclaration; | 28 import dmd.FuncDeclaration; |
26 import dmd.HaltExp; | 29 import dmd.HaltExp; |
27 import dmd.TypeStruct; | 30 import dmd.TypeStruct; |
34 import dmd.backend.dt_t; | 37 import dmd.backend.dt_t; |
35 import dmd.backend.SC; | 38 import dmd.backend.SC; |
36 import dmd.backend.FL; | 39 import dmd.backend.FL; |
37 | 40 |
38 import dmd.expression.Util; | 41 import dmd.expression.Util; |
42 import dmd.interpret.Util; | |
39 | 43 |
40 import core.stdc.string; | 44 import core.stdc.string; |
41 import std.string : toStringz; | 45 import std.string : toStringz; |
42 | 46 |
43 //static __gshared Symbol* assertexp_sfilename = null; | 47 //static __gshared Symbol* assertexp_sfilename = null; |
95 type = Type.tvoid; | 99 type = Type.tvoid; |
96 return this; | 100 return this; |
97 } | 101 } |
98 | 102 |
99 override Expression interpret(InterState istate) | 103 override Expression interpret(InterState istate) |
100 { | 104 { |
101 assert(false); | 105 Expression e; |
106 Expression e1; | |
107 | |
108 version (LOG) { | |
109 writef("AssertExp::interpret() %s\n", toChars()); | |
110 } | |
111 if (this.e1.op == TOKaddress) | |
112 { | |
113 // Special case: deal with compiler-inserted assert(&this, "null this") | |
114 AddrExp ade = cast(AddrExp)this.e1; | |
115 if (ade.e1.op == TOKthis && istate.localThis) | |
116 if (ade.e1.op == TOKdotvar | |
117 && (cast(DotVarExp)(istate.localThis)).e1.op == TOKthis) | |
118 return getVarExp(loc, istate, (cast(DotVarExp)(istate.localThis)).var); | |
119 else | |
120 return istate.localThis.interpret(istate); | |
121 } | |
122 if (this.e1.op == TOKthis) | |
123 { | |
124 if (istate.localThis) | |
125 return istate.localThis.interpret(istate); | |
126 } | |
127 e1 = this.e1.interpret(istate); | |
128 if (e1 is EXP_CANT_INTERPRET) | |
129 goto Lcant; | |
130 if (e1.isBool(true)) | |
131 { | |
132 } | |
133 else if (e1.isBool(false)) | |
134 { | |
135 if (msg) | |
136 { | |
137 e = msg.interpret(istate); | |
138 if (e is EXP_CANT_INTERPRET) | |
139 goto Lcant; | |
140 error("%s", e.toChars()); | |
141 } | |
142 else | |
143 error("%s failed", toChars()); | |
144 goto Lcant; | |
145 } | |
146 else | |
147 goto Lcant; | |
148 return e1; | |
149 | |
150 Lcant: | |
151 return EXP_CANT_INTERPRET; | |
102 } | 152 } |
103 | 153 |
104 override bool checkSideEffect(int flag) | 154 override bool checkSideEffect(int flag) |
105 { | 155 { |
106 return true; | 156 return true; |