| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/coverage.h" | 5 #include "vm/coverage.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| 11 #include "vm/json_stream.h" | 11 #include "vm/json_stream.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 DEFINE_FLAG(charp, coverage_dir, NULL, | 17 DEFINE_FLAG(charp, coverage_dir, NULL, |
| 18 "Enable writing coverage data into specified directory."); | 18 "Enable writing coverage data into specified directory."); |
| 19 | 19 |
| 20 | 20 |
| 21 // map[token_pos] -> line-number. | 21 // map[token_pos] -> line-number. |
| 22 static void ComputeTokenPosToLineNumberMap(const Script& script, | 22 static void ComputeTokenPosToLineNumberMap(const Script& script, |
| 23 GrowableArray<intptr_t>* map) { | 23 GrowableArray<intptr_t>* map) { |
| 24 const TokenStream& tkns = TokenStream::Handle(script.tokens()); | 24 const TokenStream& tkns = TokenStream::Handle(script.tokens()); |
| 25 const intptr_t len = ExternalTypedData::Handle(tkns.GetStream()).Length(); | 25 const intptr_t len = ExternalTypedData::Handle(tkns.GetStream()).Length(); |
| 26 map->Clear(); | 26 map->SetLength(len); |
| 27 #if defined(DEBUG) |
| 27 for (intptr_t i = 0; i < len; i++) { | 28 for (intptr_t i = 0; i < len; i++) { |
| 28 map->Add(-1); | 29 (*map)[i] = -1; |
| 29 } | 30 } |
| 31 #endif |
| 30 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 32 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); |
| 31 intptr_t cur_line = script.line_offset() + 1; | 33 intptr_t cur_line = script.line_offset() + 1; |
| 32 while (tkit.CurrentTokenKind() != Token::kEOS) { | 34 while (tkit.CurrentTokenKind() != Token::kEOS) { |
| 33 (*map)[tkit.CurrentPosition()] = cur_line; | 35 (*map)[tkit.CurrentPosition()] = cur_line; |
| 34 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 36 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
| 35 cur_line++; | 37 cur_line++; |
| 36 } | 38 } |
| 37 tkit.Advance(); | 39 tkit.Advance(); |
| 38 } | 40 } |
| 39 } | 41 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // functions. | 229 // functions. |
| 228 PrintClass(cls, jsarr); | 230 PrintClass(cls, jsarr); |
| 229 } | 231 } |
| 230 } | 232 } |
| 231 } | 233 } |
| 232 } | 234 } |
| 233 } | 235 } |
| 234 | 236 |
| 235 | 237 |
| 236 } // namespace dart | 238 } // namespace dart |
| OLD | NEW |