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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 return CompileWithOrigin(v8_str(source), v8_str(origin_url)); | 382 return CompileWithOrigin(v8_str(source), v8_str(origin_url)); |
383 } | 383 } |
384 | 384 |
385 | 385 |
386 // Helper functions that compile and run the source. | 386 // Helper functions that compile and run the source. |
387 static inline v8::Local<v8::Value> CompileRun(const char* source) { | 387 static inline v8::Local<v8::Value> CompileRun(const char* source) { |
388 return v8::Script::Compile(v8_str(source))->Run(); | 388 return v8::Script::Compile(v8_str(source))->Run(); |
389 } | 389 } |
390 | 390 |
391 | 391 |
| 392 // Compiles source as an ES6 module. |
| 393 static inline v8::Local<v8::Value> CompileRunModule(const char* source) { |
| 394 v8::ScriptCompiler::Source script_source(v8_str(source)); |
| 395 return v8::ScriptCompiler::CompileModule(v8::Isolate::GetCurrent(), |
| 396 &script_source)->Run(); |
| 397 } |
| 398 |
| 399 |
392 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { | 400 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { |
393 return v8::Script::Compile(source)->Run(); | 401 return v8::Script::Compile(source)->Run(); |
394 } | 402 } |
395 | 403 |
396 | 404 |
397 static inline v8::Local<v8::Value> ParserCacheCompileRun(const char* source) { | 405 static inline v8::Local<v8::Value> ParserCacheCompileRun(const char* source) { |
398 // Compile once just to get the preparse data, then compile the second time | 406 // Compile once just to get the preparse data, then compile the second time |
399 // using the data. | 407 // using the data. |
400 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 408 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
401 v8::ScriptCompiler::Source script_source(v8_str(source)); | 409 v8::ScriptCompiler::Source script_source(v8_str(source)); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 HandleAndZoneScope() {} | 605 HandleAndZoneScope() {} |
598 | 606 |
599 // Prefixing the below with main_ reduces a lot of naming clashes. | 607 // Prefixing the below with main_ reduces a lot of naming clashes. |
600 i::Zone* main_zone() { return &main_zone_; } | 608 i::Zone* main_zone() { return &main_zone_; } |
601 | 609 |
602 private: | 610 private: |
603 i::Zone main_zone_; | 611 i::Zone main_zone_; |
604 }; | 612 }; |
605 | 613 |
606 #endif // ifndef CCTEST_H_ | 614 #endif // ifndef CCTEST_H_ |
OLD | NEW |