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

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

Issue 12317107: ceil/floor/truncate/round return integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload due to error3 Created 7 years, 9 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
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 part of js_backend; 5 part of js_backend;
6 6
7 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); 7 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem();
8 8
9 class JavaScriptBitNotOperation extends BitNotOperation { 9 class JavaScriptBitNotOperation extends BitNotOperation {
10 const JavaScriptBitNotOperation(); 10 const JavaScriptBitNotOperation();
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 IntConstant intConstant = constant; 192 IntConstant intConstant = constant;
193 int intValue = intConstant.value; 193 int intValue = intConstant.value;
194 if (!integerFitsIntoDouble(intValue)) { 194 if (!integerFitsIntoDouble(intValue)) {
195 return new DoubleConstant(intValue.toDouble()); 195 return new DoubleConstant(intValue.toDouble());
196 } 196 }
197 } else if (constant.isDouble()) { 197 } else if (constant.isDouble()) {
198 DoubleConstant doubleResult = constant; 198 DoubleConstant doubleResult = constant;
199 double doubleValue = doubleResult.value; 199 double doubleValue = doubleResult.value;
200 if (!doubleValue.isInfinite && !doubleValue.isNaN && 200 if (!doubleValue.isInfinite && !doubleValue.isNaN &&
201 !constant.isMinusZero()) { 201 !constant.isMinusZero()) {
202 int intValue = doubleValue.toInt(); 202 int intValue = doubleValue.truncate();
203 if (intValue == doubleValue && integerFitsIntoDouble(intValue)) { 203 if (intValue == doubleValue && integerFitsIntoDouble(intValue)) {
204 return new IntConstant(intValue); 204 return new IntConstant(intValue);
205 } 205 }
206 } 206 }
207 } 207 }
208 return constant; 208 return constant;
209 } 209 }
210 210
211 NumConstant createInt(int i) 211 NumConstant createInt(int i)
212 => convertToJavaScriptConstant(new IntConstant(i)); 212 => convertToJavaScriptConstant(new IntConstant(i));
(...skipping 17 matching lines...) Expand all
230 // At runtime, an integer is both an integer and a double: the 230 // At runtime, an integer is both an integer and a double: the
231 // integer type check is Math.floor, which will return true only 231 // integer type check is Math.floor, which will return true only
232 // for real integers, and our double type check is 'typeof number' 232 // for real integers, and our double type check is 'typeof number'
233 // which will return true for both integers and doubles. 233 // which will return true for both integers and doubles.
234 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { 234 if (s.element == compiler.intClass && t.element == compiler.doubleClass) {
235 return true; 235 return true;
236 } 236 }
237 return compiler.types.isSubtype(s, t); 237 return compiler.types.isSubtype(s, t);
238 } 238 }
239 } 239 }
OLDNEW
« no previous file with comments | « samples/third_party/dromaeo/common/Math2.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_number.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698