| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 int first_stack_local_index_; | 136 int first_stack_local_index_; |
| 137 int num_copied_params_; | 137 int num_copied_params_; |
| 138 int num_stack_locals_; | 138 int num_stack_locals_; |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); | 140 DISALLOW_COPY_AND_ASSIGN(ParsedFunction); |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 | 143 |
| 144 class Parser : public ValueObject { | 144 class Parser : public ValueObject { |
| 145 public: | 145 public: |
| 146 Parser(const Script& script, const Library& library); | |
| 147 Parser(const Script& script, ParsedFunction* function, intptr_t token_pos); | |
| 148 | |
| 149 // Parse the top level of a whole script file and register declared classes | 146 // Parse the top level of a whole script file and register declared classes |
| 150 // in the given library. | 147 // in the given library. |
| 151 static void ParseCompilationUnit(const Library& library, | 148 static void ParseCompilationUnit(const Library& library, |
| 152 const Script& script); | 149 const Script& script); |
| 153 | 150 |
| 151 // Parse top level of a class and register all functions/fields. |
| 152 static void ParseClass(const Class& cls); |
| 153 |
| 154 static void ParseFunction(ParsedFunction* parsed_function); | 154 static void ParseFunction(ParsedFunction* parsed_function); |
| 155 | 155 |
| 156 // Format and print a message with source location. | 156 // Format and print a message with source location. |
| 157 // A null script means no source and a negative token_pos means no position. | 157 // A null script means no source and a negative token_pos means no position. |
| 158 static void PrintMessage(const Script& script, | 158 static void PrintMessage(const Script& script, |
| 159 intptr_t token_pos, | 159 intptr_t token_pos, |
| 160 const char* message_header, | 160 const char* message_header, |
| 161 const char* format, ...) PRINTF_ATTRIBUTE(4, 5); | 161 const char* format, ...) PRINTF_ATTRIBUTE(4, 5); |
| 162 | 162 |
| 163 // Build an error object containing a formatted error or warning message. | 163 // Build an error object containing a formatted error or warning message. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 178 const Script& script, | 178 const Script& script, |
| 179 intptr_t token_pos, | 179 intptr_t token_pos, |
| 180 const char* message_header, | 180 const char* message_header, |
| 181 const char* format, | 181 const char* format, |
| 182 va_list args); | 182 va_list args); |
| 183 | 183 |
| 184 private: | 184 private: |
| 185 struct Block; | 185 struct Block; |
| 186 class TryBlocks; | 186 class TryBlocks; |
| 187 | 187 |
| 188 Parser(const Script& script, const Library& library, intptr_t token_pos); |
| 189 Parser(const Script& script, ParsedFunction* function, intptr_t token_pos); |
| 190 |
| 188 // The function for which we will generate code. | 191 // The function for which we will generate code. |
| 189 const Function& current_function() const; | 192 const Function& current_function() const; |
| 190 | 193 |
| 191 // The innermost function being parsed. | 194 // The innermost function being parsed. |
| 192 const Function& innermost_function() const; | 195 const Function& innermost_function() const; |
| 193 | 196 |
| 194 // Note that a local function may be parsed multiple times. It is first parsed | 197 // Note that a local function may be parsed multiple times. It is first parsed |
| 195 // when its outermost enclosing function is being parsed. It is then parsed | 198 // when its outermost enclosing function is being parsed. It is then parsed |
| 196 // again when an enclosing function calls this local function or calls | 199 // again when an enclosing function calls this local function or calls |
| 197 // another local function enclosing it. Code for the local function will only | 200 // another local function enclosing it. Code for the local function will only |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 AstNode* RunStaticFieldInitializer(const Field& field); | 328 AstNode* RunStaticFieldInitializer(const Field& field); |
| 326 RawObject* EvaluateConstConstructorCall( | 329 RawObject* EvaluateConstConstructorCall( |
| 327 const Class& type_class, | 330 const Class& type_class, |
| 328 const AbstractTypeArguments& type_arguments, | 331 const AbstractTypeArguments& type_arguments, |
| 329 const Function& constructor, | 332 const Function& constructor, |
| 330 ArgumentListNode* arguments); | 333 ArgumentListNode* arguments); |
| 331 AstNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr); | 334 AstNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr); |
| 332 | 335 |
| 333 // Support for parsing of scripts. | 336 // Support for parsing of scripts. |
| 334 void ParseTopLevel(); | 337 void ParseTopLevel(); |
| 335 void ParseClassDefinition(const GrowableObjectArray& pending_classes); | 338 void ParseClassDeclaration(const GrowableObjectArray& pending_classes); |
| 339 void ParseClassDefinition(const Class& cls); |
| 336 void ParseMixinTypedef(const GrowableObjectArray& pending_classes); | 340 void ParseMixinTypedef(const GrowableObjectArray& pending_classes); |
| 337 void ParseTypedef(const GrowableObjectArray& pending_classes); | 341 void ParseTypedef(const GrowableObjectArray& pending_classes); |
| 338 void ParseTopLevelVariable(TopLevel* top_level); | 342 void ParseTopLevelVariable(TopLevel* top_level); |
| 339 void ParseTopLevelFunction(TopLevel* top_level); | 343 void ParseTopLevelFunction(TopLevel* top_level); |
| 340 void ParseTopLevelAccessor(TopLevel* top_level); | 344 void ParseTopLevelAccessor(TopLevel* top_level); |
| 341 | 345 |
| 342 // Support for parsing libraries. | 346 // Support for parsing libraries. |
| 343 RawObject* CallLibraryTagHandler(Dart_LibraryTag tag, | 347 RawObject* CallLibraryTagHandler(Dart_LibraryTag tag, |
| 344 intptr_t token_pos, | 348 intptr_t token_pos, |
| 345 const String& url); | 349 const String& url); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 // code at all points in the try block where an exit from the block is | 676 // code at all points in the try block where an exit from the block is |
| 673 // done using 'return', 'break' or 'continue' statements. | 677 // done using 'return', 'break' or 'continue' statements. |
| 674 TryBlocks* try_blocks_list_; | 678 TryBlocks* try_blocks_list_; |
| 675 | 679 |
| 676 DISALLOW_COPY_AND_ASSIGN(Parser); | 680 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 677 }; | 681 }; |
| 678 | 682 |
| 679 } // namespace dart | 683 } // namespace dart |
| 680 | 684 |
| 681 #endif // VM_PARSER_H_ | 685 #endif // VM_PARSER_H_ |
| OLD | NEW |