2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module gaem
.anal
.withloop
is aliced
;
20 import gaem
.anal
.utils
;
23 // ////////////////////////////////////////////////////////////////////////// //
24 void analWith (NodeFunc fn
) {
27 if (nn
is null) return;
28 if (cast(NodeStatement
)nn
) {
31 (NodeBlock n
) { foreach (Node st
; n
.stats
) anal(st
); },
32 (NodeStatementEmpty n
) {},
33 (NodeStatementAss n
) { anal(n
.el
); anal(n
.er
); },
34 (NodeStatementExpr n
) { anal(n
.e
); },
35 (NodeReturn n
) { anal(n
.e
); },
38 if (auto blk
= cast(NodeBlock
)n
.ebody
) {
39 if (blk
.stats
.length
== 0) {
40 message(fn
, n
.loc
, ": ???");
41 } else if (blk
.stats
.length
== 1) {
42 if (cast(NodeStatementExpr
)blk
.stats
[0] ||
cast(NodeReturn
)blk
.stats
[0]) {
43 message(fn
, n
.loc
, ": possible excessive '{}' in 'with'");
46 if (cast(NodeStatementEmpty
)blk
.stats
[0]) {
47 message(fn
, n
.loc
, ": empty statement in empty block in 'with'");
50 if (cast(NodeStatementBreak
)blk
.stats
[0]) {
51 message(fn
, n
.loc
, ": single 'break' in 'with', noop");
54 if (cast(NodeStatementContinue
)blk
.stats
[0]) {
55 message(fn
, n
.loc
, ": single 'continue' in 'with', noop");
62 (NodeIf n
) { anal(n
.ec
); anal(n
.et
); anal(n
.ef
); },
63 (NodeStatementBreak n
) {},
64 (NodeStatementContinue n
) {},
65 (NodeFor n
) { anal(n
.einit
); anal(n
.econd
); anal(n
.enext
); anal(n
.ebody
); },
66 (NodeWhile n
) { anal(n
.econd
); anal(n
.ebody
); },
67 (NodeDoUntil n
) { anal(n
.econd
); anal(n
.ebody
); },
68 (NodeRepeat n
) { anal(n
.ecount
); anal(n
.ebody
); },
71 foreach (ref ci
; n
.cases
) { anal(ci
.e
); anal(ci
.st
); }
73 () { assert(0, "unimplemented node: "~typeid(nn
).name
); },
78 (NodeUnary n
) { anal(n
.e
); },
79 (NodeStatementAss n
) { anal(n
.el
); anal(n
.er
); },
80 (NodeBinary n
) { anal(n
.el
); anal(n
.er
); },
83 foreach (immutable idx
, Node a
; n
.args
) anal(a
);
86 (NodeDot n
) { anal(n
.e
); },
92 (NodeFunc n
) { anal(n
.ebody
); },
93 () { assert(0, "unimplemented node: "~typeid(nn
).name
); },