OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 ASSERT(kMaxLength == i::ExternalArray::kMaxLength); | 293 ASSERT(kMaxLength == i::ExternalArray::kMaxLength); |
294 #endif // V8_SHARED | 294 #endif // V8_SHARED |
295 size_t length = 0; | 295 size_t length = 0; |
296 if (args[0]->IsUint32()) { | 296 if (args[0]->IsUint32()) { |
297 length = args[0]->Uint32Value(); | 297 length = args[0]->Uint32Value(); |
298 } else { | 298 } else { |
299 Local<Number> number = args[0]->ToNumber(); | 299 Local<Number> number = args[0]->ToNumber(); |
300 if (number.IsEmpty() || !number->IsNumber()) { | 300 if (number.IsEmpty() || !number->IsNumber()) { |
301 return ThrowException(String::New("Array length must be a number.")); | 301 return ThrowException(String::New("Array length must be a number.")); |
302 } | 302 } |
303 double raw_length = number->NumberValue(); | 303 int32_t raw_length = number->ToInt32()->Int32Value(); |
304 if (raw_length < 0) { | 304 if (raw_length < 0) { |
305 return ThrowException(String::New("Array length must not be negative.")); | 305 return ThrowException(String::New("Array length must not be negative.")); |
306 } | 306 } |
307 if (raw_length > kMaxLength) { | 307 if (raw_length > static_cast<int32_t>(kMaxLength)) { |
308 return ThrowException( | 308 return ThrowException( |
309 String::New("Array length exceeds maximum length.")); | 309 String::New("Array length exceeds maximum length.")); |
310 } | 310 } |
311 length = static_cast<size_t>(raw_length); | 311 length = static_cast<size_t>(raw_length); |
312 } | 312 } |
313 if (length > static_cast<size_t>(kMaxLength)) { | 313 if (length > static_cast<size_t>(kMaxLength)) { |
314 return ThrowException(String::New("Array length exceeds maximum length.")); | 314 return ThrowException(String::New("Array length exceeds maximum length.")); |
315 } | 315 } |
316 void* data = calloc(length, element_size); | 316 void* data = calloc(length, element_size); |
317 if (data == NULL) { | 317 if (data == NULL) { |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 } | 1328 } |
1329 | 1329 |
1330 } // namespace v8 | 1330 } // namespace v8 |
1331 | 1331 |
1332 | 1332 |
1333 #ifndef GOOGLE3 | 1333 #ifndef GOOGLE3 |
1334 int main(int argc, char* argv[]) { | 1334 int main(int argc, char* argv[]) { |
1335 return v8::Shell::Main(argc, argv); | 1335 return v8::Shell::Main(argc, argv); |
1336 } | 1336 } |
1337 #endif | 1337 #endif |
OLD | NEW |