| 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 import 'common/names.dart' show Identifiers; | 5 import 'common/names.dart' show Identifiers; |
| 6 import 'common/resolution.dart' show ParsingContext, Resolution; | 6 import 'common/resolution.dart' show ParsingContext, Resolution; |
| 7 import 'common/tasks.dart' show CompilerTask, Measurer; | 7 import 'common/tasks.dart' show CompilerTask, Measurer; |
| 8 import 'common.dart'; | 8 import 'common.dart'; |
| 9 import 'compiler.dart' show Compiler; | 9 import 'compiler.dart' show Compiler; |
| 10 import 'constants/expressions.dart'; | 10 import 'constants/expressions.dart'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 /// Class that provides information for how closures are rewritten/represented | 35 /// Class that provides information for how closures are rewritten/represented |
| 36 /// to preserve Dart semantics when compiled to JavaScript. Given a particular | 36 /// to preserve Dart semantics when compiled to JavaScript. Given a particular |
| 37 /// node to look up, it returns a information about the internal representation | 37 /// node to look up, it returns a information about the internal representation |
| 38 /// of how closure conversion is implemented. T is an ir.Node or Node. | 38 /// of how closure conversion is implemented. T is an ir.Node or Node. |
| 39 abstract class ClosureDataLookup<T> { | 39 abstract class ClosureDataLookup<T> { |
| 40 /// Look up information about the variables that have been mutated and are | 40 /// Look up information about the variables that have been mutated and are |
| 41 /// used inside the scope of [node]. | 41 /// used inside the scope of [node]. |
| 42 // TODO(johnniwinther): Split this up into two functions, one for members and | 42 // TODO(johnniwinther): Split this up into two functions, one for members and |
| 43 // one for local functions. | 43 // one for local functions. |
| 44 ClosureRepresentationInfo getClosureRepresentationInfo(Entity member); | 44 ClosureRepresentationInfo getClosureRepresentationInfo( |
| 45 covariant Entity member); |
| 45 | 46 |
| 46 /// Look up information about a loop, in case any variables it declares need | 47 /// Look up information about a loop, in case any variables it declares need |
| 47 /// to be boxed/snapshotted. | 48 /// to be boxed/snapshotted. |
| 48 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop(T loopNode); | 49 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop(T loopNode); |
| 49 | 50 |
| 50 /// Accessor to the information about closures that the SSA builder will use. | 51 /// Accessor to the information about closures that the SSA builder will use. |
| 51 ClosureAnalysisInfo getClosureAnalysisInfo(T node); | 52 ClosureAnalysisInfo getClosureAnalysisInfo(T node); |
| 52 } | 53 } |
| 53 | 54 |
| 54 /// Class that provides a black-box interface to information gleaned from | 55 /// Class that provides a black-box interface to information gleaned from |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 MemberElement get memberContext => closureClass.methodElement.memberContext; | 346 MemberElement get memberContext => closureClass.methodElement.memberContext; |
| 346 | 347 |
| 347 @override | 348 @override |
| 348 Local get declaredEntity => local; | 349 Local get declaredEntity => local; |
| 349 | 350 |
| 350 @override | 351 @override |
| 351 Entity get rootOfScope => closureClass; | 352 Entity get rootOfScope => closureClass; |
| 352 | 353 |
| 353 bool get hasNode => false; | 354 bool get hasNode => false; |
| 354 | 355 |
| 355 Node get node { | 356 VariableDefinitions get node { |
| 356 throw new SpannableAssertionFailure( | 357 throw new SpannableAssertionFailure( |
| 357 local, 'Should not access node of ClosureFieldElement.'); | 358 local, 'Should not access node of ClosureFieldElement.'); |
| 358 } | 359 } |
| 359 | 360 |
| 360 bool get hasResolvedAst => hasTreeElements; | 361 bool get hasResolvedAst => hasTreeElements; |
| 361 | 362 |
| 362 ResolvedAst get resolvedAst { | 363 ResolvedAst get resolvedAst { |
| 363 return new ParsedResolvedAst(this, null, null, treeElements, | 364 return new ParsedResolvedAst(this, null, null, treeElements, |
| 364 memberContext.compilationUnit.script.resourceUri); | 365 memberContext.compilationUnit.script.resourceUri); |
| 365 } | 366 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 381 } | 382 } |
| 382 return const ResolutionDynamicType(); | 383 return const ResolutionDynamicType(); |
| 383 } | 384 } |
| 384 | 385 |
| 385 String toString() => "ClosureFieldElement($name)"; | 386 String toString() => "ClosureFieldElement($name)"; |
| 386 | 387 |
| 387 accept(ElementVisitor visitor, arg) { | 388 accept(ElementVisitor visitor, arg) { |
| 388 return visitor.visitClosureFieldElement(this, arg); | 389 return visitor.visitClosureFieldElement(this, arg); |
| 389 } | 390 } |
| 390 | 391 |
| 391 Element get analyzableElement => closureClass.methodElement.analyzableElement; | 392 AnalyzableElement get analyzableElement => |
| 393 closureClass.methodElement.analyzableElement; |
| 392 | 394 |
| 393 @override | 395 @override |
| 394 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; | 396 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; |
| 395 | 397 |
| 396 @override | 398 @override |
| 397 bool get hasConstant => false; | 399 bool get hasConstant => false; |
| 398 | 400 |
| 399 @override | 401 @override |
| 400 ConstantExpression get constant => null; | 402 ConstantExpression get constant => null; |
| 401 } | 403 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 throw new UnsupportedError("BoxFieldElement.initializer"); | 522 throw new UnsupportedError("BoxFieldElement.initializer"); |
| 521 } | 523 } |
| 522 | 524 |
| 523 @override | 525 @override |
| 524 MemberElement get memberContext => box.executableContext.memberContext; | 526 MemberElement get memberContext => box.executableContext.memberContext; |
| 525 | 527 |
| 526 @override | 528 @override |
| 527 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; | 529 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; |
| 528 | 530 |
| 529 @override | 531 @override |
| 530 Node get node { | 532 VariableDefinitions get node { |
| 531 throw new UnsupportedError("BoxFieldElement.node"); | 533 throw new UnsupportedError("BoxFieldElement.node"); |
| 532 } | 534 } |
| 533 | 535 |
| 534 @override | 536 @override |
| 535 ResolvedAst get resolvedAst { | 537 ResolvedAst get resolvedAst { |
| 536 throw new UnsupportedError("BoxFieldElement.resolvedAst"); | 538 throw new UnsupportedError("BoxFieldElement.resolvedAst"); |
| 537 } | 539 } |
| 538 | 540 |
| 539 @override | 541 @override |
| 540 bool get hasConstant => false; | 542 bool get hasConstant => false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 551 ThisLocal(this.memberContext); | 553 ThisLocal(this.memberContext); |
| 552 | 554 |
| 553 Entity get executableContext => memberContext; | 555 Entity get executableContext => memberContext; |
| 554 | 556 |
| 555 String get name => 'this'; | 557 String get name => 'this'; |
| 556 | 558 |
| 557 ClassEntity get enclosingClass => memberContext.enclosingClass; | 559 ClassEntity get enclosingClass => memberContext.enclosingClass; |
| 558 } | 560 } |
| 559 | 561 |
| 560 /// Call method of a closure class. | 562 /// Call method of a closure class. |
| 563 // ignore: STRONG_MODE_INVALID_METHOD_OVERRIDE_FROM_BASE |
| 561 class SynthesizedCallMethodElementX extends BaseFunctionElementX | 564 class SynthesizedCallMethodElementX extends BaseFunctionElementX |
| 562 implements MethodElement { | 565 implements MethodElement { |
| 563 final LocalFunctionElement expression; | 566 final LocalFunctionElement expression; |
| 564 final FunctionExpression node; | 567 final FunctionExpression node; |
| 565 final TreeElements treeElements; | 568 final TreeElements treeElements; |
| 566 | 569 |
| 567 SynthesizedCallMethodElementX(String name, LocalFunctionElement other, | 570 SynthesizedCallMethodElementX(String name, LocalFunctionElement other, |
| 568 ClosureClassElement enclosing, this.node, this.treeElements) | 571 ClosureClassElement enclosing, this.node, this.treeElements) |
| 569 : expression = other, | 572 : expression = other, |
| 570 super(name, other.kind, Modifiers.EMPTY, enclosing) { | 573 super(name, other.kind, Modifiers.EMPTY, enclosing) { |
| 571 asyncMarker = other.asyncMarker; | 574 asyncMarker = other.asyncMarker; |
| 572 functionSignature = other.functionSignature; | 575 functionSignature = other.functionSignature; |
| 573 } | 576 } |
| 574 | 577 |
| 575 /// Use [closureClass] instead. | 578 /// Use [closureClass] instead. |
| 576 @deprecated | 579 @deprecated |
| 577 get enclosingElement => super.enclosingElement; | 580 get enclosingElement => super.enclosingElement; |
| 578 | 581 |
| 579 ClosureClassElement get closureClass => super.enclosingElement; | 582 ClosureClassElement get closureClass => super.enclosingElement; |
| 580 | 583 |
| 581 MemberElement get memberContext { | 584 MemberElement get memberContext { |
| 582 return closureClass.methodElement.memberContext; | 585 return closureClass.methodElement.memberContext; |
| 583 } | 586 } |
| 584 | 587 |
| 585 bool get hasNode => node != null; | 588 bool get hasNode => node != null; |
| 586 | 589 |
| 587 FunctionExpression parseNode(ParsingContext parsing) => node; | 590 FunctionExpression parseNode(ParsingContext parsing) => node; |
| 588 | 591 |
| 589 Element get analyzableElement => closureClass.methodElement.analyzableElement; | 592 AnalyzableElement get analyzableElement => |
| 593 closureClass.methodElement.analyzableElement; |
| 590 | 594 |
| 591 bool get hasResolvedAst => true; | 595 bool get hasResolvedAst => true; |
| 592 | 596 |
| 593 ResolvedAst get resolvedAst { | 597 ResolvedAst get resolvedAst { |
| 594 return new ParsedResolvedAst(this, node, node.body, treeElements, | 598 return new ParsedResolvedAst(this, node, node.body, treeElements, |
| 595 expression.compilationUnit.script.resourceUri); | 599 expression.compilationUnit.script.resourceUri); |
| 596 } | 600 } |
| 597 | 601 |
| 598 accept(ElementVisitor visitor, arg) { | 602 accept(ElementVisitor visitor, arg) { |
| 599 return visitor.visitMethodElement(this, arg); | 603 return visitor.visitMethodElement(this, arg); |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 /// | 1466 /// |
| 1463 /// Move the below classes to a JS model eventually. | 1467 /// Move the below classes to a JS model eventually. |
| 1464 /// | 1468 /// |
| 1465 abstract class JSEntity implements MemberEntity { | 1469 abstract class JSEntity implements MemberEntity { |
| 1466 Local get declaredEntity; | 1470 Local get declaredEntity; |
| 1467 } | 1471 } |
| 1468 | 1472 |
| 1469 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1473 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1470 Entity get rootOfScope; | 1474 Entity get rootOfScope; |
| 1471 } | 1475 } |
| OLD | NEW |