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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 return val; | 193 return val; |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 Handle<Value> Shell::Write(const Arguments& args) { | 197 Handle<Value> Shell::Write(const Arguments& args) { |
198 for (int i = 0; i < args.Length(); i++) { | 198 for (int i = 0; i < args.Length(); i++) { |
199 HandleScope handle_scope; | 199 HandleScope handle_scope; |
200 if (i != 0) { | 200 if (i != 0) { |
201 printf(" "); | 201 printf(" "); |
202 } | 202 } |
203 v8::String::Utf8Value str(args[i]); | 203 |
| 204 // Explicitly catch potential exceptions in toString(). |
| 205 v8::TryCatch try_catch; |
| 206 Handle<String> str_obj = args[i]->ToString(); |
| 207 if (try_catch.HasCaught()) return try_catch.ReThrow(); |
| 208 |
| 209 v8::String::Utf8Value str(str_obj); |
204 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); | 210 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
205 if (n != str.length()) { | 211 if (n != str.length()) { |
206 printf("Error in fwrite\n"); | 212 printf("Error in fwrite\n"); |
207 Exit(1); | 213 Exit(1); |
208 } | 214 } |
209 } | 215 } |
210 return Undefined(); | 216 return Undefined(); |
211 } | 217 } |
212 | 218 |
213 | 219 |
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 } | 1905 } |
1900 | 1906 |
1901 } // namespace v8 | 1907 } // namespace v8 |
1902 | 1908 |
1903 | 1909 |
1904 #ifndef GOOGLE3 | 1910 #ifndef GOOGLE3 |
1905 int main(int argc, char* argv[]) { | 1911 int main(int argc, char* argv[]) { |
1906 return v8::Shell::Main(argc, argv); | 1912 return v8::Shell::Main(argc, argv); |
1907 } | 1913 } |
1908 #endif | 1914 #endif |
OLD | NEW |