OLD | NEW |
1 library dart2js.cps_ir_integrity; | 1 library dart2js.cps_ir_integrity; |
2 | 2 |
3 import 'cps_ir_nodes.dart'; | 3 import 'cps_ir_nodes.dart'; |
4 import 'cps_ir_nodes_sexpr.dart'; | 4 import 'cps_ir_nodes_sexpr.dart'; |
5 import '../tracer.dart' as tracer; | 5 import '../tracer.dart' as tracer; |
6 | 6 |
7 /// Dump S-expressions on error if the tracer is enabled. | 7 /// Dump S-expressions on error if the tracer is enabled. |
8 /// | 8 /// |
9 /// Technically this has nothing to do with the tracer, but if you want one | 9 /// Technically this has nothing to do with the tracer, but if you want one |
10 /// enabled, you typically want the other as well, so we use the same flag. | 10 /// enabled, you typically want the other as well, so we use the same flag. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Decorator decorator = (n, String s) => n == node ? '**$s**' : s; | 198 Decorator decorator = (n, String s) => n == node ? '**$s**' : s; |
199 sexpr = new SExpressionStringifier(decorator).visit(topLevelNode); | 199 sexpr = new SExpressionStringifier(decorator).visit(topLevelNode); |
200 sexpr = 'SExpr dump (offending node marked with **):\n\n$sexpr'; | 200 sexpr = 'SExpr dump (offending node marked with **):\n\n$sexpr'; |
201 } catch (e) { | 201 } catch (e) { |
202 sexpr = '(Exception thrown by SExpressionStringifier: $e)'; | 202 sexpr = '(Exception thrown by SExpressionStringifier: $e)'; |
203 } | 203 } |
204 } else { | 204 } else { |
205 sexpr = '(Set DUMP_IR flag to enable SExpr dump)'; | 205 sexpr = '(Set DUMP_IR flag to enable SExpr dump)'; |
206 } | 206 } |
207 throw 'CPS integrity violation\n' | 207 throw 'CPS integrity violation\n' |
208 'After $previousPass on ${topLevelNode.element}\n' | 208 'After \'$previousPass\' on ${topLevelNode.element}\n' |
209 '$message\n\n' | 209 '$message\n\n' |
210 '$sexpr\n'; | 210 '$sexpr\n'; |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 /// Traverses the CPS term and checks that node.parent is correctly set | 214 /// Traverses the CPS term and checks that node.parent is correctly set |
215 /// for each visited node. | 215 /// for each visited node. |
216 class ParentChecker extends DeepRecursiveVisitor { | 216 class ParentChecker extends DeepRecursiveVisitor { |
217 static void checkParents(Node node, CheckCpsIntegrity main) { | 217 static void checkParents(Node node, CheckCpsIntegrity main) { |
218 ParentChecker visitor = new ParentChecker._make(main); | 218 ParentChecker visitor = new ParentChecker._make(main); |
(...skipping 26 matching lines...) Expand all Loading... |
245 } | 245 } |
246 | 246 |
247 @override | 247 @override |
248 processReference(Reference node) { | 248 processReference(Reference node) { |
249 if (node.parent != _parent) { | 249 if (node.parent != _parent) { |
250 error('Parent pointer on $node is ${node.parent} but should be $_parent', | 250 error('Parent pointer on $node is ${node.parent} but should be $_parent', |
251 node); | 251 node); |
252 } | 252 } |
253 } | 253 } |
254 } | 254 } |
OLD | NEW |