| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); | 228 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); |
| 229 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); | 229 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); |
| 230 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); | 230 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); |
| 231 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); | 231 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); |
| 232 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); | 232 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); |
| 233 | 233 |
| 234 utility_context_ = Context::New(NULL, global_template); | 234 utility_context_ = Context::New(NULL, global_template); |
| 235 utility_context_->SetSecurityToken(Undefined()); | 235 utility_context_->SetSecurityToken(Undefined()); |
| 236 Context::Scope utility_scope(utility_context_); | 236 Context::Scope utility_scope(utility_context_); |
| 237 | 237 |
| 238 i::JSArguments js_args = i::FLAG_js_arguments; |
| 239 i::Handle<i::FixedArray> arguments_array = |
| 240 i::Factory::NewFixedArray(js_args.argc()); |
| 241 for (int j = 0; j < js_args.argc(); j++) { |
| 242 i::Handle<i::String> arg = |
| 243 i::Factory::NewStringFromUtf8(i::CStrVector(js_args[j])); |
| 244 arguments_array->set(j, *arg); |
| 245 } |
| 246 i::Handle<i::JSArray> arguments_jsarray = |
| 247 i::Factory::NewJSArrayWithElements(arguments_array); |
| 248 global_template->Set(String::New("arguments"), |
| 249 Utils::ToLocal(arguments_jsarray)); |
| 250 |
| 238 // Install the debugger object in the utility scope | 251 // Install the debugger object in the utility scope |
| 239 i::Debug::Load(); | 252 i::Debug::Load(); |
| 240 i::Debug::debug_context()->set_security_token(i::Heap::undefined_value()); | 253 i::Debug::debug_context()->set_security_token(i::Heap::undefined_value()); |
| 241 i::JSObject* debug = i::Debug::debug_context()->global(); | 254 i::JSObject* debug = i::Debug::debug_context()->global(); |
| 242 utility_context_->Global()->Set(String::New("$debug"), | 255 utility_context_->Global()->Set(String::New("$debug"), |
| 243 Utils::ToLocal(&debug)); | 256 Utils::ToLocal(&debug)); |
| 244 | 257 |
| 245 // Run the d8 shell utility script in the utility context | 258 // Run the d8 shell utility script in the utility context |
| 246 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); | 259 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); |
| 247 i::Vector<const char> shell_source | 260 i::Vector<const char> shell_source |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 return 0; | 355 return 0; |
| 343 } | 356 } |
| 344 | 357 |
| 345 | 358 |
| 346 } // namespace v8 | 359 } // namespace v8 |
| 347 | 360 |
| 348 | 361 |
| 349 int main(int argc, char* argv[]) { | 362 int main(int argc, char* argv[]) { |
| 350 return v8::Shell::Main(argc, argv); | 363 return v8::Shell::Main(argc, argv); |
| 351 } | 364 } |
| OLD | NEW |