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; |
(...skipping 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3330 UnnamedMixinApplicationElementX( | 3330 UnnamedMixinApplicationElementX( |
3331 String name, ClassElement subclass, int id, this.node) | 3331 String name, ClassElement subclass, int id, this.node) |
3332 : this.subclass = subclass, | 3332 : this.subclass = subclass, |
3333 super(name, subclass.compilationUnit, id); | 3333 super(name, subclass.compilationUnit, id); |
3334 | 3334 |
3335 bool get isUnnamedMixinApplication => true; | 3335 bool get isUnnamedMixinApplication => true; |
3336 | 3336 |
3337 bool get isAbstract => true; | 3337 bool get isAbstract => true; |
3338 } | 3338 } |
3339 | 3339 |
3340 class LabelDefinitionX implements LabelDefinition<Node> { | 3340 class LabelDefinitionX extends LabelDefinition<Node> { |
3341 final Label label; | 3341 final Label label; |
3342 final String labelName; | 3342 final String labelName; |
3343 final JumpTargetX target; | 3343 final JumpTargetX target; |
3344 bool isBreakTarget = false; | 3344 bool isBreakTarget = false; |
3345 bool isContinueTarget = false; | 3345 bool isContinueTarget = false; |
3346 | 3346 |
3347 LabelDefinitionX(Label label, String labelName, this.target) | 3347 LabelDefinitionX(Label label, String labelName, this.target) |
3348 : this.label = label, | 3348 : this.label = label, |
3349 this.labelName = labelName; | 3349 this.labelName = labelName; |
3350 | 3350 |
3351 // In case of a synthetic label, just use [labelName] for identifying the | 3351 // In case of a synthetic label, just use [labelName] for identifying the |
3352 // label. | 3352 // label. |
3353 String get name => label == null ? labelName : label.identifier.source; | 3353 String get name => label == null ? labelName : label.identifier.source; |
3354 | 3354 |
3355 void setBreakTarget() { | 3355 void setBreakTarget() { |
3356 isBreakTarget = true; | 3356 isBreakTarget = true; |
3357 target.isBreakTarget = true; | 3357 target.isBreakTarget = true; |
3358 } | 3358 } |
3359 | 3359 |
3360 void setContinueTarget() { | 3360 void setContinueTarget() { |
3361 isContinueTarget = true; | 3361 isContinueTarget = true; |
3362 target.isContinueTarget = true; | 3362 target.isContinueTarget = true; |
3363 } | 3363 } |
3364 | 3364 |
3365 bool get isTarget => isBreakTarget || isContinueTarget; | |
3366 | |
3367 String toString() => 'Label:${name}'; | 3365 String toString() => 'Label:${name}'; |
3368 } | 3366 } |
3369 | 3367 |
3370 class JumpTargetX implements JumpTarget<Node> { | 3368 class JumpTargetX extends JumpTarget<Node> { |
3371 final ExecutableElement executableContext; | 3369 final ExecutableElement executableContext; |
3372 final Node statement; | 3370 final Node statement; |
3373 final int nestingLevel; | 3371 final int nestingLevel; |
3374 List<LabelDefinition<Node>> labels = <LabelDefinition<Node>>[]; | 3372 List<LabelDefinition<Node>> labels = <LabelDefinition<Node>>[]; |
3375 bool isBreakTarget = false; | 3373 bool isBreakTarget = false; |
3376 bool isContinueTarget = false; | 3374 bool isContinueTarget = false; |
3377 | 3375 |
3378 final int hashCode = ElementX.newHashCode(); | 3376 final int hashCode = ElementX.newHashCode(); |
3379 | 3377 |
3380 JumpTargetX(this.statement, this.nestingLevel, this.executableContext); | 3378 JumpTargetX(this.statement, this.nestingLevel, this.executableContext); |
3381 | 3379 |
3382 @override | 3380 @override |
3383 MemberElement get memberContext => executableContext.memberContext; | 3381 MemberElement get memberContext => executableContext.memberContext; |
3384 | 3382 |
3385 String get name => "target"; | |
3386 | |
3387 bool get isTarget => isBreakTarget || isContinueTarget; | |
3388 | |
3389 LabelDefinition<Node> addLabel(Label label, String labelName, | 3383 LabelDefinition<Node> addLabel(Label label, String labelName, |
3390 {bool isBreakTarget: false}) { | 3384 {bool isBreakTarget: false}) { |
3391 LabelDefinitionX result = new LabelDefinitionX(label, labelName, this); | 3385 LabelDefinitionX result = new LabelDefinitionX(label, labelName, this); |
3392 labels.add(result); | 3386 labels.add(result); |
3393 if (isBreakTarget) { | 3387 if (isBreakTarget) { |
3394 result.setBreakTarget(); | 3388 result.setBreakTarget(); |
3395 } | 3389 } |
3396 return result; | 3390 return result; |
3397 } | 3391 } |
3398 | 3392 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3579 body = node.asFunctionExpression().body; | 3573 body = node.asFunctionExpression().body; |
3580 } | 3574 } |
3581 return new ParsedResolvedAst( | 3575 return new ParsedResolvedAst( |
3582 declaration, | 3576 declaration, |
3583 node, | 3577 node, |
3584 body, | 3578 body, |
3585 definingElement.treeElements, | 3579 definingElement.treeElements, |
3586 definingElement.compilationUnit.script.resourceUri); | 3580 definingElement.compilationUnit.script.resourceUri); |
3587 } | 3581 } |
3588 } | 3582 } |
OLD | NEW |