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 visitFor(For node) { | 105 visitWhileCondition(WhileCondition node) { |
106 visitExpression(node.condition); | 106 visitExpression(node.condition); |
107 visitJumpTargetBody(node); | 107 visitJumpTargetBody(node); |
108 node.updates.forEach(visitExpression); | |
109 visitStatement(node.next); | 108 visitStatement(node.next); |
110 } | 109 } |
111 | 110 |
112 visitBreak(Break node) { | 111 visitBreak(Break node) { |
113 if (!label2declaration.containsKey(node.target)) { | 112 if (!label2declaration.containsKey(node.target)) { |
114 error('Break to label that is not in scope'); | 113 error('Break to label that is not in scope'); |
115 } | 114 } |
116 if (label2declaration[node.target] is! LabeledStatement) { | 115 if (label2declaration[node.target] is! LabeledStatement) { |
117 error('Break to non-labeled statement ${label2declaration[node.target]}'); | 116 error('Break to non-labeled statement ${label2declaration[node.target]}'); |
118 } | 117 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (reads != variable.readCount || writes != variable.writeCount) { | 156 if (reads != variable.readCount || writes != variable.writeCount) { |
158 error('Invalid reference count for $variable:\n' | 157 error('Invalid reference count for $variable:\n' |
159 '- Variable has $reads reads and $writes writes\n' | 158 '- Variable has $reads reads and $writes writes\n' |
160 '- Reference count is ${variable.readCount} reads and ' | 159 '- Reference count is ${variable.readCount} reads and ' |
161 '${variable.writeCount} writes'); | 160 '${variable.writeCount} writes'); |
162 } | 161 } |
163 } | 162 } |
164 } | 163 } |
165 | 164 |
166 } | 165 } |
OLD | NEW |