| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 399 } |
| 400 | 400 |
| 401 | 401 |
| 402 // Helper functions that compile and run the source. | 402 // Helper functions that compile and run the source. |
| 403 static inline v8::MaybeLocal<v8::Value> CompileRun( | 403 static inline v8::MaybeLocal<v8::Value> CompileRun( |
| 404 v8::Local<v8::Context> context, const char* source) { | 404 v8::Local<v8::Context> context, const char* source) { |
| 405 return v8::Script::Compile(v8_str(source))->Run(context); | 405 return v8::Script::Compile(v8_str(source))->Run(context); |
| 406 } | 406 } |
| 407 | 407 |
| 408 | 408 |
| 409 // Compiles source as an ES6 module. | |
| 410 static inline v8::Local<v8::Value> CompileRunModule(const char* source) { | |
| 411 v8::ScriptCompiler::Source script_source(v8_str(source)); | |
| 412 return v8::ScriptCompiler::CompileModule(v8::Isolate::GetCurrent(), | |
| 413 &script_source)->Run(); | |
| 414 } | |
| 415 | |
| 416 | |
| 417 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { | 409 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { |
| 418 return v8::Script::Compile(source)->Run(); | 410 return v8::Script::Compile(source)->Run(); |
| 419 } | 411 } |
| 420 | 412 |
| 421 | 413 |
| 422 static inline v8::Local<v8::Value> ParserCacheCompileRun(const char* source) { | 414 static inline v8::Local<v8::Value> ParserCacheCompileRun(const char* source) { |
| 423 // Compile once just to get the preparse data, then compile the second time | 415 // Compile once just to get the preparse data, then compile the second time |
| 424 // using the data. | 416 // using the data. |
| 425 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 417 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 426 v8::ScriptCompiler::Source script_source(v8_str(source)); | 418 v8::ScriptCompiler::Source script_source(v8_str(source)); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 HandleAndZoneScope() {} | 636 HandleAndZoneScope() {} |
| 645 | 637 |
| 646 // Prefixing the below with main_ reduces a lot of naming clashes. | 638 // Prefixing the below with main_ reduces a lot of naming clashes. |
| 647 i::Zone* main_zone() { return &main_zone_; } | 639 i::Zone* main_zone() { return &main_zone_; } |
| 648 | 640 |
| 649 private: | 641 private: |
| 650 i::Zone main_zone_; | 642 i::Zone main_zone_; |
| 651 }; | 643 }; |
| 652 | 644 |
| 653 #endif // ifndef CCTEST_H_ | 645 #endif // ifndef CCTEST_H_ |
| OLD | NEW |