| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 @override | 96 @override |
| 97 visitLetMutable(LetMutable node) { | 97 visitLetMutable(LetMutable node) { |
| 98 markAsSeen(node.variable); | 98 markAsSeen(node.variable); |
| 99 processReference(node.value); | 99 processReference(node.value); |
| 100 doInScope([node.variable], node, () => visit(node.body)); | 100 doInScope([node.variable], node, () => visit(node.body)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 @override | 103 @override |
| 104 visitFunctionDefinition(FunctionDefinition node) { | 104 visitFunctionDefinition(FunctionDefinition node) { |
| 105 if (node.thisParameter != null) { | |
| 106 markAsSeen(node.thisParameter); | |
| 107 } | |
| 108 node.parameters.forEach(markAsSeen); | 105 node.parameters.forEach(markAsSeen); |
| 109 if (node.body != null) { | 106 if (node.body != null) { |
| 110 doInOptionalScope(node.thisParameter, node, | 107 doInScope(node.parameters, node, () => visit(node.body)); |
| 111 () => doInScope(node.parameters, node, () => visit(node.body))); | |
| 112 } | 108 } |
| 113 } | 109 } |
| 114 | 110 |
| 115 @override | 111 @override |
| 116 visitConstructorDefinition(ConstructorDefinition node) { | 112 visitConstructorDefinition(ConstructorDefinition node) { |
| 117 if (node.thisParameter != null) { | |
| 118 markAsSeen(node.thisParameter); | |
| 119 } | |
| 120 node.parameters.forEach(markAsSeen); | 113 node.parameters.forEach(markAsSeen); |
| 121 doInScope(node.parameters, node, () { | 114 doInScope(node.parameters, node, () { |
| 122 if (node.initializers != null) node.initializers.forEach(visit); | 115 if (node.initializers != null) node.initializers.forEach(visit); |
| 123 if (node.body != null) { | 116 if (node.body != null) visit(node.body); |
| 124 doInOptionalScope(node.thisParameter, node, () => visit(node.body)); | |
| 125 } | |
| 126 }); | 117 }); |
| 127 } | 118 } |
| 128 | 119 |
| 129 doInOptionalScope(Parameter parameter, Node node, action) { | |
| 130 return (parameter == null) | |
| 131 ? action() | |
| 132 : doInScope([parameter], node, action); | |
| 133 } | |
| 134 | |
| 135 @override | 120 @override |
| 136 visitDeclareFunction(DeclareFunction node) { | 121 visitDeclareFunction(DeclareFunction node) { |
| 137 markAsSeen(node.variable); | 122 markAsSeen(node.variable); |
| 138 doInScope([node.variable], node, () { | 123 doInScope([node.variable], node, () { |
| 139 visit(node.definition); | 124 visit(node.definition); |
| 140 visit(node.body); | 125 visit(node.body); |
| 141 }); | 126 }); |
| 142 } | 127 } |
| 143 | 128 |
| 144 @override | 129 @override |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void check(ExecutableDefinition node) { | 197 void check(ExecutableDefinition node) { |
| 213 topLevelNode = node; | 198 topLevelNode = node; |
| 214 visit(node); | 199 visit(node); |
| 215 | 200 |
| 216 // Check this last, so out-of-scope references are not classified as | 201 // Check this last, so out-of-scope references are not classified as |
| 217 // a broken reference chain. | 202 // a broken reference chain. |
| 218 seenDefinitions.forEach(checkReferenceChain); | 203 seenDefinitions.forEach(checkReferenceChain); |
| 219 } | 204 } |
| 220 | 205 |
| 221 } | 206 } |
| OLD | NEW |