Mercurial > projects > ddmd
annotate dmd/DefaultStatement.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
0 | 1 module dmd.DefaultStatement; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Statement; |
5 import dmd.Loc; | |
6 import dmd.Scope; | |
7 import dmd.Expression; | |
8 import dmd.InterState; | |
9 import dmd.OutBuffer; | |
10 import dmd.HdrGenState; | |
11 import dmd.InlineScanState; | |
12 import dmd.IRState; | |
13 import dmd.BE; | |
14 | |
15 import dmd.backend.Util; | |
16 import dmd.backend.OPER; | |
17 import dmd.backend.Blockx; | |
18 import dmd.backend.block; | |
19 import dmd.backend.BC; | |
20 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
21 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
22 |
0 | 23 class DefaultStatement : Statement |
24 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
25 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
26 |
0 | 27 Statement statement; |
28 version (IN_GCC) { | |
29 block* cblock = null; // back end: label for the block | |
30 } | |
31 | |
32 this(Loc loc, Statement s) | |
33 { | |
178 | 34 register(); |
0 | 35 super(loc); |
36 this.statement = s; | |
37 } | |
38 | |
72 | 39 override Statement syntaxCopy() |
0 | 40 { |
53 | 41 DefaultStatement s = new DefaultStatement(loc, statement.syntaxCopy()); |
42 return s; | |
0 | 43 } |
44 | |
72 | 45 override Statement semantic(Scope sc) |
0 | 46 { |
47 //printf("DefaultStatement.semantic()\n"); | |
48 if (sc.sw) | |
49 { | |
50 if (sc.sw.sdefault) | |
51 { | |
52 error("switch statement already has a default"); | |
53 } | |
54 sc.sw.sdefault = this; | |
55 | |
56 if (sc.sw.tf !is sc.tf) | |
57 error("switch and default are in different finally blocks"); | |
58 | |
59 if (sc.sw.isFinal) | |
60 error("default statement not allowed in final switch statement"); | |
61 } | |
62 else | |
63 error("default not in switch statement"); | |
64 statement = statement.semantic(sc); | |
65 return this; | |
66 } | |
67 | |
72 | 68 override bool usesEH() |
0 | 69 { |
64 | 70 return statement.usesEH(); |
0 | 71 } |
72 | |
72 | 73 override BE blockExit() |
0 | 74 { |
75 return statement.blockExit(); | |
76 } | |
77 | |
72 | 78 override bool comeFrom() |
0 | 79 { |
80 return true; | |
81 } | |
82 | |
72 | 83 override Expression interpret(InterState istate) |
0 | 84 { |
85 assert(false); | |
86 } | |
87 | |
72 | 88 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 89 { |
64 | 90 buf.writestring("default:\n"); |
91 statement.toCBuffer(buf, hgs); | |
0 | 92 } |
93 | |
72 | 94 override Statement inlineScan(InlineScanState* iss) |
0 | 95 { |
96 if (statement) | |
97 statement = statement.inlineScan(iss); | |
98 return this; | |
99 } | |
100 | |
72 | 101 override void toIR(IRState* irs) |
0 | 102 { |
103 Blockx* blx = irs.blx; | |
104 block* bcase = blx.curblock; | |
105 block* bdefault = irs.getDefaultBlock(); | |
106 block_next(blx,BCgoto,bdefault); | |
107 list_append(&bcase.Bsucc,blx.curblock); | |
108 if (blx.tryblock != irs.getSwitchBlock().Btry) | |
109 error("default cannot be in different try block level from switch"); | |
110 incUsage(irs, loc); | |
111 if (statement) | |
112 statement.toIR(irs); | |
113 } | |
72 | 114 } |