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

Side by Side Diff: pkg/compiler/lib/src/types/constants.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 types.constants; 5 library types.constants;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../compiler.dart' show 8 import '../compiler.dart' show Compiler;
9 Compiler;
10 import '../constants/values.dart'; 9 import '../constants/values.dart';
11 import '../js_backend/js_backend.dart' show 10 import '../js_backend/js_backend.dart' show SyntheticConstantKind;
12 SyntheticConstantKind;
13 import 'types.dart'; 11 import 'types.dart';
14 12
15 /// Computes the [TypeMask] for the constant [value]. 13 /// Computes the [TypeMask] for the constant [value].
16 TypeMask computeTypeMask(Compiler compiler, ConstantValue value) { 14 TypeMask computeTypeMask(Compiler compiler, ConstantValue value) {
17 return value.accept(const ConstantValueTypeMasks(), compiler); 15 return value.accept(const ConstantValueTypeMasks(), compiler);
18 } 16 }
19 17
20 class ConstantValueTypeMasks extends ConstantValueVisitor<TypeMask, Compiler> { 18 class ConstantValueTypeMasks extends ConstantValueVisitor<TypeMask, Compiler> {
21 const ConstantValueTypeMasks(); 19 const ConstantValueTypeMasks();
22 20
23 @override 21 @override
24 TypeMask visitConstructed(ConstructedConstantValue constant, 22 TypeMask visitConstructed(
25 Compiler compiler) { 23 ConstructedConstantValue constant, Compiler compiler) {
26 if (compiler.backend.isInterceptorClass(constant.type.element)) { 24 if (compiler.backend.isInterceptorClass(constant.type.element)) {
27 return compiler.typesTask.nonNullType; 25 return compiler.typesTask.nonNullType;
28 } 26 }
29 return new TypeMask.nonNullExact(constant.type.element, compiler.world); 27 return new TypeMask.nonNullExact(constant.type.element, compiler.world);
30 } 28 }
31 29
32 @override 30 @override
33 TypeMask visitDeferred(DeferredConstantValue constant, Compiler compiler) { 31 TypeMask visitDeferred(DeferredConstantValue constant, Compiler compiler) {
34 return constant.referenced.accept(this, compiler); 32 return constant.referenced.accept(this, compiler);
35 } 33 }
(...skipping 18 matching lines...) Expand all
54 case SyntheticConstantKind.DUMMY_INTERCEPTOR: 52 case SyntheticConstantKind.DUMMY_INTERCEPTOR:
55 return constant.payload; 53 return constant.payload;
56 case SyntheticConstantKind.EMPTY_VALUE: 54 case SyntheticConstantKind.EMPTY_VALUE:
57 return constant.payload; 55 return constant.payload;
58 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: 56 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE:
59 return compiler.typesTask.intType; 57 return compiler.typesTask.intType;
60 case SyntheticConstantKind.NAME: 58 case SyntheticConstantKind.NAME:
61 return compiler.typesTask.stringType; 59 return compiler.typesTask.stringType;
62 default: 60 default:
63 DiagnosticReporter reporter = compiler.reporter; 61 DiagnosticReporter reporter = compiler.reporter;
64 reporter.internalError(CURRENT_ELEMENT_SPANNABLE, 62 reporter.internalError(
65 "Unexpected DummyConstantKind."); 63 CURRENT_ELEMENT_SPANNABLE, "Unexpected DummyConstantKind.");
66 return null; 64 return null;
67 } 65 }
68 } 66 }
69 67
70 @override 68 @override
71 TypeMask visitBool(BoolConstantValue constant, Compiler compiler) { 69 TypeMask visitBool(BoolConstantValue constant, Compiler compiler) {
72 return compiler.typesTask.boolType; 70 return compiler.typesTask.boolType;
73 } 71 }
74 72
75 @override 73 @override
76 TypeMask visitFunction(FunctionConstantValue constant, Compiler compiler) { 74 TypeMask visitFunction(FunctionConstantValue constant, Compiler compiler) {
77 return compiler.typesTask.functionType; 75 return compiler.typesTask.functionType;
78 } 76 }
79 77
80 @override 78 @override
81 TypeMask visitInt(IntConstantValue constant, Compiler compiler) { 79 TypeMask visitInt(IntConstantValue constant, Compiler compiler) {
82 if (constant.isUInt31()) return compiler.typesTask.uint31Type; 80 if (constant.isUInt31()) return compiler.typesTask.uint31Type;
83 if (constant.isUInt32()) return compiler.typesTask.uint32Type; 81 if (constant.isUInt32()) return compiler.typesTask.uint32Type;
84 if (constant.isPositive()) return compiler.typesTask.positiveIntType; 82 if (constant.isPositive()) return compiler.typesTask.positiveIntType;
85 return compiler.typesTask.intType; 83 return compiler.typesTask.intType;
86 } 84 }
87 85
88 @override 86 @override
89 TypeMask visitInterceptor(InterceptorConstantValue constant, 87 TypeMask visitInterceptor(
90 Compiler compiler) { 88 InterceptorConstantValue constant, Compiler compiler) {
91 return compiler.typesTask.nonNullType; 89 return compiler.typesTask.nonNullType;
92 } 90 }
93 91
94 @override 92 @override
95 TypeMask visitList(ListConstantValue constant, Compiler compiler) { 93 TypeMask visitList(ListConstantValue constant, Compiler compiler) {
96 return compiler.typesTask.constListType; 94 return compiler.typesTask.constListType;
97 } 95 }
98 96
99 @override 97 @override
100 TypeMask visitMap(MapConstantValue constant, Compiler compiler) { 98 TypeMask visitMap(MapConstantValue constant, Compiler compiler) {
101 return compiler.typesTask.constMapType; 99 return compiler.typesTask.constMapType;
102 } 100 }
103 101
104 @override 102 @override
105 TypeMask visitNull(NullConstantValue constant, Compiler compiler) { 103 TypeMask visitNull(NullConstantValue constant, Compiler compiler) {
106 return compiler.typesTask.nullType; 104 return compiler.typesTask.nullType;
107 } 105 }
108 106
109 @override 107 @override
110 TypeMask visitString(StringConstantValue constant, Compiler compiler) { 108 TypeMask visitString(StringConstantValue constant, Compiler compiler) {
111 return compiler.typesTask.stringType; 109 return compiler.typesTask.stringType;
112 } 110 }
113 111
114 @override 112 @override
115 TypeMask visitType(TypeConstantValue constant, Compiler compiler) { 113 TypeMask visitType(TypeConstantValue constant, Compiler compiler) {
116 return compiler.typesTask.typeType; 114 return compiler.typesTask.typeType;
117 } 115 }
118 } 116 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/types/abstract_value_domain.dart ('k') | pkg/compiler/lib/src/types/container_type_mask.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698