OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ | 5 #ifndef TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ |
6 #define TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ | 6 #define TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ |
7 | 7 |
8 #include <iostream> | 8 #include <iostream> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 10 matching lines...) Expand all Loading... |
21 class SourcePositionTableIterator; | 21 class SourcePositionTableIterator; |
22 | 22 |
23 namespace interpreter { | 23 namespace interpreter { |
24 | 24 |
25 class BytecodeArrayIterator; | 25 class BytecodeArrayIterator; |
26 | 26 |
27 class BytecodeExpectationsPrinter final { | 27 class BytecodeExpectationsPrinter final { |
28 public: | 28 public: |
29 explicit BytecodeExpectationsPrinter(v8::Isolate* i) | 29 explicit BytecodeExpectationsPrinter(v8::Isolate* i) |
30 : isolate_(i), | 30 : isolate_(i), |
| 31 module_(false), |
31 wrap_(true), | 32 wrap_(true), |
32 top_level_(false), | 33 top_level_(false), |
33 test_function_name_(kDefaultTopFunctionName) {} | 34 test_function_name_(kDefaultTopFunctionName) {} |
34 | 35 |
35 void PrintExpectation(std::ostream& stream, // NOLINT | 36 void PrintExpectation(std::ostream& stream, // NOLINT |
36 const std::string& snippet) const; | 37 const std::string& snippet) const; |
37 | 38 |
| 39 void set_module(bool module) { module_ = module; } |
| 40 bool module() const { return module_; } |
| 41 |
38 void set_wrap(bool wrap) { wrap_ = wrap; } | 42 void set_wrap(bool wrap) { wrap_ = wrap; } |
39 bool wrap() const { return wrap_; } | 43 bool wrap() const { return wrap_; } |
40 | 44 |
41 void set_top_level(bool top_level) { top_level_ = top_level; } | 45 void set_top_level(bool top_level) { top_level_ = top_level; } |
42 bool top_level() const { return top_level_; } | 46 bool top_level() const { return top_level_; } |
43 | 47 |
44 void set_test_function_name(const std::string& test_function_name) { | 48 void set_test_function_name(const std::string& test_function_name) { |
45 test_function_name_ = test_function_name; | 49 test_function_name_ = test_function_name; |
46 } | 50 } |
47 std::string test_function_name() const { return test_function_name_; } | 51 std::string test_function_name() const { return test_function_name_; } |
(...skipping 25 matching lines...) Expand all Loading... |
73 const std::string& body) const; | 77 const std::string& body) const; |
74 void PrintBytecodeArray(std::ostream& stream, // NOLINT | 78 void PrintBytecodeArray(std::ostream& stream, // NOLINT |
75 i::Handle<i::BytecodeArray> bytecode_array) const; | 79 i::Handle<i::BytecodeArray> bytecode_array) const; |
76 void PrintHandlers(std::ostream& stream, // NOLINT | 80 void PrintHandlers(std::ostream& stream, // NOLINT |
77 i::Handle<i::BytecodeArray> bytecode_array) const; | 81 i::Handle<i::BytecodeArray> bytecode_array) const; |
78 | 82 |
79 v8::Local<v8::String> V8StringFromUTF8(const char* data) const; | 83 v8::Local<v8::String> V8StringFromUTF8(const char* data) const; |
80 std::string WrapCodeInFunction(const char* function_name, | 84 std::string WrapCodeInFunction(const char* function_name, |
81 const std::string& function_body) const; | 85 const std::string& function_body) const; |
82 | 86 |
83 v8::Local<v8::Script> Compile(const char* program) const; | 87 v8::Local<v8::Script> CompileScript(const char* program) const; |
| 88 v8::Local<v8::Module> CompileModule(const char* program) const; |
84 void Run(v8::Local<v8::Script> script) const; | 89 void Run(v8::Local<v8::Script> script) const; |
85 i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal( | 90 i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal( |
86 const char* global_name) const; | 91 const char* global_name) const; |
| 92 i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForModule( |
| 93 v8::Local<v8::Module> module) const; |
87 i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForScript( | 94 i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForScript( |
88 v8::Local<v8::Script> script) const; | 95 v8::Local<v8::Script> script) const; |
89 | 96 |
90 i::Isolate* i_isolate() const { | 97 i::Isolate* i_isolate() const { |
91 return reinterpret_cast<i::Isolate*>(isolate_); | 98 return reinterpret_cast<i::Isolate*>(isolate_); |
92 } | 99 } |
93 | 100 |
94 v8::Isolate* isolate_; | 101 v8::Isolate* isolate_; |
| 102 bool module_; |
95 bool wrap_; | 103 bool wrap_; |
96 bool top_level_; | 104 bool top_level_; |
97 std::string test_function_name_; | 105 std::string test_function_name_; |
98 | 106 |
99 static const char* const kDefaultTopFunctionName; | 107 static const char* const kDefaultTopFunctionName; |
100 static const char* const kIndent; | 108 static const char* const kIndent; |
101 }; | 109 }; |
102 | 110 |
103 } // namespace interpreter | 111 } // namespace interpreter |
104 } // namespace internal | 112 } // namespace internal |
105 } // namespace v8 | 113 } // namespace v8 |
106 | 114 |
107 #endif // TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ | 115 #endif // TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ |
OLD | NEW |