| 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 "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 // Parse and evaluate the metadata expressions at token_pos in the | 205 // Parse and evaluate the metadata expressions at token_pos in the |
| 206 // class namespace of class cls (which can be the implicit toplevel | 206 // class namespace of class cls (which can be the implicit toplevel |
| 207 // class if the metadata is at the top-level). | 207 // class if the metadata is at the top-level). |
| 208 static RawObject* ParseMetadata(const Class& cls, intptr_t token_pos); | 208 static RawObject* ParseMetadata(const Class& cls, intptr_t token_pos); |
| 209 | 209 |
| 210 // Build a function containing the initializer expression of the | 210 // Build a function containing the initializer expression of the |
| 211 // given static field. | 211 // given static field. |
| 212 static ParsedFunction* ParseStaticFieldInitializer(const Field& field); | 212 static ParsedFunction* ParseStaticFieldInitializer(const Field& field); |
| 213 | 213 |
| 214 // Returns a RawFunction or RawError. | |
| 215 static RawObject* ParseFunctionFromSource(const Class& owning_class, | |
| 216 const String& source); | |
| 217 | |
| 218 // Parse a function to retrieve parameter information that is not retained in | 214 // Parse a function to retrieve parameter information that is not retained in |
| 219 // the dart::Function object. Returns either an error if the parse fails | 215 // the dart::Function object. Returns either an error if the parse fails |
| 220 // (which could be the case for local functions), or a flat array of entries | 216 // (which could be the case for local functions), or a flat array of entries |
| 221 // for each parameter. Each parameter entry contains: | 217 // for each parameter. Each parameter entry contains: |
| 222 // * a Dart bool indicating whether the parameter was declared final | 218 // * a Dart bool indicating whether the parameter was declared final |
| 223 // * its default value (or null if none was declared) | 219 // * its default value (or null if none was declared) |
| 224 // * an array of metadata (or null if no metadata was declared). | 220 // * an array of metadata (or null if no metadata was declared). |
| 225 enum { | 221 enum { |
| 226 kParameterIsFinalOffset, | 222 kParameterIsFinalOffset, |
| 227 kParameterDefaultValueOffset, | 223 kParameterDefaultValueOffset, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 bool is_patch_source() const { | 292 bool is_patch_source() const { |
| 297 return script_.kind() == RawScript::kPatchTag; | 293 return script_.kind() == RawScript::kPatchTag; |
| 298 } | 294 } |
| 299 | 295 |
| 300 intptr_t TokenPos() const { return tokens_iterator_.CurrentPosition(); } | 296 intptr_t TokenPos() const { return tokens_iterator_.CurrentPosition(); } |
| 301 | 297 |
| 302 Token::Kind CurrentToken() { | 298 Token::Kind CurrentToken() { |
| 303 if (token_kind_ == Token::kILLEGAL) { | 299 if (token_kind_ == Token::kILLEGAL) { |
| 304 ComputeCurrentToken(); | 300 ComputeCurrentToken(); |
| 305 } | 301 } |
| 306 INC_STAT(isolate_, num_token_checks, 1); | |
| 307 return token_kind_; | 302 return token_kind_; |
| 308 } | 303 } |
| 309 | 304 |
| 310 void ComputeCurrentToken(); | 305 void ComputeCurrentToken(); |
| 311 | 306 |
| 312 RawLibraryPrefix* ParsePrefix(); | 307 RawLibraryPrefix* ParsePrefix(); |
| 313 | 308 |
| 314 Token::Kind LookaheadToken(int num_tokens); | 309 Token::Kind LookaheadToken(int num_tokens); |
| 315 String* CurrentLiteral() const; | 310 String* CurrentLiteral() const; |
| 316 RawDouble* CurrentDoubleLiteral() const; | 311 RawDouble* CurrentDoubleLiteral() const; |
| 317 RawInteger* CurrentIntegerLiteral() const; | 312 RawInteger* CurrentIntegerLiteral() const; |
| 318 | 313 |
| 319 // Sets parser to given token position in the stream. | 314 // Sets parser to given token position in the stream. |
| 320 void SetPosition(intptr_t position); | 315 void SetPosition(intptr_t position); |
| 321 | 316 |
| 322 void ConsumeToken() { | 317 void ConsumeToken() { |
| 323 // Reset cache and advance the token. | 318 // Reset cache and advance the token. |
| 324 token_kind_ = Token::kILLEGAL; | 319 token_kind_ = Token::kILLEGAL; |
| 325 tokens_iterator_.Advance(); | 320 tokens_iterator_.Advance(); |
| 326 INC_STAT(isolate_, num_tokens_consumed, 1); | 321 INC_STAT(thread(), num_tokens_consumed, 1); |
| 327 } | 322 } |
| 328 void ConsumeRightAngleBracket(); | 323 void ConsumeRightAngleBracket(); |
| 329 void CheckToken(Token::Kind token_expected, const char* msg = NULL); | 324 void CheckToken(Token::Kind token_expected, const char* msg = NULL); |
| 330 void ExpectToken(Token::Kind token_expected); | 325 void ExpectToken(Token::Kind token_expected); |
| 331 void ExpectSemicolon(); | 326 void ExpectSemicolon(); |
| 332 void UnexpectedToken(); | 327 void UnexpectedToken(); |
| 333 String* ExpectUserDefinedTypeIdentifier(const char* msg); | 328 String* ExpectUserDefinedTypeIdentifier(const char* msg); |
| 334 String* ExpectIdentifier(const char* msg); | 329 String* ExpectIdentifier(const char* msg); |
| 335 bool IsAwaitKeyword(); | 330 bool IsAwaitKeyword(); |
| 336 bool IsYieldKeyword(); | 331 bool IsYieldKeyword(); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 883 |
| 889 // Indentation of parser trace. | 884 // Indentation of parser trace. |
| 890 intptr_t trace_indent_; | 885 intptr_t trace_indent_; |
| 891 | 886 |
| 892 DISALLOW_COPY_AND_ASSIGN(Parser); | 887 DISALLOW_COPY_AND_ASSIGN(Parser); |
| 893 }; | 888 }; |
| 894 | 889 |
| 895 } // namespace dart | 890 } // namespace dart |
| 896 | 891 |
| 897 #endif // VM_PARSER_H_ | 892 #endif // VM_PARSER_H_ |
| OLD | NEW |