| 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" |
| 11 #include "vm/class_finalizer.h" |
| 11 #include "vm/compiler_stats.h" | 12 #include "vm/compiler_stats.h" |
| 12 #include "vm/scanner.h" | 13 #include "vm/scanner.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 // Forward declarations. | 17 // Forward declarations. |
| 17 class Function; | 18 class Function; |
| 18 class Script; | 19 class Script; |
| 19 class TokenStream; | 20 class TokenStream; |
| 20 | 21 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Format an error or warning message into the message_buffer. | 175 // Format an error or warning message into the message_buffer. |
| 175 // A null script means no source and a negative token_index means no position. | 176 // A null script means no source and a negative token_index means no position. |
| 176 static void FormatMessage(const Script& script, | 177 static void FormatMessage(const Script& script, |
| 177 intptr_t token_index, | 178 intptr_t token_index, |
| 178 const char* message_header, | 179 const char* message_header, |
| 179 char* message_buffer, | 180 char* message_buffer, |
| 180 intptr_t message_buffer_size, | 181 intptr_t message_buffer_size, |
| 181 const char* format, | 182 const char* format, |
| 182 va_list args); | 183 va_list args); |
| 183 | 184 |
| 184 // Reports error message at location of current token. | 185 // Reports error/warning message at location of current token. |
| 185 void ErrorMsg(const char* msg, ...); | 186 void ErrorMsg(const char* msg, ...); |
| 187 void Warning(const char* msg, ...); |
| 188 void Unimplemented(const char* msg); |
| 189 |
| 190 // Reports error message at given location. |
| 186 void ErrorMsg(intptr_t token_index, const char* msg, ...); | 191 void ErrorMsg(intptr_t token_index, const char* msg, ...); |
| 187 void Warning(const char* msg, ...); | |
| 188 void Warning(intptr_t token_index, const char* msg, ...); | 192 void Warning(intptr_t token_index, const char* msg, ...); |
| 189 void Unimplemented(const char* msg); | |
| 190 | 193 |
| 191 const Instance& EvaluateConstExpr(AstNode* expr); | 194 const Instance& EvaluateConstExpr(AstNode* expr); |
| 192 void RunStaticFieldInitializer(const Field& field); | 195 void RunStaticFieldInitializer(const Field& field); |
| 193 RawObject* EvaluateConstConstructorCall( | 196 RawObject* EvaluateConstConstructorCall( |
| 194 const Class& type_class, | 197 const Class& type_class, |
| 195 const AbstractTypeArguments& type_arguments, | 198 const AbstractTypeArguments& type_arguments, |
| 196 const Function& constructor, | 199 const Function& constructor, |
| 197 ArgumentListNode* arguments); | 200 ArgumentListNode* arguments); |
| 198 AstNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr); | 201 AstNode* FoldConstExpr(intptr_t expr_pos, AstNode* expr); |
| 199 | 202 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 210 Dart_Handle CallLibraryTagHandler(Dart_LibraryTag tag, | 213 Dart_Handle CallLibraryTagHandler(Dart_LibraryTag tag, |
| 211 intptr_t token_pos, | 214 intptr_t token_pos, |
| 212 const String& url, | 215 const String& url, |
| 213 const Array& import_map); | 216 const Array& import_map); |
| 214 void ParseLibraryDefinition(); | 217 void ParseLibraryDefinition(); |
| 215 void ParseLibraryName(); | 218 void ParseLibraryName(); |
| 216 void ParseLibraryImport(); | 219 void ParseLibraryImport(); |
| 217 void ParseLibraryInclude(); | 220 void ParseLibraryInclude(); |
| 218 void ParseLibraryResource(); | 221 void ParseLibraryResource(); |
| 219 | 222 |
| 220 enum TypeResolution { | |
| 221 kIgnore, // Parsed type is ignored and replaced by Dynamic. | |
| 222 kDoNotResolve, // Type resolution is postponed. | |
| 223 kCanResolve, // Type resolution is optional. | |
| 224 kMustResolve // Type resolution is required. | |
| 225 }; | |
| 226 void ResolveTypeFromClass(const Class& cls, | 223 void ResolveTypeFromClass(const Class& cls, |
| 227 TypeResolution type_resolution, | 224 ClassFinalizer::TypeFinalization finalization, |
| 228 AbstractType* type); | 225 AbstractType* type); |
| 229 RawAbstractType* ParseType(TypeResolution type_resolution); | 226 RawAbstractType* ParseType(ClassFinalizer::TypeFinalization finalization); |
| 230 void ParseTypeParameters(const Class& cls); | 227 void ParseTypeParameters(const Class& cls); |
| 231 RawAbstractTypeArguments* ParseTypeArguments(TypeResolution type_resolution); | 228 RawAbstractTypeArguments* ParseTypeArguments( |
| 229 Error* malformed_error, |
| 230 ClassFinalizer::TypeFinalization finalization); |
| 232 void ParseQualIdent(QualIdent* qual_ident); | 231 void ParseQualIdent(QualIdent* qual_ident); |
| 233 void ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method); | 232 void ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method); |
| 234 void ParseFieldDefinition(ClassDesc* members, MemberDesc* field); | 233 void ParseFieldDefinition(ClassDesc* members, MemberDesc* field); |
| 235 void ParseClassMemberDefinition(ClassDesc* members); | 234 void ParseClassMemberDefinition(ClassDesc* members); |
| 236 void ParseFormalParameter(bool allow_explicit_default_value, | 235 void ParseFormalParameter(bool allow_explicit_default_value, |
| 237 ParamList* params); | 236 ParamList* params); |
| 238 void ParseFormalParameters(bool allow_explicit_default_values, | 237 void ParseFormalParameters(bool allow_explicit_default_values, |
| 239 ParamList* params); | 238 ParamList* params); |
| 240 void ParseFormalParameterList(bool allow_explicit_default_values, | 239 void ParseFormalParameterList(bool allow_explicit_default_values, |
| 241 ParamList* params); | 240 ParamList* params); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // Adds try block to the list of try blocks seen so far. | 315 // Adds try block to the list of try blocks seen so far. |
| 317 void PushTryBlock(Block* try_block); | 316 void PushTryBlock(Block* try_block); |
| 318 // Pops the inner most try block from the list. | 317 // Pops the inner most try block from the list. |
| 319 TryBlocks* PopTryBlock(); | 318 TryBlocks* PopTryBlock(); |
| 320 // Add specified node to try block list so that it can be patched with | 319 // Add specified node to try block list so that it can be patched with |
| 321 // inlined finally code if needed. | 320 // inlined finally code if needed. |
| 322 void AddNodeForFinallyInlining(AstNode* node); | 321 void AddNodeForFinallyInlining(AstNode* node); |
| 323 // Add the inlined finally block to the specified node. | 322 // Add the inlined finally block to the specified node. |
| 324 void AddFinallyBlockToNode(AstNode* node, InlinedFinallyNode* finally_node); | 323 void AddFinallyBlockToNode(AstNode* node, InlinedFinallyNode* finally_node); |
| 325 AstNode* ParseTryStatement(String* label_name); | 324 AstNode* ParseTryStatement(String* label_name); |
| 326 RawAbstractType* ParseFinalVarOrType(TypeResolution type_resolution); | 325 RawAbstractType* ParseFinalVarOrType( |
| 326 ClassFinalizer::TypeFinalization finalization); |
| 327 AstNode* ParseVariableDeclaration(const AbstractType& type, bool is_const); | 327 AstNode* ParseVariableDeclaration(const AbstractType& type, bool is_const); |
| 328 AstNode* ParseVariableDeclarationList(); | 328 AstNode* ParseVariableDeclarationList(); |
| 329 AstNode* ParseFunctionStatement(bool is_literal); | 329 AstNode* ParseFunctionStatement(bool is_literal); |
| 330 AstNode* ParseStatement(); | 330 AstNode* ParseStatement(); |
| 331 SequenceNode* ParseNestedStatement(bool parsing_loop_body, | 331 SequenceNode* ParseNestedStatement(bool parsing_loop_body, |
| 332 SourceLabel* label); | 332 SourceLabel* label); |
| 333 void ParseStatementSequence(); | 333 void ParseStatementSequence(); |
| 334 bool IsIdentifier(); | 334 bool IsIdentifier(); |
| 335 bool IsFunctionTypeAliasName(); | 335 bool IsFunctionTypeAliasName(); |
| 336 bool TryParseTypeParameter(); | 336 bool TryParseTypeParameter(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 // code at all points in the try block where an exit from the block is | 461 // code at all points in the try block where an exit from the block is |
| 462 // done using 'return', 'break' or 'continue' statements. | 462 // done using 'return', 'break' or 'continue' statements. |
| 463 TryBlocks* try_blocks_list_; | 463 TryBlocks* try_blocks_list_; |
| 464 | 464 |
| 465 DISALLOW_COPY_AND_ASSIGN(Parser); | 465 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 466 }; | 466 }; |
| 467 | 467 |
| 468 } // namespace dart | 468 } // namespace dart |
| 469 | 469 |
| 470 #endif // VM_PARSER_H_ | 470 #endif // VM_PARSER_H_ |
| OLD | NEW |