| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.variables; | 5 library dart2js.resolution.variables; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../compiler.dart' show | 8 import '../compiler.dart' show |
| 9 Compiler; | 9 Compiler; |
| 10 import '../elements/modelx.dart' show | 10 import '../elements/modelx.dart' show |
| 11 LocalVariableElementX, | 11 LocalVariableElementX, |
| 12 VariableList; | 12 VariableList; |
| 13 import '../tree/tree.dart'; | 13 import '../tree/tree.dart'; |
| 14 import '../universe/use.dart' show |
| 15 TypeUse; |
| 14 import '../util/util.dart' show | 16 import '../util/util.dart' show |
| 15 Link; | 17 Link; |
| 16 | 18 |
| 17 import 'members.dart' show | 19 import 'members.dart' show |
| 18 ResolverVisitor; | 20 ResolverVisitor; |
| 19 import 'registry.dart' show | 21 import 'registry.dart' show |
| 20 ResolutionRegistry; | 22 ResolutionRegistry; |
| 21 import 'resolution_common.dart' show | 23 import 'resolution_common.dart' show |
| 22 CommonResolverVisitor; | 24 CommonResolverVisitor; |
| 23 import 'scope.dart' show | 25 import 'scope.dart' show |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 if (scope.variableReferencedInInitializer) { | 49 if (scope.variableReferencedInInitializer) { |
| 48 reporter.reportErrorMessage( | 50 reporter.reportErrorMessage( |
| 49 identifier, MessageKind.REFERENCE_IN_INITIALIZATION, | 51 identifier, MessageKind.REFERENCE_IN_INITIALIZATION, |
| 50 {'variableName': name}); | 52 {'variableName': name}); |
| 51 } | 53 } |
| 52 return identifier; | 54 return identifier; |
| 53 } | 55 } |
| 54 | 56 |
| 55 Identifier visitIdentifier(Identifier node) { | 57 Identifier visitIdentifier(Identifier node) { |
| 56 // The variable is initialized to null. | 58 // The variable is initialized to null. |
| 57 registry.registerInstantiatedType(compiler.coreTypes.nullType); | 59 // TODO(johnniwinther): Register a feature instead. |
| 60 registry.registerTypeUse( |
| 61 new TypeUse.instantiation(compiler.coreTypes.nullType)); |
| 58 if (definitions.modifiers.isConst) { | 62 if (definitions.modifiers.isConst) { |
| 59 reporter.reportErrorMessage( | 63 reporter.reportErrorMessage( |
| 60 node, MessageKind.CONST_WITHOUT_INITIALIZER); | 64 node, MessageKind.CONST_WITHOUT_INITIALIZER); |
| 61 } | 65 } |
| 62 if (definitions.modifiers.isFinal && | 66 if (definitions.modifiers.isFinal && |
| 63 !resolver.allowFinalWithoutInitializer) { | 67 !resolver.allowFinalWithoutInitializer) { |
| 64 reporter.reportErrorMessage( | 68 reporter.reportErrorMessage( |
| 65 node, MessageKind.FINAL_WITHOUT_INITIALIZER); | 69 node, MessageKind.FINAL_WITHOUT_INITIALIZER); |
| 66 } | 70 } |
| 67 return node; | 71 return node; |
| 68 } | 72 } |
| 69 | 73 |
| 70 visitNodeList(NodeList node) { | 74 visitNodeList(NodeList node) { |
| 71 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { | 75 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { |
| 72 Identifier name = visit(link.head); | 76 Identifier name = visit(link.head); |
| 73 LocalVariableElementX element = new LocalVariableElementX( | 77 LocalVariableElementX element = new LocalVariableElementX( |
| 74 name.source, resolver.enclosingElement, | 78 name.source, resolver.enclosingElement, |
| 75 variables, name.token); | 79 variables, name.token); |
| 76 resolver.defineLocalVariable(link.head, element); | 80 resolver.defineLocalVariable(link.head, element); |
| 77 resolver.addToScope(element); | 81 resolver.addToScope(element); |
| 78 if (definitions.modifiers.isConst) { | 82 if (definitions.modifiers.isConst) { |
| 79 compiler.enqueuer.resolution.addDeferredAction(element, () { | 83 compiler.enqueuer.resolution.addDeferredAction(element, () { |
| 80 element.constant = | 84 element.constant = |
| 81 compiler.resolver.constantCompiler.compileConstant(element); | 85 compiler.resolver.constantCompiler.compileConstant(element); |
| 82 }); | 86 }); |
| 83 } | 87 } |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 } | 90 } |
| OLD | NEW |