LCOV - code coverage report
Current view: top level - js/src/vm - NumberObject.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 5 60.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       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 vm_NumberObject_h
       8             : #define vm_NumberObject_h
       9             : 
      10             : #include "jsnum.h"
      11             : 
      12             : namespace js {
      13             : 
      14             : class NumberObject : public NativeObject
      15             : {
      16             :     /* Stores this Number object's [[PrimitiveValue]]. */
      17             :     static const unsigned PRIMITIVE_VALUE_SLOT = 0;
      18             : 
      19             :   public:
      20             :     static const unsigned RESERVED_SLOTS = 1;
      21             : 
      22             :     static const Class class_;
      23             : 
      24             :     /*
      25             :      * Creates a new Number object boxing the given number.
      26             :      * If proto is nullptr, then Number.prototype will be used instead.
      27             :      */
      28             :     static inline NumberObject* create(JSContext* cx, double d,
      29             :                                        HandleObject proto = nullptr);
      30             : 
      31           0 :     double unbox() const {
      32           0 :         return getFixedSlot(PRIMITIVE_VALUE_SLOT).toNumber();
      33             :     }
      34             : 
      35             :   private:
      36          21 :     inline void setPrimitiveValue(double d) {
      37          21 :         setFixedSlot(PRIMITIVE_VALUE_SLOT, NumberValue(d));
      38          21 :     }
      39             : 
      40             :     /* For access to init, as Number.prototype is special. */
      41             :     friend JSObject*
      42             :     js::InitNumberClass(JSContext* cx, HandleObject global);
      43             : };
      44             : 
      45             : } // namespace js
      46             : 
      47             : #endif /* vm_NumberObject_h */

Generated by: LCOV version 1.13