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

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

Issue 2628693004: TokenPositions on more nodes when running from Kernel (Closed)
Patch Set: Changes based on feedback 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();
377 // Position is saved as unsigned, 379 // Position is saved as unsigned,
378 // but actually ranges from -1 and up (thus the -1) 380 // but actually ranges from -1 and up (thus the -1)
379 return TokenPosition(value - 1); 381 intptr_t value = ReadUInt() - 1;
382 TokenPosition result = TokenPosition(value);
383 max_position_ = Utils::Maximum(max_position_, result);
384 if (min_position_.IsNoSource()) {
385 min_position_ = result;
386 } else if (result.IsReal()) {
387 min_position_ = Utils::Minimum(min_position_, result);
388 }
389
390 return result;
380 } 391 }
381 392
382 intptr_t ReadListLength() { return ReadUInt(); } 393 intptr_t ReadListLength() { return ReadUInt(); }
383 394
384 uint8_t ReadByte() { return buffer_[offset_++]; } 395 uint8_t ReadByte() { return buffer_[offset_++]; }
385 396
386 bool ReadBool() { return (ReadByte() & 1) == 1; } 397 bool ReadBool() { return (ReadByte() & 1) == 1; }
387 398
388 word ReadFlags() { return ReadByte(); } 399 word ReadFlags() { return ReadByte(); }
389 400
(...skipping 23 matching lines...) Expand all
413 "Reading Kernel file: Expected to be at EOF " 424 "Reading Kernel file: Expected to be at EOF "
414 "(offset: %" Pd64 ", size: %" Pd64 ")", 425 "(offset: %" Pd64 ", size: %" Pd64 ")",
415 offset_, size_); 426 offset_, size_);
416 } 427 }
417 } 428 }
418 429
419 void DumpOffset(const char* str) { 430 void DumpOffset(const char* str) {
420 OS::PrintErr("@%" Pd64 " %s\n", offset_, str); 431 OS::PrintErr("@%" Pd64 " %s\n", offset_, str);
421 } 432 }
422 433
434 // The largest position read yet (since last reset).
435 // This is automatically updated when calling ReadPosition,
436 // but can be overwritten (e.g. via the PositionScope class).
437 TokenPosition max_position() { return max_position_; }
438 // The smallest position read yet (since last reset).
439 // This is automatically updated when calling ReadPosition,
440 // but can be overwritten (e.g. via the PositionScope class).
441 TokenPosition min_position() { return min_position_; }
442 // The current script id for what we are currently processing.
443 // Note though that this is only a convenience helper and has to be set
444 // manually.
445 intptr_t current_script_id() { return current_script_id_; }
446 void set_current_script_id(intptr_t script_id) {
447 current_script_id_ = script_id;
448 }
449
423 template <typename T, typename RT> 450 template <typename T, typename RT>
424 T* ReadOptional() { 451 T* ReadOptional() {
425 Tag tag = ReadTag(); 452 Tag tag = ReadTag();
426 if (tag == kNothing) { 453 if (tag == kNothing) {
427 return NULL; 454 return NULL;
428 } 455 }
429 ASSERT(tag == kSomething); 456 ASSERT(tag == kSomething);
430 return RT::ReadFrom(this); 457 return RT::ReadFrom(this);
431 } 458 }
432 459
433 template <typename T> 460 template <typename T>
434 T* ReadOptional() { 461 T* ReadOptional() {
435 return ReadOptional<T, T>(); 462 return ReadOptional<T, T>();
436 } 463 }
437 464
438 ReaderHelper* helper() { return &builder_; } 465 ReaderHelper* helper() { return &builder_; }
439 466
440 private: 467 private:
441 const uint8_t* buffer_; 468 const uint8_t* buffer_;
442 int64_t size_; 469 int64_t size_;
443 int64_t offset_; 470 int64_t offset_;
444 ReaderHelper builder_; 471 ReaderHelper builder_;
472 TokenPosition max_position_;
473 TokenPosition min_position_;
474 intptr_t current_script_id_;
475
476 friend class PositionScope;
445 }; 477 };
446 478
447 479
448 class WriterHelper { 480 class WriterHelper {
449 public: 481 public:
450 WriterHelper() : labels_(NULL) {} 482 WriterHelper() : labels_(NULL) {}
451 483
452 void SetProgram(Program* program) { 484 void SetProgram(Program* program) {
453 program_ = program; 485 program_ = program;
454 for (int i = 0; i < program->libraries().length(); i++) { 486 for (int i = 0; i < program->libraries().length(); i++) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 646
615 WriterHelper* helper() { return &helper_; } 647 WriterHelper* helper() { return &helper_; }
616 648
617 private: 649 private:
618 ByteWriter* out_; 650 ByteWriter* out_;
619 WriterHelper helper_; 651 WriterHelper helper_;
620 int64_t offset_; 652 int64_t offset_;
621 }; 653 };
622 654
623 655
656 // A helper class that resets the readers min and max positions both upon
657 // initialization and upon destruction, i.e. when created the min an max
658 // positions will be reset to "noSource", when destructing the min and max will
659 // be reset to have they value they would have had, if they hadn't been reset in
660 // the first place.
661 class PositionScope {
662 public:
663 explicit PositionScope(Reader* reader)
664 : reader_(reader),
665 min_(reader->min_position_),
666 max_(reader->max_position_) {
667 reader->min_position_ = reader->max_position_ = TokenPosition::kNoSource;
668 }
669
670 ~PositionScope() {
671 if (reader_->min_position_.IsNoSource()) {
672 reader_->min_position_ = min_;
673 } else if (min_.IsReal()) {
674 reader_->min_position_ = Utils::Minimum(reader_->min_position_, min_);
675 }
676 reader_->max_position_ = Utils::Maximum(reader_->max_position_, max_);
677 }
678
679 private:
680 Reader* reader_;
681 TokenPosition min_;
682 TokenPosition max_;
683 };
684
624 template <typename T> 685 template <typename T>
625 template <typename IT> 686 template <typename IT>
626 void List<T>::ReadFrom(Reader* reader, TreeNode* parent) { 687 void List<T>::ReadFrom(Reader* reader, TreeNode* parent) {
627 TRACE_READ_OFFSET(); 688 TRACE_READ_OFFSET();
628 ASSERT(parent != NULL); 689 ASSERT(parent != NULL);
629 int length = reader->ReadListLength(); 690 int length = reader->ReadListLength();
630 EnsureInitialized(length); 691 EnsureInitialized(length);
631 692
632 for (int i = 0; i < length_; i++) { 693 for (int i = 0; i < length_; i++) {
633 IT* object = GetOrCreate<IT>(i, parent); 694 IT* object = GetOrCreate<IT>(i, parent);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 926 }
866 927
867 928
868 Library* Library::ReadFrom(Reader* reader) { 929 Library* Library::ReadFrom(Reader* reader) {
869 TRACE_READ_OFFSET(); 930 TRACE_READ_OFFSET();
870 int flags = reader->ReadFlags(); 931 int flags = reader->ReadFlags();
871 ASSERT(flags == 0); // external libraries not supported 932 ASSERT(flags == 0); // external libraries not supported
872 name_ = Reference::ReadStringFrom(reader); 933 name_ = Reference::ReadStringFrom(reader);
873 import_uri_ = Reference::ReadStringFrom(reader); 934 import_uri_ = Reference::ReadStringFrom(reader);
874 source_uri_index_ = reader->ReadUInt(); 935 source_uri_index_ = reader->ReadUInt();
936 reader->set_current_script_id(source_uri_index_);
875 937
876 int num_classes = reader->ReadUInt(); 938 int num_classes = reader->ReadUInt();
877 classes().EnsureInitialized(num_classes); 939 classes().EnsureInitialized(num_classes);
878 for (int i = 0; i < num_classes; i++) { 940 for (int i = 0; i < num_classes; i++) {
879 Tag tag = reader->ReadTag(); 941 Tag tag = reader->ReadTag();
880 if (tag == kNormalClass) { 942 if (tag == kNormalClass) {
881 NormalClass* klass = classes().GetOrCreate<NormalClass>(i, this); 943 NormalClass* klass = classes().GetOrCreate<NormalClass>(i, this);
882 klass->ReadFrom(reader); 944 klass->ReadFrom(reader);
883 } else { 945 } else {
884 ASSERT(tag == kMixinClass); 946 ASSERT(tag == kMixinClass);
(...skipping 30 matching lines...) Expand all
915 } 977 }
916 978
917 979
918 Class* Class::ReadFrom(Reader* reader) { 980 Class* Class::ReadFrom(Reader* reader) {
919 TRACE_READ_OFFSET(); 981 TRACE_READ_OFFSET();
920 982
921 position_ = reader->ReadPosition(); 983 position_ = reader->ReadPosition();
922 is_abstract_ = reader->ReadBool(); 984 is_abstract_ = reader->ReadBool();
923 name_ = Reference::ReadStringFrom(reader); 985 name_ = Reference::ReadStringFrom(reader);
924 source_uri_index_ = reader->ReadUInt(); 986 source_uri_index_ = reader->ReadUInt();
987 reader->set_current_script_id(source_uri_index_);
925 annotations_.ReadFromStatic<Expression>(reader); 988 annotations_.ReadFromStatic<Expression>(reader);
926 989
927 return this; 990 return this;
928 } 991 }
929 992
930 993
931 void Class::WriteTo(Writer* writer) { 994 void Class::WriteTo(Writer* writer) {
932 TRACE_WRITE_OFFSET(); 995 TRACE_WRITE_OFFSET();
933 writer->WritePosition(position_); 996 writer->WritePosition(position_);
934 writer->WriteBool(is_abstract_); 997 writer->WriteBool(is_abstract_);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 Field* Field::ReadFrom(Reader* reader) { 1228 Field* Field::ReadFrom(Reader* reader) {
1166 TRACE_READ_OFFSET(); 1229 TRACE_READ_OFFSET();
1167 Tag tag = reader->ReadTag(); 1230 Tag tag = reader->ReadTag();
1168 ASSERT(tag == kField); 1231 ASSERT(tag == kField);
1169 1232
1170 position_ = reader->ReadPosition(); 1233 position_ = reader->ReadPosition();
1171 end_position_ = reader->ReadPosition(); 1234 end_position_ = reader->ReadPosition();
1172 flags_ = reader->ReadFlags(); 1235 flags_ = reader->ReadFlags();
1173 name_ = Name::ReadFrom(reader); 1236 name_ = Name::ReadFrom(reader);
1174 source_uri_index_ = reader->ReadUInt(); 1237 source_uri_index_ = reader->ReadUInt();
1238 reader->set_current_script_id(source_uri_index_);
1175 annotations_.ReadFromStatic<Expression>(reader); 1239 annotations_.ReadFromStatic<Expression>(reader);
1176 type_ = DartType::ReadFrom(reader); 1240 type_ = DartType::ReadFrom(reader);
1177 inferred_value_ = reader->ReadOptional<InferredValue>(); 1241 inferred_value_ = reader->ReadOptional<InferredValue>();
1178 initializer_ = reader->ReadOptional<Expression>(); 1242 initializer_ = reader->ReadOptional<Expression>();
1179 return this; 1243 return this;
1180 } 1244 }
1181 1245
1182 1246
1183 void Field::WriteTo(Writer* writer) { 1247 void Field::WriteTo(Writer* writer) {
1184 TRACE_WRITE_OFFSET(); 1248 TRACE_WRITE_OFFSET();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 Tag tag = reader->ReadTag(); 1296 Tag tag = reader->ReadTag();
1233 ASSERT(tag == kProcedure); 1297 ASSERT(tag == kProcedure);
1234 1298
1235 VariableScope<ReaderHelper> parameters(reader->helper()); 1299 VariableScope<ReaderHelper> parameters(reader->helper());
1236 position_ = reader->ReadPosition(); 1300 position_ = reader->ReadPosition();
1237 end_position_ = reader->ReadPosition(); 1301 end_position_ = reader->ReadPosition();
1238 kind_ = static_cast<ProcedureKind>(reader->ReadByte()); 1302 kind_ = static_cast<ProcedureKind>(reader->ReadByte());
1239 flags_ = reader->ReadFlags(); 1303 flags_ = reader->ReadFlags();
1240 name_ = Name::ReadFrom(reader); 1304 name_ = Name::ReadFrom(reader);
1241 source_uri_index_ = reader->ReadUInt(); 1305 source_uri_index_ = reader->ReadUInt();
1306 reader->set_current_script_id(source_uri_index_);
1242 annotations_.ReadFromStatic<Expression>(reader); 1307 annotations_.ReadFromStatic<Expression>(reader);
1243 function_ = reader->ReadOptional<FunctionNode>(); 1308 function_ = reader->ReadOptional<FunctionNode>();
1244 return this; 1309 return this;
1245 } 1310 }
1246 1311
1247 1312
1248 void Procedure::WriteTo(Writer* writer) { 1313 void Procedure::WriteTo(Writer* writer) {
1249 TRACE_WRITE_OFFSET(); 1314 TRACE_WRITE_OFFSET();
1250 writer->WriteTag(kProcedure); 1315 writer->WriteTag(kProcedure);
1251 1316
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 TRACE_WRITE_OFFSET(); 2195 TRACE_WRITE_OFFSET();
2131 VariableScope<WriterHelper> parameters(writer->helper()); 2196 VariableScope<WriterHelper> parameters(writer->helper());
2132 writer->WriteTag(kFunctionExpression); 2197 writer->WriteTag(kFunctionExpression);
2133 function_->WriteTo(writer); 2198 function_->WriteTo(writer);
2134 } 2199 }
2135 2200
2136 2201
2137 Let* Let::ReadFrom(Reader* reader) { 2202 Let* Let::ReadFrom(Reader* reader) {
2138 TRACE_READ_OFFSET(); 2203 TRACE_READ_OFFSET();
2139 VariableScope<ReaderHelper> vars(reader->helper()); 2204 VariableScope<ReaderHelper> vars(reader->helper());
2205 PositionScope scope(reader);
2206
2140 Let* let = new Let(); 2207 Let* let = new Let();
2141 let->variable_ = VariableDeclaration::ReadFromImpl(reader); 2208 let->variable_ = VariableDeclaration::ReadFromImpl(reader);
2142 let->body_ = Expression::ReadFrom(reader); 2209 let->body_ = Expression::ReadFrom(reader);
2210 let->position_ = reader->min_position();
2211 let->end_position_ = reader->max_position();
2212
2143 return let; 2213 return let;
2144 } 2214 }
2145 2215
2146 2216
2147 void Let::WriteTo(Writer* writer) { 2217 void Let::WriteTo(Writer* writer) {
2148 TRACE_WRITE_OFFSET(); 2218 TRACE_WRITE_OFFSET();
2149 VariableScope<WriterHelper> vars(writer->helper()); 2219 VariableScope<WriterHelper> vars(writer->helper());
2150 writer->WriteTag(kLet); 2220 writer->WriteTag(kLet);
2151 variable_->WriteToImpl(writer); 2221 variable_->WriteToImpl(writer);
2152 body_->WriteTo(writer); 2222 body_->WriteTo(writer);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2296
2227 void ExpressionStatement::WriteTo(Writer* writer) { 2297 void ExpressionStatement::WriteTo(Writer* writer) {
2228 TRACE_WRITE_OFFSET(); 2298 TRACE_WRITE_OFFSET();
2229 writer->WriteTag(kExpressionStatement); 2299 writer->WriteTag(kExpressionStatement);
2230 expression_->WriteTo(writer); 2300 expression_->WriteTo(writer);
2231 } 2301 }
2232 2302
2233 2303
2234 Block* Block::ReadFromImpl(Reader* reader) { 2304 Block* Block::ReadFromImpl(Reader* reader) {
2235 TRACE_READ_OFFSET(); 2305 TRACE_READ_OFFSET();
2306 PositionScope scope(reader);
2307
2236 VariableScope<ReaderHelper> vars(reader->helper()); 2308 VariableScope<ReaderHelper> vars(reader->helper());
2237 Block* block = new Block(); 2309 Block* block = new Block();
2238 block->statements().ReadFromStatic<Statement>(reader); 2310 block->statements().ReadFromStatic<Statement>(reader);
2311 block->position_ = reader->min_position();
2312 block->end_position_ = reader->max_position();
2313
2239 return block; 2314 return block;
2240 } 2315 }
2241 2316
2242 2317
2243 void Block::WriteTo(Writer* writer) { 2318 void Block::WriteTo(Writer* writer) {
2244 writer->WriteTag(kBlock); 2319 writer->WriteTag(kBlock);
2245 WriteToImpl(writer); 2320 WriteToImpl(writer);
2246 } 2321 }
2247 2322
2248 2323
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 TRACE_WRITE_OFFSET(); 2421 TRACE_WRITE_OFFSET();
2347 writer->WriteTag(kDoStatement); 2422 writer->WriteTag(kDoStatement);
2348 body_->WriteTo(writer); 2423 body_->WriteTo(writer);
2349 condition_->WriteTo(writer); 2424 condition_->WriteTo(writer);
2350 } 2425 }
2351 2426
2352 2427
2353 ForStatement* ForStatement::ReadFrom(Reader* reader) { 2428 ForStatement* ForStatement::ReadFrom(Reader* reader) {
2354 TRACE_READ_OFFSET(); 2429 TRACE_READ_OFFSET();
2355 VariableScope<ReaderHelper> vars(reader->helper()); 2430 VariableScope<ReaderHelper> vars(reader->helper());
2431 PositionScope scope(reader);
2432
2356 ForStatement* forstmt = new ForStatement(); 2433 ForStatement* forstmt = new ForStatement();
2357 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); 2434 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader);
2358 forstmt->condition_ = reader->ReadOptional<Expression>(); 2435 forstmt->condition_ = reader->ReadOptional<Expression>();
2359 forstmt->updates_.ReadFromStatic<Expression>(reader); 2436 forstmt->updates_.ReadFromStatic<Expression>(reader);
2360 forstmt->body_ = Statement::ReadFrom(reader); 2437 forstmt->body_ = Statement::ReadFrom(reader);
2438 forstmt->end_position_ = reader->max_position();
2439 forstmt->position_ = reader->min_position();
2440
2361 return forstmt; 2441 return forstmt;
2362 } 2442 }
2363 2443
2364 2444
2365 void ForStatement::WriteTo(Writer* writer) { 2445 void ForStatement::WriteTo(Writer* writer) {
2366 TRACE_WRITE_OFFSET(); 2446 TRACE_WRITE_OFFSET();
2367 writer->WriteTag(kForStatement); 2447 writer->WriteTag(kForStatement);
2368 VariableScope<WriterHelper> vars(writer->helper()); 2448 VariableScope<WriterHelper> vars(writer->helper());
2369 variables_.WriteToStatic<VariableDeclarationImpl>(writer); 2449 variables_.WriteToStatic<VariableDeclarationImpl>(writer);
2370 writer->WriteOptional<Expression>(condition_); 2450 writer->WriteOptional<Expression>(condition_);
2371 updates_.WriteTo(writer); 2451 updates_.WriteTo(writer);
2372 body_->WriteTo(writer); 2452 body_->WriteTo(writer);
2373 } 2453 }
2374 2454
2375 2455
2376 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { 2456 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) {
2377 TRACE_READ_OFFSET(); 2457 TRACE_READ_OFFSET();
2378 VariableScope<ReaderHelper> vars(reader->helper()); 2458 VariableScope<ReaderHelper> vars(reader->helper());
2459 PositionScope scope(reader);
2460
2379 ForInStatement* forinstmt = new ForInStatement(); 2461 ForInStatement* forinstmt = new ForInStatement();
2380 forinstmt->is_async_ = is_async; 2462 forinstmt->is_async_ = is_async;
2381 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader); 2463 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader);
2382 forinstmt->iterable_ = Expression::ReadFrom(reader); 2464 forinstmt->iterable_ = Expression::ReadFrom(reader);
2383 forinstmt->body_ = Statement::ReadFrom(reader); 2465 forinstmt->body_ = Statement::ReadFrom(reader);
2466 forinstmt->end_position_ = reader->max_position();
2467 forinstmt->position_ = reader->min_position();
2468
2384 return forinstmt; 2469 return forinstmt;
2385 } 2470 }
2386 2471
2387 2472
2388 void ForInStatement::WriteTo(Writer* writer) { 2473 void ForInStatement::WriteTo(Writer* writer) {
2389 TRACE_WRITE_OFFSET(); 2474 TRACE_WRITE_OFFSET();
2390 writer->WriteTag(is_async_ ? kAsyncForInStatement : kForInStatement); 2475 writer->WriteTag(is_async_ ? kAsyncForInStatement : kForInStatement);
2391 VariableScope<WriterHelper> vars(writer->helper()); 2476 VariableScope<WriterHelper> vars(writer->helper());
2392 variable_->WriteToImpl(writer); 2477 variable_->WriteToImpl(writer);
2393 iterable_->WriteTo(writer); 2478 iterable_->WriteTo(writer);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 void ReturnStatement::WriteTo(Writer* writer) { 2576 void ReturnStatement::WriteTo(Writer* writer) {
2492 TRACE_WRITE_OFFSET(); 2577 TRACE_WRITE_OFFSET();
2493 writer->WriteTag(kReturnStatement); 2578 writer->WriteTag(kReturnStatement);
2494 writer->WritePosition(position_); 2579 writer->WritePosition(position_);
2495 writer->WriteOptional<Expression>(expression_); 2580 writer->WriteOptional<Expression>(expression_);
2496 } 2581 }
2497 2582
2498 2583
2499 TryCatch* TryCatch::ReadFrom(Reader* reader) { 2584 TryCatch* TryCatch::ReadFrom(Reader* reader) {
2500 TRACE_READ_OFFSET(); 2585 TRACE_READ_OFFSET();
2586 PositionScope scope(reader);
2587
2501 TryCatch* tc = new TryCatch(); 2588 TryCatch* tc = new TryCatch();
2502 tc->body_ = Statement::ReadFrom(reader); 2589 tc->body_ = Statement::ReadFrom(reader);
2503 tc->catches_.ReadFromStatic<Catch>(reader); 2590 tc->catches_.ReadFromStatic<Catch>(reader);
2591 tc->position_ = reader->min_position();
2592
2504 return tc; 2593 return tc;
2505 } 2594 }
2506 2595
2507 2596
2508 void TryCatch::WriteTo(Writer* writer) { 2597 void TryCatch::WriteTo(Writer* writer) {
2509 TRACE_WRITE_OFFSET(); 2598 TRACE_WRITE_OFFSET();
2510 writer->WriteTag(kTryCatch); 2599 writer->WriteTag(kTryCatch);
2511 body_->WriteTo(writer); 2600 body_->WriteTo(writer);
2512 catches_.WriteTo(writer); 2601 catches_.WriteTo(writer);
2513 } 2602 }
2514 2603
2515 2604
2516 Catch* Catch::ReadFrom(Reader* reader) { 2605 Catch* Catch::ReadFrom(Reader* reader) {
2517 TRACE_READ_OFFSET(); 2606 TRACE_READ_OFFSET();
2518 VariableScope<ReaderHelper> vars(reader->helper()); 2607 VariableScope<ReaderHelper> vars(reader->helper());
2608 PositionScope scope(reader);
2609
2519 Catch* c = new Catch(); 2610 Catch* c = new Catch();
2520 c->guard_ = DartType::ReadFrom(reader); 2611 c->guard_ = DartType::ReadFrom(reader);
2521 c->exception_ = 2612 c->exception_ =
2522 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 2613 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
2523 c->stack_trace_ = 2614 c->stack_trace_ =
2524 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 2615 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
2525 c->body_ = Statement::ReadFrom(reader); 2616 c->body_ = Statement::ReadFrom(reader);
2617 c->end_position_ = reader->max_position();
2618 c->position_ = reader->min_position();
2619
2526 return c; 2620 return c;
2527 } 2621 }
2528 2622
2529 2623
2530 void Catch::WriteTo(Writer* writer) { 2624 void Catch::WriteTo(Writer* writer) {
2531 TRACE_WRITE_OFFSET(); 2625 TRACE_WRITE_OFFSET();
2532 VariableScope<WriterHelper> vars(writer->helper()); 2626 VariableScope<WriterHelper> vars(writer->helper());
2533 guard_->WriteTo(writer); 2627 guard_->WriteTo(writer);
2534 writer->WriteOptionalStatic<VariableDeclaration, VariableDeclarationImpl>( 2628 writer->WriteOptionalStatic<VariableDeclaration, VariableDeclarationImpl>(
2535 exception_); 2629 exception_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { 2672 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) {
2579 TRACE_READ_OFFSET(); 2673 TRACE_READ_OFFSET();
2580 Tag tag = reader->ReadTag(); 2674 Tag tag = reader->ReadTag();
2581 ASSERT(tag == kVariableDeclaration); 2675 ASSERT(tag == kVariableDeclaration);
2582 return VariableDeclaration::ReadFromImpl(reader); 2676 return VariableDeclaration::ReadFromImpl(reader);
2583 } 2677 }
2584 2678
2585 2679
2586 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) { 2680 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) {
2587 TRACE_READ_OFFSET(); 2681 TRACE_READ_OFFSET();
2682 PositionScope scope(reader);
2683
2588 VariableDeclaration* decl = new VariableDeclaration(); 2684 VariableDeclaration* decl = new VariableDeclaration();
2589 decl->position_ = reader->ReadPosition(); 2685 decl->position_ = reader->ReadPosition();
2590 decl->flags_ = reader->ReadFlags(); 2686 decl->flags_ = reader->ReadFlags();
2591 decl->name_ = Reference::ReadStringFrom(reader); 2687 decl->name_ = Reference::ReadStringFrom(reader);
2592 decl->type_ = DartType::ReadFrom(reader); 2688 decl->type_ = DartType::ReadFrom(reader);
2593 decl->inferred_value_ = reader->ReadOptional<InferredValue>(); 2689 decl->inferred_value_ = reader->ReadOptional<InferredValue>();
2594 decl->initializer_ = reader->ReadOptional<Expression>(); 2690 decl->initializer_ = reader->ReadOptional<Expression>();
2691
2692 // Go to next token position so it ends *after* the last potentially
2693 // debuggable position in the initializer.
2694 TokenPosition position = reader->max_position();
2695 if (position.IsReal()) position.Next();
2696 decl->end_position_ = position;
2595 reader->helper()->variables().Push(decl); 2697 reader->helper()->variables().Push(decl);
2698
2596 return decl; 2699 return decl;
2597 } 2700 }
2598 2701
2599 2702
2600 void VariableDeclaration::WriteTo(Writer* writer) { 2703 void VariableDeclaration::WriteTo(Writer* writer) {
2601 TRACE_WRITE_OFFSET(); 2704 TRACE_WRITE_OFFSET();
2602 writer->WriteTag(kVariableDeclaration); 2705 writer->WriteTag(kVariableDeclaration);
2603 WriteToImpl(writer); 2706 WriteToImpl(writer);
2604 } 2707 }
2605 2708
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) { 3057 void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) {
2955 ASSERT(byte_writer != NULL); 3058 ASSERT(byte_writer != NULL);
2956 3059
2957 kernel::Writer writer(byte_writer); 3060 kernel::Writer writer(byte_writer);
2958 program->WriteTo(&writer); 3061 program->WriteTo(&writer);
2959 } 3062 }
2960 3063
2961 3064
2962 } // namespace dart 3065 } // namespace dart
2963 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3066 #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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698