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

Side by Side Diff: runtime/lib/integers.cc

Issue 11348259: Canonicalize all integer constants taht we create by parsing a string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const String& dummy_key = String::Handle(Symbols::Empty()); 188 const String& dummy_key = String::Handle(Symbols::Empty());
189 Scanner scanner(value, dummy_key); 189 Scanner scanner(value, dummy_key);
190 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); 190 const Scanner::GrowableTokenStream& tokens = scanner.GetStream();
191 String* int_string; 191 String* int_string;
192 bool is_positive; 192 bool is_positive;
193 if (Scanner::IsValidLiteral(tokens, 193 if (Scanner::IsValidLiteral(tokens,
194 Token::kINTEGER, 194 Token::kINTEGER,
195 &is_positive, 195 &is_positive,
196 &int_string)) { 196 &int_string)) {
197 if (is_positive) { 197 if (is_positive) {
198 return Integer::New(*int_string); 198 return Integer::NewCanonical(*int_string);
199 } 199 }
200 String& temp = String::Handle(); 200 String& temp = String::Handle();
201 temp = String::Concat(String::Handle(Symbols::New("-")), *int_string); 201 temp = String::Concat(String::Handle(Symbols::New("-")), *int_string);
202 return Integer::New(temp); 202 return Integer::NewCanonical(temp);
srdjan 2012/11/27 23:32:07 ditto.
siva 2012/11/28 00:22:56 Done.
203 } 203 }
204 204
205 GrowableArray<const Object*> args; 205 GrowableArray<const Object*> args;
206 args.Add(&value); 206 args.Add(&value);
207 Exceptions::ThrowByType(Exceptions::kFormat, args); 207 Exceptions::ThrowByType(Exceptions::kFormat, args);
208 return Object::null(); 208 return Object::null();
209 } 209 }
210 210
211 211
212 static RawInteger* ShiftOperationHelper(Token::Kind kind, 212 static RawInteger* ShiftOperationHelper(Token::Kind kind,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { 309 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) {
310 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); 310 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0));
311 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); 311 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value));
312 ASSERT(CheckInteger(value)); 312 ASSERT(CheckInteger(value));
313 ASSERT(CheckInteger(result)); 313 ASSERT(CheckInteger(result));
314 return result.AsValidInteger(); 314 return result.AsValidInteger();
315 } 315 }
316 316
317 } // namespace dart 317 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698