OLD | NEW |
1 library tree_ir.integrity; | 1 library tree_ir.integrity; |
2 | 2 |
3 import 'tree_ir_nodes.dart'; | 3 import 'tree_ir_nodes.dart'; |
4 | 4 |
5 /// Performs integrity checks on the tree_ir. | 5 /// Performs integrity checks on the tree_ir. |
6 /// | 6 /// |
7 /// Should only be run for debugging purposes, not in production. | 7 /// Should only be run for debugging purposes, not in production. |
8 /// | 8 /// |
9 /// - Reference counts on must match the actual number of references. | 9 /// - Reference counts on must match the actual number of references. |
10 /// - Labels must be in scope when referenced. | 10 /// - Labels must be in scope when referenced. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 visitLabeledStatement(LabeledStatement node) { | 96 visitLabeledStatement(LabeledStatement node) { |
97 visitJumpTargetBody(node); | 97 visitJumpTargetBody(node); |
98 visitStatement(node.next); | 98 visitStatement(node.next); |
99 } | 99 } |
100 | 100 |
101 visitWhileTrue(WhileTrue node) { | 101 visitWhileTrue(WhileTrue node) { |
102 visitJumpTargetBody(node); | 102 visitJumpTargetBody(node); |
103 } | 103 } |
104 | 104 |
105 visitWhileCondition(WhileCondition node) { | 105 visitFor(For node) { |
106 visitExpression(node.condition); | 106 visitExpression(node.condition); |
107 visitJumpTargetBody(node); | 107 visitJumpTargetBody(node); |
| 108 node.updates.forEach(visitExpression); |
108 visitStatement(node.next); | 109 visitStatement(node.next); |
109 } | 110 } |
110 | 111 |
111 visitBreak(Break node) { | 112 visitBreak(Break node) { |
112 if (!label2declaration.containsKey(node.target)) { | 113 if (!label2declaration.containsKey(node.target)) { |
113 error('Break to label that is not in scope'); | 114 error('Break to label that is not in scope'); |
114 } | 115 } |
115 if (label2declaration[node.target] is! LabeledStatement) { | 116 if (label2declaration[node.target] is! LabeledStatement) { |
116 error('Break to non-labeled statement ${label2declaration[node.target]}'); | 117 error('Break to non-labeled statement ${label2declaration[node.target]}'); |
117 } | 118 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if (reads != variable.readCount || writes != variable.writeCount) { | 157 if (reads != variable.readCount || writes != variable.writeCount) { |
157 error('Invalid reference count for $variable:\n' | 158 error('Invalid reference count for $variable:\n' |
158 '- Variable has $reads reads and $writes writes\n' | 159 '- Variable has $reads reads and $writes writes\n' |
159 '- Reference count is ${variable.readCount} reads and ' | 160 '- Reference count is ${variable.readCount} reads and ' |
160 '${variable.writeCount} writes'); | 161 '${variable.writeCount} writes'); |
161 } | 162 } |
162 } | 163 } |
163 } | 164 } |
164 | 165 |
165 } | 166 } |
OLD | NEW |