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

Side by Side Diff: lib/compiler/implementation/js_backend/constant_system_javascript.dart

Issue 10916232: Implement checked mode for const constructors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/constant_system_dart.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); 5 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem();
6 6
7 class JavaScriptBitNotOperation extends BitNotOperation { 7 class JavaScriptBitNotOperation extends BitNotOperation {
8 const JavaScriptBitNotOperation(); 8 const JavaScriptBitNotOperation();
9 9
10 Constant fold(Constant constant) { 10 Constant fold(Constant constant) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 BoolConstant createBool(bool value) => new BoolConstant(value); 210 BoolConstant createBool(bool value) => new BoolConstant(value);
211 NullConstant createNull() => new NullConstant(); 211 NullConstant createNull() => new NullConstant();
212 212
213 // Integer checks don't verify that the number is not -0.0. 213 // Integer checks don't verify that the number is not -0.0.
214 bool isInt(Constant constant) => constant.isInt() || constant.isMinusZero(); 214 bool isInt(Constant constant) => constant.isInt() || constant.isMinusZero();
215 bool isDouble(Constant constant) 215 bool isDouble(Constant constant)
216 => constant.isDouble() && !constant.isMinusZero(); 216 => constant.isDouble() && !constant.isMinusZero();
217 bool isString(Constant constant) => constant.isString(); 217 bool isString(Constant constant) => constant.isString();
218 bool isBool(Constant constant) => constant.isBool(); 218 bool isBool(Constant constant) => constant.isBool();
219 bool isNull(Constant constant) => constant.isNull(); 219 bool isNull(Constant constant) => constant.isNull();
220 } 220
221 bool isSubtype(Compiler compiler, DartType s, DartType t) {
222 // At runtime, an integer is both an integer and a double: the
223 // integer type check is Math.floor, which will return true only
224 // for real integers, and our double type check is 'typeof number'
225 // which will return true for both integers and doubles.
226 if (s.element == compiler.intClass && t.element == compiler.doubleClass) {
227 return true;
228 }
229 return compiler.types.isSubtype(s, t);
230 }
231 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/constant_system_dart.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698