LCOV - code coverage report
Current view: top level - test/cctest/interpreter - bytecode-expectations-printer.h (source / functions) Hit Total Coverage
Test: app.info Lines: 4 4 100.0 %
Date: 2017-10-20 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             : 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         498 :         test_function_name_(kDefaultTopFunctionName) {}
      36             : 
      37             :   void PrintExpectation(std::ostream& stream,  // NOLINT
      38             :                         const std::string& snippet) const;
      39             : 
      40           6 :   void set_module(bool module) { module_ = module; }
      41             :   bool module() const { return module_; }
      42             : 
      43         192 :   void set_wrap(bool wrap) { wrap_ = wrap; }
      44             :   bool wrap() const { return wrap_; }
      45             : 
      46          18 :   void set_top_level(bool top_level) { top_level_ = top_level; }
      47             :   bool top_level() const { return top_level_; }
      48             : 
      49             :   void set_test_function_name(const std::string& test_function_name) {
      50             :     test_function_name_ = test_function_name;
      51             :   }
      52             :   std::string test_function_name() const { return test_function_name_; }
      53             : 
      54             :  private:
      55             :   void PrintEscapedString(std::ostream& stream,  // NOLINT
      56             :                           const std::string& string) const;
      57             :   void PrintBytecodeOperand(std::ostream& stream,  // NOLINT
      58             :                             const BytecodeArrayIterator& bytecode_iterator,
      59             :                             const Bytecode& bytecode, int op_index,
      60             :                             int parameter_count) const;
      61             :   void PrintBytecode(std::ostream& stream,  // NOLINT
      62             :                      const BytecodeArrayIterator& bytecode_iterator,
      63             :                      int parameter_count) const;
      64             :   void PrintSourcePosition(std::ostream& stream,  // NOLINT
      65             :                            SourcePositionTableIterator& source_iterator,
      66             :                            int bytecode_offset) const;
      67             :   void PrintV8String(std::ostream& stream,  // NOLINT
      68             :                      i::String* string) const;
      69             :   void PrintConstant(std::ostream& stream,  // NOLINT
      70             :                      i::Handle<i::Object> constant) const;
      71             :   void PrintFrameSize(std::ostream& stream,  // NOLINT
      72             :                       i::Handle<i::BytecodeArray> bytecode_array) const;
      73             :   void PrintBytecodeSequence(std::ostream& stream,  // NOLINT
      74             :                              i::Handle<i::BytecodeArray> bytecode_array) const;
      75             :   void PrintConstantPool(std::ostream& stream,  // NOLINT
      76             :                          i::FixedArray* constant_pool) const;
      77             :   void PrintCodeSnippet(std::ostream& stream,  // NOLINT
      78             :                         const std::string& body) const;
      79             :   void PrintBytecodeArray(std::ostream& stream,  // NOLINT
      80             :                           i::Handle<i::BytecodeArray> bytecode_array) const;
      81             :   void PrintHandlers(std::ostream& stream,  // NOLINT
      82             :                      i::Handle<i::BytecodeArray> bytecode_array) const;
      83             : 
      84             :   v8::Local<v8::String> V8StringFromUTF8(const char* data) const;
      85             :   std::string WrapCodeInFunction(const char* function_name,
      86             :                                  const std::string& function_body) const;
      87             : 
      88             :   v8::Local<v8::Script> CompileScript(const char* program) const;
      89             :   v8::Local<v8::Module> CompileModule(const char* program) const;
      90             :   void Run(v8::Local<v8::Script> script) const;
      91             :   i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal(
      92             :       const char* global_name) const;
      93             :   i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForModule(
      94             :       v8::Local<v8::Module> module) const;
      95             :   i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForScript(
      96             :       v8::Local<v8::Script> script) const;
      97             : 
      98             :   i::Isolate* i_isolate() const {
      99             :     return reinterpret_cast<i::Isolate*>(isolate_);
     100             :   }
     101             : 
     102             :   v8::Isolate* isolate_;
     103             :   bool module_;
     104             :   bool wrap_;
     105             :   bool top_level_;
     106             :   std::string test_function_name_;
     107             : 
     108             :   static const char* const kDefaultTopFunctionName;
     109             :   static const char* const kIndent;
     110             : };
     111             : 
     112             : }  // namespace interpreter
     113             : }  // namespace internal
     114             : }  // namespace v8
     115             : 
     116             : #endif  // TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_

Generated by: LCOV version 1.10