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; |
361 MaybeLocal<Script> result = | 363 MaybeLocal<Script> result = |
362 source_type == SCRIPT | 364 ScriptCompiler::Compile(context, &cached_source, compile_options); |
Dan Ehrenberg
2016/05/27 09:51:18
Add a check here that source_type == SCRIPT?
adamk
2016/05/27 18:53:07
Done.
| |
363 ? ScriptCompiler::Compile(context, &cached_source, compile_options) | |
364 : ScriptCompiler::CompileModule(context, &cached_source, | |
365 compile_options); | |
366 CHECK(data == NULL || !data->rejected); | 365 CHECK(data == NULL || !data->rejected); |
367 return result; | 366 return result; |
368 } | 367 } |
369 | 368 |
370 | 369 |
371 // Executes a string within the current v8 context. | 370 // Executes a string within the current v8 context. |
372 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | 371 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, |
373 Local<Value> name, bool print_result, | 372 Local<Value> name, bool print_result, |
374 bool report_exceptions, SourceType source_type) { | 373 bool report_exceptions, SourceType source_type) { |
375 HandleScope handle_scope(isolate); | 374 HandleScope handle_scope(isolate); |
(...skipping 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2526 } | 2525 } |
2527 | 2526 |
2528 } // namespace v8 | 2527 } // namespace v8 |
2529 | 2528 |
2530 | 2529 |
2531 #ifndef GOOGLE3 | 2530 #ifndef GOOGLE3 |
2532 int main(int argc, char* argv[]) { | 2531 int main(int argc, char* argv[]) { |
2533 return v8::Shell::Main(argc, argv); | 2532 return v8::Shell::Main(argc, argv); |
2534 } | 2533 } |
2535 #endif | 2534 #endif |
OLD | NEW |