| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 visitJumpTargetBody(JumpTarget target) { | 80 visitJumpTargetBody(JumpTarget target) { |
| 81 Label label = target.label; | 81 Label label = target.label; |
| 82 if (label2declaration.containsKey(label)) { | 82 if (label2declaration.containsKey(label)) { |
| 83 error('Duplicate declaration of label $label'); | 83 error('Duplicate declaration of label $label'); |
| 84 } | 84 } |
| 85 label2declaration[label] = target; | 85 label2declaration[label] = target; |
| 86 labelUses[label] = 0; | 86 labelUses[label] = 0; |
| 87 visitStatement(target.body); | 87 visitStatement(target.body); |
| 88 label2declaration.remove(target); | 88 label2declaration.remove(label); |
| 89 | 89 |
| 90 if (labelUses[label] != label.useCount) { | 90 if (labelUses[label] != label.useCount) { |
| 91 error('Label $label has ${labelUses[label]} uses ' | 91 error('Label $label has ${labelUses[label]} uses ' |
| 92 'but its reference count is ${label.useCount}'); | 92 'but its reference count is ${label.useCount}'); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 visitLabeledStatement(LabeledStatement node) { | 96 visitLabeledStatement(LabeledStatement node) { |
| 97 visitJumpTargetBody(node); | 97 visitJumpTargetBody(node); |
| 98 visitStatement(node.next); | 98 visitStatement(node.next); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (reads != variable.readCount || writes != variable.writeCount) { | 157 if (reads != variable.readCount || writes != variable.writeCount) { |
| 158 error('Invalid reference count for $variable:\n' | 158 error('Invalid reference count for $variable:\n' |
| 159 '- Variable has $reads reads and $writes writes\n' | 159 '- Variable has $reads reads and $writes writes\n' |
| 160 '- Reference count is ${variable.readCount} reads and ' | 160 '- Reference count is ${variable.readCount} reads and ' |
| 161 '${variable.writeCount} writes'); | 161 '${variable.writeCount} writes'); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 } | 166 } |
| OLD | NEW |