Mercurial > projects > ddmd
comparison dmd/GotoCaseStatement.d @ 64:4290d870944a
More fixes
author | korDen |
---|---|
date | Mon, 23 Aug 2010 20:29:15 +0400 |
parents | cab4c37afb89 |
children | 2e2a5c3f943a |
comparison
equal
deleted
inserted
replaced
63:cab4c37afb89 | 64:4290d870944a |
---|---|
8 import dmd.Loc; | 8 import dmd.Loc; |
9 import dmd.InterState; | 9 import dmd.InterState; |
10 import dmd.OutBuffer; | 10 import dmd.OutBuffer; |
11 import dmd.HdrGenState; | 11 import dmd.HdrGenState; |
12 import dmd.BE; | 12 import dmd.BE; |
13 import dmd.WANT; | |
13 | 14 |
14 class GotoCaseStatement : Statement | 15 class GotoCaseStatement : Statement |
15 { | 16 { |
16 Expression exp; // NULL, or which case to goto | 17 Expression exp; // NULL, or which case to goto |
17 CaseStatement cs; // case statement it resolves to | 18 CaseStatement cs; // case statement it resolves to |
18 | 19 |
19 this(Loc loc, Expression exp) | 20 this(Loc loc, Expression exp) |
20 { | 21 { |
21 assert(false); | |
22 super(loc); | 22 super(loc); |
23 cs = null; | |
24 this.exp = exp; | |
23 } | 25 } |
24 | 26 |
25 Statement syntaxCopy() | 27 Statement syntaxCopy() |
26 { | 28 { |
27 assert(false); | 29 Expression e = exp ? exp.syntaxCopy() : null; |
30 GotoCaseStatement s = new GotoCaseStatement(loc, e); | |
31 return s; | |
28 } | 32 } |
29 | 33 |
30 Statement semantic(Scope sc) | 34 Statement semantic(Scope sc) |
31 { | 35 { |
32 assert(false); | 36 if (exp) |
37 exp = exp.semantic(sc); | |
38 | |
39 if (!sc.sw) | |
40 error("goto case not in switch statement"); | |
41 else | |
42 { | |
43 sc.sw.gotoCases.push(cast(void*)this); | |
44 if (exp) | |
45 { | |
46 exp = exp.implicitCastTo(sc, sc.sw.condition.type); | |
47 exp = exp.optimize(WANTvalue); | |
48 } | |
49 } | |
50 return this; | |
33 } | 51 } |
34 | 52 |
35 Expression interpret(InterState istate) | 53 Expression interpret(InterState istate) |
36 { | 54 { |
37 assert(false); | 55 assert(false); |
38 } | 56 } |
39 | 57 |
40 BE blockExit() | 58 BE blockExit() |
41 { | 59 { |
42 assert(false); | 60 return BEgoto; |
43 } | 61 } |
44 | 62 |
45 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 63 void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
46 { | 64 { |
47 assert(false); | 65 buf.writestring("goto case"); |
66 if (exp) | |
67 { | |
68 buf.writebyte(' '); | |
69 exp.toCBuffer(buf, hgs); | |
70 } | |
71 buf.writebyte(';'); | |
72 buf.writenl(); | |
48 } | 73 } |
49 | 74 |
50 void toIR(IRState* irs) | 75 void toIR(IRState* irs) |
51 { | 76 { |
52 assert(false); | 77 assert(false); |