Mercurial > projects > ddmd
annotate dmd/ScopeStatement.d @ 168:ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
author | korDen |
---|---|
date | Thu, 30 Sep 2010 12:57:13 +0400 |
parents | 14feb7ae01a6 |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.ScopeStatement; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Statement; |
5 import dmd.Loc; | |
6 import dmd.Scope; | |
7 import dmd.OutBuffer; | |
8 import dmd.HdrGenState; | |
9 import dmd.Expression; | |
10 import dmd.InterState; | |
11 import dmd.InlineScanState; | |
12 import dmd.ScopeDsymbol; | |
13 import dmd.ArrayTypes; | |
14 import dmd.CompoundStatement; | |
15 import dmd.IRState; | |
16 import dmd.BE; | |
17 | |
18 import dmd.backend.Blockx; | |
19 import dmd.backend.BC; | |
20 import dmd.backend.Util; | |
21 | |
22 class ScopeStatement : Statement | |
23 { | |
24 Statement statement; | |
25 | |
26 this(Loc loc, Statement s) | |
27 { | |
28 super(loc); | |
29 this.statement = s; | |
30 } | |
31 | |
72 | 32 override Statement syntaxCopy() |
0 | 33 { |
34 Statement s = statement ? statement.syntaxCopy() : null; | |
35 s = new ScopeStatement(loc, s); | |
36 return s; | |
37 } | |
38 | |
72 | 39 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 40 { |
41 buf.writeByte('{'); | |
42 buf.writenl(); | |
43 | |
44 if (statement) | |
45 statement.toCBuffer(buf, hgs); | |
46 | |
47 buf.writeByte('}'); | |
48 buf.writenl(); | |
49 } | |
50 | |
72 | 51 override ScopeStatement isScopeStatement() { return this; } |
0 | 52 |
72 | 53 override Statement semantic(Scope sc) |
0 | 54 { |
55 ScopeDsymbol sym; | |
56 | |
57 //printf("ScopeStatement.semantic(sc = %p)\n", sc); | |
58 if (statement) | |
59 { | |
60 Statements a; | |
61 | |
62 sym = new ScopeDsymbol(); | |
63 sym.parent = sc.scopesym; | |
64 sc = sc.push(sym); | |
65 | |
66 a = statement.flatten(sc); | |
67 if (a) | |
68 { | |
69 statement = new CompoundStatement(loc, a); | |
70 } | |
71 | |
72 statement = statement.semantic(sc); | |
73 if (statement) | |
74 { | |
75 Statement sentry; | |
76 Statement sexception; | |
77 Statement sfinally; | |
78 | |
79 statement.scopeCode(sc, &sentry, &sexception, &sfinally); | |
80 if (sfinally) | |
81 { | |
82 //printf("adding sfinally\n"); | |
83 statement = new CompoundStatement(loc, statement, sfinally); | |
84 } | |
85 } | |
86 | |
87 sc.pop(); | |
88 } | |
89 return this; | |
90 } | |
91 | |
72 | 92 override bool hasBreak() |
0 | 93 { |
94 //printf("ScopeStatement.hasBreak() %s\n", toChars()); | |
95 return statement ? statement.hasBreak() : false; | |
96 } | |
97 | |
72 | 98 override bool hasContinue() |
0 | 99 { |
100 return statement ? statement.hasContinue() : false; | |
101 } | |
102 | |
72 | 103 override bool usesEH() |
0 | 104 { |
105 return statement ? statement.usesEH() : false; | |
106 } | |
107 | |
72 | 108 override BE blockExit() |
0 | 109 { |
110 //printf("ScopeStatement::blockExit(%p)\n", statement); | |
111 return statement ? statement.blockExit() : BE.BEfallthru; | |
112 } | |
113 | |
72 | 114 override bool comeFrom() |
0 | 115 { |
116 //printf("ScopeStatement.comeFrom()\n"); | |
117 return statement ? statement.comeFrom() : false; | |
118 } | |
119 | |
72 | 120 override bool isEmpty() |
0 | 121 { |
122 //printf("ScopeStatement::isEmpty() %d\n", statement ? statement->isEmpty() : TRUE); | |
123 return statement ? statement.isEmpty() : true; | |
124 } | |
125 | |
72 | 126 override Expression interpret(InterState istate) |
0 | 127 { |
154
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
128 version(LOG) |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
129 writef("ScopeStatement::interpret()\n"); |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
130 |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
131 if (istate.start is this) |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
132 istate.start = null; |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
133 return statement ? statement.interpret(istate) : null; |
0 | 134 } |
135 | |
72 | 136 override Statement inlineScan(InlineScanState* iss) |
0 | 137 { |
138 if (statement) | |
139 statement = statement.inlineScan(iss); | |
140 return this; | |
141 } | |
142 | |
72 | 143 override void toIR(IRState* irs) |
0 | 144 { |
145 if (statement) | |
146 { | |
147 Blockx* blx = irs.blx; | |
148 IRState mystate = IRState(irs,this); | |
149 | |
150 if (mystate.prev.ident) | |
151 mystate.ident = mystate.prev.ident; | |
152 | |
153 statement.toIR(&mystate); | |
154 | |
155 if (mystate.breakBlock) | |
156 block_goto(blx, BC.BCgoto, mystate.breakBlock); | |
157 } | |
158 } | |
72 | 159 } |