1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_CODE_COMMENTS_H_
6#define RUNTIME_VM_CODE_COMMENTS_H_
7
8#if !defined(DART_PRECOMPILED_RUNTIME) && \
9 (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
10
11#include "vm/code_observers.h"
12#include "vm/compiler/assembler/assembler.h"
13#include "vm/object.h"
14
15namespace dart {
16
17class CodeCommentsWrapper final : public CodeComments {
18 public:
19 explicit CodeCommentsWrapper(const Code::Comments& comments)
20 : comments_(comments), string_(String::Handle()) {}
21
22 intptr_t Length() const override { return comments_.Length(); }
23
24 intptr_t PCOffsetAt(intptr_t i) const override {
25 return comments_.PCOffsetAt(i);
26 }
27
28 const char* CommentAt(intptr_t i) const override {
29 string_ = comments_.CommentAt(i);
30 return string_.ToCString();
31 }
32
33 private:
34 const Code::Comments& comments_;
35 String& string_;
36};
37
38const Code::Comments& CreateCommentsFrom(compiler::Assembler* assembler);
39
40
41} // namespace dart
42
43#endif // !defined(DART_PRECOMPILED_RUNTIME) && \
44 // (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
45#endif // RUNTIME_VM_CODE_COMMENTS_H_
46