| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 for (char* p = path_buffer; *p; p++) { | 580 for (char* p = path_buffer; *p; p++) { |
| 581 if (*p == '/' || *p == '\\') file_name_buffer = p + 1; | 581 if (*p == '/' || *p == '\\') file_name_buffer = p + 1; |
| 582 } | 582 } |
| 583 | 583 |
| 584 // Throw an exception in case the script couldn't be read. | 584 // Throw an exception in case the script couldn't be read. |
| 585 if (script.is_empty()) { | 585 if (script.is_empty()) { |
| 586 static const char* kErrorPrefix = "Unable to read from file "; | 586 static const char* kErrorPrefix = "Unable to read from file "; |
| 587 static const size_t kErrorPrefixLength = 25; // strlen is not constant | 587 static const size_t kErrorPrefixLength = 25; // strlen is not constant |
| 588 ASSERT(strlen(kErrorPrefix) == kErrorPrefixLength); | 588 ASSERT(strlen(kErrorPrefix) == kErrorPrefixLength); |
| 589 static const int kMaxErrorLength = kMaxPathLength + kErrorPrefixLength; | 589 static const int kMaxErrorLength = kMaxPathLength + kErrorPrefixLength; |
| 590 char error_buffer[kMaxErrorLength + 1]; | 590 EmbeddedVector<char, kMaxErrorLength + 1> error_buffer; |
| 591 OS::SNPrintF(error_buffer, kMaxErrorLength, "%s%s", | 591 OS::SNPrintF(error_buffer, "%s%s", kErrorPrefix, file_name_buffer); |
| 592 kErrorPrefix, file_name_buffer); | 592 v8::Handle<v8::String> error = |
| 593 v8::Handle<v8::String> error = v8::String::New(error_buffer); | 593 v8::String::New(error_buffer.start(), error_buffer.length()); |
| 594 v8::ThrowException(v8::Exception::Error(error)); | 594 v8::ThrowException(v8::Exception::Error(error)); |
| 595 return result; | 595 return result; |
| 596 } | 596 } |
| 597 | 597 |
| 598 // Convert the file name buffer into a script origin | 598 // Convert the file name buffer into a script origin |
| 599 v8::ScriptOrigin origin = | 599 v8::ScriptOrigin origin = |
| 600 v8::ScriptOrigin(v8::String::New(file_name_buffer)); | 600 v8::ScriptOrigin(v8::String::New(file_name_buffer)); |
| 601 | 601 |
| 602 // Compile and run script. | 602 // Compile and run script. |
| 603 v8::Handle<v8::String> source = | 603 v8::Handle<v8::String> source = |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 // All allocation spaces other than NEW_SPACE have the same effect. | 661 // All allocation spaces other than NEW_SPACE have the same effect. |
| 662 Heap::CollectGarbage(0, OLD_DATA_SPACE); | 662 Heap::CollectGarbage(0, OLD_DATA_SPACE); |
| 663 return v8::Undefined(); | 663 return v8::Undefined(); |
| 664 } | 664 } |
| 665 | 665 |
| 666 | 666 |
| 667 static GCExtension kGCExtension; | 667 static GCExtension kGCExtension; |
| 668 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 668 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
| 669 | 669 |
| 670 } } // namespace v8::internal | 670 } } // namespace v8::internal |
| OLD | NEW |