Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: runtime/vm/coverage.cc

Issue 324203003: Add SetLength to GrowableArray and use it in code coverage. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/growable_array.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/growable_array.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698