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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 bool FLAG_debugger = false; | 199 bool FLAG_debugger = false; |
200 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 200 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
201 HandleScope handle_scope(isolate); | 201 HandleScope handle_scope(isolate); |
202 TryCatch try_catch; | 202 TryCatch try_catch; |
203 options.script_executed = true; | 203 options.script_executed = true; |
204 if (FLAG_debugger) { | 204 if (FLAG_debugger) { |
205 // When debugging make exceptions appear to be uncaught. | 205 // When debugging make exceptions appear to be uncaught. |
206 try_catch.SetVerbose(true); | 206 try_catch.SetVerbose(true); |
207 } | 207 } |
208 ScriptOrigin origin(name); | 208 ScriptOrigin origin(name); |
209 Handle<UnboundScript> script = ScriptCompiler::CompileUnbound( | 209 ScriptCompiler::Source script_source(source, origin); |
210 isolate, ScriptCompiler::Source(source, origin)); | 210 Handle<UnboundScript> script = |
| 211 ScriptCompiler::CompileUnbound(isolate, &script_source); |
211 if (script.IsEmpty()) { | 212 if (script.IsEmpty()) { |
212 // Print errors that happened during compilation. | 213 // Print errors that happened during compilation. |
213 if (report_exceptions && !FLAG_debugger) | 214 if (report_exceptions && !FLAG_debugger) |
214 ReportException(isolate, &try_catch); | 215 ReportException(isolate, &try_catch); |
215 return false; | 216 return false; |
216 } else { | 217 } else { |
217 PerIsolateData* data = PerIsolateData::Get(isolate); | 218 PerIsolateData* data = PerIsolateData::Get(isolate); |
218 Local<Context> realm = | 219 Local<Context> realm = |
219 Local<Context>::New(isolate, data->realms_[data->realm_current_]); | 220 Local<Context>::New(isolate, data->realms_[data->realm_current_]); |
220 realm->Enter(); | 221 realm->Enter(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // Realm.eval(i, s) evaluates s in realm i and returns the result. | 401 // Realm.eval(i, s) evaluates s in realm i and returns the result. |
401 void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) { | 402 void Shell::RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args) { |
402 Isolate* isolate = args.GetIsolate(); | 403 Isolate* isolate = args.GetIsolate(); |
403 PerIsolateData* data = PerIsolateData::Get(isolate); | 404 PerIsolateData* data = PerIsolateData::Get(isolate); |
404 int index = data->RealmIndexOrThrow(args, 0); | 405 int index = data->RealmIndexOrThrow(args, 0); |
405 if (index == -1) return; | 406 if (index == -1) return; |
406 if (args.Length() < 2 || !args[1]->IsString()) { | 407 if (args.Length() < 2 || !args[1]->IsString()) { |
407 Throw(args.GetIsolate(), "Invalid argument"); | 408 Throw(args.GetIsolate(), "Invalid argument"); |
408 return; | 409 return; |
409 } | 410 } |
| 411 ScriptCompiler::Source script_source(args[1]->ToString()); |
410 Handle<UnboundScript> script = ScriptCompiler::CompileUnbound( | 412 Handle<UnboundScript> script = ScriptCompiler::CompileUnbound( |
411 isolate, ScriptCompiler::Source(args[1]->ToString())); | 413 isolate, &script_source); |
412 if (script.IsEmpty()) return; | 414 if (script.IsEmpty()) return; |
413 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]); | 415 Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]); |
414 realm->Enter(); | 416 realm->Enter(); |
415 Handle<Value> result = script->BindToCurrentContext()->Run(); | 417 Handle<Value> result = script->BindToCurrentContext()->Run(); |
416 realm->Exit(); | 418 realm->Exit(); |
417 args.GetReturnValue().Set(result); | 419 args.GetReturnValue().Set(result); |
418 } | 420 } |
419 | 421 |
420 | 422 |
421 // Realm.shared is an accessor for a single shared value across realms. | 423 // Realm.shared is an accessor for a single shared value across realms. |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 } | 1769 } |
1768 | 1770 |
1769 } // namespace v8 | 1771 } // namespace v8 |
1770 | 1772 |
1771 | 1773 |
1772 #ifndef GOOGLE3 | 1774 #ifndef GOOGLE3 |
1773 int main(int argc, char* argv[]) { | 1775 int main(int argc, char* argv[]) { |
1774 return v8::Shell::Main(argc, argv); | 1776 return v8::Shell::Main(argc, argv); |
1775 } | 1777 } |
1776 #endif | 1778 #endif |
OLD | NEW |