OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 V8::SetCounterFunction(LookupCounter); | 337 V8::SetCounterFunction(LookupCounter); |
338 // Initialize the global objects | 338 // Initialize the global objects |
339 HandleScope scope; | 339 HandleScope scope; |
340 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); | 340 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); |
341 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); | 341 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); |
342 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); | 342 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); |
343 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); | 343 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); |
344 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); | 344 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); |
345 | 345 |
346 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); | 346 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); |
347 os_templ->Set(String::New("system"), FunctionTemplate::New(System)); | 347 AddOSMethods(os_templ); |
348 os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory)); | |
349 os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment)); | |
350 global_template->Set(String::New("os"), os_templ); | 348 global_template->Set(String::New("os"), os_templ); |
351 | 349 |
352 utility_context_ = Context::New(NULL, global_template); | 350 utility_context_ = Context::New(NULL, global_template); |
353 utility_context_->SetSecurityToken(Undefined()); | 351 utility_context_->SetSecurityToken(Undefined()); |
354 Context::Scope utility_scope(utility_context_); | 352 Context::Scope utility_scope(utility_context_); |
355 | 353 |
356 i::JSArguments js_args = i::FLAG_js_arguments; | 354 i::JSArguments js_args = i::FLAG_js_arguments; |
357 i::Handle<i::FixedArray> arguments_array = | 355 i::Handle<i::FixedArray> arguments_array = |
358 i::Factory::NewFixedArray(js_args.argc()); | 356 i::Factory::NewFixedArray(js_args.argc()); |
359 for (int j = 0; j < js_args.argc(); j++) { | 357 for (int j = 0; j < js_args.argc(); j++) { |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 return 0; | 668 return 0; |
671 } | 669 } |
672 | 670 |
673 | 671 |
674 } // namespace v8 | 672 } // namespace v8 |
675 | 673 |
676 | 674 |
677 int main(int argc, char* argv[]) { | 675 int main(int argc, char* argv[]) { |
678 return v8::Shell::Main(argc, argv); | 676 return v8::Shell::Main(argc, argv); |
679 } | 677 } |
OLD | NEW |