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.members; | 5 library dart2js.resolution.members; |
6 | 6 |
7 import 'package:front_end/src/fasta/scanner.dart' show isUserDefinableOperator; | 7 import 'package:front_end/src/fasta/scanner.dart' show isUserDefinableOperator; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/names.dart' show Selectors; | 10 import '../common/names.dart' show Selectors; |
11 import '../common/resolution.dart' show Resolution; | 11 import '../common/resolution.dart' show Resolution; |
12 import '../compile_time_constants.dart'; | 12 import '../compile_time_constants.dart'; |
13 import '../constants/constructors.dart' | 13 import '../constants/constructors.dart' |
14 show RedirectingFactoryConstantConstructor; | 14 show RedirectingFactoryConstantConstructor; |
15 import '../constants/expressions.dart'; | 15 import '../constants/expressions.dart'; |
16 import '../constants/values.dart'; | 16 import '../constants/values.dart'; |
17 import '../common_elements.dart'; | 17 import '../common_elements.dart'; |
18 import '../elements/elements.dart'; | 18 import '../elements/elements.dart'; |
19 import '../elements/entities.dart' show AsyncMarker; | 19 import '../elements/entities.dart' show AsyncMarker; |
20 import '../elements/modelx.dart' | 20 import '../elements/modelx.dart' |
21 show | 21 show |
22 ConstructorElementX, | 22 ConstructorElementX, |
23 ErroneousElementX, | 23 ErroneousElementX, |
24 FunctionElementX, | 24 FunctionElementX, |
25 JumpTargetX, | 25 JumpTargetX, |
| 26 LabelDefinitionX, |
26 LocalFunctionElementX, | 27 LocalFunctionElementX, |
27 LocalParameterElementX, | 28 LocalParameterElementX, |
28 ParameterElementX, | 29 ParameterElementX, |
29 VariableElementX, | 30 VariableElementX, |
30 VariableList; | 31 VariableList; |
31 import '../elements/jumps.dart'; | 32 import '../elements/jumps.dart'; |
32 import '../elements/names.dart'; | 33 import '../elements/names.dart'; |
33 import '../elements/operators.dart'; | 34 import '../elements/operators.dart'; |
34 import '../elements/resolution_types.dart'; | 35 import '../elements/resolution_types.dart'; |
35 import '../options.dart'; | 36 import '../options.dart'; |
(...skipping 4210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4246 | 4247 |
4247 if (isValidAsConstant) { | 4248 if (isValidAsConstant) { |
4248 ConstantExpression constant = new ConcatenateConstantExpression(parts); | 4249 ConstantExpression constant = new ConcatenateConstantExpression(parts); |
4249 registry.setConstant(node, constant); | 4250 registry.setConstant(node, constant); |
4250 return new ConstantResult(node, constant); | 4251 return new ConstantResult(node, constant); |
4251 } | 4252 } |
4252 return const NoneResult(); | 4253 return const NoneResult(); |
4253 } | 4254 } |
4254 | 4255 |
4255 ResolutionResult visitBreakStatement(BreakStatement node) { | 4256 ResolutionResult visitBreakStatement(BreakStatement node) { |
4256 JumpTarget target; | 4257 JumpTargetX target; |
4257 if (node.target == null) { | 4258 if (node.target == null) { |
4258 target = statementScope.currentBreakTarget(); | 4259 target = statementScope.currentBreakTarget(); |
4259 if (target == null) { | 4260 if (target == null) { |
4260 reporter.reportErrorMessage(node, MessageKind.NO_BREAK_TARGET); | 4261 reporter.reportErrorMessage(node, MessageKind.NO_BREAK_TARGET); |
4261 return const NoneResult(); | 4262 return const NoneResult(); |
4262 } | 4263 } |
4263 target.isBreakTarget = true; | 4264 target.isBreakTarget = true; |
4264 } else { | 4265 } else { |
4265 String labelName = node.target.source; | 4266 String labelName = node.target.source; |
4266 LabelDefinition label = statementScope.lookupLabel(labelName); | 4267 LabelDefinitionX label = statementScope.lookupLabel(labelName); |
4267 if (label == null) { | 4268 if (label == null) { |
4268 reporter.reportErrorMessage( | 4269 reporter.reportErrorMessage( |
4269 node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); | 4270 node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); |
4270 return const NoneResult(); | 4271 return const NoneResult(); |
4271 } | 4272 } |
4272 target = label.target; | 4273 target = label.target; |
4273 if (!target.statement.isValidBreakTarget()) { | 4274 if (!target.statement.isValidBreakTarget()) { |
4274 reporter.reportErrorMessage(node.target, MessageKind.INVALID_BREAK); | 4275 reporter.reportErrorMessage(node.target, MessageKind.INVALID_BREAK); |
4275 return const NoneResult(); | 4276 return const NoneResult(); |
4276 } | 4277 } |
4277 label.setBreakTarget(); | 4278 label.setBreakTarget(); |
4278 registry.useLabel(node, label); | 4279 registry.useLabel(node, label); |
4279 } | 4280 } |
4280 registry.registerTargetOf(node, target); | 4281 registry.registerTargetOf(node, target); |
4281 return const NoneResult(); | 4282 return const NoneResult(); |
4282 } | 4283 } |
4283 | 4284 |
4284 ResolutionResult visitContinueStatement(ContinueStatement node) { | 4285 ResolutionResult visitContinueStatement(ContinueStatement node) { |
4285 JumpTarget target; | 4286 JumpTargetX target; |
4286 if (node.target == null) { | 4287 if (node.target == null) { |
4287 target = statementScope.currentContinueTarget(); | 4288 target = statementScope.currentContinueTarget(); |
4288 if (target == null) { | 4289 if (target == null) { |
4289 reporter.reportErrorMessage(node, MessageKind.NO_CONTINUE_TARGET); | 4290 reporter.reportErrorMessage(node, MessageKind.NO_CONTINUE_TARGET); |
4290 return const NoneResult(); | 4291 return const NoneResult(); |
4291 } | 4292 } |
4292 target.isContinueTarget = true; | 4293 target.isContinueTarget = true; |
4293 } else { | 4294 } else { |
4294 String labelName = node.target.source; | 4295 String labelName = node.target.source; |
4295 LabelDefinition label = statementScope.lookupLabel(labelName); | 4296 LabelDefinitionX label = statementScope.lookupLabel(labelName); |
4296 if (label == null) { | 4297 if (label == null) { |
4297 reporter.reportErrorMessage( | 4298 reporter.reportErrorMessage( |
4298 node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); | 4299 node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); |
4299 return const NoneResult(); | 4300 return const NoneResult(); |
4300 } | 4301 } |
4301 target = label.target; | 4302 target = label.target; |
4302 if (!target.statement.isValidContinueTarget()) { | 4303 if (!target.statement.isValidContinueTarget()) { |
4303 reporter.reportErrorMessage(node.target, MessageKind.INVALID_CONTINUE); | 4304 reporter.reportErrorMessage(node.target, MessageKind.INVALID_CONTINUE); |
4304 } | 4305 } |
4305 label.setContinueTarget(); | 4306 label.setContinueTarget(); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4817 } | 4818 } |
4818 return const NoneResult(); | 4819 return const NoneResult(); |
4819 } | 4820 } |
4820 } | 4821 } |
4821 | 4822 |
4822 /// Looks up [name] in [scope] and unwraps the result. | 4823 /// Looks up [name] in [scope] and unwraps the result. |
4823 Element lookupInScope( | 4824 Element lookupInScope( |
4824 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4825 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
4825 return Elements.unwrap(scope.lookup(name), reporter, node); | 4826 return Elements.unwrap(scope.lookup(name), reporter, node); |
4826 } | 4827 } |
OLD | NEW |