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

Side by Side Diff: runtime/vm/kernel.h

Issue 2852943003: Move the Kernel string offsets into the VM's heap. (Closed)
Patch Set: Incorporate review comments. Created 3 years, 7 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
« no previous file with comments | « runtime/vm/bootstrap_nocore.cc ('k') | runtime/vm/kernel.cc » ('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) 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 4
5 #ifndef RUNTIME_VM_KERNEL_H_ 5 #ifndef RUNTIME_VM_KERNEL_H_
6 #define RUNTIME_VM_KERNEL_H_ 6 #define RUNTIME_VM_KERNEL_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DISALLOW_COPY_AND_ASSIGN(List); 236 DISALLOW_COPY_AND_ASSIGN(List);
237 }; 237 };
238 238
239 239
240 class TypeParameterList : public List<TypeParameter> { 240 class TypeParameterList : public List<TypeParameter> {
241 public: 241 public:
242 void ReadFrom(Reader* reader); 242 void ReadFrom(Reader* reader);
243 }; 243 };
244 244
245 245
246 template <typename A, typename B>
247 class Tuple {
248 public:
249 static Tuple<A, B>* ReadFrom(Reader* reader);
250
251 Tuple(A* a, B* b) : first_(a), second_(b) {}
252
253 A* first() { return first_; }
254 B* second() { return second_; }
255
256 private:
257 Tuple() {}
258
259 Ref<A> first_;
260 Child<B> second_;
261
262 DISALLOW_COPY_AND_ASSIGN(Tuple);
263 };
264
265
266 class String {
267 public:
268 // Read a string reference, which is an index into the string table.
269 static String* ReadFrom(Reader* reader);
270
271 // Read a string implementation given its size.
272 static String* ReadRaw(Reader* reader, intptr_t size);
273
274 String(intptr_t offset, int size) : offset_(offset), size_(size) {}
275
276 intptr_t offset() { return offset_; }
277 int size() { return size_; }
278
279 bool is_empty() { return size_ == 0; }
280
281 private:
282 intptr_t offset_;
283 int size_;
284
285 DISALLOW_COPY_AND_ASSIGN(String);
286 };
287
288
289 class StringTable {
290 public:
291 void ReadFrom(Reader* reader);
292
293 List<String>& strings() { return strings_; }
294
295 private:
296 StringTable() {}
297
298 friend class Program;
299
300 List<String> strings_;
301
302 DISALLOW_COPY_AND_ASSIGN(StringTable);
303 };
304
305
306 class Source { 246 class Source {
307 public: 247 public:
308 ~Source(); 248 ~Source();
309 249
310 private: 250 private:
311 uint8_t* uri_; // UTF-8 encoded. 251 uint8_t* uri_; // UTF-8 encoded.
312 intptr_t uri_size_; // In bytes. 252 intptr_t uri_size_; // In bytes.
313 uint8_t* source_code_; // UTF-8 encoded. 253 uint8_t* source_code_; // UTF-8 encoded.
314 intptr_t source_code_size_; // In bytes. 254 intptr_t source_code_size_; // In bytes.
315 intptr_t* line_starts_; 255 intptr_t* line_starts_;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 class Field; 323 class Field;
384 class Library; 324 class Library;
385 class LinkedNode; 325 class LinkedNode;
386 class Member; 326 class Member;
387 class Procedure; 327 class Procedure;
388 328
389 class CanonicalName { 329 class CanonicalName {
390 public: 330 public:
391 ~CanonicalName(); 331 ~CanonicalName();
392 332
393 String* name() { return name_; } 333 intptr_t name() { return name_index_; }
394 CanonicalName* parent() { return parent_; } 334 CanonicalName* parent() { return parent_; }
395 bool is_referenced() { return is_referenced_; } 335 bool is_referenced() { return is_referenced_; }
396 void set_referenced(bool referenced) { is_referenced_ = referenced; } 336 void set_referenced(bool referenced) { is_referenced_ = referenced; }
397 337
398 CanonicalName* AddChild(String* string); 338 CanonicalName* AddChild(intptr_t string_index);
399 339
400 static CanonicalName* NewRoot(); 340 static CanonicalName* NewRoot();
401 341
402 private: 342 private:
403 CanonicalName(); 343 CanonicalName();
404 344
405 CanonicalName* parent_; 345 CanonicalName* parent_;
406 String* name_; 346 intptr_t name_index_;
407 MallocGrowableArray<CanonicalName*> children_; 347 MallocGrowableArray<CanonicalName*> children_;
408 bool is_referenced_; 348 bool is_referenced_;
409 349
410 DISALLOW_COPY_AND_ASSIGN(CanonicalName); 350 DISALLOW_COPY_AND_ASSIGN(CanonicalName);
411 }; 351 };
412 352
413 353
414 class Node { 354 class Node {
415 public: 355 public:
416 virtual ~Node(); 356 virtual ~Node();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 public: 421 public:
482 Library* ReadFrom(Reader* reader); 422 Library* ReadFrom(Reader* reader);
483 423
484 virtual ~Library(); 424 virtual ~Library();
485 425
486 DEFINE_CASTING_OPERATIONS(Library); 426 DEFINE_CASTING_OPERATIONS(Library);
487 427
488 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 428 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
489 virtual void VisitChildren(Visitor* visitor); 429 virtual void VisitChildren(Visitor* visitor);
490 430
491 String* import_uri() { return import_uri_; } 431 intptr_t import_uri() { return import_uri_index_; }
492 intptr_t source_uri_index() { return source_uri_index_; } 432 intptr_t source_uri_index() { return source_uri_index_; }
493 String* name() { return name_; } 433 intptr_t name() { return name_index_; }
494 List<Typedef>& typedefs() { return typedefs_; } 434 List<Typedef>& typedefs() { return typedefs_; }
495 List<Class>& classes() { return classes_; } 435 List<Class>& classes() { return classes_; }
496 List<Field>& fields() { return fields_; } 436 List<Field>& fields() { return fields_; }
497 List<Procedure>& procedures() { return procedures_; } 437 List<Procedure>& procedures() { return procedures_; }
498 438
499 const uint8_t* kernel_data() { return kernel_data_; } 439 const uint8_t* kernel_data() { return kernel_data_; }
500 intptr_t kernel_data_size() { return kernel_data_size_; } 440 intptr_t kernel_data_size() { return kernel_data_size_; }
501 441
502 private: 442 private:
503 Library() : name_(NULL), kernel_data_(NULL), kernel_data_size_(-1) {} 443 Library() : name_index_(-1), kernel_data_(NULL), kernel_data_size_(-1) {}
504 444
505 template <typename T> 445 template <typename T>
506 friend class List; 446 friend class List;
507 447
508 Ref<String> name_; 448 intptr_t name_index_;
509 Ref<String> import_uri_; 449 intptr_t import_uri_index_;
510 intptr_t source_uri_index_; 450 intptr_t source_uri_index_;
511 List<Typedef> typedefs_; 451 List<Typedef> typedefs_;
512 List<Class> classes_; 452 List<Class> classes_;
513 List<Field> fields_; 453 List<Field> fields_;
514 List<Procedure> procedures_; 454 List<Procedure> procedures_;
515 const uint8_t* kernel_data_; 455 const uint8_t* kernel_data_;
516 intptr_t kernel_data_size_; 456 intptr_t kernel_data_size_;
517 457
518 DISALLOW_COPY_AND_ASSIGN(Library); 458 DISALLOW_COPY_AND_ASSIGN(Library);
519 }; 459 };
520 460
521 461
522 class Typedef : public LinkedNode { 462 class Typedef : public LinkedNode {
523 public: 463 public:
524 Typedef* ReadFrom(Reader* reader); 464 Typedef* ReadFrom(Reader* reader);
525 465
526 virtual ~Typedef(); 466 virtual ~Typedef();
527 467
528 DEFINE_CASTING_OPERATIONS(Typedef); 468 DEFINE_CASTING_OPERATIONS(Typedef);
529 469
530 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 470 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
531 virtual void VisitChildren(Visitor* visitor); 471 virtual void VisitChildren(Visitor* visitor);
532 472
533 Library* parent() { return parent_; } 473 Library* parent() { return parent_; }
534 String* name() { return name_; } 474 intptr_t name() { return name_index_; }
535 intptr_t source_uri_index() { return source_uri_index_; } 475 intptr_t source_uri_index() { return source_uri_index_; }
536 TokenPosition position() { return position_; } 476 TokenPosition position() { return position_; }
537 TypeParameterList& type_parameters() { return type_parameters_; } 477 TypeParameterList& type_parameters() { return type_parameters_; }
538 DartType* type() { return type_; } 478 DartType* type() { return type_; }
539 479
540 protected: 480 protected:
541 Typedef() : position_(TokenPosition::kNoSource) {} 481 Typedef() : position_(TokenPosition::kNoSource) {}
542 482
543 private: 483 private:
544 template <typename T> 484 template <typename T>
545 friend class List; 485 friend class List;
546 486
547 Ref<Library> parent_; 487 Ref<Library> parent_;
548 Ref<String> name_; 488 intptr_t name_index_;
549 intptr_t source_uri_index_; 489 intptr_t source_uri_index_;
550 TokenPosition position_; 490 TokenPosition position_;
551 TypeParameterList type_parameters_; 491 TypeParameterList type_parameters_;
552 Child<DartType> type_; 492 Child<DartType> type_;
553 }; 493 };
554 494
555 495
556 class Class : public LinkedNode { 496 class Class : public LinkedNode {
557 public: 497 public:
558 Class* ReadFrom(Reader* reader); 498 Class* ReadFrom(Reader* reader);
559 499
560 virtual ~Class(); 500 virtual ~Class();
561 501
562 DEFINE_CASTING_OPERATIONS(Class); 502 DEFINE_CASTING_OPERATIONS(Class);
563 503
564 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 504 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
565 virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0; 505 virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0;
566 506
567 Library* parent() { return parent_; } 507 Library* parent() { return parent_; }
568 String* name() { return name_; } 508 intptr_t name() { return name_index_; }
569 intptr_t source_uri_index() { return source_uri_index_; } 509 intptr_t source_uri_index() { return source_uri_index_; }
570 bool is_abstract() { return is_abstract_; } 510 bool is_abstract() { return is_abstract_; }
571 List<Expression>& annotations() { return annotations_; } 511 List<Expression>& annotations() { return annotations_; }
572 TokenPosition position() { return position_; } 512 TokenPosition position() { return position_; }
573 513
574 virtual List<TypeParameter>& type_parameters() = 0; 514 virtual List<TypeParameter>& type_parameters() = 0;
575 virtual List<InterfaceType>& implemented_classes() = 0; 515 virtual List<InterfaceType>& implemented_classes() = 0;
576 virtual List<Field>& fields() = 0; 516 virtual List<Field>& fields() = 0;
577 virtual List<Constructor>& constructors() = 0; 517 virtual List<Constructor>& constructors() = 0;
578 virtual List<Procedure>& procedures() = 0; 518 virtual List<Procedure>& procedures() = 0;
579 519
580 protected: 520 protected:
581 Class() : is_abstract_(false), position_(TokenPosition::kNoSource) {} 521 Class() : is_abstract_(false), position_(TokenPosition::kNoSource) {}
582 522
583 private: 523 private:
584 template <typename T> 524 template <typename T>
585 friend class List; 525 friend class List;
586 526
587 Ref<Library> parent_; 527 Ref<Library> parent_;
588 Ref<String> name_; 528 intptr_t name_index_;
589 intptr_t source_uri_index_; 529 intptr_t source_uri_index_;
590 bool is_abstract_; 530 bool is_abstract_;
591 List<Expression> annotations_; 531 List<Expression> annotations_;
592 TokenPosition position_; 532 TokenPosition position_;
593 533
594 DISALLOW_COPY_AND_ASSIGN(Class); 534 DISALLOW_COPY_AND_ASSIGN(Class);
595 }; 535 };
596 536
597 537
598 class NormalClass : public Class { 538 class NormalClass : public Class {
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 List<NamedExpression> named_; 1224 List<NamedExpression> named_;
1285 1225
1286 DISALLOW_COPY_AND_ASSIGN(Arguments); 1226 DISALLOW_COPY_AND_ASSIGN(Arguments);
1287 }; 1227 };
1288 1228
1289 1229
1290 class NamedExpression : public TreeNode { 1230 class NamedExpression : public TreeNode {
1291 public: 1231 public:
1292 static NamedExpression* ReadFrom(Reader* reader); 1232 static NamedExpression* ReadFrom(Reader* reader);
1293 1233
1294 NamedExpression(String* name, Expression* expr) 1234 NamedExpression(intptr_t name_index, Expression* expr)
1295 : name_(name), expression_(expr) {} 1235 : name_index_(name_index), expression_(expr) {}
1296 virtual ~NamedExpression(); 1236 virtual ~NamedExpression();
1297 1237
1298 DEFINE_CASTING_OPERATIONS(NamedExpression); 1238 DEFINE_CASTING_OPERATIONS(NamedExpression);
1299 1239
1300 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 1240 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
1301 virtual void VisitChildren(Visitor* visitor); 1241 virtual void VisitChildren(Visitor* visitor);
1302 1242
1303 String* name() { return name_; } 1243 intptr_t name() { return name_index_; }
1304 Expression* expression() { return expression_; } 1244 Expression* expression() { return expression_; }
1305 1245
1306 private: 1246 private:
1307 NamedExpression() {} 1247 NamedExpression() {}
1308 1248
1309 Ref<String> name_; 1249 intptr_t name_index_;
1310 Child<Expression> expression_; 1250 Child<Expression> expression_;
1311 1251
1312 DISALLOW_COPY_AND_ASSIGN(NamedExpression); 1252 DISALLOW_COPY_AND_ASSIGN(NamedExpression);
1313 }; 1253 };
1314 1254
1315 1255
1316 class MethodInvocation : public Expression { 1256 class MethodInvocation : public Expression {
1317 public: 1257 public:
1318 static MethodInvocation* ReadFrom(Reader* reader); 1258 static MethodInvocation* ReadFrom(Reader* reader);
1319 1259
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 virtual void VisitChildren(Visitor* visitor); 1512 virtual void VisitChildren(Visitor* visitor);
1573 }; 1513 };
1574 1514
1575 1515
1576 class StringLiteral : public BasicLiteral { 1516 class StringLiteral : public BasicLiteral {
1577 public: 1517 public:
1578 static StringLiteral* ReadFrom(Reader* reader); 1518 static StringLiteral* ReadFrom(Reader* reader);
1579 1519
1580 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); 1520 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1581 1521
1582 explicit StringLiteral(String* string) : value_(string) {} 1522 explicit StringLiteral(intptr_t string_index) : value_index_(string_index) {}
1583 virtual ~StringLiteral(); 1523 virtual ~StringLiteral();
1584 1524
1585 DEFINE_CASTING_OPERATIONS(StringLiteral); 1525 DEFINE_CASTING_OPERATIONS(StringLiteral);
1586 1526
1587 String* value() { return value_; } 1527 intptr_t value() { return value_index_; }
1588 1528
1589 protected: 1529 protected:
1590 StringLiteral() {} 1530 StringLiteral() {}
1591 1531
1592 Ref<String> value_; 1532 intptr_t value_index_;
1593 1533
1594 private: 1534 private:
1595 DISALLOW_COPY_AND_ASSIGN(StringLiteral); 1535 DISALLOW_COPY_AND_ASSIGN(StringLiteral);
1596 }; 1536 };
1597 1537
1598 1538
1599 class BigintLiteral : public StringLiteral { 1539 class BigintLiteral : public StringLiteral {
1600 public: 1540 public:
1601 static BigintLiteral* ReadFrom(Reader* reader); 1541 static BigintLiteral* ReadFrom(Reader* reader);
1602 1542
1603 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); 1543 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1604 1544
1605 explicit BigintLiteral(String* string) : StringLiteral(string) {} 1545 explicit BigintLiteral(intptr_t string_index) : StringLiteral(string_index) {}
1606 virtual ~BigintLiteral(); 1546 virtual ~BigintLiteral();
1607 1547
1608 DEFINE_CASTING_OPERATIONS(BigintLiteral); 1548 DEFINE_CASTING_OPERATIONS(BigintLiteral);
1609 1549
1610 private: 1550 private:
1611 BigintLiteral() {} 1551 BigintLiteral() {}
1612 1552
1613 DISALLOW_COPY_AND_ASSIGN(BigintLiteral); 1553 DISALLOW_COPY_AND_ASSIGN(BigintLiteral);
1614 }; 1554 };
1615 1555
(...skipping 23 matching lines...) Expand all
1639 class DoubleLiteral : public BasicLiteral { 1579 class DoubleLiteral : public BasicLiteral {
1640 public: 1580 public:
1641 static DoubleLiteral* ReadFrom(Reader* reader); 1581 static DoubleLiteral* ReadFrom(Reader* reader);
1642 1582
1643 virtual ~DoubleLiteral(); 1583 virtual ~DoubleLiteral();
1644 1584
1645 DEFINE_CASTING_OPERATIONS(DoubleLiteral); 1585 DEFINE_CASTING_OPERATIONS(DoubleLiteral);
1646 1586
1647 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); 1587 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1648 1588
1649 String* value() { return value_; } 1589 intptr_t value() { return value_index_; }
1650 1590
1651 private: 1591 private:
1652 DoubleLiteral() {} 1592 DoubleLiteral() {}
1653 1593
1654 Ref<String> value_; 1594 intptr_t value_index_;
1655 1595
1656 DISALLOW_COPY_AND_ASSIGN(DoubleLiteral); 1596 DISALLOW_COPY_AND_ASSIGN(DoubleLiteral);
1657 }; 1597 };
1658 1598
1659 1599
1660 class BoolLiteral : public BasicLiteral { 1600 class BoolLiteral : public BasicLiteral {
1661 public: 1601 public:
1662 static BoolLiteral* ReadFrom(Reader* reader, bool value); 1602 static BoolLiteral* ReadFrom(Reader* reader, bool value);
1663 1603
1664 virtual ~BoolLiteral(); 1604 virtual ~BoolLiteral();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 public: 1639 public:
1700 static SymbolLiteral* ReadFrom(Reader* reader); 1640 static SymbolLiteral* ReadFrom(Reader* reader);
1701 1641
1702 virtual ~SymbolLiteral(); 1642 virtual ~SymbolLiteral();
1703 1643
1704 DEFINE_CASTING_OPERATIONS(SymbolLiteral); 1644 DEFINE_CASTING_OPERATIONS(SymbolLiteral);
1705 1645
1706 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); 1646 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
1707 virtual void VisitChildren(Visitor* visitor); 1647 virtual void VisitChildren(Visitor* visitor);
1708 1648
1709 String* value() { return value_; } 1649 intptr_t value() { return value_index_; }
1710 1650
1711 private: 1651 private:
1712 SymbolLiteral() {} 1652 SymbolLiteral() {}
1713 1653
1714 Ref<String> value_; 1654 intptr_t value_index_;
1715 1655
1716 DISALLOW_COPY_AND_ASSIGN(SymbolLiteral); 1656 DISALLOW_COPY_AND_ASSIGN(SymbolLiteral);
1717 }; 1657 };
1718 1658
1719 1659
1720 class TypeLiteral : public Expression { 1660 class TypeLiteral : public Expression {
1721 public: 1661 public:
1722 static TypeLiteral* ReadFrom(Reader* reader); 1662 static TypeLiteral* ReadFrom(Reader* reader);
1723 1663
1724 virtual ~TypeLiteral(); 1664 virtual ~TypeLiteral();
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 virtual ~VariableDeclaration(); 2552 virtual ~VariableDeclaration();
2613 2553
2614 DEFINE_CASTING_OPERATIONS(VariableDeclaration); 2554 DEFINE_CASTING_OPERATIONS(VariableDeclaration);
2615 2555
2616 virtual void AcceptStatementVisitor(StatementVisitor* visitor); 2556 virtual void AcceptStatementVisitor(StatementVisitor* visitor);
2617 virtual void VisitChildren(Visitor* visitor); 2557 virtual void VisitChildren(Visitor* visitor);
2618 2558
2619 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; } 2559 bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; }
2620 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; } 2560 bool IsFinal() { return (flags_ & kFlagFinal) == kFlagFinal; }
2621 2561
2622 String* name() { return name_; } 2562 intptr_t name() { return name_index_; }
2623 DartType* type() { return type_; } 2563 DartType* type() { return type_; }
2624 Expression* initializer() { return initializer_; } 2564 Expression* initializer() { return initializer_; }
2625 TokenPosition equals_position() { return equals_position_; } 2565 TokenPosition equals_position() { return equals_position_; }
2626 TokenPosition end_position() { return end_position_; } 2566 TokenPosition end_position() { return end_position_; }
2627 void set_end_position(TokenPosition position) { end_position_ = position; } 2567 void set_end_position(TokenPosition position) { end_position_ = position; }
2628 2568
2629 private: 2569 private:
2630 VariableDeclaration() 2570 VariableDeclaration()
2631 : equals_position_(TokenPosition::kNoSourcePos), 2571 : equals_position_(TokenPosition::kNoSourcePos),
2632 end_position_(TokenPosition::kNoSource) {} 2572 end_position_(TokenPosition::kNoSource) {}
2633 2573
2634 template <typename T> 2574 template <typename T>
2635 friend class List; 2575 friend class List;
2636 2576
2637 word flags_; 2577 word flags_;
2638 Ref<String> name_; 2578 intptr_t name_index_;
2639 Child<DartType> type_; 2579 Child<DartType> type_;
2640 Child<Expression> initializer_; 2580 Child<Expression> initializer_;
2641 TokenPosition equals_position_; 2581 TokenPosition equals_position_;
2642 TokenPosition end_position_; 2582 TokenPosition end_position_;
2643 2583
2644 DISALLOW_COPY_AND_ASSIGN(VariableDeclaration); 2584 DISALLOW_COPY_AND_ASSIGN(VariableDeclaration);
2645 }; 2585 };
2646 2586
2647 2587
2648 class FunctionDeclaration : public Statement { 2588 class FunctionDeclaration : public Statement {
(...skipping 24 matching lines...) Expand all
2673 public: 2613 public:
2674 static Name* ReadFrom(Reader* reader); 2614 static Name* ReadFrom(Reader* reader);
2675 2615
2676 virtual ~Name(); 2616 virtual ~Name();
2677 2617
2678 DEFINE_CASTING_OPERATIONS(Name); 2618 DEFINE_CASTING_OPERATIONS(Name);
2679 2619
2680 virtual void AcceptVisitor(Visitor* visitor); 2620 virtual void AcceptVisitor(Visitor* visitor);
2681 virtual void VisitChildren(Visitor* visitor); 2621 virtual void VisitChildren(Visitor* visitor);
2682 2622
2683 String* string() { return string_; } 2623 intptr_t string_index() { return string_index_; }
2684 CanonicalName* library() { return library_reference_; } 2624 CanonicalName* library() { return library_reference_; }
2685 2625
2686 private: 2626 private:
2687 Name(String* string, CanonicalName* library_reference) 2627 Name(intptr_t string_index, CanonicalName* library_reference)
2688 : string_(string), library_reference_(library_reference) {} // NOLINT 2628 : string_index_(string_index),
2629 library_reference_(library_reference) {} // NOLINT
2689 2630
2690 Ref<String> string_; 2631 intptr_t string_index_;
2691 Ref<CanonicalName> library_reference_; // Library. 2632 Ref<CanonicalName> library_reference_; // Library.
2692 2633
2693 DISALLOW_COPY_AND_ASSIGN(Name); 2634 DISALLOW_COPY_AND_ASSIGN(Name);
2694 }; 2635 };
2695 2636
2696 2637
2697 class DartType : public Node { 2638 class DartType : public Node {
2698 public: 2639 public:
2699 static DartType* ReadFrom(Reader* reader); 2640 static DartType* ReadFrom(Reader* reader);
2700 2641
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 private: 2754 private:
2814 TypedefType() {} 2755 TypedefType() {}
2815 2756
2816 Ref<CanonicalName> typedef_reference_; // Typedef. 2757 Ref<CanonicalName> typedef_reference_; // Typedef.
2817 List<DartType> type_arguments_; 2758 List<DartType> type_arguments_;
2818 2759
2819 DISALLOW_COPY_AND_ASSIGN(TypedefType); 2760 DISALLOW_COPY_AND_ASSIGN(TypedefType);
2820 }; 2761 };
2821 2762
2822 2763
2764 class NamedParameter {
2765 public:
2766 static NamedParameter* ReadFrom(Reader* reader);
2767
2768 NamedParameter(intptr_t name_index, DartType* type)
2769 : name_index_(name_index), type_(type) {}
2770
2771 intptr_t name() { return name_index_; }
2772 DartType* type() { return type_; }
2773
2774 private:
2775 NamedParameter() : name_index_(-1) {}
2776
2777 intptr_t name_index_;
2778 Child<DartType> type_;
2779
2780 DISALLOW_COPY_AND_ASSIGN(NamedParameter);
2781 };
2782
2783
2823 class FunctionType : public DartType { 2784 class FunctionType : public DartType {
2824 public: 2785 public:
2825 static FunctionType* ReadFrom(Reader* reader); 2786 static FunctionType* ReadFrom(Reader* reader);
2826 static FunctionType* ReadFrom(Reader* reader, bool _without_type_arguments_); 2787 static FunctionType* ReadFrom(Reader* reader, bool _without_type_arguments_);
2827 2788
2828 virtual ~FunctionType(); 2789 virtual ~FunctionType();
2829 2790
2830 DEFINE_CASTING_OPERATIONS(FunctionType); 2791 DEFINE_CASTING_OPERATIONS(FunctionType);
2831 2792
2832 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor); 2793 virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor);
2833 virtual void VisitChildren(Visitor* visitor); 2794 virtual void VisitChildren(Visitor* visitor);
2834 2795
2835 TypeParameterList& type_parameters() { return type_parameters_; } 2796 TypeParameterList& type_parameters() { return type_parameters_; }
2836 int required_parameter_count() { return required_parameter_count_; } 2797 int required_parameter_count() { return required_parameter_count_; }
2837 List<DartType>& positional_parameters() { return positional_parameters_; } 2798 List<DartType>& positional_parameters() { return positional_parameters_; }
2838 List<Tuple<String, DartType> >& named_parameters() { 2799 List<NamedParameter>& named_parameters() { return named_parameters_; }
2839 return named_parameters_;
2840 }
2841 DartType* return_type() { return return_type_; } 2800 DartType* return_type() { return return_type_; }
2842 2801
2843 private: 2802 private:
2844 FunctionType() {} 2803 FunctionType() {}
2845 2804
2846 TypeParameterList type_parameters_; 2805 TypeParameterList type_parameters_;
2847 int required_parameter_count_; 2806 int required_parameter_count_;
2848 List<DartType> positional_parameters_; 2807 List<DartType> positional_parameters_;
2849 List<Tuple<String, DartType> > named_parameters_; 2808 List<NamedParameter> named_parameters_;
2850 Child<DartType> return_type_; 2809 Child<DartType> return_type_;
2851 2810
2852 DISALLOW_COPY_AND_ASSIGN(FunctionType); 2811 DISALLOW_COPY_AND_ASSIGN(FunctionType);
2853 }; 2812 };
2854 2813
2855 2814
2856 class TypeParameterType : public DartType { 2815 class TypeParameterType : public DartType {
2857 public: 2816 public:
2858 static TypeParameterType* ReadFrom(Reader* reader); 2817 static TypeParameterType* ReadFrom(Reader* reader);
2859 2818
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 public: 2856 public:
2898 TypeParameter* ReadFrom(Reader* reader); 2857 TypeParameter* ReadFrom(Reader* reader);
2899 2858
2900 virtual ~TypeParameter(); 2859 virtual ~TypeParameter();
2901 2860
2902 DEFINE_CASTING_OPERATIONS(TypeParameter); 2861 DEFINE_CASTING_OPERATIONS(TypeParameter);
2903 2862
2904 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 2863 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
2905 virtual void VisitChildren(Visitor* visitor); 2864 virtual void VisitChildren(Visitor* visitor);
2906 2865
2907 String* name() { return name_; } 2866 intptr_t name() { return name_index_; }
2908 DartType* bound() { return bound_; } 2867 DartType* bound() { return bound_; }
2909 2868
2910 private: 2869 private:
2911 TypeParameter() {} 2870 TypeParameter() {}
2912 2871
2913 template <typename T> 2872 template <typename T>
2914 friend class List; 2873 friend class List;
2915 friend class TypeParameterList; 2874 friend class TypeParameterList;
2916 2875
2917 Ref<String> name_; 2876 intptr_t name_index_;
2918 Child<DartType> bound_; 2877 Child<DartType> bound_;
2919 2878
2920 DISALLOW_COPY_AND_ASSIGN(TypeParameter); 2879 DISALLOW_COPY_AND_ASSIGN(TypeParameter);
2921 }; 2880 };
2922 2881
2923 2882
2924 class Program : public TreeNode { 2883 class Program : public TreeNode {
2925 public: 2884 public:
2926 static Program* ReadFrom(Reader* reader); 2885 static Program* ReadFrom(Reader* reader);
2927 2886
2928 virtual ~Program(); 2887 virtual ~Program();
2929 2888
2930 DEFINE_CASTING_OPERATIONS(Program); 2889 DEFINE_CASTING_OPERATIONS(Program);
2931 2890
2932 virtual void AcceptTreeVisitor(TreeVisitor* visitor); 2891 virtual void AcceptTreeVisitor(TreeVisitor* visitor);
2933 virtual void VisitChildren(Visitor* visitor); 2892 virtual void VisitChildren(Visitor* visitor);
2934 2893
2935 StringTable& string_table() { return string_table_; }
2936 SourceTable& source_table() { return source_table_; } 2894 SourceTable& source_table() { return source_table_; }
2937 List<Library>& libraries() { return libraries_; } 2895 List<Library>& libraries() { return libraries_; }
2938 CanonicalName* main_method() { return main_method_reference_; } 2896 CanonicalName* main_method() { return main_method_reference_; }
2939 CanonicalName* canonical_name_root() { return canonical_name_root_; } 2897 CanonicalName* canonical_name_root() { return canonical_name_root_; }
2940 MallocGrowableArray<MallocGrowableArray<intptr_t>*> valid_token_positions; 2898 MallocGrowableArray<MallocGrowableArray<intptr_t>*> valid_token_positions;
2941 MallocGrowableArray<MallocGrowableArray<intptr_t>*> yield_token_positions; 2899 MallocGrowableArray<MallocGrowableArray<intptr_t>*> yield_token_positions;
2942 intptr_t string_data_offset() { return string_data_offset_; } 2900 intptr_t string_table_offset() { return string_table_offset_; }
2943 2901
2944 private: 2902 private:
2945 Program() {} 2903 Program() {}
2946 2904
2947 Child<CanonicalName> canonical_name_root_; 2905 Child<CanonicalName> canonical_name_root_;
2948 List<Library> libraries_; 2906 List<Library> libraries_;
2949 Ref<CanonicalName> main_method_reference_; // Procedure. 2907 Ref<CanonicalName> main_method_reference_; // Procedure.
2950 StringTable string_table_;
2951 SourceTable source_table_; 2908 SourceTable source_table_;
2952 2909
2953 // The offset from the start of the binary to the start of the UTF-8 encoded 2910 // The offset from the start of the binary to the start of the string table.
2954 // string data. 2911 intptr_t string_table_offset_;
2955 intptr_t string_data_offset_;
2956 2912
2957 DISALLOW_COPY_AND_ASSIGN(Program); 2913 DISALLOW_COPY_AND_ASSIGN(Program);
2958 }; 2914 };
2959 2915
2960 2916
2961 class Reference : public AllStatic { 2917 class Reference : public AllStatic {
2962 public: 2918 public:
2963 static CanonicalName* ReadMemberFrom(Reader* reader, bool allow_null = false); 2919 static CanonicalName* ReadMemberFrom(Reader* reader, bool allow_null = false);
2964 2920
2965 static CanonicalName* ReadClassFrom(Reader* reader, bool allow_null = false); 2921 static CanonicalName* ReadClassFrom(Reader* reader, bool allow_null = false);
2966 2922
2967 static CanonicalName* ReadTypedefFrom(Reader* reader); 2923 static CanonicalName* ReadTypedefFrom(Reader* reader);
2968
2969 static String* ReadStringFrom(Reader* reader);
2970 }; 2924 };
2971 2925
2972 2926
2973 class ExpressionVisitor { 2927 class ExpressionVisitor {
2974 public: 2928 public:
2975 virtual ~ExpressionVisitor() {} 2929 virtual ~ExpressionVisitor() {}
2976 2930
2977 virtual void VisitDefaultExpression(Expression* node) = 0; 2931 virtual void VisitDefaultExpression(Expression* node) = 0;
2978 virtual void VisitDefaultBasicLiteral(BasicLiteral* node) { 2932 virtual void VisitDefaultBasicLiteral(BasicLiteral* node) {
2979 VisitDefaultExpression(node); 2933 VisitDefaultExpression(node);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3361 } // namespace kernel 3315 } // namespace kernel
3362 3316
3363 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 3317 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
3364 intptr_t buffer_length); 3318 intptr_t buffer_length);
3365 3319
3366 3320
3367 } // namespace dart 3321 } // namespace dart
3368 3322
3369 #endif // !defined(DART_PRECOMPILED_RUNTIME) 3323 #endif // !defined(DART_PRECOMPILED_RUNTIME)
3370 #endif // RUNTIME_VM_KERNEL_H_ 3324 #endif // RUNTIME_VM_KERNEL_H_
OLDNEW
« no previous file with comments | « runtime/vm/bootstrap_nocore.cc ('k') | runtime/vm/kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698