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

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

Issue 1969563002: Eliminate GrowableTokenStream (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | runtime/vm/object.h » ('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 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 char* p_end = NULL; 199 char* p_end = NULL;
200 const int64_t int_value = strtoll(cstr, &p_end, 10); 200 const int64_t int_value = strtoll(cstr, &p_end, 10);
201 if (p_end == (cstr + len)) { 201 if (p_end == (cstr + len)) {
202 if ((int_value != LLONG_MIN) && (int_value != LLONG_MAX)) { 202 if ((int_value != LLONG_MIN) && (int_value != LLONG_MAX)) {
203 return Integer::New(int_value); 203 return Integer::New(int_value);
204 } 204 }
205 } 205 }
206 } 206 }
207 } 207 }
208 208
209 Scanner scanner(value, Symbols::Empty());
210 const Scanner::GrowableTokenStream& tokens = scanner.GetStream();
211 const String* int_string; 209 const String* int_string;
212 bool is_positive; 210 bool is_positive;
213 if (Scanner::IsValidLiteral(tokens, 211 if (Scanner::IsValidInteger(value, &is_positive, &int_string)) {
214 Token::kINTEGER,
215 &is_positive,
216 &int_string)) {
217 if (is_positive) { 212 if (is_positive) {
218 return Integer::New(*int_string); 213 return Integer::New(*int_string);
219 } 214 }
220 String& temp = String::Handle(); 215 String& temp = String::Handle();
221 temp = String::Concat(Symbols::Dash(), *int_string); 216 temp = String::Concat(Symbols::Dash(), *int_string);
222 return Integer::New(temp); 217 return Integer::New(temp);
223 } 218 }
224 219
225 return Integer::null(); 220 return Integer::null();
226 } 221 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { 397 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) {
403 // First arg is null type arguments, since class Bigint is not parameterized. 398 // First arg is null type arguments, since class Bigint is not parameterized.
404 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); 399 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1));
405 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); 400 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2));
406 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); 401 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3));
407 ASSERT(!digits.IsNull()); 402 ASSERT(!digits.IsNull());
408 return Bigint::New(neg.value(), used.Value(), digits); 403 return Bigint::New(neg.value(), used.Value(), digits);
409 } 404 }
410 405
411 } // namespace dart 406 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698