Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.resolution; | 5 library dart2js.resolution; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 import '../tree/tree.dart'; | 46 import '../tree/tree.dart'; |
| 47 import '../universe/call_structure.dart' show CallStructure; | 47 import '../universe/call_structure.dart' show CallStructure; |
| 48 import '../universe/use.dart' show StaticUse, TypeUse; | 48 import '../universe/use.dart' show StaticUse, TypeUse; |
| 49 import '../universe/world_impact.dart' show WorldImpact; | 49 import '../universe/world_impact.dart' show WorldImpact; |
| 50 import '../util/util.dart' show Link, Setlet; | 50 import '../util/util.dart' show Link, Setlet; |
| 51 import 'class_hierarchy.dart'; | 51 import 'class_hierarchy.dart'; |
| 52 import 'class_members.dart' show MembersCreator; | 52 import 'class_members.dart' show MembersCreator; |
| 53 import 'constructors.dart'; | 53 import 'constructors.dart'; |
| 54 import 'members.dart'; | 54 import 'members.dart'; |
| 55 import 'registry.dart'; | 55 import 'registry.dart'; |
| 56 import 'scope.dart' show MutableScope; | |
| 56 import 'signatures.dart'; | 57 import 'signatures.dart'; |
| 57 import 'tree_elements.dart'; | 58 import 'tree_elements.dart'; |
| 58 import 'typedefs.dart'; | 59 import 'typedefs.dart'; |
| 59 | 60 |
| 60 class ResolverTask extends CompilerTask { | 61 class ResolverTask extends CompilerTask { |
| 61 final ConstantCompiler constantCompiler; | 62 final ConstantCompiler constantCompiler; |
| 62 final Compiler compiler; | 63 final Compiler compiler; |
| 63 | 64 |
| 64 ResolverTask(Compiler compiler, this.constantCompiler) | 65 ResolverTask(Compiler compiler, this.constantCompiler) |
| 65 : compiler = compiler, | 66 : compiler = compiler, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 | 242 |
| 242 if (element.isGenerativeConstructor) { | 243 if (element.isGenerativeConstructor) { |
| 243 // Even if there is no initializer list we still have to do the | 244 // Even if there is no initializer list we still have to do the |
| 244 // resolution in case there is an implicit super constructor call. | 245 // resolution in case there is an implicit super constructor call. |
| 245 InitializerResolver resolver = | 246 InitializerResolver resolver = |
| 246 new InitializerResolver(visitor, element, tree); | 247 new InitializerResolver(visitor, element, tree); |
| 247 FunctionElement redirection = resolver.resolveInitializers(); | 248 FunctionElement redirection = resolver.resolveInitializers(); |
| 248 if (redirection != null) { | 249 if (redirection != null) { |
| 249 resolveRedirectingConstructor(resolver, tree, element, redirection); | 250 resolveRedirectingConstructor(resolver, tree, element, redirection); |
| 250 } | 251 } |
| 252 if (compiler.options.enableInitializingFormalAccess) { | |
|
Johnni Winther
2016/06/13 08:56:48
There is a better approach:
1. Create a subscope
eernst
2016/06/14 15:01:51
That sounds like a much better idea, but there are
| |
| 253 // Ensure that the initializing formal parameters will not be in scope | |
| 254 // when the body of the constructor is resolved. | |
| 255 // TODO(eernst): The following is a temporary solution. An acceptable | |
| 256 // solution requires some more thinking & refactoring: We don't | |
| 257 // otherwise delete from scopes, it introduces ordering dependencies, | |
| 258 // etc.etc.etc. | |
| 259 assert(visitor.scope is MutableScope); | |
| 260 MutableScope mutableScope = visitor.scope; | |
| 261 List<String> names = mutableScope.elements.keys.toList(); | |
| 262 for (String name in names) { | |
| 263 if (mutableScope.elements[name] is InitializingFormalElement) { | |
| 264 mutableScope.elements.remove(name); | |
| 265 } | |
| 266 } | |
| 267 } | |
| 251 } else if (tree.initializers != null) { | 268 } else if (tree.initializers != null) { |
| 252 reporter.reportErrorMessage( | 269 reporter.reportErrorMessage( |
| 253 tree, MessageKind.FUNCTION_WITH_INITIALIZER); | 270 tree, MessageKind.FUNCTION_WITH_INITIALIZER); |
| 254 } | 271 } |
| 255 | 272 |
| 256 if (!compiler.options.analyzeSignaturesOnly || | 273 if (!compiler.options.analyzeSignaturesOnly || |
| 257 tree.isRedirectingFactory) { | 274 tree.isRedirectingFactory) { |
| 258 // We need to analyze the redirecting factory bodies to ensure that | 275 // We need to analyze the redirecting factory bodies to ensure that |
| 259 // we can analyze compile-time constants. | 276 // we can analyze compile-time constants. |
| 260 visitor.visit(tree.body); | 277 visitor.visit(tree.body); |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1121 TreeElements get treeElements { | 1138 TreeElements get treeElements { |
| 1122 assert(invariant(this, _treeElements != null, | 1139 assert(invariant(this, _treeElements != null, |
| 1123 message: "TreeElements have not been computed for $this.")); | 1140 message: "TreeElements have not been computed for $this.")); |
| 1124 return _treeElements; | 1141 return _treeElements; |
| 1125 } | 1142 } |
| 1126 | 1143 |
| 1127 void reuseElement() { | 1144 void reuseElement() { |
| 1128 _treeElements = null; | 1145 _treeElements = null; |
| 1129 } | 1146 } |
| 1130 } | 1147 } |
| OLD | NEW |