| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 Handle<Value> result = script->Run(); | 208 Handle<Value> result = script->Run(); |
| 209 if (result.IsEmpty()) { | 209 if (result.IsEmpty()) { |
| 210 ASSERT(try_catch.HasCaught()); | 210 ASSERT(try_catch.HasCaught()); |
| 211 // Print errors that happened during execution. | 211 // Print errors that happened during execution. |
| 212 if (report_exceptions && !FLAG_debugger) | 212 if (report_exceptions && !FLAG_debugger) |
| 213 ReportException(isolate, &try_catch); | 213 ReportException(isolate, &try_catch); |
| 214 return false; | 214 return false; |
| 215 } else { | 215 } else { |
| 216 ASSERT(!try_catch.HasCaught()); | 216 ASSERT(!try_catch.HasCaught()); |
| 217 if (print_result) { | 217 if (print_result) { |
| 218 #if !defined(V8_SHARED) |
| 218 if (options.test_shell) { | 219 if (options.test_shell) { |
| 220 #endif |
| 219 if (!result->IsUndefined()) { | 221 if (!result->IsUndefined()) { |
| 220 // If all went well and the result wasn't undefined then print | 222 // If all went well and the result wasn't undefined then print |
| 221 // the returned value. | 223 // the returned value. |
| 222 v8::String::Utf8Value str(result); | 224 v8::String::Utf8Value str(result); |
| 223 fwrite(*str, sizeof(**str), str.length(), stdout); | 225 fwrite(*str, sizeof(**str), str.length(), stdout); |
| 224 printf("\n"); | 226 printf("\n"); |
| 225 } | 227 } |
| 228 #if !defined(V8_SHARED) |
| 226 } else { | 229 } else { |
| 227 Context::Scope context_scope(utility_context_); | 230 Context::Scope context_scope(utility_context_); |
| 228 Handle<Object> global = utility_context_->Global(); | 231 Handle<Object> global = utility_context_->Global(); |
| 229 Handle<Value> fun = global->Get(String::New("Stringify")); | 232 Handle<Value> fun = global->Get(String::New("Stringify")); |
| 230 Handle<Value> argv[1] = { result }; | 233 Handle<Value> argv[1] = { result }; |
| 231 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv); | 234 Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv); |
| 232 v8::String::Utf8Value str(s); | 235 v8::String::Utf8Value str(s); |
| 233 fwrite(*str, sizeof(**str), str.length(), stdout); | 236 fwrite(*str, sizeof(**str), str.length(), stdout); |
| 234 printf("\n"); | 237 printf("\n"); |
| 235 } | 238 } |
| 236 } | 239 } |
| 240 #endif |
| 237 return true; | 241 return true; |
| 238 } | 242 } |
| 239 } | 243 } |
| 240 } | 244 } |
| 241 | 245 |
| 242 | 246 |
| 243 Handle<Value> Shell::Print(const Arguments& args) { | 247 Handle<Value> Shell::Print(const Arguments& args) { |
| 244 Handle<Value> val = Write(args); | 248 Handle<Value> val = Write(args); |
| 245 printf("\n"); | 249 printf("\n"); |
| 246 fflush(stdout); | 250 fflush(stdout); |
| (...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 } | 1985 } |
| 1982 | 1986 |
| 1983 } // namespace v8 | 1987 } // namespace v8 |
| 1984 | 1988 |
| 1985 | 1989 |
| 1986 #ifndef GOOGLE3 | 1990 #ifndef GOOGLE3 |
| 1987 int main(int argc, char* argv[]) { | 1991 int main(int argc, char* argv[]) { |
| 1988 return v8::Shell::Main(argc, argv); | 1992 return v8::Shell::Main(argc, argv); |
| 1989 } | 1993 } |
| 1990 #endif | 1994 #endif |
| OLD | NEW |