annotate dmd/GotoCaseStatement.d @ 72:2e2a5c3f943a

reduced warnings by adding override to the methods think this also normalizes different line endings used all over the place
author Trass3r
date Sat, 28 Aug 2010 16:19:48 +0200
parents 4290d870944a
children e28b18c23469
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.GotoCaseStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.CaseStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.BE;
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
13 import dmd.WANT;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 class GotoCaseStatement : Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 Expression exp; // NULL, or which case to goto
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 CaseStatement cs; // case statement it resolves to
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 this(Loc loc, Expression exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 super(loc);
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
23 cs = null;
4290d870944a More fixes
korDen
parents: 63
diff changeset
24 this.exp = exp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
27 override Statement syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
29 Expression e = exp ? exp.syntaxCopy() : null;
4290d870944a More fixes
korDen
parents: 63
diff changeset
30 GotoCaseStatement s = new GotoCaseStatement(loc, e);
4290d870944a More fixes
korDen
parents: 63
diff changeset
31 return s;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
34 override Statement semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
36 if (exp)
4290d870944a More fixes
korDen
parents: 63
diff changeset
37 exp = exp.semantic(sc);
4290d870944a More fixes
korDen
parents: 63
diff changeset
38
4290d870944a More fixes
korDen
parents: 63
diff changeset
39 if (!sc.sw)
4290d870944a More fixes
korDen
parents: 63
diff changeset
40 error("goto case not in switch statement");
4290d870944a More fixes
korDen
parents: 63
diff changeset
41 else
4290d870944a More fixes
korDen
parents: 63
diff changeset
42 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
43 sc.sw.gotoCases.push(cast(void*)this);
4290d870944a More fixes
korDen
parents: 63
diff changeset
44 if (exp)
4290d870944a More fixes
korDen
parents: 63
diff changeset
45 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
46 exp = exp.implicitCastTo(sc, sc.sw.condition.type);
4290d870944a More fixes
korDen
parents: 63
diff changeset
47 exp = exp.optimize(WANTvalue);
4290d870944a More fixes
korDen
parents: 63
diff changeset
48 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
49 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
50 return this;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
53 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
58 override BE blockExit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
60 return BEgoto;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
63 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
65 buf.writestring("goto case");
4290d870944a More fixes
korDen
parents: 63
diff changeset
66 if (exp)
4290d870944a More fixes
korDen
parents: 63
diff changeset
67 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
68 buf.writebyte(' ');
4290d870944a More fixes
korDen
parents: 63
diff changeset
69 exp.toCBuffer(buf, hgs);
4290d870944a More fixes
korDen
parents: 63
diff changeset
70 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
71 buf.writebyte(';');
4290d870944a More fixes
korDen
parents: 63
diff changeset
72 buf.writenl();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
75 override void toIR(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
79 }