| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 VM_PARSER_H_ | 5 #ifndef VM_PARSER_H_ |
| 6 #define VM_PARSER_H_ | 6 #define VM_PARSER_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class ParsedFunction : public ZoneAllocated { | 32 class ParsedFunction : public ZoneAllocated { |
| 33 public: | 33 public: |
| 34 explicit ParsedFunction(const Function& function) | 34 explicit ParsedFunction(const Function& function) |
| 35 : function_(function), | 35 : function_(function), |
| 36 node_sequence_(NULL), | 36 node_sequence_(NULL), |
| 37 instantiator_(NULL), | 37 instantiator_(NULL), |
| 38 default_parameter_values_(Array::ZoneHandle()), | 38 default_parameter_values_(Array::ZoneHandle()), |
| 39 saved_current_context_var_(NULL), | 39 saved_current_context_var_(NULL), |
| 40 saved_entry_context_var_(NULL), | 40 saved_entry_context_var_(NULL), |
| 41 expression_temp_var_(NULL), | 41 expression_temp_var_(NULL), |
| 42 array_literal_var_(NULL), | |
| 43 first_parameter_index_(0), | 42 first_parameter_index_(0), |
| 44 first_stack_local_index_(0), | 43 first_stack_local_index_(0), |
| 45 num_copied_params_(0), | 44 num_copied_params_(0), |
| 46 num_stack_locals_(0) { | 45 num_stack_locals_(0) { |
| 47 ASSERT(function.IsZoneHandle()); | 46 ASSERT(function.IsZoneHandle()); |
| 48 } | 47 } |
| 49 | 48 |
| 50 const Function& function() const { return function_; } | 49 const Function& function() const { return function_; } |
| 51 | 50 |
| 52 SequenceNode* node_sequence() const { return node_sequence_; } | 51 SequenceNode* node_sequence() const { return node_sequence_; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 94 } |
| 96 void set_expression_temp_var(LocalVariable* value) { | 95 void set_expression_temp_var(LocalVariable* value) { |
| 97 ASSERT(!has_expression_temp_var()); | 96 ASSERT(!has_expression_temp_var()); |
| 98 expression_temp_var_ = value; | 97 expression_temp_var_ = value; |
| 99 } | 98 } |
| 100 bool has_expression_temp_var() const { | 99 bool has_expression_temp_var() const { |
| 101 return expression_temp_var_ != NULL; | 100 return expression_temp_var_ != NULL; |
| 102 } | 101 } |
| 103 static LocalVariable* CreateExpressionTempVar(intptr_t token_pos); | 102 static LocalVariable* CreateExpressionTempVar(intptr_t token_pos); |
| 104 | 103 |
| 105 void set_array_literal_var(LocalVariable* local) { | |
| 106 ASSERT((local != NULL) && (array_literal_var_ == NULL)); | |
| 107 array_literal_var_ = local; | |
| 108 } | |
| 109 LocalVariable* array_literal_var() const { | |
| 110 ASSERT(array_literal_var_ != NULL); | |
| 111 return array_literal_var_; | |
| 112 } | |
| 113 | |
| 114 static LocalVariable* CreateArrayLiteralVar(intptr_t token_pos); | |
| 115 | |
| 116 int first_parameter_index() const { return first_parameter_index_; } | 104 int first_parameter_index() const { return first_parameter_index_; } |
| 117 int first_stack_local_index() const { return first_stack_local_index_; } | 105 int first_stack_local_index() const { return first_stack_local_index_; } |
| 118 int num_copied_params() const { return num_copied_params_; } | 106 int num_copied_params() const { return num_copied_params_; } |
| 119 int num_stack_locals() const { return num_stack_locals_; } | 107 int num_stack_locals() const { return num_stack_locals_; } |
| 120 | 108 |
| 121 void AllocateVariables(); | 109 void AllocateVariables(); |
| 122 | 110 |
| 123 private: | 111 private: |
| 124 const Function& function_; | 112 const Function& function_; |
| 125 SequenceNode* node_sequence_; | 113 SequenceNode* node_sequence_; |
| 126 AstNode* instantiator_; | 114 AstNode* instantiator_; |
| 127 Array& default_parameter_values_; | 115 Array& default_parameter_values_; |
| 128 LocalVariable* saved_current_context_var_; | 116 LocalVariable* saved_current_context_var_; |
| 129 LocalVariable* saved_entry_context_var_; | 117 LocalVariable* saved_entry_context_var_; |
| 130 LocalVariable* expression_temp_var_; | 118 LocalVariable* expression_temp_var_; |
| 131 // TODO(hausner): Remove once ArrayNode creation is removed from flow | |
| 132 // graph builder. | |
| 133 LocalVariable* array_literal_var_; | |
| 134 | 119 |
| 135 int first_parameter_index_; | 120 int first_parameter_index_; |
| 136 int first_stack_local_index_; | 121 int first_stack_local_index_; |
| 137 int num_copied_params_; | 122 int num_copied_params_; |
| 138 int num_stack_locals_; | 123 int num_stack_locals_; |
| 139 | 124 |
| 140 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 125 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 141 }; | 126 }; |
| 142 | 127 |
| 143 | 128 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 bool allow_closure_names); | 578 bool allow_closure_names); |
| 594 RawString* ResolveImportVar(intptr_t ident_pos, const String& ident); | 579 RawString* ResolveImportVar(intptr_t ident_pos, const String& ident); |
| 595 AstNode* OptimizeBinaryOpNode(intptr_t op_pos, | 580 AstNode* OptimizeBinaryOpNode(intptr_t op_pos, |
| 596 Token::Kind binary_op, | 581 Token::Kind binary_op, |
| 597 AstNode* lhs, | 582 AstNode* lhs, |
| 598 AstNode* rhs); | 583 AstNode* rhs); |
| 599 AstNode* ExpandAssignableOp(intptr_t op_pos, | 584 AstNode* ExpandAssignableOp(intptr_t op_pos, |
| 600 Token::Kind assignment_op, | 585 Token::Kind assignment_op, |
| 601 AstNode* lhs, | 586 AstNode* lhs, |
| 602 AstNode* rhs); | 587 AstNode* rhs); |
| 603 AstNode* PrepareCompoundAssignmentNodes(AstNode** expr); | 588 LetNode* PrepareCompoundAssignmentNodes(AstNode** expr); |
| 604 LocalVariable* CreateTempConstVariable(intptr_t token_pos, const char* s); | 589 LocalVariable* CreateTempConstVariable(intptr_t token_pos, const char* s); |
| 605 | 590 |
| 606 static bool IsAssignableExpr(AstNode* expr); | 591 static bool IsAssignableExpr(AstNode* expr); |
| 607 | 592 |
| 608 static SequenceNode* NodeAsSequenceNode(intptr_t sequence_pos, | 593 static SequenceNode* NodeAsSequenceNode(intptr_t sequence_pos, |
| 609 AstNode* node, | 594 AstNode* node, |
| 610 LocalScope* scope); | 595 LocalScope* scope); |
| 611 | 596 |
| 612 SequenceNode* MakeImplicitConstructor(const Function& func); | 597 SequenceNode* MakeImplicitConstructor(const Function& func); |
| 613 AstNode* MakeStaticCall(const String& cls_name, | 598 AstNode* MakeStaticCall(const String& cls_name, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 629 void EnsureSavedCurrentContext(); | 614 void EnsureSavedCurrentContext(); |
| 630 AstNode* CreateAssignmentNode(AstNode* original, AstNode* rhs); | 615 AstNode* CreateAssignmentNode(AstNode* original, AstNode* rhs); |
| 631 AstNode* InsertClosureCallNodes(AstNode* condition); | 616 AstNode* InsertClosureCallNodes(AstNode* condition); |
| 632 | 617 |
| 633 ConstructorCallNode* CreateConstructorCallNode( | 618 ConstructorCallNode* CreateConstructorCallNode( |
| 634 intptr_t token_pos, | 619 intptr_t token_pos, |
| 635 const AbstractTypeArguments& type_arguments, | 620 const AbstractTypeArguments& type_arguments, |
| 636 const Function& constructor, | 621 const Function& constructor, |
| 637 ArgumentListNode* arguments); | 622 ArgumentListNode* arguments); |
| 638 | 623 |
| 639 LocalVariable* BuildArrayTempLocal(intptr_t token_pos); | |
| 640 | |
| 641 Script& script_; | 624 Script& script_; |
| 642 TokenStream::Iterator tokens_iterator_; | 625 TokenStream::Iterator tokens_iterator_; |
| 643 Token::Kind token_kind_; // Cached token kind for current token. | 626 Token::Kind token_kind_; // Cached token kind for current token. |
| 644 Block* current_block_; | 627 Block* current_block_; |
| 645 | 628 |
| 646 // is_top_level_ is true if parsing the "top level" of a compilation unit, | 629 // is_top_level_ is true if parsing the "top level" of a compilation unit, |
| 647 // that is class definitions, function type aliases, global functions, | 630 // that is class definitions, function type aliases, global functions, |
| 648 // global variables. | 631 // global variables. |
| 649 bool is_top_level_; | 632 bool is_top_level_; |
| 650 | 633 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 676 // code at all points in the try block where an exit from the block is | 659 // code at all points in the try block where an exit from the block is |
| 677 // done using 'return', 'break' or 'continue' statements. | 660 // done using 'return', 'break' or 'continue' statements. |
| 678 TryBlocks* try_blocks_list_; | 661 TryBlocks* try_blocks_list_; |
| 679 | 662 |
| 680 DISALLOW_COPY_AND_ASSIGN(Parser); | 663 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 681 }; | 664 }; |
| 682 | 665 |
| 683 } // namespace dart | 666 } // namespace dart |
| 684 | 667 |
| 685 #endif // VM_PARSER_H_ | 668 #endif // VM_PARSER_H_ |
| OLD | NEW |