Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/js/src/vm/NumberObject.h
Line
Count
Source (jump to first uncovered line)
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 GlobalObject;
15
16
class NumberObject : public NativeObject
17
{
18
    /* Stores this Number object's [[PrimitiveValue]]. */
19
    static const unsigned PRIMITIVE_VALUE_SLOT = 0;
20
21
  public:
22
    static const unsigned RESERVED_SLOTS = 1;
23
24
    static const Class class_;
25
26
    /*
27
     * Creates a new Number object boxing the given number.
28
     * If proto is nullptr, then Number.prototype will be used instead.
29
     */
30
    static inline NumberObject* create(JSContext* cx, double d,
31
                                       HandleObject proto = nullptr);
32
33
0
    double unbox() const {
34
0
        return getFixedSlot(PRIMITIVE_VALUE_SLOT).toNumber();
35
0
    }
36
37
  private:
38
0
    inline void setPrimitiveValue(double d) {
39
0
        setFixedSlot(PRIMITIVE_VALUE_SLOT, NumberValue(d));
40
0
    }
41
42
    /* For access to init, as Number.prototype is special. */
43
    friend JSObject*
44
    js::InitNumberClass(JSContext* cx, Handle<GlobalObject*> global);
45
};
46
47
} // namespace js
48
49
#endif /* vm_NumberObject_h */