LCOV - code coverage report
Current view: top level - src - type-hints.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 4 50.0 %
Date: 2017-10-20 Functions: 1 2 50.0 %

          Line data    Source code
       1             : // Copyright 2015 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 V8_TYPE_HINTS_H_
       6             : #define V8_TYPE_HINTS_H_
       7             : 
       8             : #include "src/base/flags.h"
       9             : #include "src/utils.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : 
      14             : // Type hints for an binary operation.
      15             : enum class BinaryOperationHint : uint8_t {
      16             :   kNone,
      17             :   kSignedSmall,
      18             :   kSignedSmallInputs,
      19             :   kSigned32,
      20             :   kNumber,
      21             :   kNumberOrOddball,
      22             :   kString,
      23             :   kAny
      24             : };
      25             : 
      26           0 : inline size_t hash_value(BinaryOperationHint hint) {
      27           0 :   return static_cast<unsigned>(hint);
      28             : }
      29             : 
      30             : std::ostream& operator<<(std::ostream&, BinaryOperationHint);
      31             : 
      32             : // Type hints for an compare operation.
      33             : enum class CompareOperationHint : uint8_t {
      34             :   kNone,
      35             :   kSignedSmall,
      36             :   kNumber,
      37             :   kNumberOrOddball,
      38             :   kInternalizedString,
      39             :   kString,
      40             :   kSymbol,
      41             :   kReceiver,
      42             :   kAny
      43             : };
      44             : 
      45      117720 : inline size_t hash_value(CompareOperationHint hint) {
      46      117720 :   return static_cast<unsigned>(hint);
      47             : }
      48             : 
      49             : std::ostream& operator<<(std::ostream&, CompareOperationHint);
      50             : 
      51             : // Type hints for for..in statements.
      52             : enum class ForInHint : uint8_t {
      53             :   kNone,
      54             :   kEnumCacheKeysAndIndices,
      55             :   kEnumCacheKeys,
      56             :   kAny
      57             : };
      58             : 
      59             : std::ostream& operator<<(std::ostream&, ForInHint);
      60             : 
      61             : // Type hints for the ToBoolean type conversion.
      62             : enum class ToBooleanHint : uint16_t {
      63             :   kNone = 0u,
      64             :   kUndefined = 1u << 0,
      65             :   kBoolean = 1u << 1,
      66             :   kNull = 1u << 2,
      67             :   kSmallInteger = 1u << 3,
      68             :   kReceiver = 1u << 4,
      69             :   kString = 1u << 5,
      70             :   kSymbol = 1u << 6,
      71             :   kHeapNumber = 1u << 7,
      72             :   kAny = kUndefined | kBoolean | kNull | kSmallInteger | kReceiver | kString |
      73             :          kSymbol | kHeapNumber,
      74             :   kNeedsMap = kReceiver | kString | kSymbol | kHeapNumber,
      75             :   kCanBeUndetectable = kReceiver,
      76             : };
      77             : 
      78             : std::ostream& operator<<(std::ostream&, ToBooleanHint);
      79             : std::string ToString(ToBooleanHint);
      80             : 
      81             : typedef base::Flags<ToBooleanHint, uint16_t> ToBooleanHints;
      82             : 
      83             : std::ostream& operator<<(std::ostream&, ToBooleanHints);
      84             : std::string ToString(ToBooleanHints);
      85             : 
      86             : DEFINE_OPERATORS_FOR_FLAGS(ToBooleanHints)
      87             : 
      88             : enum StringAddFlags {
      89             :   // Omit both parameter checks.
      90             :   STRING_ADD_CHECK_NONE = 0,
      91             :   // Check left parameter.
      92             :   STRING_ADD_CHECK_LEFT = 1 << 0,
      93             :   // Check right parameter.
      94             :   STRING_ADD_CHECK_RIGHT = 1 << 1,
      95             :   // Check both parameters.
      96             :   STRING_ADD_CHECK_BOTH = STRING_ADD_CHECK_LEFT | STRING_ADD_CHECK_RIGHT,
      97             :   // Convert parameters when check fails (instead of throwing an exception).
      98             :   STRING_ADD_CONVERT = 1 << 2,
      99             :   STRING_ADD_CONVERT_LEFT = STRING_ADD_CHECK_LEFT | STRING_ADD_CONVERT,
     100             :   STRING_ADD_CONVERT_RIGHT = STRING_ADD_CHECK_RIGHT | STRING_ADD_CONVERT
     101             : };
     102             : 
     103             : std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);
     104             : 
     105             : }  // namespace internal
     106             : }  // namespace v8
     107             : 
     108             : #endif  // V8_TYPE_HINTS_H_

Generated by: LCOV version 1.10