| OLD | NEW |
| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 if (FLAG_trace_intrinsified_natives) { | 178 if (FLAG_trace_intrinsified_natives) { |
| 179 OS::Print("Integer_equalToInteger %s == %s\n", | 179 OS::Print("Integer_equalToInteger %s == %s\n", |
| 180 left.ToCString(), right.ToCString()); | 180 left.ToCString(), right.ToCString()); |
| 181 } | 181 } |
| 182 return Bool::Get(left.CompareWith(right) == 0); | 182 return Bool::Get(left.CompareWith(right) == 0); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 DEFINE_NATIVE_ENTRY(Integer_parse, 1) { | 186 DEFINE_NATIVE_ENTRY(Integer_parse, 1) { |
| 187 GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); | 187 GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); |
| 188 const String& dummy_key = String::Handle(Symbols::Empty()); | 188 Scanner scanner(value, Symbols::Empty()); |
| 189 Scanner scanner(value, dummy_key); | |
| 190 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); | 189 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); |
| 191 String* int_string; | 190 String* int_string; |
| 192 bool is_positive; | 191 bool is_positive; |
| 193 if (Scanner::IsValidLiteral(tokens, | 192 if (Scanner::IsValidLiteral(tokens, |
| 194 Token::kINTEGER, | 193 Token::kINTEGER, |
| 195 &is_positive, | 194 &is_positive, |
| 196 &int_string)) { | 195 &int_string)) { |
| 197 if (is_positive) { | 196 if (is_positive) { |
| 198 return Integer::New(*int_string); | 197 return Integer::New(*int_string); |
| 199 } | 198 } |
| 200 String& temp = String::Handle(); | 199 String& temp = String::Handle(); |
| 201 temp = String::Concat(String::Handle(Symbols::New("-")), *int_string); | 200 temp = String::Concat(Symbols::Dash(), *int_string); |
| 202 return Integer::New(temp); | 201 return Integer::New(temp); |
| 203 } | 202 } |
| 204 | 203 |
| 205 const Array& args = Array::Handle(Array::New(1)); | 204 const Array& args = Array::Handle(Array::New(1)); |
| 206 args.SetAt(0, value); | 205 args.SetAt(0, value); |
| 207 Exceptions::ThrowByType(Exceptions::kFormat, args); | 206 Exceptions::ThrowByType(Exceptions::kFormat, args); |
| 208 return Object::null(); | 207 return Object::null(); |
| 209 } | 208 } |
| 210 | 209 |
| 211 | 210 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 307 |
| 309 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { | 308 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { |
| 310 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); | 309 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); |
| 311 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); | 310 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); |
| 312 ASSERT(CheckInteger(value)); | 311 ASSERT(CheckInteger(value)); |
| 313 ASSERT(CheckInteger(result)); | 312 ASSERT(CheckInteger(result)); |
| 314 return result.AsValidInteger(); | 313 return result.AsValidInteger(); |
| 315 } | 314 } |
| 316 | 315 |
| 317 } // namespace dart | 316 } // namespace dart |
| OLD | NEW |