| 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) | 603 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) |
| 604 if (enter_context) utility_context->Exit(); | 604 if (enter_context) utility_context->Exit(); |
| 605 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 605 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
| 606 } | 606 } |
| 607 | 607 |
| 608 | 608 |
| 609 #ifndef V8_SHARED | 609 #ifndef V8_SHARED |
| 610 Handle<Array> Shell::GetCompletions(Isolate* isolate, | 610 Handle<Array> Shell::GetCompletions(Isolate* isolate, |
| 611 Handle<String> text, | 611 Handle<String> text, |
| 612 Handle<String> full) { | 612 Handle<String> full) { |
| 613 HandleScope handle_scope(isolate); | 613 EscapableHandleScope handle_scope(isolate); |
| 614 v8::Local<v8::Context> utility_context = | 614 v8::Local<v8::Context> utility_context = |
| 615 v8::Local<v8::Context>::New(isolate, utility_context_); | 615 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 616 v8::Context::Scope context_scope(utility_context); | 616 v8::Context::Scope context_scope(utility_context); |
| 617 Handle<Object> global = utility_context->Global(); | 617 Handle<Object> global = utility_context->Global(); |
| 618 Handle<Value> fun = | 618 Local<Value> fun = |
| 619 global->Get(String::NewFromUtf8(isolate, "GetCompletions")); | 619 global->Get(String::NewFromUtf8(isolate, "GetCompletions")); |
| 620 static const int kArgc = 3; | 620 static const int kArgc = 3; |
| 621 v8::Local<v8::Context> evaluation_context = | 621 v8::Local<v8::Context> evaluation_context = |
| 622 v8::Local<v8::Context>::New(isolate, evaluation_context_); | 622 v8::Local<v8::Context>::New(isolate, evaluation_context_); |
| 623 Handle<Value> argv[kArgc] = { evaluation_context->Global(), text, full }; | 623 Handle<Value> argv[kArgc] = { evaluation_context->Global(), text, full }; |
| 624 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 624 Local<Value> val = Local<Function>::Cast(fun)->Call(global, kArgc, argv); |
| 625 return handle_scope.Close(Handle<Array>::Cast(val)); | 625 return handle_scope.Escape(Local<Array>::Cast(val)); |
| 626 } | 626 } |
| 627 | 627 |
| 628 | 628 |
| 629 #ifdef ENABLE_DEBUGGER_SUPPORT | 629 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 630 Handle<Object> Shell::DebugMessageDetails(Isolate* isolate, | 630 Handle<Object> Shell::DebugMessageDetails(Isolate* isolate, |
| 631 Handle<String> message) { | 631 Handle<String> message) { |
| 632 HandleScope handle_scope(isolate); | 632 HandleScope handle_scope(isolate); |
| 633 v8::Local<v8::Context> context = | 633 v8::Local<v8::Context> context = |
| 634 v8::Local<v8::Context>::New(isolate, utility_context_); | 634 v8::Local<v8::Context>::New(isolate, utility_context_); |
| 635 v8::Context::Scope context_scope(context); | 635 v8::Context::Scope context_scope(context); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 } | 959 } |
| 960 | 960 |
| 961 | 961 |
| 962 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { | 962 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { |
| 963 #ifndef V8_SHARED | 963 #ifndef V8_SHARED |
| 964 // This needs to be a critical section since this is not thread-safe | 964 // This needs to be a critical section since this is not thread-safe |
| 965 i::LockGuard<i::Mutex> lock_guard(&context_mutex_); | 965 i::LockGuard<i::Mutex> lock_guard(&context_mutex_); |
| 966 #endif // V8_SHARED | 966 #endif // V8_SHARED |
| 967 // Initialize the global objects | 967 // Initialize the global objects |
| 968 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 968 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
| 969 HandleScope handle_scope(isolate); | 969 EscapableHandleScope handle_scope(isolate); |
| 970 Local<Context> context = Context::New(isolate, NULL, global_template); | 970 Local<Context> context = Context::New(isolate, NULL, global_template); |
| 971 ASSERT(!context.IsEmpty()); | 971 ASSERT(!context.IsEmpty()); |
| 972 Context::Scope scope(context); | 972 Context::Scope scope(context); |
| 973 | 973 |
| 974 #ifndef V8_SHARED | 974 #ifndef V8_SHARED |
| 975 i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory(); | 975 i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory(); |
| 976 i::JSArguments js_args = i::FLAG_js_arguments; | 976 i::JSArguments js_args = i::FLAG_js_arguments; |
| 977 i::Handle<i::FixedArray> arguments_array = | 977 i::Handle<i::FixedArray> arguments_array = |
| 978 factory->NewFixedArray(js_args.argc); | 978 factory->NewFixedArray(js_args.argc); |
| 979 for (int j = 0; j < js_args.argc; j++) { | 979 for (int j = 0; j < js_args.argc; j++) { |
| 980 i::Handle<i::String> arg = | 980 i::Handle<i::String> arg = |
| 981 factory->NewStringFromUtf8(i::CStrVector(js_args[j])); | 981 factory->NewStringFromUtf8(i::CStrVector(js_args[j])); |
| 982 arguments_array->set(j, *arg); | 982 arguments_array->set(j, *arg); |
| 983 } | 983 } |
| 984 i::Handle<i::JSArray> arguments_jsarray = | 984 i::Handle<i::JSArray> arguments_jsarray = |
| 985 factory->NewJSArrayWithElements(arguments_array); | 985 factory->NewJSArrayWithElements(arguments_array); |
| 986 context->Global()->Set(String::NewFromUtf8(isolate, "arguments"), | 986 context->Global()->Set(String::NewFromUtf8(isolate, "arguments"), |
| 987 Utils::ToLocal(arguments_jsarray)); | 987 Utils::ToLocal(arguments_jsarray)); |
| 988 #endif // V8_SHARED | 988 #endif // V8_SHARED |
| 989 return handle_scope.Close(context); | 989 return handle_scope.Escape(context); |
| 990 } | 990 } |
| 991 | 991 |
| 992 | 992 |
| 993 void Shell::Exit(int exit_code) { | 993 void Shell::Exit(int exit_code) { |
| 994 // Use _exit instead of exit to avoid races between isolate | 994 // Use _exit instead of exit to avoid races between isolate |
| 995 // threads and static destructors. | 995 // threads and static destructors. |
| 996 fflush(stdout); | 996 fflush(stdout); |
| 997 fflush(stderr); | 997 fflush(stderr); |
| 998 _exit(exit_code); | 998 _exit(exit_code); |
| 999 } | 999 } |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 } // namespace v8 | 1765 } // namespace v8 |
| 1766 | 1766 |
| 1767 | 1767 |
| 1768 #ifndef GOOGLE3 | 1768 #ifndef GOOGLE3 |
| 1769 int main(int argc, char* argv[]) { | 1769 int main(int argc, char* argv[]) { |
| 1770 return v8::Shell::Main(argc, argv); | 1770 return v8::Shell::Main(argc, argv); |
| 1771 } | 1771 } |
| 1772 #endif | 1772 #endif |
| OLD | NEW |