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

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

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 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 '../js_backend/js_backend.dart'; 8 import '../js_backend/js_backend.dart';
9 import '../native/native.dart' as native; 9 import '../native/native.dart' as native;
10 import '../tree/tree.dart' as ast; 10 import '../tree/tree.dart' as ast;
11 import '../types/types.dart'; 11 import '../types/types.dart';
12 import '../universe/selector.dart' show Selector; 12 import '../universe/selector.dart' show Selector;
13 import '../world.dart' show ClassWorld, World; 13 import '../world.dart' show ClassWorld, World;
14 14
15 class TypeMaskFactory { 15 class TypeMaskFactory {
16 static TypeMask fromInferredType(TypeMask mask, Compiler compiler) { 16 static TypeMask fromInferredType(TypeMask mask, Compiler compiler) {
17 JavaScriptBackend backend = compiler.backend; 17 JavaScriptBackend backend = compiler.backend;
18 if (mask == null) return backend.dynamicType; 18 if (mask == null) return backend.dynamicType;
19 return mask; 19 return mask;
20 } 20 }
21 21
22 static TypeMask inferredReturnTypeForElement( 22 static TypeMask inferredReturnTypeForElement(
23 Element element, Compiler compiler) { 23 Element element, Compiler compiler) {
24 return fromInferredType( 24 return fromInferredType(
25 compiler.typesTask.getGuaranteedReturnTypeOfElement(element), 25 compiler.typesTask.getGuaranteedReturnTypeOfElement(element), compiler);
26 compiler);
27 } 26 }
28 27
29 static TypeMask inferredTypeForElement(Element element, Compiler compiler) { 28 static TypeMask inferredTypeForElement(Element element, Compiler compiler) {
30 return fromInferredType( 29 return fromInferredType(
31 compiler.typesTask.getGuaranteedTypeOfElement(element), 30 compiler.typesTask.getGuaranteedTypeOfElement(element), compiler);
32 compiler);
33 } 31 }
34 32
35 static TypeMask inferredTypeForSelector(Selector selector, 33 static TypeMask inferredTypeForSelector(
36 TypeMask mask, 34 Selector selector, TypeMask mask, Compiler compiler) {
37 Compiler compiler) {
38 return fromInferredType( 35 return fromInferredType(
39 compiler.typesTask.getGuaranteedTypeOfSelector(selector, mask), 36 compiler.typesTask.getGuaranteedTypeOfSelector(selector, mask),
40 compiler); 37 compiler);
41 } 38 }
42 39
43 static TypeMask inferredForNode(Element owner, ast.Node node, 40 static TypeMask inferredForNode(
44 Compiler compiler) { 41 Element owner, ast.Node node, Compiler compiler) {
45 return fromInferredType( 42 return fromInferredType(
46 compiler.typesTask.getGuaranteedTypeOfNode(owner, node), 43 compiler.typesTask.getGuaranteedTypeOfNode(owner, node), compiler);
47 compiler);
48 } 44 }
49 45
50 static TypeMask fromNativeBehavior(native.NativeBehavior nativeBehavior, 46 static TypeMask fromNativeBehavior(
51 Compiler compiler) { 47 native.NativeBehavior nativeBehavior, Compiler compiler) {
52 ClassWorld classWorld = compiler.world; 48 ClassWorld classWorld = compiler.world;
53 JavaScriptBackend backend = compiler.backend; 49 JavaScriptBackend backend = compiler.backend;
54 if (nativeBehavior.typesReturned.isEmpty) return backend.dynamicType; 50 if (nativeBehavior.typesReturned.isEmpty) return backend.dynamicType;
55 51
56 TypeMask result = nativeBehavior.typesReturned 52 TypeMask result = nativeBehavior.typesReturned
57 .map((type) => fromNativeType(type, compiler)) 53 .map((type) => fromNativeType(type, compiler))
58 .reduce((t1, t2) => t1.union(t2, classWorld)); 54 .reduce((t1, t2) => t1.union(t2, classWorld));
59 assert(!result.isEmpty); 55 assert(!result.isEmpty);
60 return result; 56 return result;
61 } 57 }
(...skipping 10 matching lines...) Expand all
72 return backend.nullType; 68 return backend.nullType;
73 } else if (type.element == coreClasses.nullClass) { 69 } else if (type.element == coreClasses.nullClass) {
74 return backend.nullType; 70 return backend.nullType;
75 } else if (type.treatAsDynamic) { 71 } else if (type.treatAsDynamic) {
76 return backend.dynamicType; 72 return backend.dynamicType;
77 } else { 73 } else {
78 return new TypeMask.nonNullSubtype(type.element, classWorld); 74 return new TypeMask.nonNullSubtype(type.element, classWorld);
79 } 75 }
80 } 76 }
81 } 77 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/ssa_tracer.dart ('k') | pkg/compiler/lib/src/ssa/types_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698