OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 '../closure.dart'; | 5 import '../closure.dart'; |
6 import '../common.dart'; | 6 import '../common.dart'; |
7 import '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../io/source_information.dart'; | 10 import '../io/source_information.dart'; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 if (isInterceptorClass) { | 261 if (isInterceptorClass) { |
262 // Only use the extra parameter in intercepted classes. | 262 // Only use the extra parameter in intercepted classes. |
263 directLocals[closureData.thisLocal] = value; | 263 directLocals[closureData.thisLocal] = value; |
264 } | 264 } |
265 } else if (isNativeUpgradeFactory) { | 265 } else if (isNativeUpgradeFactory) { |
266 SyntheticLocal parameter = | 266 SyntheticLocal parameter = |
267 new SyntheticLocal('receiver', executableContext); | 267 new SyntheticLocal('receiver', executableContext); |
268 // Unlike `this`, receiver is nullable since direct calls to generative | 268 // Unlike `this`, receiver is nullable since direct calls to generative |
269 // constructor call the constructor with `null`. | 269 // constructor call the constructor with `null`. |
270 ClassWorld classWorld = _compiler.world; | 270 ClassWorld classWorld = _compiler.closedWorld; |
271 HParameterValue value = | 271 HParameterValue value = |
272 new HParameterValue(parameter, new TypeMask.exact(cls, classWorld)); | 272 new HParameterValue(parameter, new TypeMask.exact(cls, classWorld)); |
273 builder.graph.explicitReceiverParameter = value; | 273 builder.graph.explicitReceiverParameter = value; |
274 builder.graph.entry.addAtEntry(value); | 274 builder.graph.entry.addAtEntry(value); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 /// Returns true if the local can be accessed directly. Boxed variables or | 278 /// Returns true if the local can be accessed directly. Boxed variables or |
279 /// captured variables that are stored in the closure-field return [:false:]. | 279 /// captured variables that are stored in the closure-field return [:false:]. |
280 bool isAccessedDirectly(Local local) { | 280 bool isAccessedDirectly(Local local) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 return this; | 618 return this; |
619 } | 619 } |
620 | 620 |
621 TypeMask cachedTypeOfThis; | 621 TypeMask cachedTypeOfThis; |
622 | 622 |
623 TypeMask getTypeOfThis() { | 623 TypeMask getTypeOfThis() { |
624 TypeMask result = cachedTypeOfThis; | 624 TypeMask result = cachedTypeOfThis; |
625 if (result == null) { | 625 if (result == null) { |
626 ThisLocal local = closureData.thisLocal; | 626 ThisLocal local = closureData.thisLocal; |
627 ClassElement cls = local.enclosingClass; | 627 ClassElement cls = local.enclosingClass; |
628 ClassWorld classWorld = _compiler.world; | 628 ClassWorld classWorld = _compiler.closedWorld; |
629 if (classWorld.isUsedAsMixin(cls)) { | 629 if (classWorld.isUsedAsMixin(cls)) { |
630 // If the enclosing class is used as a mixin, [:this:] can be | 630 // If the enclosing class is used as a mixin, [:this:] can be |
631 // of the class that mixins the enclosing class. These two | 631 // of the class that mixins the enclosing class. These two |
632 // classes do not have a subclass relationship, so, for | 632 // classes do not have a subclass relationship, so, for |
633 // simplicity, we mark the type as an interface type. | 633 // simplicity, we mark the type as an interface type. |
634 result = new TypeMask.nonNullSubtype(cls.declaration, _compiler.world); | 634 result = |
| 635 new TypeMask.nonNullSubtype(cls.declaration, _compiler.closedWorld); |
635 } else { | 636 } else { |
636 result = new TypeMask.nonNullSubclass(cls.declaration, _compiler.world); | 637 result = new TypeMask.nonNullSubclass( |
| 638 cls.declaration, _compiler.closedWorld); |
637 } | 639 } |
638 cachedTypeOfThis = result; | 640 cachedTypeOfThis = result; |
639 } | 641 } |
640 return result; | 642 return result; |
641 } | 643 } |
642 | 644 |
643 Map<Element, TypeMask> cachedTypesOfCapturedVariables = | 645 Map<Element, TypeMask> cachedTypesOfCapturedVariables = |
644 new Map<Element, TypeMask>(); | 646 new Map<Element, TypeMask>(); |
645 | 647 |
646 TypeMask getTypeOfCapturedVariable(Element element) { | 648 TypeMask getTypeOfCapturedVariable(Element element) { |
647 assert(element.isField); | 649 assert(element.isField); |
648 return cachedTypesOfCapturedVariables.putIfAbsent(element, () { | 650 return cachedTypesOfCapturedVariables.putIfAbsent(element, () { |
649 return TypeMaskFactory.inferredTypeForElement(element, _compiler); | 651 return TypeMaskFactory.inferredTypeForElement(element, _compiler); |
650 }); | 652 }); |
651 } | 653 } |
652 | 654 |
653 /// Variables stored in the current activation. These variables are | 655 /// Variables stored in the current activation. These variables are |
654 /// being updated in try/catch blocks, and should be | 656 /// being updated in try/catch blocks, and should be |
655 /// accessed indirectly through [HLocalGet] and [HLocalSet]. | 657 /// accessed indirectly through [HLocalGet] and [HLocalSet]. |
656 Map<Local, HLocalValue> activationVariables = <Local, HLocalValue>{}; | 658 Map<Local, HLocalValue> activationVariables = <Local, HLocalValue>{}; |
657 } | 659 } |
OLD | NEW |