OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
9 import '../common/resolution.dart' show Resolution, ParsingContext; | 9 import '../common/resolution.dart' show Resolution, ParsingContext; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
11 import '../constants/constant_constructors.dart'; | 11 import '../constants/constant_constructors.dart'; |
12 import '../constants/constructors.dart'; | 12 import '../constants/constructors.dart'; |
13 import '../constants/expressions.dart'; | 13 import '../constants/expressions.dart'; |
14 import '../diagnostics/messages.dart' show MessageTemplate; | 14 import '../diagnostics/messages.dart' show MessageTemplate; |
15 import '../ordered_typeset.dart' show OrderedTypeSet; | 15 import '../ordered_typeset.dart' show OrderedTypeSet; |
16 import '../resolution/class_members.dart' show ClassMemberMixin; | 16 import '../resolution/class_members.dart' show ClassMemberMixin; |
17 import '../resolution/resolution.dart' show AnalyzableElementX; | 17 import '../resolution/resolution.dart' show AnalyzableElementX; |
18 import '../resolution/scope.dart' | 18 import '../resolution/scope.dart' |
19 show ClassScope, LibraryScope, Scope, TypeDeclarationScope; | 19 show ClassScope, LibraryScope, Scope, TypeDeclarationScope; |
20 import '../resolution/tree_elements.dart' show TreeElements; | 20 import '../resolution/tree_elements.dart' show TreeElements; |
21 import '../resolution/typedefs.dart' show TypedefCyclicVisitor; | 21 import '../resolution/typedefs.dart' show TypedefCyclicVisitor; |
22 import '../script.dart'; | 22 import '../script.dart'; |
23 import 'package:front_end/src/fasta/scanner.dart' show ErrorToken, Token; | 23 import 'package:front_end/src/fasta/scanner.dart' show ErrorToken, Token; |
24 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; | 24 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; |
25 import '../tree/tree.dart'; | 25 import '../tree/tree.dart'; |
26 import '../util/util.dart'; | 26 import '../util/util.dart'; |
27 import 'common.dart'; | 27 import 'common.dart'; |
28 import 'elements.dart'; | 28 import 'elements.dart'; |
29 import 'entities.dart'; | 29 import 'entities.dart'; |
| 30 import 'jumps.dart'; |
30 import 'names.dart'; | 31 import 'names.dart'; |
31 import 'resolution_types.dart'; | 32 import 'resolution_types.dart'; |
32 import 'visitor.dart' show ElementVisitor; | 33 import 'visitor.dart' show ElementVisitor; |
33 | 34 |
34 /// Object that identifies a declaration site. | 35 /// Object that identifies a declaration site. |
35 /// | 36 /// |
36 /// For most elements, this is the element itself, but for variable declarations | 37 /// For most elements, this is the element itself, but for variable declarations |
37 /// where multi-declarations like `var a, b, c` are allowed, the declaration | 38 /// where multi-declarations like `var a, b, c` are allowed, the declaration |
38 /// site is a separate object. | 39 /// site is a separate object. |
39 // TODO(johnniwinther): Add [beginToken] and [endToken] getters. | 40 // TODO(johnniwinther): Add [beginToken] and [endToken] getters. |
(...skipping 3229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3269 UnnamedMixinApplicationElementX( | 3270 UnnamedMixinApplicationElementX( |
3270 String name, ClassElement subclass, int id, this.node) | 3271 String name, ClassElement subclass, int id, this.node) |
3271 : this.subclass = subclass, | 3272 : this.subclass = subclass, |
3272 super(name, subclass.compilationUnit, id); | 3273 super(name, subclass.compilationUnit, id); |
3273 | 3274 |
3274 bool get isUnnamedMixinApplication => true; | 3275 bool get isUnnamedMixinApplication => true; |
3275 | 3276 |
3276 bool get isAbstract => true; | 3277 bool get isAbstract => true; |
3277 } | 3278 } |
3278 | 3279 |
3279 class LabelDefinitionX implements LabelDefinition { | 3280 class LabelDefinitionX implements LabelDefinition<Node> { |
3280 final Label label; | 3281 final Label label; |
3281 final String labelName; | 3282 final String labelName; |
3282 final JumpTarget target; | 3283 final JumpTarget<Node> target; |
3283 bool isBreakTarget = false; | 3284 bool isBreakTarget = false; |
3284 bool isContinueTarget = false; | 3285 bool isContinueTarget = false; |
3285 | 3286 |
3286 LabelDefinitionX(Label label, String labelName, this.target) | 3287 LabelDefinitionX(Label label, String labelName, this.target) |
3287 : this.label = label, | 3288 : this.label = label, |
3288 this.labelName = labelName; | 3289 this.labelName = labelName; |
3289 | 3290 |
3290 // In case of a synthetic label, just use [labelName] for identifying the | 3291 // In case of a synthetic label, just use [labelName] for identifying the |
3291 // label. | 3292 // label. |
3292 String get name => label == null ? labelName : label.identifier.source; | 3293 String get name => label == null ? labelName : label.identifier.source; |
3293 | 3294 |
3294 void setBreakTarget() { | 3295 void setBreakTarget() { |
3295 isBreakTarget = true; | 3296 isBreakTarget = true; |
3296 target.isBreakTarget = true; | 3297 target.isBreakTarget = true; |
3297 } | 3298 } |
3298 | 3299 |
3299 void setContinueTarget() { | 3300 void setContinueTarget() { |
3300 isContinueTarget = true; | 3301 isContinueTarget = true; |
3301 target.isContinueTarget = true; | 3302 target.isContinueTarget = true; |
3302 } | 3303 } |
3303 | 3304 |
3304 bool get isTarget => isBreakTarget || isContinueTarget; | 3305 bool get isTarget => isBreakTarget || isContinueTarget; |
3305 | 3306 |
3306 String toString() => 'Label:${name}'; | 3307 String toString() => 'Label:${name}'; |
3307 } | 3308 } |
3308 | 3309 |
3309 class JumpTargetX implements JumpTarget { | 3310 class JumpTargetX implements JumpTarget<Node> { |
3310 final ExecutableElement executableContext; | 3311 final ExecutableElement executableContext; |
3311 final Node statement; | 3312 final Node statement; |
3312 final int nestingLevel; | 3313 final int nestingLevel; |
3313 List<LabelDefinition> labels = <LabelDefinition>[]; | 3314 List<LabelDefinition<Node>> labels = <LabelDefinition<Node>>[]; |
3314 bool isBreakTarget = false; | 3315 bool isBreakTarget = false; |
3315 bool isContinueTarget = false; | 3316 bool isContinueTarget = false; |
3316 | 3317 |
3317 final int hashCode = ElementX.newHashCode(); | 3318 final int hashCode = ElementX.newHashCode(); |
3318 | 3319 |
3319 JumpTargetX(this.statement, this.nestingLevel, this.executableContext); | 3320 JumpTargetX(this.statement, this.nestingLevel, this.executableContext); |
3320 | 3321 |
3321 @override | 3322 @override |
3322 MemberElement get memberContext => executableContext.memberContext; | 3323 MemberElement get memberContext => executableContext.memberContext; |
3323 | 3324 |
3324 String get name => "target"; | 3325 String get name => "target"; |
3325 | 3326 |
3326 bool get isTarget => isBreakTarget || isContinueTarget; | 3327 bool get isTarget => isBreakTarget || isContinueTarget; |
3327 | 3328 |
3328 LabelDefinition addLabel(Label label, String labelName) { | 3329 LabelDefinition<Node> addLabel(Label label, String labelName) { |
3329 LabelDefinition result = new LabelDefinitionX(label, labelName, this); | 3330 LabelDefinition<Node> result = new LabelDefinitionX(label, labelName, this); |
3330 labels.add(result); | 3331 labels.add(result); |
3331 return result; | 3332 return result; |
3332 } | 3333 } |
3333 | 3334 |
3334 bool get isSwitch => statement is SwitchStatement; | 3335 bool get isSwitch => statement is SwitchStatement; |
3335 | 3336 |
3336 String toString() => 'Target:$statement'; | 3337 String toString() => 'Target:$statement'; |
3337 } | 3338 } |
3338 | 3339 |
3339 class TypeVariableElementX extends ElementX | 3340 class TypeVariableElementX extends ElementX |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3514 body = node.asFunctionExpression().body; | 3515 body = node.asFunctionExpression().body; |
3515 } | 3516 } |
3516 return new ParsedResolvedAst( | 3517 return new ParsedResolvedAst( |
3517 declaration, | 3518 declaration, |
3518 node, | 3519 node, |
3519 body, | 3520 body, |
3520 definingElement.treeElements, | 3521 definingElement.treeElements, |
3521 definingElement.compilationUnit.script.resourceUri); | 3522 definingElement.compilationUnit.script.resourceUri); |
3522 } | 3523 } |
3523 } | 3524 } |
OLD | NEW |