OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 if (source.IsEmpty()) { | 277 if (source.IsEmpty()) { |
278 return ThrowException(String::New("Error loading file")); | 278 return ThrowException(String::New("Error loading file")); |
279 } | 279 } |
280 if (!ExecuteString(source, String::New(*file), false, true)) { | 280 if (!ExecuteString(source, String::New(*file), false, true)) { |
281 return ThrowException(String::New("Error executing file")); | 281 return ThrowException(String::New("Error executing file")); |
282 } | 282 } |
283 } | 283 } |
284 return Undefined(); | 284 return Undefined(); |
285 } | 285 } |
286 | 286 |
287 static size_t convertToUint(Local<Value> value_in, TryCatch* try_catch) { | 287 static int32_t convertToUint(Local<Value> value_in, TryCatch* try_catch) { |
288 if (value_in->IsUint32()) { | 288 if (value_in->IsInt32()) { |
289 return value_in->Uint32Value(); | 289 return value_in->Int32Value(); |
290 } | 290 } |
291 | 291 |
292 Local<Value> number = value_in->ToNumber(); | 292 Local<Value> number = value_in->ToNumber(); |
293 if (try_catch->HasCaught()) return 0; | 293 if (try_catch->HasCaught()) return 0; |
294 | 294 |
295 ASSERT(number->IsNumber()); | 295 ASSERT(number->IsNumber()); |
296 Local<Int32> int32 = number->ToInt32(); | 296 Local<Int32> int32 = number->ToInt32(); |
297 if (try_catch->HasCaught() || int32.IsEmpty()) return 0; | 297 if (try_catch->HasCaught() || int32.IsEmpty()) return 0; |
298 | 298 |
299 int32_t raw_value = int32->Int32Value(); | 299 int32_t raw_value = int32->Int32Value(); |
300 if (try_catch->HasCaught()) return 0; | 300 if (try_catch->HasCaught()) return 0; |
301 | 301 |
302 if (raw_value < 0) { | 302 if (raw_value < 0) { |
303 ThrowException(String::New("Array length must not be negative.")); | 303 ThrowException(String::New("Array length must not be negative.")); |
304 return 0; | 304 return 0; |
305 } | 305 } |
306 | 306 |
307 static const int kMaxLength = 0x3fffffff; | 307 static const int kMaxLength = 0x3fffffff; |
308 #ifndef V8_SHARED | 308 #ifndef V8_SHARED |
309 ASSERT(kMaxLength == i::ExternalArray::kMaxLength); | 309 ASSERT(kMaxLength == i::ExternalArray::kMaxLength); |
310 #endif // V8_SHARED | 310 #endif // V8_SHARED |
311 if (raw_value > static_cast<int32_t>(kMaxLength)) { | 311 if (raw_value > static_cast<int32_t>(kMaxLength)) { |
312 ThrowException( | 312 ThrowException( |
313 String::New("Array length exceeds maximum length.")); | 313 String::New("Array length exceeds maximum length.")); |
314 } | 314 } |
315 return static_cast<size_t>(raw_value); | 315 return raw_value; |
316 } | 316 } |
317 | 317 |
318 | 318 |
319 const char kArrayBufferMarkerPropName[] = "d8::_is_array_buffer_"; | 319 const char kArrayBufferMarkerPropName[] = "d8::_is_array_buffer_"; |
320 | 320 |
321 | 321 |
322 Handle<Value> Shell::CreateExternalArrayBuffer(int32_t length) { | 322 Handle<Value> Shell::CreateExternalArrayBuffer(int32_t length) { |
323 static const int32_t kMaxSize = 0x7fffffff; | 323 static const int32_t kMaxSize = 0x7fffffff; |
324 // Make sure the total size fits into a (signed) int. | 324 // Make sure the total size fits into a (signed) int. |
325 if (length < 0 || length > kMaxSize) { | 325 if (length < 0 || length > kMaxSize) { |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 } | 1542 } |
1543 | 1543 |
1544 } // namespace v8 | 1544 } // namespace v8 |
1545 | 1545 |
1546 | 1546 |
1547 #ifndef GOOGLE3 | 1547 #ifndef GOOGLE3 |
1548 int main(int argc, char* argv[]) { | 1548 int main(int argc, char* argv[]) { |
1549 return v8::Shell::Main(argc, argv); | 1549 return v8::Shell::Main(argc, argv); |
1550 } | 1550 } |
1551 #endif | 1551 #endif |
OLD | NEW |