| 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 "vm/ast.h" | 10 #include "vm/ast.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // The class ParsedFunction holds the result of parsing a function. | 30 // The class ParsedFunction holds the result of parsing a function. |
| 31 class ParsedFunction : ValueObject { | 31 class ParsedFunction : ValueObject { |
| 32 public: | 32 public: |
| 33 explicit ParsedFunction(const Function& function) | 33 explicit ParsedFunction(const Function& function) |
| 34 : function_(function), | 34 : function_(function), |
| 35 node_sequence_(NULL), | 35 node_sequence_(NULL), |
| 36 instantiator_(NULL), | 36 instantiator_(NULL), |
| 37 default_parameter_values_(Array::Handle()), | 37 default_parameter_values_(Array::Handle()), |
| 38 saved_context_var_(NULL), | 38 saved_context_var_(NULL), |
| 39 expression_temp_var_(NULL), |
| 39 first_parameter_index_(0), | 40 first_parameter_index_(0), |
| 40 first_stack_local_index_(0), | 41 first_stack_local_index_(0), |
| 41 copied_parameter_count_(0), | 42 copied_parameter_count_(0), |
| 42 stack_local_count_(0) { } | 43 stack_local_count_(0) { } |
| 43 | 44 |
| 44 const Function& function() const { return function_; } | 45 const Function& function() const { return function_; } |
| 45 | 46 |
| 46 SequenceNode* node_sequence() const { return node_sequence_; } | 47 SequenceNode* node_sequence() const { return node_sequence_; } |
| 47 void SetNodeSequence(SequenceNode* node_sequence); | 48 void SetNodeSequence(SequenceNode* node_sequence); |
| 48 | 49 |
| 49 AstNode* instantiator() const { return instantiator_; } | 50 AstNode* instantiator() const { return instantiator_; } |
| 50 void set_instantiator(AstNode* instantiator) { | 51 void set_instantiator(AstNode* instantiator) { |
| 51 // May be NULL. | 52 // May be NULL. |
| 52 instantiator_ = instantiator; | 53 instantiator_ = instantiator; |
| 53 } | 54 } |
| 54 | 55 |
| 55 const Array& default_parameter_values() const { | 56 const Array& default_parameter_values() const { |
| 56 return default_parameter_values_; | 57 return default_parameter_values_; |
| 57 } | 58 } |
| 58 void set_default_parameter_values(const Array& default_parameter_values) { | 59 void set_default_parameter_values(const Array& default_parameter_values) { |
| 59 default_parameter_values_ = default_parameter_values.raw(); | 60 default_parameter_values_ = default_parameter_values.raw(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 LocalVariable* saved_context_var() const { return saved_context_var_; } | 63 LocalVariable* saved_context_var() const { return saved_context_var_; } |
| 63 void set_saved_context_var(LocalVariable* saved_context_var) { | 64 void set_saved_context_var(LocalVariable* saved_context_var) { |
| 64 ASSERT(saved_context_var != NULL); | 65 ASSERT(saved_context_var != NULL); |
| 65 saved_context_var_ = saved_context_var; | 66 saved_context_var_ = saved_context_var; |
| 66 } | 67 } |
| 67 | 68 |
| 69 LocalVariable* expression_temp_var() const { |
| 70 ASSERT(has_expression_temp_var()); |
| 71 return expression_temp_var_; |
| 72 } |
| 73 void set_expression_temp_var(LocalVariable* value) { |
| 74 ASSERT(!has_expression_temp_var()); |
| 75 expression_temp_var_ = value; |
| 76 } |
| 77 bool has_expression_temp_var() const { |
| 78 return expression_temp_var_ != NULL; |
| 79 } |
| 80 static LocalVariable* CreateExpressionTempVar(intptr_t token_index); |
| 81 |
| 68 int first_parameter_index() const { return first_parameter_index_; } | 82 int first_parameter_index() const { return first_parameter_index_; } |
| 69 int first_stack_local_index() const { return first_stack_local_index_; } | 83 int first_stack_local_index() const { return first_stack_local_index_; } |
| 70 int copied_parameter_count() const { return copied_parameter_count_; } | 84 int copied_parameter_count() const { return copied_parameter_count_; } |
| 71 int stack_local_count() const { return stack_local_count_; } | 85 int stack_local_count() const { return stack_local_count_; } |
| 72 | 86 |
| 73 void AllocateVariables(); | 87 void AllocateVariables(); |
| 74 | 88 |
| 75 private: | 89 private: |
| 76 const Function& function_; | 90 const Function& function_; |
| 77 SequenceNode* node_sequence_; | 91 SequenceNode* node_sequence_; |
| 78 AstNode* instantiator_; | 92 AstNode* instantiator_; |
| 79 Array& default_parameter_values_; | 93 Array& default_parameter_values_; |
| 80 LocalVariable* saved_context_var_; | 94 LocalVariable* saved_context_var_; |
| 95 LocalVariable* expression_temp_var_; |
| 81 | 96 |
| 82 int first_parameter_index_; | 97 int first_parameter_index_; |
| 83 int first_stack_local_index_; | 98 int first_stack_local_index_; |
| 84 int copied_parameter_count_; | 99 int copied_parameter_count_; |
| 85 int stack_local_count_; | 100 int stack_local_count_; |
| 86 | 101 |
| 87 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 102 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 88 }; | 103 }; |
| 89 | 104 |
| 90 | 105 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 const char* function_name, | 476 const char* function_name, |
| 462 ArgumentListNode* arguments); | 477 ArgumentListNode* arguments); |
| 463 String& Interpolate(ArrayNode* values); | 478 String& Interpolate(ArrayNode* values); |
| 464 AstNode* MakeAssertCall(intptr_t begin, intptr_t end); | 479 AstNode* MakeAssertCall(intptr_t begin, intptr_t end); |
| 465 AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type); | 480 AstNode* ThrowTypeError(intptr_t type_pos, const AbstractType& type); |
| 466 | 481 |
| 467 void CheckFunctionIsCallable(intptr_t token_index, const Function& function); | 482 void CheckFunctionIsCallable(intptr_t token_index, const Function& function); |
| 468 void CheckOperatorArity(const MemberDesc& member, Token::Kind operator_token); | 483 void CheckOperatorArity(const MemberDesc& member, Token::Kind operator_token); |
| 469 | 484 |
| 470 const LocalVariable& GetIncrementTempLocal(); | 485 const LocalVariable& GetIncrementTempLocal(); |
| 486 void EnsureExpressionTemp(); |
| 471 | 487 |
| 472 const Script& script_; | 488 const Script& script_; |
| 473 const TokenStream& tokens_; | 489 const TokenStream& tokens_; |
| 474 intptr_t token_index_; | 490 intptr_t token_index_; |
| 475 Token::Kind token_kind_; // Cached token kind for the token_index_. | 491 Token::Kind token_kind_; // Cached token kind for the token_index_. |
| 476 Block* current_block_; | 492 Block* current_block_; |
| 477 | 493 |
| 478 // is_top_level_ is true if parsing the "top level" of a compilation unit, | 494 // is_top_level_ is true if parsing the "top level" of a compilation unit, |
| 479 // that is interface and class definitions. | 495 // that is interface and class definitions. |
| 480 bool is_top_level_; | 496 bool is_top_level_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 496 | 512 |
| 497 // The current library (and thus class dictionary) used to resolve names. | 513 // The current library (and thus class dictionary) used to resolve names. |
| 498 const Library& library_; | 514 const Library& library_; |
| 499 | 515 |
| 500 // List of try blocks seen so far, this is used to generate inlined finally | 516 // List of try blocks seen so far, this is used to generate inlined finally |
| 501 // code at all points in the try block where an exit from the block is | 517 // code at all points in the try block where an exit from the block is |
| 502 // done using 'return', 'break' or 'continue' statements. | 518 // done using 'return', 'break' or 'continue' statements. |
| 503 TryBlocks* try_blocks_list_; | 519 TryBlocks* try_blocks_list_; |
| 504 | 520 |
| 505 // Allocate temporary only once per function. | 521 // Allocate temporary only once per function. |
| 506 LocalVariable* increment_temp_; | 522 LocalVariable* expression_temp_; |
| 507 | 523 |
| 508 DISALLOW_COPY_AND_ASSIGN(Parser); | 524 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 509 }; | 525 }; |
| 510 | 526 |
| 511 } // namespace dart | 527 } // namespace dart |
| 512 | 528 |
| 513 #endif // VM_PARSER_H_ | 529 #endif // VM_PARSER_H_ |
| OLD | NEW |