LCOV - code coverage report
Current view: top level - test/cctest/interpreter - bytecode-expectations-printer.h (source / functions) Hit Total Coverage
Test: app.info Lines: 7 7 100.0 %
Date: 2019-04-17 Functions: 0 0 -

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_
       6             : #define TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_
       7             : 
       8             : #include <iostream>
       9             : #include <string>
      10             : #include <vector>
      11             : 
      12             : #include "src/interpreter/bytecodes.h"
      13             : #include "src/objects.h"
      14             : 
      15             : namespace v8 {
      16             : 
      17             : class Isolate;
      18             : 
      19             : namespace internal {
      20             : 
      21             : class BytecodeArray;
      22             : class SourcePositionTableIterator;
      23             : 
      24             : namespace interpreter {
      25             : 
      26             : class BytecodeArrayIterator;
      27             : 
      28         430 : class BytecodeExpectationsPrinter final {
      29             :  public:
      30             :   explicit BytecodeExpectationsPrinter(v8::Isolate* i)
      31             :       : isolate_(i),
      32             :         module_(false),
      33             :         wrap_(true),
      34             :         top_level_(false),
      35             :         print_callee_(false),
      36             :         oneshot_opt_(false),
      37         430 :         test_function_name_(kDefaultTopFunctionName) {}
      38             : 
      39             :   void PrintExpectation(std::ostream& stream,  // NOLINT
      40             :                         const std::string& snippet) const;
      41             : 
      42           5 :   void set_module(bool module) { module_ = module; }
      43             :   bool module() const { return module_; }
      44             : 
      45         175 :   void set_wrap(bool wrap) { wrap_ = wrap; }
      46             :   bool wrap() const { return wrap_; }
      47             : 
      48          35 :   void set_top_level(bool top_level) { top_level_ = top_level; }
      49             :   bool top_level() const { return top_level_; }
      50             : 
      51          10 :   void set_print_callee(bool print_callee) { print_callee_ = print_callee; }
      52             :   bool print_callee() { return print_callee_; }
      53             : 
      54          10 :   void set_oneshot_opt(bool oneshot_opt) { oneshot_opt_ = oneshot_opt; }
      55             :   bool oneshot_opt() { return oneshot_opt_; }
      56             : 
      57             :   void set_test_function_name(const std::string& test_function_name) {
      58             :     test_function_name_ = test_function_name;
      59             :   }
      60             :   std::string test_function_name() const { return test_function_name_; }
      61             : 
      62             :  private:
      63             :   void PrintEscapedString(std::ostream& stream,  // NOLINT
      64             :                           const std::string& string) const;
      65             :   void PrintBytecodeOperand(std::ostream& stream,  // NOLINT
      66             :                             const BytecodeArrayIterator& bytecode_iterator,
      67             :                             const Bytecode& bytecode, int op_index,
      68             :                             int parameter_count) const;
      69             :   void PrintBytecode(std::ostream& stream,  // NOLINT
      70             :                      const BytecodeArrayIterator& bytecode_iterator,
      71             :                      int parameter_count) const;
      72             :   void PrintSourcePosition(std::ostream& stream,  // NOLINT
      73             :                            SourcePositionTableIterator& source_iterator,
      74             :                            int bytecode_offset) const;
      75             :   void PrintV8String(std::ostream& stream,  // NOLINT
      76             :                      i::String string) const;
      77             :   void PrintConstant(std::ostream& stream,  // NOLINT
      78             :                      i::Handle<i::Object> constant) const;
      79             :   void PrintFrameSize(std::ostream& stream,  // NOLINT
      80             :                       i::Handle<i::BytecodeArray> bytecode_array) const;
      81             :   void PrintBytecodeSequence(std::ostream& stream,  // NOLINT
      82             :                              i::Handle<i::BytecodeArray> bytecode_array) const;
      83             :   void PrintConstantPool(std::ostream& stream,  // NOLINT
      84             :                          i::FixedArray constant_pool) const;
      85             :   void PrintCodeSnippet(std::ostream& stream,  // NOLINT
      86             :                         const std::string& body) const;
      87             :   void PrintBytecodeArray(std::ostream& stream,  // NOLINT
      88             :                           i::Handle<i::BytecodeArray> bytecode_array) const;
      89             :   void PrintHandlers(std::ostream& stream,  // NOLINT
      90             :                      i::Handle<i::BytecodeArray> bytecode_array) const;
      91             : 
      92             :   v8::Local<v8::String> V8StringFromUTF8(const char* data) const;
      93             :   std::string WrapCodeInFunction(const char* function_name,
      94             :                                  const std::string& function_body) const;
      95             : 
      96             :   v8::Local<v8::Script> CompileScript(const char* program) const;
      97             :   v8::Local<v8::Module> CompileModule(const char* program) const;
      98             :   void Run(v8::Local<v8::Script> script) const;
      99             :   i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal(
     100             :       const char* global_name) const;
     101             :   i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForModule(
     102             :       v8::Local<v8::Module> module) const;
     103             :   i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForScript(
     104             :       v8::Local<v8::Script> script) const;
     105             :   i::Handle<i::BytecodeArray> GetBytecodeArrayOfCallee(
     106             :       const char* source_code) const;
     107             : 
     108             :   i::Isolate* i_isolate() const {
     109             :     return reinterpret_cast<i::Isolate*>(isolate_);
     110             :   }
     111             : 
     112             :   v8::Isolate* isolate_;
     113             :   bool module_;
     114             :   bool wrap_;
     115             :   bool top_level_;
     116             :   bool print_callee_;
     117             :   bool oneshot_opt_;
     118             :   std::string test_function_name_;
     119             : 
     120             :   static const char* const kDefaultTopFunctionName;
     121             :   static const char* const kIndent;
     122             : };
     123             : 
     124             : }  // namespace interpreter
     125             : }  // namespace internal
     126             : }  // namespace v8
     127             : 
     128             : #endif  // TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_

Generated by: LCOV version 1.10