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

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

Issue 2628693004: TokenPositions on more nodes when running from Kernel (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #if !defined(DART_PRECOMPILED_RUNTIME) 4 #if !defined(DART_PRECOMPILED_RUNTIME)
5 5
6 #include <map> 6 #include <map>
7 #include <vector> 7 #include <vector>
8 8
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // 11... 365 // 11...
366 ASSERT(offset_ + 4 <= size_); 366 ASSERT(offset_ + 4 <= size_);
367 uint32_t value = ((byte0 & ~0xc0) << 24) | (buffer_[offset_ + 1] << 16) | 367 uint32_t value = ((byte0 & ~0xc0) << 24) | (buffer_[offset_ + 1] << 16) |
368 (buffer_[offset_ + 2] << 8) | 368 (buffer_[offset_ + 2] << 8) |
369 (buffer_[offset_ + 3] << 0); 369 (buffer_[offset_ + 3] << 0);
370 offset_ += 4; 370 offset_ += 4;
371 return value; 371 return value;
372 } 372 }
373 } 373 }
374 374
375 /**
376 * Read and return a TokenPosition from this reader.
377 */
375 TokenPosition ReadPosition() { 378 TokenPosition ReadPosition() {
376 intptr_t value = ReadUInt(); 379 intptr_t value = ReadUInt();
Kevin Millikin (Google) 2017/01/12 13:43:04 Just do: intptr_t value = ReadUInt() - 1;
jensj 2017/01/13 10:14:44 Done.
377 // Position is saved as unsigned, 380 // Position is saved as unsigned,
378 // but actually ranges from -1 and up (thus the -1) 381 // but actually ranges from -1 and up (thus the -1)
379 return TokenPosition(value - 1); 382 --value;
383 TokenPosition result = TokenPosition(value);
384 max_position_ = Utils::Maximum(max_position_, result);
385 if (min_position_.IsNoSource()) {
386 min_position_ = result;
387 } else if (result.IsReal()) {
388 min_position_ = Utils::Minimum(min_position_, result);
389 }
390
391 return result;
380 } 392 }
381 393
382 intptr_t ReadListLength() { return ReadUInt(); } 394 intptr_t ReadListLength() { return ReadUInt(); }
383 395
384 uint8_t ReadByte() { return buffer_[offset_++]; } 396 uint8_t ReadByte() { return buffer_[offset_++]; }
385 397
386 bool ReadBool() { return (ReadByte() & 1) == 1; } 398 bool ReadBool() { return (ReadByte() & 1) == 1; }
387 399
388 word ReadFlags() { return ReadByte(); } 400 word ReadFlags() { return ReadByte(); }
389 401
(...skipping 23 matching lines...) Expand all
413 "Reading Kernel file: Expected to be at EOF " 425 "Reading Kernel file: Expected to be at EOF "
414 "(offset: %" Pd64 ", size: %" Pd64 ")", 426 "(offset: %" Pd64 ", size: %" Pd64 ")",
415 offset_, size_); 427 offset_, size_);
416 } 428 }
417 } 429 }
418 430
419 void DumpOffset(const char* str) { 431 void DumpOffset(const char* str) {
420 OS::PrintErr("@%" Pd64 " %s\n", offset_, str); 432 OS::PrintErr("@%" Pd64 " %s\n", offset_, str);
421 } 433 }
422 434
435 TokenPosition max_position() { return max_position_; }
436 TokenPosition min_position() { return min_position_; }
437 intptr_t current_script_id() { return current_script_id_; }
438 void set_current_script_id(intptr_t script_id) {
439 current_script_id_ = script_id;
440 }
441
423 template <typename T, typename RT> 442 template <typename T, typename RT>
424 T* ReadOptional() { 443 T* ReadOptional() {
425 Tag tag = ReadTag(); 444 Tag tag = ReadTag();
426 if (tag == kNothing) { 445 if (tag == kNothing) {
427 return NULL; 446 return NULL;
428 } 447 }
429 ASSERT(tag == kSomething); 448 ASSERT(tag == kSomething);
430 return RT::ReadFrom(this); 449 return RT::ReadFrom(this);
431 } 450 }
432 451
433 template <typename T> 452 template <typename T>
434 T* ReadOptional() { 453 T* ReadOptional() {
435 return ReadOptional<T, T>(); 454 return ReadOptional<T, T>();
436 } 455 }
437 456
438 ReaderHelper* helper() { return &builder_; } 457 ReaderHelper* helper() { return &builder_; }
439 458
440 private: 459 private:
441 const uint8_t* buffer_; 460 const uint8_t* buffer_;
442 int64_t size_; 461 int64_t size_;
443 int64_t offset_; 462 int64_t offset_;
444 ReaderHelper builder_; 463 ReaderHelper builder_;
464 TokenPosition max_position_;
Kevin Millikin (Google) 2017/01/12 13:43:04 Please document these.
jensj 2017/01/13 10:14:44 I've added some comments (though at the getters in
465 TokenPosition min_position_;
466 intptr_t current_script_id_;
467
468 friend class PositionScope;
445 }; 469 };
446 470
447 471
448 class WriterHelper { 472 class WriterHelper {
449 public: 473 public:
450 WriterHelper() : labels_(NULL) {} 474 WriterHelper() : labels_(NULL) {}
451 475
452 void SetProgram(Program* program) { 476 void SetProgram(Program* program) {
453 program_ = program; 477 program_ = program;
454 for (int i = 0; i < program->libraries().length(); i++) { 478 for (int i = 0; i < program->libraries().length(); i++) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 638
615 WriterHelper* helper() { return &helper_; } 639 WriterHelper* helper() { return &helper_; }
616 640
617 private: 641 private:
618 ByteWriter* out_; 642 ByteWriter* out_;
619 WriterHelper helper_; 643 WriterHelper helper_;
620 int64_t offset_; 644 int64_t offset_;
621 }; 645 };
622 646
623 647
648 class PositionScope {
Kevin Millikin (Google) 2017/01/12 13:43:04 Document this class.
jensj 2017/01/13 10:14:44 Done.
649 public:
650 explicit PositionScope(Reader* reader)
651 : reader_(reader),
652 min_(reader->min_position_),
653 max_(reader->max_position_) {
654 reader->min_position_ = reader->max_position_ = TokenPosition::kNoSource;
655 }
656
657 ~PositionScope() {
658 if (reader_->min_position_.IsNoSource()) {
659 reader_->min_position_ = min_;
660 } else if (min_.IsReal()) {
661 reader_->min_position_ = Utils::Minimum(reader_->min_position_, min_);
662 }
663 reader_->max_position_ = Utils::Maximum(reader_->max_position_, max_);
664 }
665
666 private:
667 Reader* reader_;
668 TokenPosition min_;
669 TokenPosition max_;
670 };
671
624 template <typename T> 672 template <typename T>
625 template <typename IT> 673 template <typename IT>
626 void List<T>::ReadFrom(Reader* reader, TreeNode* parent) { 674 void List<T>::ReadFrom(Reader* reader, TreeNode* parent) {
627 TRACE_READ_OFFSET(); 675 TRACE_READ_OFFSET();
628 ASSERT(parent != NULL); 676 ASSERT(parent != NULL);
629 int length = reader->ReadListLength(); 677 int length = reader->ReadListLength();
630 EnsureInitialized(length); 678 EnsureInitialized(length);
631 679
632 for (int i = 0; i < length_; i++) { 680 for (int i = 0; i < length_; i++) {
633 IT* object = GetOrCreate<IT>(i, parent); 681 IT* object = GetOrCreate<IT>(i, parent);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 913 }
866 914
867 915
868 Library* Library::ReadFrom(Reader* reader) { 916 Library* Library::ReadFrom(Reader* reader) {
869 TRACE_READ_OFFSET(); 917 TRACE_READ_OFFSET();
870 int flags = reader->ReadFlags(); 918 int flags = reader->ReadFlags();
871 ASSERT(flags == 0); // external libraries not supported 919 ASSERT(flags == 0); // external libraries not supported
872 name_ = Reference::ReadStringFrom(reader); 920 name_ = Reference::ReadStringFrom(reader);
873 import_uri_ = Reference::ReadStringFrom(reader); 921 import_uri_ = Reference::ReadStringFrom(reader);
874 source_uri_index_ = reader->ReadUInt(); 922 source_uri_index_ = reader->ReadUInt();
923 reader->set_current_script_id(source_uri_index_);
875 924
876 int num_classes = reader->ReadUInt(); 925 int num_classes = reader->ReadUInt();
877 classes().EnsureInitialized(num_classes); 926 classes().EnsureInitialized(num_classes);
878 for (int i = 0; i < num_classes; i++) { 927 for (int i = 0; i < num_classes; i++) {
879 Tag tag = reader->ReadTag(); 928 Tag tag = reader->ReadTag();
880 if (tag == kNormalClass) { 929 if (tag == kNormalClass) {
881 NormalClass* klass = classes().GetOrCreate<NormalClass>(i, this); 930 NormalClass* klass = classes().GetOrCreate<NormalClass>(i, this);
882 klass->ReadFrom(reader); 931 klass->ReadFrom(reader);
883 } else { 932 } else {
884 ASSERT(tag == kMixinClass); 933 ASSERT(tag == kMixinClass);
(...skipping 30 matching lines...) Expand all
915 } 964 }
916 965
917 966
918 Class* Class::ReadFrom(Reader* reader) { 967 Class* Class::ReadFrom(Reader* reader) {
919 TRACE_READ_OFFSET(); 968 TRACE_READ_OFFSET();
920 969
921 position_ = reader->ReadPosition(); 970 position_ = reader->ReadPosition();
922 is_abstract_ = reader->ReadBool(); 971 is_abstract_ = reader->ReadBool();
923 name_ = Reference::ReadStringFrom(reader); 972 name_ = Reference::ReadStringFrom(reader);
924 source_uri_index_ = reader->ReadUInt(); 973 source_uri_index_ = reader->ReadUInt();
974 reader->set_current_script_id(source_uri_index_);
925 annotations_.ReadFromStatic<Expression>(reader); 975 annotations_.ReadFromStatic<Expression>(reader);
926 976
927 return this; 977 return this;
928 } 978 }
929 979
930 980
931 void Class::WriteTo(Writer* writer) { 981 void Class::WriteTo(Writer* writer) {
932 TRACE_WRITE_OFFSET(); 982 TRACE_WRITE_OFFSET();
933 writer->WritePosition(position_); 983 writer->WritePosition(position_);
934 writer->WriteBool(is_abstract_); 984 writer->WriteBool(is_abstract_);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 Field* Field::ReadFrom(Reader* reader) { 1215 Field* Field::ReadFrom(Reader* reader) {
1166 TRACE_READ_OFFSET(); 1216 TRACE_READ_OFFSET();
1167 Tag tag = reader->ReadTag(); 1217 Tag tag = reader->ReadTag();
1168 ASSERT(tag == kField); 1218 ASSERT(tag == kField);
1169 1219
1170 position_ = reader->ReadPosition(); 1220 position_ = reader->ReadPosition();
1171 end_position_ = reader->ReadPosition(); 1221 end_position_ = reader->ReadPosition();
1172 flags_ = reader->ReadFlags(); 1222 flags_ = reader->ReadFlags();
1173 name_ = Name::ReadFrom(reader); 1223 name_ = Name::ReadFrom(reader);
1174 source_uri_index_ = reader->ReadUInt(); 1224 source_uri_index_ = reader->ReadUInt();
1225 reader->set_current_script_id(source_uri_index_);
1175 annotations_.ReadFromStatic<Expression>(reader); 1226 annotations_.ReadFromStatic<Expression>(reader);
1176 type_ = DartType::ReadFrom(reader); 1227 type_ = DartType::ReadFrom(reader);
1177 inferred_value_ = reader->ReadOptional<InferredValue>(); 1228 inferred_value_ = reader->ReadOptional<InferredValue>();
1178 initializer_ = reader->ReadOptional<Expression>(); 1229 initializer_ = reader->ReadOptional<Expression>();
1179 return this; 1230 return this;
1180 } 1231 }
1181 1232
1182 1233
1183 void Field::WriteTo(Writer* writer) { 1234 void Field::WriteTo(Writer* writer) {
1184 TRACE_WRITE_OFFSET(); 1235 TRACE_WRITE_OFFSET();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 Tag tag = reader->ReadTag(); 1283 Tag tag = reader->ReadTag();
1233 ASSERT(tag == kProcedure); 1284 ASSERT(tag == kProcedure);
1234 1285
1235 VariableScope<ReaderHelper> parameters(reader->helper()); 1286 VariableScope<ReaderHelper> parameters(reader->helper());
1236 position_ = reader->ReadPosition(); 1287 position_ = reader->ReadPosition();
1237 end_position_ = reader->ReadPosition(); 1288 end_position_ = reader->ReadPosition();
1238 kind_ = static_cast<ProcedureKind>(reader->ReadByte()); 1289 kind_ = static_cast<ProcedureKind>(reader->ReadByte());
1239 flags_ = reader->ReadFlags(); 1290 flags_ = reader->ReadFlags();
1240 name_ = Name::ReadFrom(reader); 1291 name_ = Name::ReadFrom(reader);
1241 source_uri_index_ = reader->ReadUInt(); 1292 source_uri_index_ = reader->ReadUInt();
1293 reader->set_current_script_id(source_uri_index_);
1242 annotations_.ReadFromStatic<Expression>(reader); 1294 annotations_.ReadFromStatic<Expression>(reader);
1243 function_ = reader->ReadOptional<FunctionNode>(); 1295 function_ = reader->ReadOptional<FunctionNode>();
1244 return this; 1296 return this;
1245 } 1297 }
1246 1298
1247 1299
1248 void Procedure::WriteTo(Writer* writer) { 1300 void Procedure::WriteTo(Writer* writer) {
1249 TRACE_WRITE_OFFSET(); 1301 TRACE_WRITE_OFFSET();
1250 writer->WriteTag(kProcedure); 1302 writer->WriteTag(kProcedure);
1251 1303
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 TRACE_WRITE_OFFSET(); 2182 TRACE_WRITE_OFFSET();
2131 VariableScope<WriterHelper> parameters(writer->helper()); 2183 VariableScope<WriterHelper> parameters(writer->helper());
2132 writer->WriteTag(kFunctionExpression); 2184 writer->WriteTag(kFunctionExpression);
2133 function_->WriteTo(writer); 2185 function_->WriteTo(writer);
2134 } 2186 }
2135 2187
2136 2188
2137 Let* Let::ReadFrom(Reader* reader) { 2189 Let* Let::ReadFrom(Reader* reader) {
2138 TRACE_READ_OFFSET(); 2190 TRACE_READ_OFFSET();
2139 VariableScope<ReaderHelper> vars(reader->helper()); 2191 VariableScope<ReaderHelper> vars(reader->helper());
2192 PositionScope scope(reader);
2193
2140 Let* let = new Let(); 2194 Let* let = new Let();
2141 let->variable_ = VariableDeclaration::ReadFromImpl(reader); 2195 let->variable_ = VariableDeclaration::ReadFromImpl(reader);
2142 let->body_ = Expression::ReadFrom(reader); 2196 let->body_ = Expression::ReadFrom(reader);
2197 let->position_ = reader->min_position();
2198 let->end_position_ = reader->max_position();
2199
2143 return let; 2200 return let;
2144 } 2201 }
2145 2202
2146 2203
2147 void Let::WriteTo(Writer* writer) { 2204 void Let::WriteTo(Writer* writer) {
2148 TRACE_WRITE_OFFSET(); 2205 TRACE_WRITE_OFFSET();
2149 VariableScope<WriterHelper> vars(writer->helper()); 2206 VariableScope<WriterHelper> vars(writer->helper());
2150 writer->WriteTag(kLet); 2207 writer->WriteTag(kLet);
2151 variable_->WriteToImpl(writer); 2208 variable_->WriteToImpl(writer);
2152 body_->WriteTo(writer); 2209 body_->WriteTo(writer);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2283
2227 void ExpressionStatement::WriteTo(Writer* writer) { 2284 void ExpressionStatement::WriteTo(Writer* writer) {
2228 TRACE_WRITE_OFFSET(); 2285 TRACE_WRITE_OFFSET();
2229 writer->WriteTag(kExpressionStatement); 2286 writer->WriteTag(kExpressionStatement);
2230 expression_->WriteTo(writer); 2287 expression_->WriteTo(writer);
2231 } 2288 }
2232 2289
2233 2290
2234 Block* Block::ReadFromImpl(Reader* reader) { 2291 Block* Block::ReadFromImpl(Reader* reader) {
2235 TRACE_READ_OFFSET(); 2292 TRACE_READ_OFFSET();
2293 PositionScope scope(reader);
2294
2236 VariableScope<ReaderHelper> vars(reader->helper()); 2295 VariableScope<ReaderHelper> vars(reader->helper());
2237 Block* block = new Block(); 2296 Block* block = new Block();
2238 block->statements().ReadFromStatic<Statement>(reader); 2297 block->statements().ReadFromStatic<Statement>(reader);
2298 block->position_ = reader->min_position();
2299 block->end_position_ = reader->max_position();
2300
2239 return block; 2301 return block;
2240 } 2302 }
2241 2303
2242 2304
2243 void Block::WriteTo(Writer* writer) { 2305 void Block::WriteTo(Writer* writer) {
2244 writer->WriteTag(kBlock); 2306 writer->WriteTag(kBlock);
2245 WriteToImpl(writer); 2307 WriteToImpl(writer);
2246 } 2308 }
2247 2309
2248 2310
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 TRACE_WRITE_OFFSET(); 2408 TRACE_WRITE_OFFSET();
2347 writer->WriteTag(kDoStatement); 2409 writer->WriteTag(kDoStatement);
2348 body_->WriteTo(writer); 2410 body_->WriteTo(writer);
2349 condition_->WriteTo(writer); 2411 condition_->WriteTo(writer);
2350 } 2412 }
2351 2413
2352 2414
2353 ForStatement* ForStatement::ReadFrom(Reader* reader) { 2415 ForStatement* ForStatement::ReadFrom(Reader* reader) {
2354 TRACE_READ_OFFSET(); 2416 TRACE_READ_OFFSET();
2355 VariableScope<ReaderHelper> vars(reader->helper()); 2417 VariableScope<ReaderHelper> vars(reader->helper());
2418 PositionScope scope(reader);
2419
2356 ForStatement* forstmt = new ForStatement(); 2420 ForStatement* forstmt = new ForStatement();
2357 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); 2421 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader);
2358 forstmt->condition_ = reader->ReadOptional<Expression>(); 2422 forstmt->condition_ = reader->ReadOptional<Expression>();
2359 forstmt->updates_.ReadFromStatic<Expression>(reader); 2423 forstmt->updates_.ReadFromStatic<Expression>(reader);
2360 forstmt->body_ = Statement::ReadFrom(reader); 2424 forstmt->body_ = Statement::ReadFrom(reader);
2425 forstmt->end_position_ = reader->max_position();
2426 forstmt->position_ = reader->min_position();
2427
2361 return forstmt; 2428 return forstmt;
2362 } 2429 }
2363 2430
2364 2431
2365 void ForStatement::WriteTo(Writer* writer) { 2432 void ForStatement::WriteTo(Writer* writer) {
2366 TRACE_WRITE_OFFSET(); 2433 TRACE_WRITE_OFFSET();
2367 writer->WriteTag(kForStatement); 2434 writer->WriteTag(kForStatement);
2368 VariableScope<WriterHelper> vars(writer->helper()); 2435 VariableScope<WriterHelper> vars(writer->helper());
2369 variables_.WriteToStatic<VariableDeclarationImpl>(writer); 2436 variables_.WriteToStatic<VariableDeclarationImpl>(writer);
2370 writer->WriteOptional<Expression>(condition_); 2437 writer->WriteOptional<Expression>(condition_);
2371 updates_.WriteTo(writer); 2438 updates_.WriteTo(writer);
2372 body_->WriteTo(writer); 2439 body_->WriteTo(writer);
2373 } 2440 }
2374 2441
2375 2442
2376 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { 2443 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) {
2377 TRACE_READ_OFFSET(); 2444 TRACE_READ_OFFSET();
2378 VariableScope<ReaderHelper> vars(reader->helper()); 2445 VariableScope<ReaderHelper> vars(reader->helper());
2446 PositionScope scope(reader);
2447
2379 ForInStatement* forinstmt = new ForInStatement(); 2448 ForInStatement* forinstmt = new ForInStatement();
2380 forinstmt->is_async_ = is_async; 2449 forinstmt->is_async_ = is_async;
2381 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader); 2450 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader);
2382 forinstmt->iterable_ = Expression::ReadFrom(reader); 2451 forinstmt->iterable_ = Expression::ReadFrom(reader);
2383 forinstmt->body_ = Statement::ReadFrom(reader); 2452 forinstmt->body_ = Statement::ReadFrom(reader);
2453 forinstmt->end_position_ = reader->max_position();
2454 forinstmt->position_ = reader->min_position();
2455
2384 return forinstmt; 2456 return forinstmt;
2385 } 2457 }
2386 2458
2387 2459
2388 void ForInStatement::WriteTo(Writer* writer) { 2460 void ForInStatement::WriteTo(Writer* writer) {
2389 TRACE_WRITE_OFFSET(); 2461 TRACE_WRITE_OFFSET();
2390 writer->WriteTag(is_async_ ? kAsyncForInStatement : kForInStatement); 2462 writer->WriteTag(is_async_ ? kAsyncForInStatement : kForInStatement);
2391 VariableScope<WriterHelper> vars(writer->helper()); 2463 VariableScope<WriterHelper> vars(writer->helper());
2392 variable_->WriteToImpl(writer); 2464 variable_->WriteToImpl(writer);
2393 iterable_->WriteTo(writer); 2465 iterable_->WriteTo(writer);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 void ReturnStatement::WriteTo(Writer* writer) { 2563 void ReturnStatement::WriteTo(Writer* writer) {
2492 TRACE_WRITE_OFFSET(); 2564 TRACE_WRITE_OFFSET();
2493 writer->WriteTag(kReturnStatement); 2565 writer->WriteTag(kReturnStatement);
2494 writer->WritePosition(position_); 2566 writer->WritePosition(position_);
2495 writer->WriteOptional<Expression>(expression_); 2567 writer->WriteOptional<Expression>(expression_);
2496 } 2568 }
2497 2569
2498 2570
2499 TryCatch* TryCatch::ReadFrom(Reader* reader) { 2571 TryCatch* TryCatch::ReadFrom(Reader* reader) {
2500 TRACE_READ_OFFSET(); 2572 TRACE_READ_OFFSET();
2573 PositionScope scope(reader);
2574
2501 TryCatch* tc = new TryCatch(); 2575 TryCatch* tc = new TryCatch();
2502 tc->body_ = Statement::ReadFrom(reader); 2576 tc->body_ = Statement::ReadFrom(reader);
2503 tc->catches_.ReadFromStatic<Catch>(reader); 2577 tc->catches_.ReadFromStatic<Catch>(reader);
2578 tc->position_ = reader->min_position();
2579
2504 return tc; 2580 return tc;
2505 } 2581 }
2506 2582
2507 2583
2508 void TryCatch::WriteTo(Writer* writer) { 2584 void TryCatch::WriteTo(Writer* writer) {
2509 TRACE_WRITE_OFFSET(); 2585 TRACE_WRITE_OFFSET();
2510 writer->WriteTag(kTryCatch); 2586 writer->WriteTag(kTryCatch);
2511 body_->WriteTo(writer); 2587 body_->WriteTo(writer);
2512 catches_.WriteTo(writer); 2588 catches_.WriteTo(writer);
2513 } 2589 }
2514 2590
2515 2591
2516 Catch* Catch::ReadFrom(Reader* reader) { 2592 Catch* Catch::ReadFrom(Reader* reader) {
2517 TRACE_READ_OFFSET(); 2593 TRACE_READ_OFFSET();
2518 VariableScope<ReaderHelper> vars(reader->helper()); 2594 VariableScope<ReaderHelper> vars(reader->helper());
2595 PositionScope scope(reader);
2596
2519 Catch* c = new Catch(); 2597 Catch* c = new Catch();
2520 c->guard_ = DartType::ReadFrom(reader); 2598 c->guard_ = DartType::ReadFrom(reader);
2521 c->exception_ = 2599 c->exception_ =
2522 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 2600 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
2523 c->stack_trace_ = 2601 c->stack_trace_ =
2524 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 2602 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
2525 c->body_ = Statement::ReadFrom(reader); 2603 c->body_ = Statement::ReadFrom(reader);
2604 c->end_position_ = reader->max_position();
2605 c->position_ = reader->min_position();
2606
2526 return c; 2607 return c;
2527 } 2608 }
2528 2609
2529 2610
2530 void Catch::WriteTo(Writer* writer) { 2611 void Catch::WriteTo(Writer* writer) {
2531 TRACE_WRITE_OFFSET(); 2612 TRACE_WRITE_OFFSET();
2532 VariableScope<WriterHelper> vars(writer->helper()); 2613 VariableScope<WriterHelper> vars(writer->helper());
2533 guard_->WriteTo(writer); 2614 guard_->WriteTo(writer);
2534 writer->WriteOptionalStatic<VariableDeclaration, VariableDeclarationImpl>( 2615 writer->WriteOptionalStatic<VariableDeclaration, VariableDeclarationImpl>(
2535 exception_); 2616 exception_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { 2659 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) {
2579 TRACE_READ_OFFSET(); 2660 TRACE_READ_OFFSET();
2580 Tag tag = reader->ReadTag(); 2661 Tag tag = reader->ReadTag();
2581 ASSERT(tag == kVariableDeclaration); 2662 ASSERT(tag == kVariableDeclaration);
2582 return VariableDeclaration::ReadFromImpl(reader); 2663 return VariableDeclaration::ReadFromImpl(reader);
2583 } 2664 }
2584 2665
2585 2666
2586 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) { 2667 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) {
2587 TRACE_READ_OFFSET(); 2668 TRACE_READ_OFFSET();
2669 PositionScope scope(reader);
2670
2588 VariableDeclaration* decl = new VariableDeclaration(); 2671 VariableDeclaration* decl = new VariableDeclaration();
2589 decl->position_ = reader->ReadPosition(); 2672 decl->position_ = reader->ReadPosition();
2590 decl->flags_ = reader->ReadFlags(); 2673 decl->flags_ = reader->ReadFlags();
2591 decl->name_ = Reference::ReadStringFrom(reader); 2674 decl->name_ = Reference::ReadStringFrom(reader);
2592 decl->type_ = DartType::ReadFrom(reader); 2675 decl->type_ = DartType::ReadFrom(reader);
2593 decl->inferred_value_ = reader->ReadOptional<InferredValue>(); 2676 decl->inferred_value_ = reader->ReadOptional<InferredValue>();
2594 decl->initializer_ = reader->ReadOptional<Expression>(); 2677 decl->initializer_ = reader->ReadOptional<Expression>();
2678
2679 // Go to next token position so it ends *after* the last potentially
2680 // debuggable position in the initializer.
2681 TokenPosition position = reader->max_position();
2682 if (position.IsReal()) position.Next();
2683 decl->end_position_ = position;
2595 reader->helper()->variables().Push(decl); 2684 reader->helper()->variables().Push(decl);
2685
2596 return decl; 2686 return decl;
2597 } 2687 }
2598 2688
2599 2689
2600 void VariableDeclaration::WriteTo(Writer* writer) { 2690 void VariableDeclaration::WriteTo(Writer* writer) {
2601 TRACE_WRITE_OFFSET(); 2691 TRACE_WRITE_OFFSET();
2602 writer->WriteTag(kVariableDeclaration); 2692 writer->WriteTag(kVariableDeclaration);
2603 WriteToImpl(writer); 2693 WriteToImpl(writer);
2604 } 2694 }
2605 2695
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) { 3044 void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) {
2955 ASSERT(byte_writer != NULL); 3045 ASSERT(byte_writer != NULL);
2956 3046
2957 kernel::Writer writer(byte_writer); 3047 kernel::Writer writer(byte_writer);
2958 program->WriteTo(&writer); 3048 program->WriteTo(&writer);
2959 } 3049 }
2960 3050
2961 3051
2962 } // namespace dart 3052 } // namespace dart
2963 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3053 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel.h ('k') | runtime/vm/kernel_reader.cc » ('j') | runtime/vm/kernel_to_il.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698