| 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 | #include "vm/globals.h" // For INCLUDE_IL_PRINTER |
| 5 | #if defined(INCLUDE_IL_PRINTER) |
| 6 | |
| 7 | #include "vm/code_comments.h" |
| 8 | #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9 | #include "vm/compiler/assembler/assembler.h" |
| 10 | #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 11 | #include "vm/object.h" |
| 12 | |
| 13 | namespace dart { |
| 14 | |
| 15 | #if !defined(DART_PRECOMPILED_RUNTIME) |
| 16 | const CodeComments& CreateCommentsFrom(compiler::Assembler* assembler) { |
| 17 | const auto& comments = assembler->comments(); |
| 18 | Code::Comments& result = Code::Comments::New(count: comments.length()); |
| 19 | |
| 20 | for (intptr_t i = 0; i < comments.length(); i++) { |
| 21 | result.SetPCOffsetAt(idx: i, pc_offset: comments[i]->pc_offset()); |
| 22 | result.SetCommentAt(idx: i, comment: comments[i]->comment()); |
| 23 | } |
| 24 | |
| 25 | return result; |
| 26 | } |
| 27 | #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 28 | |
| 29 | } // namespace dart |
| 30 | #endif // defined(INCLUDE_IL_PRINTER) |
| 31 |
