| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/tasks.dart'; | 9 import '../common/tasks.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 /// A local variable to disambiguate between a variable that has been captured | 419 /// A local variable to disambiguate between a variable that has been captured |
| 420 /// from one scope to another. This is the ir.Node version that corresponds to | 420 /// from one scope to another. This is the ir.Node version that corresponds to |
| 421 /// [BoxLocal]. | 421 /// [BoxLocal]. |
| 422 class NodeBox { | 422 class NodeBox { |
| 423 final String name; | 423 final String name; |
| 424 final ir.TreeNode executableContext; | 424 final ir.TreeNode executableContext; |
| 425 NodeBox(this.name, this.executableContext); | 425 NodeBox(this.name, this.executableContext); |
| 426 } | 426 } |
| 427 | 427 |
| 428 class JClosureClass extends JClass { | 428 class JClosureClass extends JClass { |
| 429 JClosureClass(JLibrary library, int classIndex, String name) | 429 JClosureClass(JLibrary library, String name) |
| 430 : super(library, classIndex, name, isAbstract: false); | 430 : super(library, name, isAbstract: false); |
| 431 | 431 |
| 432 @override | 432 @override |
| 433 bool get isClosure => true; | 433 bool get isClosure => true; |
| 434 | 434 |
| 435 String toString() => '${jsElementPrefix}closure_class($name)'; | 435 String toString() => '${jsElementPrefix}closure_class($name)'; |
| 436 } | 436 } |
| 437 | 437 |
| 438 class JClosureField extends JField { | 438 class JClosureField extends JField { |
| 439 JClosureField(String name, int memberIndex, | 439 JClosureField(String name, KernelClosureClass containingClass, bool isConst, |
| 440 KernelClosureClass containingClass, bool isConst, bool isAssignable) | 440 bool isAssignable) |
| 441 : super( | 441 : super( |
| 442 memberIndex, | |
| 443 containingClass.closureClassEntity.library, | 442 containingClass.closureClassEntity.library, |
| 444 containingClass.closureClassEntity, | 443 containingClass.closureClassEntity, |
| 445 new Name(name, containingClass.closureClassEntity.library), | 444 new Name(name, containingClass.closureClassEntity.library), |
| 446 isAssignable: isAssignable, | 445 isAssignable: isAssignable, |
| 447 isConst: isConst, | 446 isConst: isConst, |
| 448 isStatic: false); | 447 isStatic: false); |
| 449 } | 448 } |
| 450 | 449 |
| 451 /// A container for variables declared in a particular scope that are accessed | 450 /// A container for variables declared in a particular scope that are accessed |
| 452 /// elsewhere. | 451 /// elsewhere. |
| 453 // TODO(efortuna, johnniwinther): Don't implement JClass. This isn't actually a | 452 // TODO(efortuna, johnniwinther): Don't implement JClass. This isn't actually a |
| 454 // class. | 453 // class. |
| 455 class JRecord implements JClass { | 454 class JRecord extends JClass { |
| 456 final JLibrary library; | 455 JRecord(LibraryEntity library, String name) |
| 457 final String name; | 456 : super(library, name, isAbstract: false); |
| 458 | |
| 459 /// Index into the classData, classList and classEnvironment lists where this | |
| 460 /// entity is stored in [JsToFrontendMapImpl]. | |
| 461 final int classIndex; | |
| 462 | |
| 463 JRecord(this.library, this.classIndex, this.name); | |
| 464 | |
| 465 bool get isAbstract => false; | |
| 466 | 457 |
| 467 bool get isClosure => false; | 458 bool get isClosure => false; |
| 468 | 459 |
| 469 String toString() => '${jsElementPrefix}record_container($name)'; | 460 String toString() => '${jsElementPrefix}record_container($name)'; |
| 470 } | 461 } |
| 471 | 462 |
| 472 /// A variable that has been "boxed" to prevent name shadowing with the | 463 /// A variable that has been "boxed" to prevent name shadowing with the |
| 473 /// original variable and ensure that this variable is updated/read with the | 464 /// original variable and ensure that this variable is updated/read with the |
| 474 /// most recent value. | 465 /// most recent value. |
| 475 /// This corresponds to BoxFieldElement; we reuse BoxLocal from the original | 466 /// This corresponds to BoxFieldElement; we reuse BoxLocal from the original |
| 476 /// algorithm to correspond to the actual name of the variable. | 467 /// algorithm to correspond to the actual name of the variable. |
| 477 class JRecordField extends JField { | 468 class JRecordField extends JField { |
| 478 final BoxLocal box; | 469 final BoxLocal box; |
| 479 JRecordField(String name, int memberIndex, this.box, JClass containingClass, | 470 JRecordField(String name, this.box, JClass containingClass, bool isConst) |
| 480 bool isConst) | 471 : super(containingClass.library, containingClass, |
| 481 : super(memberIndex, containingClass.library, containingClass, | |
| 482 new Name(name, containingClass.library), | 472 new Name(name, containingClass.library), |
| 483 isStatic: false, isAssignable: true, isConst: isConst); | 473 isStatic: false, isAssignable: true, isConst: isConst); |
| 484 } | 474 } |
| 485 | 475 |
| 486 class ClosureClassDefinition implements ClassDefinition { | 476 class ClosureClassDefinition implements ClassDefinition { |
| 487 final ClassEntity cls; | 477 final ClassEntity cls; |
| 488 final SourceSpan location; | 478 final SourceSpan location; |
| 489 | 479 |
| 490 ClosureClassDefinition(this.cls, this.location); | 480 ClosureClassDefinition(this.cls, this.location); |
| 491 | 481 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 KernelScopeInfo scopeInfo; | 609 KernelScopeInfo scopeInfo; |
| 620 | 610 |
| 621 /// Collected [CapturedScope] data for nodes. | 611 /// Collected [CapturedScope] data for nodes. |
| 622 Map<ir.Node, KernelCapturedScope> capturedScopesMap = | 612 Map<ir.Node, KernelCapturedScope> capturedScopesMap = |
| 623 <ir.Node, KernelCapturedScope>{}; | 613 <ir.Node, KernelCapturedScope>{}; |
| 624 | 614 |
| 625 /// Collected [ScopeInfo] data for nodes. | 615 /// Collected [ScopeInfo] data for nodes. |
| 626 Map<ir.TreeNode, KernelScopeInfo> closuresToGenerate = | 616 Map<ir.TreeNode, KernelScopeInfo> closuresToGenerate = |
| 627 <ir.TreeNode, KernelScopeInfo>{}; | 617 <ir.TreeNode, KernelScopeInfo>{}; |
| 628 } | 618 } |
| OLD | NEW |