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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 if (*filename == NULL) { | 1029 if (*filename == NULL) { |
1030 return ThrowException(String::New("Error loading file")); | 1030 return ThrowException(String::New("Error loading file")); |
1031 } | 1031 } |
1032 char* chars = ReadChars(*filename, &size); | 1032 char* chars = ReadChars(*filename, &size); |
1033 if (chars == NULL) { | 1033 if (chars == NULL) { |
1034 return ThrowException(String::New("Error reading file")); | 1034 return ThrowException(String::New("Error reading file")); |
1035 } | 1035 } |
1036 // We skip checking the string for UTF8 characters and use it raw as | 1036 // We skip checking the string for UTF8 characters and use it raw as |
1037 // backing store for the external string with 8-bit characters. | 1037 // backing store for the external string with 8-bit characters. |
1038 BinaryResource* resource = new BinaryResource(chars, size); | 1038 BinaryResource* resource = new BinaryResource(chars, size); |
1039 i::Handle<i::String> string( | 1039 return String::NewExternal(resource); |
1040 FACTORY->NewExternalStringFromAscii(resource)); | |
1041 return Utils::ToLocal(string); | |
1042 } | 1040 } |
1043 | 1041 |
1044 | 1042 |
1045 #ifndef V8_SHARED | 1043 #ifndef V8_SHARED |
1046 static char* ReadToken(char* data, char token) { | 1044 static char* ReadToken(char* data, char token) { |
1047 char* next = i::OS::StrChr(data, token); | 1045 char* next = i::OS::StrChr(data, token); |
1048 if (next != NULL) { | 1046 if (next != NULL) { |
1049 *next = '\0'; | 1047 *next = '\0'; |
1050 return (next + 1); | 1048 return (next + 1); |
1051 } | 1049 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 } | 1523 } |
1526 | 1524 |
1527 } // namespace v8 | 1525 } // namespace v8 |
1528 | 1526 |
1529 | 1527 |
1530 #ifndef GOOGLE3 | 1528 #ifndef GOOGLE3 |
1531 int main(int argc, char* argv[]) { | 1529 int main(int argc, char* argv[]) { |
1532 return v8::Shell::Main(argc, argv); | 1530 return v8::Shell::Main(argc, argv); |
1533 } | 1531 } |
1534 #endif | 1532 #endif |
OLD | NEW |