| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 visitContinue(Continue node) { | 122 visitContinue(Continue node) { |
| 123 if (!label2declaration.containsKey(node.target)) { | 123 if (!label2declaration.containsKey(node.target)) { |
| 124 error('Continue to label that is not in scope'); | 124 error('Continue to label that is not in scope'); |
| 125 } | 125 } |
| 126 if (label2declaration[node.target] is! Loop) { | 126 if (label2declaration[node.target] is! Loop) { |
| 127 error('Continue to non-loop statement ${label2declaration[node.target]}'); | 127 error('Continue to non-loop statement ${label2declaration[node.target]}'); |
| 128 } | 128 } |
| 129 labelUses[node.target]++; | 129 labelUses[node.target]++; |
| 130 } | 130 } |
| 131 | 131 |
| 132 visitInnerFunction(FunctionDefinition node) { | |
| 133 checkBody(node); | |
| 134 } | |
| 135 | |
| 136 void checkBody(FunctionDefinition node) { | 132 void checkBody(FunctionDefinition node) { |
| 137 node.parameters.forEach(declare); | 133 node.parameters.forEach(declare); |
| 138 visitStatement(node.body); | 134 visitStatement(node.body); |
| 139 node.parameters.forEach(undeclare); | 135 node.parameters.forEach(undeclare); |
| 140 } | 136 } |
| 141 | 137 |
| 142 dynamic error(String message) { | 138 dynamic error(String message) { |
| 143 throw 'Tree IR integrity violation in ${topLevelNode.element}:\n$message'; | 139 throw 'Tree IR integrity violation in ${topLevelNode.element}:\n$message'; |
| 144 } | 140 } |
| 145 | 141 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 157 if (reads != variable.readCount || writes != variable.writeCount) { | 153 if (reads != variable.readCount || writes != variable.writeCount) { |
| 158 error('Invalid reference count for $variable:\n' | 154 error('Invalid reference count for $variable:\n' |
| 159 '- Variable has $reads reads and $writes writes\n' | 155 '- Variable has $reads reads and $writes writes\n' |
| 160 '- Reference count is ${variable.readCount} reads and ' | 156 '- Reference count is ${variable.readCount} reads and ' |
| 161 '${variable.writeCount} writes'); | 157 '${variable.writeCount} writes'); |
| 162 } | 158 } |
| 163 } | 159 } |
| 164 } | 160 } |
| 165 | 161 |
| 166 } | 162 } |
| OLD | NEW |