| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 SequenceNode* node_sequence_; | 61 SequenceNode* node_sequence_; |
| 62 AstNode* instantiator_; | 62 AstNode* instantiator_; |
| 63 Array& default_parameter_values_; | 63 Array& default_parameter_values_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 65 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 | 68 |
| 69 class Parser : ValueObject { | 69 class Parser : ValueObject { |
| 70 public: | 70 public: |
| 71 static const int kErrorBuflen = 512; | |
| 72 | |
| 73 Parser(const Script& script, const Library& library); | 71 Parser(const Script& script, const Library& library); |
| 74 Parser(const Script& script, | 72 Parser(const Script& script, |
| 75 const Function& function, | 73 const Function& function, |
| 76 intptr_t token_index); | 74 intptr_t token_index); |
| 77 | 75 |
| 78 // Parse the top level of a whole script file and register declared classes | 76 // Parse the top level of a whole script file and register declared classes |
| 79 // and interfaces in the given library. | 77 // and interfaces in the given library. |
| 80 static void ParseCompilationUnit(const Library& library, | 78 static void ParseCompilationUnit(const Library& library, |
| 81 const Script& script); | 79 const Script& script); |
| 82 | 80 |
| 83 static void ParseFunction(ParsedFunction* parsed_function); | 81 static void ParseFunction(ParsedFunction* parsed_function); |
| 84 | 82 |
| 85 static void ReportMsg(const Script& script, | 83 // Format an error or warning message into the message_buffer. |
| 86 intptr_t token_index, | 84 // A null script means no source and a negative token_index means no position. |
| 87 const char* msg_type, | 85 static void FormatMessage(const Script& script, |
| 88 char* message, | 86 intptr_t token_index, |
| 89 const char* format, va_list args); | 87 const char* message_header, |
| 88 char* message_buffer, |
| 89 intptr_t message_buffer_size, |
| 90 const char* format, |
| 91 va_list args); |
| 90 | 92 |
| 91 private: | 93 private: |
| 92 struct Block; | 94 struct Block; |
| 93 class TryBlocks; | 95 class TryBlocks; |
| 94 | 96 |
| 95 // The function being parsed. | 97 // The function being parsed. |
| 96 const Function& current_function() const; | 98 const Function& current_function() const; |
| 97 | 99 |
| 98 // Note that a local function may be parsed multiple times. It is first parsed | 100 // Note that a local function may be parsed multiple times. It is first parsed |
| 99 // when its outermost enclosing function is being parsed. It is then parsed | 101 // when its outermost enclosing function is being parsed. It is then parsed |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 Class& current_class_; | 437 Class& current_class_; |
| 436 | 438 |
| 437 // The current library (and thus class dictionary) used to resolve names. | 439 // The current library (and thus class dictionary) used to resolve names. |
| 438 const Library& library_; | 440 const Library& library_; |
| 439 | 441 |
| 440 // List of try blocks seen so far, this is used to generate inlined finally | 442 // List of try blocks seen so far, this is used to generate inlined finally |
| 441 // code at all points in the try block where an exit from the block is | 443 // code at all points in the try block where an exit from the block is |
| 442 // done using 'return', 'break' or 'continue' statements. | 444 // done using 'return', 'break' or 'continue' statements. |
| 443 TryBlocks* try_blocks_list_; | 445 TryBlocks* try_blocks_list_; |
| 444 | 446 |
| 445 char error_msg_[kErrorBuflen]; | |
| 446 | |
| 447 DISALLOW_COPY_AND_ASSIGN(Parser); | 447 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 448 }; | 448 }; |
| 449 | 449 |
| 450 } // namespace dart | 450 } // namespace dart |
| 451 | 451 |
| 452 #endif // VM_PARSER_H_ | 452 #endif // VM_PARSER_H_ |
| OLD | NEW |