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

Side by Side Diff: pkg/compiler/lib/src/ssa/types.dart

Issue 2488353004: Remove Compiler access from ResolutionEnqueuer (Closed)
Patch Set: Updated cf. comments. Created 4 years, 1 month 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 import '../compiler.dart' show Compiler; 5 import '../compiler.dart' show Compiler;
6 import '../core_types.dart' show CoreClasses; 6 import '../core_types.dart' show CoreClasses;
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../native/native.dart' as native; 8 import '../native/native.dart' as native;
9 import '../tree/tree.dart' as ast; 9 import '../tree/tree.dart' as ast;
10 import '../types/types.dart'; 10 import '../types/types.dart';
11 import '../universe/selector.dart' show Selector; 11 import '../universe/selector.dart' show Selector;
12 import '../world.dart' show ClosedWorld; 12 import '../world.dart' show ClosedWorld;
13 13
14 class TypeMaskFactory { 14 class TypeMaskFactory {
15 static TypeMask inferredReturnTypeForElement( 15 static TypeMask inferredReturnTypeForElement(
16 Element element, Compiler compiler) { 16 Element element, Compiler compiler) {
17 return compiler.globalInference.results.returnTypeOf(element) ?? 17 return compiler.globalInference.results.returnTypeOf(element) ??
18 compiler.commonMasks.dynamicType; 18 compiler.closedWorld.commonMasks.dynamicType;
19 } 19 }
20 20
21 static TypeMask inferredTypeForElement(Element element, Compiler compiler) { 21 static TypeMask inferredTypeForElement(Element element, Compiler compiler) {
22 return compiler.globalInference.results.typeOf(element) ?? 22 return compiler.globalInference.results.typeOf(element) ??
23 compiler.commonMasks.dynamicType; 23 compiler.closedWorld.commonMasks.dynamicType;
24 } 24 }
25 25
26 static TypeMask inferredTypeForSelector( 26 static TypeMask inferredTypeForSelector(
27 Selector selector, TypeMask mask, Compiler compiler) { 27 Selector selector, TypeMask mask, Compiler compiler) {
28 return compiler.globalInference.results.typeOfSelector(selector, mask) ?? 28 return compiler.globalInference.results.typeOfSelector(selector, mask) ??
29 compiler.commonMasks.dynamicType; 29 compiler.closedWorld.commonMasks.dynamicType;
30 } 30 }
31 31
32 static TypeMask fromNativeBehavior( 32 static TypeMask fromNativeBehavior(
33 native.NativeBehavior nativeBehavior, Compiler compiler) { 33 native.NativeBehavior nativeBehavior, Compiler compiler) {
34 ClosedWorld closedWorld = compiler.closedWorld;
35 CommonMasks commonMasks = closedWorld.commonMasks;
34 var typesReturned = nativeBehavior.typesReturned; 36 var typesReturned = nativeBehavior.typesReturned;
35 if (typesReturned.isEmpty) return compiler.commonMasks.dynamicType; 37 if (typesReturned.isEmpty) return commonMasks.dynamicType;
36 38
37 ClosedWorld world = compiler.closedWorld; 39 CoreClasses coreClasses = closedWorld.coreClasses;
38 CommonMasks commonMasks = compiler.commonMasks;
39 CoreClasses coreClasses = compiler.coreClasses;
40 40
41 // [type] is either an instance of [DartType] or special objects 41 // [type] is either an instance of [DartType] or special objects
42 // like [native.SpecialType.JsObject]. 42 // like [native.SpecialType.JsObject].
43 TypeMask fromNativeType(dynamic type) { 43 TypeMask fromNativeType(dynamic type) {
44 if (type == native.SpecialType.JsObject) { 44 if (type == native.SpecialType.JsObject) {
45 return new TypeMask.nonNullExact(coreClasses.objectClass, world); 45 return new TypeMask.nonNullExact(coreClasses.objectClass, closedWorld);
46 } 46 }
47 47
48 if (type.isVoid) return commonMasks.nullType; 48 if (type.isVoid) return commonMasks.nullType;
49 if (type.element == coreClasses.nullClass) return commonMasks.nullType; 49 if (type.element == coreClasses.nullClass) return commonMasks.nullType;
50 if (type.treatAsDynamic) return commonMasks.dynamicType; 50 if (type.treatAsDynamic) return commonMasks.dynamicType;
51 return new TypeMask.nonNullSubtype(type.element, world); 51 return new TypeMask.nonNullSubtype(type.element, closedWorld);
52 } 52 }
53 53
54 TypeMask result = typesReturned 54 TypeMask result = typesReturned
55 .map(fromNativeType) 55 .map(fromNativeType)
56 .reduce((t1, t2) => t1.union(t2, compiler.closedWorld)); 56 .reduce((t1, t2) => t1.union(t2, closedWorld));
57 assert(!result.isEmpty); 57 assert(!result.isEmpty);
58 return result; 58 return result;
59 } 59 }
60 } 60 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | pkg/compiler/lib/src/types/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698