tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TypeData.h (1314B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef jit_TypeData_h
      8 #define jit_TypeData_h
      9 
     10 #include "js/Value.h"
     11 
     12 namespace js {
     13 namespace jit {
     14 
     15 class TypeData {
     16  JSValueType type_;
     17 
     18 public:
     19  TypeData() : type_(JSVAL_TYPE_UNKNOWN) {}
     20  explicit TypeData(JSValueType type) : type_(type) {}
     21 
     22  JSValueType type() const { return type_; }
     23  bool hasData() const { return type_ != JSVAL_TYPE_UNKNOWN; }
     24 };
     25 
     26 class TypeDataList {
     27  const static size_t MaxLength = 6;
     28 
     29  uint8_t count_ = 0;
     30  TypeData typeData_[MaxLength];
     31 
     32 public:
     33  TypeDataList() {}
     34 
     35  uint8_t count() const { return count_; }
     36 
     37  void addTypeData(TypeData data) {
     38    MOZ_ASSERT(count_ < MaxLength);
     39    MOZ_ASSERT(!typeData_[count_].hasData());
     40    typeData_[count_++] = data;
     41  }
     42  TypeData get(uint32_t idx) const {
     43    MOZ_ASSERT(idx < count_);
     44    return typeData_[idx];
     45  }
     46 
     47  const TypeData* begin() const { return &typeData_[0]; }
     48  const TypeData* end() const { return begin() + count_; }
     49 };
     50 
     51 }  // namespace jit
     52 }  // namespace js
     53 
     54 #endif /* jit_TypeData_h */