summaryrefslogtreecommitdiff
path: root/chromium/v8/src/debug/debug-property-iterator.h
blob: b28fe78ac88ef13c268afd0cb96ef0ffb89f55be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_DEBUG_DEBUG_PROPERTY_ITERATOR_H_
#define V8_DEBUG_DEBUG_PROPERTY_ITERATOR_H_

#include "include/v8-local-handle.h"
#include "include/v8-maybe.h"
#include "include/v8-object.h"
#include "src/debug/debug-interface.h"
#include "src/execution/isolate.h"
#include "src/handles/handles.h"
#include "src/objects/prototype.h"

namespace v8 {

class Name;

namespace internal {

class JSReceiver;

class DebugPropertyIterator final : public debug::PropertyIterator {
 public:
  V8_WARN_UNUSED_RESULT static std::unique_ptr<DebugPropertyIterator> Create(
      Isolate* isolate, Handle<JSReceiver> receiver, bool skip_indices);
  ~DebugPropertyIterator() override = default;
  DebugPropertyIterator(const DebugPropertyIterator&) = delete;
  DebugPropertyIterator& operator=(const DebugPropertyIterator&) = delete;

  bool Done() const override;
  V8_WARN_UNUSED_RESULT Maybe<bool> Advance() override;

  v8::Local<v8::Name> name() const override;
  bool is_native_accessor() override;
  bool has_native_getter() override;
  bool has_native_setter() override;
  v8::Maybe<v8::PropertyAttribute> attributes() override;
  v8::Maybe<v8::debug::PropertyDescriptor> descriptor() override;

  bool is_own() override;
  bool is_array_index() override;

 private:
  DebugPropertyIterator(Isolate* isolate, Handle<JSReceiver> receiver,
                        bool skip_indices);

  V8_WARN_UNUSED_RESULT bool FillKeysForCurrentPrototypeAndStage();
  bool should_move_to_next_stage() const;
  void CalculateNativeAccessorFlags();
  Handle<Name> raw_name() const;
  void AdvanceToPrototype();
  V8_WARN_UNUSED_RESULT bool AdvanceInternal();

  Isolate* isolate_;
  PrototypeIterator prototype_iterator_;
  enum {
    kExoticIndices = 0,
    kEnumerableStrings = 1,
    kAllProperties = 2
  } stage_ = kExoticIndices;
  bool skip_indices_;

  size_t current_key_index_;
  Handle<FixedArray> current_keys_;
  size_t current_keys_length_;

  bool calculated_native_accessor_flags_ = false;
  int native_accessor_flags_ = 0;
  bool is_own_ = true;
  bool is_done_ = false;
};
}  // namespace internal
}  // namespace v8

#endif  // V8_DEBUG_DEBUG_PROPERTY_ITERATOR_H_