Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: pkg/compiler/lib/src/world.dart

Issue 2307883002: Fix type masks for js-interop types. (Closed)
Patch Set: Update status Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 library dart2js.world; 5 library dart2js.world;
6 6
7 import 'closure.dart' show SynthesizedCallMethodElementX; 7 import 'closure.dart' show SynthesizedCallMethodElementX;
8 import 'common/backend_api.dart' show Backend; 8 import 'common/backend_api.dart' show Backend;
9 import 'common.dart'; 9 import 'common.dart';
10 import 'compiler.dart' show Compiler; 10 import 'compiler.dart' show Compiler;
11 import 'core_types.dart' show CoreClasses; 11 import 'core_types.dart' show CoreClasses;
12 import 'dart_types.dart'; 12 import 'dart_types.dart';
13 import 'elements/elements.dart' 13 import 'elements/elements.dart'
14 show 14 show
15 ClassElement, 15 ClassElement,
16 Element, 16 Element,
17 FunctionElement, 17 FunctionElement,
18 MixinApplicationElement, 18 MixinApplicationElement,
19 TypedefElement, 19 TypedefElement,
20 VariableElement; 20 VariableElement;
21 import 'js_backend/backend.dart' show JavaScriptBackend;
21 import 'ordered_typeset.dart'; 22 import 'ordered_typeset.dart';
22 import 'types/masks.dart' show TypeMask, FlatTypeMask; 23 import 'types/masks.dart' show TypeMask, FlatTypeMask;
23 import 'universe/class_set.dart'; 24 import 'universe/class_set.dart';
24 import 'universe/function_set.dart' show FunctionSet; 25 import 'universe/function_set.dart' show FunctionSet;
25 import 'universe/selector.dart' show Selector; 26 import 'universe/selector.dart' show Selector;
26 import 'universe/side_effects.dart' show SideEffects; 27 import 'universe/side_effects.dart' show SideEffects;
27 import 'util/util.dart' show Link; 28 import 'util/util.dart' show Link;
28 29
29 /// The [ClassWorld] represents the information known about a program when 30 /// The [ClassWorld] represents the information known about a program when
30 /// compiling with closed-world semantics. 31 /// compiling with closed-world semantics.
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 ClassSet classSet = _classSets[cls.declaration]; 399 ClassSet classSet = _classSets[cls.declaration];
399 if (classSet == null) { 400 if (classSet == null) {
400 // Vacuously true. 401 // Vacuously true.
401 return true; 402 return true;
402 } 403 }
403 return classSet.hasOnlyInstantiatedSubclasses; 404 return classSet.hasOnlyInstantiatedSubclasses;
404 } 405 }
405 406
406 @override 407 @override
407 ClassElement getLubOfInstantiatedSubclasses(ClassElement cls) { 408 ClassElement getLubOfInstantiatedSubclasses(ClassElement cls) {
409 if (backend.isJsInterop(cls)) {
410 return backend.helpers.jsJavaScriptObjectClass;
411 }
408 ClassHierarchyNode hierarchy = _classHierarchyNodes[cls.declaration]; 412 ClassHierarchyNode hierarchy = _classHierarchyNodes[cls.declaration];
409 return hierarchy != null 413 return hierarchy != null
410 ? hierarchy.getLubOfInstantiatedSubclasses() 414 ? hierarchy.getLubOfInstantiatedSubclasses()
411 : null; 415 : null;
412 } 416 }
413 417
414 @override 418 @override
415 ClassElement getLubOfInstantiatedSubtypes(ClassElement cls) { 419 ClassElement getLubOfInstantiatedSubtypes(ClassElement cls) {
420 if (backend.isJsInterop(cls)) {
421 return backend.helpers.jsJavaScriptObjectClass;
422 }
416 ClassSet classSet = _classSets[cls.declaration]; 423 ClassSet classSet = _classSets[cls.declaration];
417 return classSet != null ? classSet.getLubOfInstantiatedSubtypes() : null; 424 return classSet != null ? classSet.getLubOfInstantiatedSubtypes() : null;
418 } 425 }
419 426
420 /// Returns an iterable over the common supertypes of the [classes]. 427 /// Returns an iterable over the common supertypes of the [classes].
421 Iterable<ClassElement> commonSupertypesOf(Iterable<ClassElement> classes) { 428 Iterable<ClassElement> commonSupertypesOf(Iterable<ClassElement> classes) {
422 Iterator<ClassElement> iterator = classes.iterator; 429 Iterator<ClassElement> iterator = classes.iterator;
423 if (!iterator.moveNext()) return const <ClassElement>[]; 430 if (!iterator.moveNext()) return const <ClassElement>[];
424 431
425 ClassElement cls = iterator.current; 432 ClassElement cls = iterator.current;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 548
542 /// Returns `true` if any subclass of [superclass] implements [type]. 549 /// Returns `true` if any subclass of [superclass] implements [type].
543 bool hasAnySubclassThatImplements( 550 bool hasAnySubclassThatImplements(
544 ClassElement superclass, ClassElement type) { 551 ClassElement superclass, ClassElement type) {
545 Set<ClassElement> subclasses = typesImplementedBySubclassesOf(superclass); 552 Set<ClassElement> subclasses = typesImplementedBySubclassesOf(superclass);
546 if (subclasses == null) return false; 553 if (subclasses == null) return false;
547 return subclasses.contains(type); 554 return subclasses.contains(type);
548 } 555 }
549 556
550 final Compiler compiler; 557 final Compiler compiler;
551 Backend get backend => compiler.backend; 558 JavaScriptBackend get backend => compiler.backend;
552 final FunctionSet allFunctions; 559 final FunctionSet allFunctions;
553 final Set<Element> functionsCalledInLoop = new Set<Element>(); 560 final Set<Element> functionsCalledInLoop = new Set<Element>();
554 final Map<Element, SideEffects> sideEffects = new Map<Element, SideEffects>(); 561 final Map<Element, SideEffects> sideEffects = new Map<Element, SideEffects>();
555 562
556 final Set<TypedefElement> allTypedefs = new Set<TypedefElement>(); 563 final Set<TypedefElement> allTypedefs = new Set<TypedefElement>();
557 564
558 final Map<ClassElement, Set<MixinApplicationElement>> _mixinUses = 565 final Map<ClassElement, Set<MixinApplicationElement>> _mixinUses =
559 new Map<ClassElement, Set<MixinApplicationElement>>(); 566 new Map<ClassElement, Set<MixinApplicationElement>>();
560 Map<ClassElement, List<MixinApplicationElement>> _liveMixinUses; 567 Map<ClassElement, List<MixinApplicationElement>> _liveMixinUses;
561 568
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // function expressions's element. 880 // function expressions's element.
874 // TODO(herhut): Generate classes for function expressions earlier. 881 // TODO(herhut): Generate classes for function expressions earlier.
875 if (element is SynthesizedCallMethodElementX) { 882 if (element is SynthesizedCallMethodElementX) {
876 return getMightBePassedToApply(element.expression); 883 return getMightBePassedToApply(element.expression);
877 } 884 }
878 return functionsThatMightBePassedToApply.contains(element); 885 return functionsThatMightBePassedToApply.contains(element);
879 } 886 }
880 887
881 bool get hasClosedWorldAssumption => !compiler.options.hasIncrementalSupport; 888 bool get hasClosedWorldAssumption => !compiler.options.hasIncrementalSupport;
882 } 889 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/class_members.dart ('k') | tests/compiler/dart2js/jsinterop/abstract_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698