Mercurial > projects > ddmd
comparison dmd/GotoDefaultStatement.d @ 68:ee3a9f34dc48
final bits of codegen implementation to compile Phobos
author | korDen |
---|---|
date | Tue, 24 Aug 2010 16:44:34 +0400 |
parents | 4290d870944a |
children | 2e2a5c3f943a |
comparison
equal
deleted
inserted
replaced
67:f708f0452e81 | 68:ee3a9f34dc48 |
---|---|
8 import dmd.InterState; | 8 import dmd.InterState; |
9 import dmd.OutBuffer; | 9 import dmd.OutBuffer; |
10 import dmd.HdrGenState; | 10 import dmd.HdrGenState; |
11 import dmd.IRState; | 11 import dmd.IRState; |
12 import dmd.BE; | 12 import dmd.BE; |
13 | |
14 import dmd.backend.block; | |
15 import dmd.backend.Blockx; | |
16 import dmd.backend.Util; | |
17 import dmd.backend.BC; | |
13 | 18 |
14 class GotoDefaultStatement : Statement | 19 class GotoDefaultStatement : Statement |
15 { | 20 { |
16 SwitchStatement sw; | 21 SwitchStatement sw; |
17 | 22 |
50 buf.writestring("goto default;\n"); | 55 buf.writestring("goto default;\n"); |
51 } | 56 } |
52 | 57 |
53 void toIR(IRState *irs) | 58 void toIR(IRState *irs) |
54 { | 59 { |
55 assert(false); | 60 block *b; |
61 Blockx *blx = irs.blx; | |
62 block *bdest = irs.getDefaultBlock(); | |
63 | |
64 b = blx.curblock; | |
65 | |
66 // The rest is equivalent to GotoStatement | |
67 | |
68 // Adjust exception handler scope index if in different try blocks | |
69 if (b.Btry != bdest.Btry) | |
70 { | |
71 // Check that bdest is in an enclosing try block | |
72 for (block* bt = b.Btry; bt != bdest.Btry; bt = bt.Btry) | |
73 { | |
74 if (!bt) | |
75 { | |
76 //printf("b.Btry = %p, bdest.Btry = %p\n", b.Btry, bdest.Btry); | |
77 error("cannot goto into try block"); | |
78 break; | |
79 } | |
80 } | |
81 | |
82 //setScopeIndex(blx, b, bdest.Btry ? bdest.Btry.Bscope_index : -1); | |
83 } | |
84 | |
85 list_append(&b.Bsucc,bdest); | |
86 incUsage(irs, loc); | |
87 block_next(blx,BCgoto,null); | |
56 } | 88 } |
57 } | 89 } |