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 | 203 v8::String::Utf8Value str(args[i]); |
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); | |
210 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); | 204 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
211 if (n != str.length()) { | 205 if (n != str.length()) { |
212 printf("Error in fwrite\n"); | 206 printf("Error in fwrite\n"); |
213 Exit(1); | 207 Exit(1); |
214 } | 208 } |
215 } | 209 } |
216 return Undefined(); | 210 return Undefined(); |
217 } | 211 } |
218 | 212 |
219 | 213 |
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 } | 1899 } |
1906 | 1900 |
1907 } // namespace v8 | 1901 } // namespace v8 |
1908 | 1902 |
1909 | 1903 |
1910 #ifndef GOOGLE3 | 1904 #ifndef GOOGLE3 |
1911 int main(int argc, char* argv[]) { | 1905 int main(int argc, char* argv[]) { |
1912 return v8::Shell::Main(argc, argv); | 1906 return v8::Shell::Main(argc, argv); |
1913 } | 1907 } |
1914 #endif | 1908 #endif |
OLD | NEW |