Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/js/UbiNodeUtils.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 js_UbiNodeUtils_h
8
#define js_UbiNodeUtils_h
9
10
#include "jspubtd.h"
11
12
#include "js/UbiNode.h"
13
#include "js/UniquePtr.h"
14
15
using JS::ubi::Edge;
16
using JS::ubi::EdgeRange;
17
using JS::ubi::EdgeVector;
18
19
namespace JS {
20
namespace ubi {
21
// An EdgeRange concrete class that simply holds a vector of Edges,
22
// populated by the addTracerEdges method.
23
class SimpleEdgeRange : public EdgeRange {
24
    EdgeVector edges;
25
    size_t i;
26
27
  protected:
28
0
    void settle() {
29
0
        front_ = i < edges.length() ? &edges[i] : nullptr;
30
0
    }
31
32
  public:
33
0
    explicit SimpleEdgeRange() : edges(), i(0) { }
34
35
    bool addTracerEdges(JSRuntime* rt, void* thing, JS::TraceKind kind, bool wantNames);
36
37
0
    bool addEdge(Edge edge) {
38
0
        if(!edges.append(std::move(edge)))
39
0
            return false;
40
0
        settle();
41
0
        return true;
42
0
    }
43
44
0
    void popFront() override { i++; settle(); }
45
};
46
47
} // namespace JS
48
} // namespace ubi
49
50
51
#endif // js_UbiNodeUtils_h