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

Side by Side Diff: runtime/vm/object.cc

Issue 8468025: Fix integer's % operation; fix parsing of doubles; update co19 tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « runtime/lib/integers.dart ('k') | tests/co19/co19-runtime.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 5259 matching lines...) Expand 10 before | Expand all | Expand 10 after
5270 { 5270 {
5271 RawObject* raw = Object::Allocate(cls, Double::InstanceSize(), space); 5271 RawObject* raw = Object::Allocate(cls, Double::InstanceSize(), space);
5272 NoGCScope no_gc; 5272 NoGCScope no_gc;
5273 result ^= raw; 5273 result ^= raw;
5274 } 5274 }
5275 result.set_value(d); 5275 result.set_value(d);
5276 return result.raw(); 5276 return result.raw();
5277 } 5277 }
5278 5278
5279 5279
5280 static bool IsWhiteSpace(char ch) {
5281 return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t';
5282 }
5283
5284
5280 RawDouble* Double::New(const String& str, Heap::Space space) { 5285 RawDouble* Double::New(const String& str, Heap::Space space) {
5281 // TODO(regis): For now, we use strtod to convert a string to double. 5286 // TODO(regis): For now, we use strtod to convert a string to double.
5282 const char* nptr = str.ToCString(); 5287 const char* nptr = str.ToCString();
5283 char* endptr = NULL; 5288 char* endptr = NULL;
5284 double double_value = strtod(nptr, &endptr); 5289 double double_value = strtod(nptr, &endptr);
5285 // We do not treat overflow or underflow as an error and therefore do not 5290 // We do not treat overflow or underflow as an error and therefore do not
5286 // check errno for ERANGE. 5291 // check errno for ERANGE.
5287 if ((*endptr != '\0')) { 5292 if (!IsWhiteSpace(*endptr)) {
5288 return Double::Handle().raw(); 5293 return Double::Handle().raw();
5289 } 5294 }
5290 return New(double_value, space); 5295 return New(double_value, space);
5291 } 5296 }
5292 5297
5293 5298
5294 const char* Double::ToCString() const { 5299 const char* Double::ToCString() const {
5295 if (isnan(value())) { 5300 if (isnan(value())) {
5296 return "NaN"; 5301 return "NaN";
5297 } 5302 }
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
6995 const String& str = String::Handle(pattern()); 7000 const String& str = String::Handle(pattern());
6996 const char* format = "JSRegExp: pattern=%s flags=%s"; 7001 const char* format = "JSRegExp: pattern=%s flags=%s";
6997 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7002 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6998 char* chars = reinterpret_cast<char*>( 7003 char* chars = reinterpret_cast<char*>(
6999 Isolate::Current()->current_zone()->Allocate(len + 1)); 7004 Isolate::Current()->current_zone()->Allocate(len + 1));
7000 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7005 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7001 return chars; 7006 return chars;
7002 } 7007 }
7003 7008
7004 } // namespace dart 7009 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/integers.dart ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698