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

Side by Side Diff: pkg/compiler/lib/src/constants/constant_system.dart

Issue 2684783003: Refactor ConstantSystem (Closed)
Patch Set: Updated cf. comments. Created 3 years, 10 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.constant_system; 5 library dart2js.constant_system;
6 6
7 import '../compiler.dart' show Compiler; 7 import '../common/backend_api.dart' show BackendClasses;
8 import '../elements/resolution_types.dart'; 8 import '../core_types.dart' show CommonElements;
9 import '../elements/resolution_types.dart' show DartTypes;
10 import '../elements/types.dart';
9 import '../resolution/operators.dart'; 11 import '../resolution/operators.dart';
10 import '../tree/dartstring.dart' show DartString; 12 import '../tree/dartstring.dart' show DartString;
11 import 'values.dart'; 13 import 'values.dart';
12 14
13 abstract class Operation { 15 abstract class Operation {
14 String get name; 16 String get name;
15 } 17 }
16 18
17 abstract class UnaryOperation extends Operation { 19 abstract class UnaryOperation extends Operation {
18 /** Returns [:null:] if it was unable to fold the operation. */ 20 /** Returns [:null:] if it was unable to fold the operation. */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 BinaryOperation get codeUnitAt; 59 BinaryOperation get codeUnitAt;
58 UnaryOperation get round; 60 UnaryOperation get round;
59 61
60 const ConstantSystem(); 62 const ConstantSystem();
61 63
62 ConstantValue createInt(int i); 64 ConstantValue createInt(int i);
63 ConstantValue createDouble(double d); 65 ConstantValue createDouble(double d);
64 ConstantValue createString(DartString string); 66 ConstantValue createString(DartString string);
65 ConstantValue createBool(bool value); 67 ConstantValue createBool(bool value);
66 ConstantValue createNull(); 68 ConstantValue createNull();
67 ConstantValue createList( 69 ConstantValue createList(InterfaceType type, List<ConstantValue> values);
68 ResolutionInterfaceType type, List<ConstantValue> values); 70 ConstantValue createMap(
69 // TODO(johnniwinther): Remove the need for [compiler]. 71 CommonElements commonElements,
70 ConstantValue createMap(Compiler compiler, ResolutionInterfaceType type, 72 BackendClasses backendClasses,
71 List<ConstantValue> keys, List<ConstantValue> values); 73 InterfaceType type,
72 // TODO(johnniwinther): Remove the need for [compiler]. 74 List<ConstantValue> keys,
73 ConstantValue createType(Compiler compiler, ResolutionDartType type); 75 List<ConstantValue> values);
74 // TODO(johnniwinther): Remove the need for [compiler]. 76 ConstantValue createType(CommonElements commonElements,
75 ConstantValue createSymbol(Compiler compiler, String text); 77 BackendClasses backendClasses, DartType type);
78 ConstantValue createSymbol(CommonElements commonElements,
79 BackendClasses backendClasses, String text);
76 80
77 // We need to special case the subtype check for JavaScript constant 81 // We need to special case the subtype check for JavaScript constant
78 // system because an int is a double at runtime. 82 // system because an int is a double at runtime.
79 bool isSubtype(DartTypes types, ResolutionDartType s, ResolutionDartType t); 83 bool isSubtype(DartTypes types, DartType s, DartType t);
80 84
81 /** Returns true if the [constant] is an integer at runtime. */ 85 /** Returns true if the [constant] is an integer at runtime. */
82 bool isInt(ConstantValue constant); 86 bool isInt(ConstantValue constant);
83 /** Returns true if the [constant] is a double at runtime. */ 87 /** Returns true if the [constant] is a double at runtime. */
84 bool isDouble(ConstantValue constant); 88 bool isDouble(ConstantValue constant);
85 /** Returns true if the [constant] is a string at runtime. */ 89 /** Returns true if the [constant] is a string at runtime. */
86 bool isString(ConstantValue constant); 90 bool isString(ConstantValue constant);
87 /** Returns true if the [constant] is a boolean at runtime. */ 91 /** Returns true if the [constant] is a boolean at runtime. */
88 bool isBool(ConstantValue constant); 92 bool isBool(ConstantValue constant);
89 /** Returns true if the [constant] is null at runtime. */ 93 /** Returns true if the [constant] is null at runtime. */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return greaterEqual; 144 return greaterEqual;
141 case BinaryOperatorKind.EQ: 145 case BinaryOperatorKind.EQ:
142 return equal; 146 return equal;
143 case BinaryOperatorKind.IF_NULL: 147 case BinaryOperatorKind.IF_NULL:
144 return ifNull; 148 return ifNull;
145 default: 149 default:
146 return null; 150 return null;
147 } 151 }
148 } 152 }
149 } 153 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constant_system_dart.dart ('k') | pkg/compiler/lib/src/constants/evaluation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698