| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
| 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
| 8 #define V8_SHARED | 8 #define V8_SHARED |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 return result; | 331 return result; |
| 332 } | 332 } |
| 333 | 333 |
| 334 | 334 |
| 335 // Compile a string within the current v8 context. | 335 // Compile a string within the current v8 context. |
| 336 MaybeLocal<Script> Shell::CompileString( | 336 MaybeLocal<Script> Shell::CompileString( |
| 337 Isolate* isolate, Local<String> source, Local<Value> name, | 337 Isolate* isolate, Local<String> source, Local<Value> name, |
| 338 ScriptCompiler::CompileOptions compile_options, SourceType source_type) { | 338 ScriptCompiler::CompileOptions compile_options, SourceType source_type) { |
| 339 Local<Context> context(isolate->GetCurrentContext()); | 339 Local<Context> context(isolate->GetCurrentContext()); |
| 340 ScriptOrigin origin(name); | 340 ScriptOrigin origin(name); |
| 341 if (compile_options == ScriptCompiler::kNoCompileOptions) { | 341 // TODO(adamk): Make use of compile options for Modules. |
| 342 if (compile_options == ScriptCompiler::kNoCompileOptions || |
| 343 source_type == MODULE) { |
| 342 ScriptCompiler::Source script_source(source, origin); | 344 ScriptCompiler::Source script_source(source, origin); |
| 343 return source_type == SCRIPT | 345 return source_type == SCRIPT |
| 344 ? ScriptCompiler::Compile(context, &script_source, | 346 ? ScriptCompiler::Compile(context, &script_source, |
| 345 compile_options) | 347 compile_options) |
| 346 : ScriptCompiler::CompileModule(context, &script_source, | 348 : ScriptCompiler::CompileModule(context, &script_source, |
| 347 compile_options); | 349 compile_options); |
| 348 } | 350 } |
| 349 | 351 |
| 350 ScriptCompiler::CachedData* data = | 352 ScriptCompiler::CachedData* data = |
| 351 CompileForCachedData(source, name, compile_options); | 353 CompileForCachedData(source, name, compile_options); |
| 352 ScriptCompiler::Source cached_source(source, origin, data); | 354 ScriptCompiler::Source cached_source(source, origin, data); |
| 353 if (compile_options == ScriptCompiler::kProduceCodeCache) { | 355 if (compile_options == ScriptCompiler::kProduceCodeCache) { |
| 354 compile_options = ScriptCompiler::kConsumeCodeCache; | 356 compile_options = ScriptCompiler::kConsumeCodeCache; |
| 355 } else if (compile_options == ScriptCompiler::kProduceParserCache) { | 357 } else if (compile_options == ScriptCompiler::kProduceParserCache) { |
| 356 compile_options = ScriptCompiler::kConsumeParserCache; | 358 compile_options = ScriptCompiler::kConsumeParserCache; |
| 357 } else { | 359 } else { |
| 358 DCHECK(false); // A new compile option? | 360 DCHECK(false); // A new compile option? |
| 359 } | 361 } |
| 360 if (data == NULL) compile_options = ScriptCompiler::kNoCompileOptions; | 362 if (data == NULL) compile_options = ScriptCompiler::kNoCompileOptions; |
| 363 DCHECK_EQ(SCRIPT, source_type); |
| 361 MaybeLocal<Script> result = | 364 MaybeLocal<Script> result = |
| 362 source_type == SCRIPT | 365 ScriptCompiler::Compile(context, &cached_source, compile_options); |
| 363 ? ScriptCompiler::Compile(context, &cached_source, compile_options) | |
| 364 : ScriptCompiler::CompileModule(context, &cached_source, | |
| 365 compile_options); | |
| 366 CHECK(data == NULL || !data->rejected); | 366 CHECK(data == NULL || !data->rejected); |
| 367 return result; | 367 return result; |
| 368 } | 368 } |
| 369 | 369 |
| 370 | 370 |
| 371 // Executes a string within the current v8 context. | 371 // Executes a string within the current v8 context. |
| 372 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | 372 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, |
| 373 Local<Value> name, bool print_result, | 373 Local<Value> name, bool print_result, |
| 374 bool report_exceptions, SourceType source_type) { | 374 bool report_exceptions, SourceType source_type) { |
| 375 HandleScope handle_scope(isolate); | 375 HandleScope handle_scope(isolate); |
| (...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 } | 2547 } |
| 2548 | 2548 |
| 2549 } // namespace v8 | 2549 } // namespace v8 |
| 2550 | 2550 |
| 2551 | 2551 |
| 2552 #ifndef GOOGLE3 | 2552 #ifndef GOOGLE3 |
| 2553 int main(int argc, char* argv[]) { | 2553 int main(int argc, char* argv[]) { |
| 2554 return v8::Shell::Main(argc, argv); | 2554 return v8::Shell::Main(argc, argv); |
| 2555 } | 2555 } |
| 2556 #endif | 2556 #endif |
| OLD | NEW |