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 RUNTIME_VM_PARSER_H_ | 5 #ifndef RUNTIME_VM_PARSER_H_ |
6 #define RUNTIME_VM_PARSER_H_ | 6 #define RUNTIME_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 18 matching lines...) Expand all Loading... |
29 class ScopeBuildingResult; | 29 class ScopeBuildingResult; |
30 | 30 |
31 } // kernel | 31 } // kernel |
32 | 32 |
33 class ArgumentsDescriptor; | 33 class ArgumentsDescriptor; |
34 class Isolate; | 34 class Isolate; |
35 class LocalScope; | 35 class LocalScope; |
36 class LocalVariable; | 36 class LocalVariable; |
37 struct RegExpCompileData; | 37 struct RegExpCompileData; |
38 class SourceLabel; | 38 class SourceLabel; |
39 template <typename T> class GrowableArray; | 39 template <typename T> |
| 40 class GrowableArray; |
40 class Parser; | 41 class Parser; |
41 | 42 |
42 struct CatchParamDesc; | 43 struct CatchParamDesc; |
43 class ClassDesc; | 44 class ClassDesc; |
44 struct MemberDesc; | 45 struct MemberDesc; |
45 struct ParamList; | 46 struct ParamList; |
46 struct QualIdent; | 47 struct QualIdent; |
47 class TopLevel; | 48 class TopLevel; |
48 class RecursionChecker; | 49 class RecursionChecker; |
49 | 50 |
(...skipping 17 matching lines...) Expand all Loading... |
67 return (key1.Value() == key2.Value()); | 68 return (key1.Value() == key2.Value()); |
68 } | 69 } |
69 static bool IsMatch(const TokenPosition& key1, const Object& b) { | 70 static bool IsMatch(const TokenPosition& key1, const Object& b) { |
70 const Smi& key2 = Smi::Cast(b); | 71 const Smi& key2 = Smi::Cast(b); |
71 return (key1.value() == key2.Value()); | 72 return (key1.value() == key2.Value()); |
72 } | 73 } |
73 static uword Hash(const Object& obj) { | 74 static uword Hash(const Object& obj) { |
74 const Smi& key = Smi::Cast(obj); | 75 const Smi& key = Smi::Cast(obj); |
75 return HashValue(key.Value()); | 76 return HashValue(key.Value()); |
76 } | 77 } |
77 static uword Hash(const TokenPosition& key) { | 78 static uword Hash(const TokenPosition& key) { return HashValue(key.value()); } |
78 return HashValue(key.value()); | |
79 } | |
80 // Used by CacheConstantValue if a new constant is added to the map. | 79 // Used by CacheConstantValue if a new constant is added to the map. |
81 static RawObject* NewKey(const TokenPosition& key) { | 80 static RawObject* NewKey(const TokenPosition& key) { |
82 return Smi::New(key.value()); | 81 return Smi::New(key.value()); |
83 } | 82 } |
84 | 83 |
85 private: | 84 private: |
86 static uword HashValue(intptr_t pos) { | 85 static uword HashValue(intptr_t pos) { return pos % (Smi::kMaxValue - 13); } |
87 return pos % (Smi::kMaxValue - 13); | |
88 } | |
89 }; | 86 }; |
90 typedef UnorderedHashMap<ConstMapKeyEqualsTraits> ConstantsMap; | 87 typedef UnorderedHashMap<ConstMapKeyEqualsTraits> ConstantsMap; |
91 | 88 |
92 // The class ParsedFunction holds the result of parsing a function. | 89 // The class ParsedFunction holds the result of parsing a function. |
93 class ParsedFunction : public ZoneAllocated { | 90 class ParsedFunction : public ZoneAllocated { |
94 public: | 91 public: |
95 ParsedFunction(Thread* thread, const Function& function) | 92 ParsedFunction(Thread* thread, const Function& function) |
96 : thread_(thread), | 93 : thread_(thread), |
97 function_(function), | 94 function_(function), |
98 code_(Code::Handle(zone(), function.unoptimized_code())), | 95 code_(Code::Handle(zone(), function.unoptimized_code())), |
99 node_sequence_(NULL), | 96 node_sequence_(NULL), |
100 regexp_compile_data_(NULL), | 97 regexp_compile_data_(NULL), |
101 instantiator_(NULL), | 98 instantiator_(NULL), |
102 current_context_var_(NULL), | 99 current_context_var_(NULL), |
103 expression_temp_var_(NULL), | 100 expression_temp_var_(NULL), |
104 finally_return_temp_var_(NULL), | 101 finally_return_temp_var_(NULL), |
105 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), | 102 deferred_prefixes_(new ZoneGrowableArray<const LibraryPrefix*>()), |
106 guarded_fields_(new ZoneGrowableArray<const Field*>()), | 103 guarded_fields_(new ZoneGrowableArray<const Field*>()), |
107 default_parameter_values_(NULL), | 104 default_parameter_values_(NULL), |
108 first_parameter_index_(0), | 105 first_parameter_index_(0), |
109 first_stack_local_index_(0), | 106 first_stack_local_index_(0), |
110 num_copied_params_(0), | 107 num_copied_params_(0), |
111 num_stack_locals_(0), | 108 num_stack_locals_(0), |
112 have_seen_await_expr_(false), | 109 have_seen_await_expr_(false), |
113 kernel_scopes_(NULL) { | 110 kernel_scopes_(NULL) { |
114 ASSERT(function.IsZoneHandle()); | 111 ASSERT(function.IsZoneHandle()); |
115 // Every function has a local variable for the current context. | 112 // Every function has a local variable for the current context. |
116 LocalVariable* temp = new(zone()) LocalVariable( | 113 LocalVariable* temp = new (zone()) |
117 function.token_pos(), | 114 LocalVariable(function.token_pos(), function.token_pos(), |
118 function.token_pos(), | 115 Symbols::CurrentContextVar(), Object::dynamic_type()); |
119 Symbols::CurrentContextVar(), | |
120 Object::dynamic_type()); | |
121 ASSERT(temp != NULL); | 116 ASSERT(temp != NULL); |
122 current_context_var_ = temp; | 117 current_context_var_ = temp; |
123 } | 118 } |
124 | 119 |
125 const Function& function() const { return function_; } | 120 const Function& function() const { return function_; } |
126 const Code& code() const { return code_; } | 121 const Code& code() const { return code_; } |
127 | 122 |
128 SequenceNode* node_sequence() const { return node_sequence_; } | 123 SequenceNode* node_sequence() const { return node_sequence_; } |
129 void SetNodeSequence(SequenceNode* node_sequence); | 124 void SetNodeSequence(SequenceNode* node_sequence); |
130 | 125 |
(...skipping 21 matching lines...) Expand all Loading... |
152 | 147 |
153 const Instance& DefaultParameterValueAt(intptr_t i) const { | 148 const Instance& DefaultParameterValueAt(intptr_t i) const { |
154 ASSERT(default_parameter_values_ != NULL); | 149 ASSERT(default_parameter_values_ != NULL); |
155 return *default_parameter_values_->At(i); | 150 return *default_parameter_values_->At(i); |
156 } | 151 } |
157 | 152 |
158 ZoneGrowableArray<const Instance*>* default_parameter_values() const { | 153 ZoneGrowableArray<const Instance*>* default_parameter_values() const { |
159 return default_parameter_values_; | 154 return default_parameter_values_; |
160 } | 155 } |
161 | 156 |
162 LocalVariable* current_context_var() const { | 157 LocalVariable* current_context_var() const { return current_context_var_; } |
163 return current_context_var_; | |
164 } | |
165 | 158 |
166 LocalVariable* expression_temp_var() const { | 159 LocalVariable* expression_temp_var() const { |
167 ASSERT(has_expression_temp_var()); | 160 ASSERT(has_expression_temp_var()); |
168 return expression_temp_var_; | 161 return expression_temp_var_; |
169 } | 162 } |
170 void set_expression_temp_var(LocalVariable* value) { | 163 void set_expression_temp_var(LocalVariable* value) { |
171 ASSERT(!has_expression_temp_var()); | 164 ASSERT(!has_expression_temp_var()); |
172 expression_temp_var_ = value; | 165 expression_temp_var_ = value; |
173 } | 166 } |
174 bool has_expression_temp_var() const { | 167 bool has_expression_temp_var() const { return expression_temp_var_ != NULL; } |
175 return expression_temp_var_ != NULL; | |
176 } | |
177 | 168 |
178 LocalVariable* finally_return_temp_var() const { | 169 LocalVariable* finally_return_temp_var() const { |
179 ASSERT(has_finally_return_temp_var()); | 170 ASSERT(has_finally_return_temp_var()); |
180 return finally_return_temp_var_; | 171 return finally_return_temp_var_; |
181 } | 172 } |
182 void set_finally_return_temp_var(LocalVariable* value) { | 173 void set_finally_return_temp_var(LocalVariable* value) { |
183 ASSERT(!has_finally_return_temp_var()); | 174 ASSERT(!has_finally_return_temp_var()); |
184 finally_return_temp_var_ = value; | 175 finally_return_temp_var_ = value; |
185 } | 176 } |
186 bool has_finally_return_temp_var() const { | 177 bool has_finally_return_temp_var() const { |
(...skipping 11 matching lines...) Expand all Loading... |
198 | 189 |
199 ZoneGrowableArray<const Field*>* guarded_fields() const { | 190 ZoneGrowableArray<const Field*>* guarded_fields() const { |
200 return guarded_fields_; | 191 return guarded_fields_; |
201 } | 192 } |
202 | 193 |
203 int first_parameter_index() const { return first_parameter_index_; } | 194 int first_parameter_index() const { return first_parameter_index_; } |
204 int first_stack_local_index() const { return first_stack_local_index_; } | 195 int first_stack_local_index() const { return first_stack_local_index_; } |
205 int num_copied_params() const { return num_copied_params_; } | 196 int num_copied_params() const { return num_copied_params_; } |
206 int num_stack_locals() const { return num_stack_locals_; } | 197 int num_stack_locals() const { return num_stack_locals_; } |
207 int num_non_copied_params() const { | 198 int num_non_copied_params() const { |
208 return (num_copied_params_ == 0) | 199 return (num_copied_params_ == 0) ? function().num_fixed_parameters() : 0; |
209 ? function().num_fixed_parameters() : 0; | |
210 } | 200 } |
211 | 201 |
212 void AllocateVariables(); | 202 void AllocateVariables(); |
213 void AllocateIrregexpVariables(intptr_t num_stack_locals); | 203 void AllocateIrregexpVariables(intptr_t num_stack_locals); |
214 | 204 |
215 void record_await() { have_seen_await_expr_ = true; } | 205 void record_await() { have_seen_await_expr_ = true; } |
216 bool have_seen_await() const { return have_seen_await_expr_; } | 206 bool have_seen_await() const { return have_seen_await_expr_; } |
217 | 207 |
218 Thread* thread() const { return thread_; } | 208 Thread* thread() const { return thread_; } |
219 Isolate* isolate() const { return thread_->isolate(); } | 209 Isolate* isolate() const { return thread_->isolate(); } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 }; | 284 }; |
295 static RawObject* ParseFunctionParameters(const Function& func); | 285 static RawObject* ParseFunctionParameters(const Function& func); |
296 | 286 |
297 private: | 287 private: |
298 friend class EffectGraphVisitor; // For BuildNoSuchMethodArguments. | 288 friend class EffectGraphVisitor; // For BuildNoSuchMethodArguments. |
299 | 289 |
300 struct Block; | 290 struct Block; |
301 class TryStack; | 291 class TryStack; |
302 class TokenPosScope; | 292 class TokenPosScope; |
303 | 293 |
304 Parser(const Script& script, | 294 Parser(const Script& script, const Library& library, TokenPosition token_pos); |
305 const Library& library, | |
306 TokenPosition token_pos); | |
307 Parser(const Script& script, | 295 Parser(const Script& script, |
308 ParsedFunction* function, | 296 ParsedFunction* function, |
309 TokenPosition token_pos); | 297 TokenPosition token_pos); |
310 ~Parser(); | 298 ~Parser(); |
311 | 299 |
312 // The function for which we will generate code. | 300 // The function for which we will generate code. |
313 const Function& current_function() const; | 301 const Function& current_function() const; |
314 | 302 |
315 // The innermost function being parsed. | 303 // The innermost function being parsed. |
316 const Function& innermost_function() const; | 304 const Function& innermost_function() const; |
(...skipping 21 matching lines...) Expand all Loading... |
338 | 326 |
339 // FunctionLevel is 0 when parsing code of current_function(), and denotes | 327 // FunctionLevel is 0 when parsing code of current_function(), and denotes |
340 // the relative nesting level when parsing a nested function. | 328 // the relative nesting level when parsing a nested function. |
341 int FunctionLevel() const; | 329 int FunctionLevel() const; |
342 | 330 |
343 // The class being parsed. | 331 // The class being parsed. |
344 const Class& current_class() const; | 332 const Class& current_class() const; |
345 void set_current_class(const Class& value); | 333 void set_current_class(const Class& value); |
346 | 334 |
347 // ParsedFunction accessor. | 335 // ParsedFunction accessor. |
348 ParsedFunction* parsed_function() const { | 336 ParsedFunction* parsed_function() const { return parsed_function_; } |
349 return parsed_function_; | |
350 } | |
351 | 337 |
352 const Script& script() const { return script_; } | 338 const Script& script() const { return script_; } |
353 void SetScript(const Script& script, TokenPosition token_pos); | 339 void SetScript(const Script& script, TokenPosition token_pos); |
354 | 340 |
355 const Library& library() const { return library_; } | 341 const Library& library() const { return library_; } |
356 void set_library(const Library& value) const { library_ = value.raw(); } | 342 void set_library(const Library& value) const { library_ = value.raw(); } |
357 | 343 |
358 // Parsing a library or a regular source script. | 344 // Parsing a library or a regular source script. |
359 bool is_library_source() const { | 345 bool is_library_source() const { |
360 return (script_.kind() == RawScript::kScriptTag) || | 346 return (script_.kind() == RawScript::kScriptTag) || |
361 (script_.kind() == RawScript::kLibraryTag); | 347 (script_.kind() == RawScript::kLibraryTag); |
362 } | 348 } |
363 | 349 |
364 bool is_part_source() const { | 350 bool is_part_source() const { |
365 return script_.kind() == RawScript::kSourceTag; | 351 return script_.kind() == RawScript::kSourceTag; |
366 } | 352 } |
367 | 353 |
368 // Parsing library patch script. | 354 // Parsing library patch script. |
369 bool is_patch_source() const { | 355 bool is_patch_source() const { |
370 return script_.kind() == RawScript::kPatchTag; | 356 return script_.kind() == RawScript::kPatchTag; |
371 } | 357 } |
372 | 358 |
373 TokenPosition TokenPos() const { | 359 TokenPosition TokenPos() const { return tokens_iterator_.CurrentPosition(); } |
374 return tokens_iterator_.CurrentPosition(); | |
375 } | |
376 TokenPosition PrevTokenPos() const { return prev_token_pos_; } | 360 TokenPosition PrevTokenPos() const { return prev_token_pos_; } |
377 | 361 |
378 Token::Kind CurrentToken() { | 362 Token::Kind CurrentToken() { |
379 if (token_kind_ == Token::kILLEGAL) { | 363 if (token_kind_ == Token::kILLEGAL) { |
380 ComputeCurrentToken(); | 364 ComputeCurrentToken(); |
381 } | 365 } |
382 return token_kind_; | 366 return token_kind_; |
383 } | 367 } |
384 | 368 |
385 void ComputeCurrentToken(); | 369 void ComputeCurrentToken(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 const TypeArguments& type_arguments); | 430 const TypeArguments& type_arguments); |
447 | 431 |
448 // Report error if parsed code is too deeply nested; avoid stack overflow. | 432 // Report error if parsed code is too deeply nested; avoid stack overflow. |
449 void CheckStack(); | 433 void CheckStack(); |
450 | 434 |
451 // Report already formatted error. | 435 // Report already formatted error. |
452 static void ReportError(const Error& error); | 436 static void ReportError(const Error& error); |
453 | 437 |
454 // Concatenate and report an already formatted error and a new error message. | 438 // Concatenate and report an already formatted error and a new error message. |
455 static void ReportErrors(const Error& prev_error, | 439 static void ReportErrors(const Error& prev_error, |
456 const Script& script, TokenPosition token_pos, | 440 const Script& script, |
457 const char* format, ...) PRINTF_ATTRIBUTE(4, 5); | 441 TokenPosition token_pos, |
| 442 const char* format, |
| 443 ...) PRINTF_ATTRIBUTE(4, 5); |
458 | 444 |
459 // Report error message at location of current token in current script. | 445 // Report error message at location of current token in current script. |
460 void ReportError(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3); | 446 void ReportError(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3); |
461 | 447 |
462 void ReportErrorBefore(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 448 void ReportErrorBefore(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
463 | 449 |
464 // Report error message at given location in current script. | 450 // Report error message at given location in current script. |
465 void ReportError(TokenPosition token_pos, | 451 void ReportError(TokenPosition token_pos, const char* msg, ...) const |
466 const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4); | 452 PRINTF_ATTRIBUTE(3, 4); |
467 | 453 |
468 // Report warning message at location of current token in current script. | 454 // Report warning message at location of current token in current script. |
469 void ReportWarning(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3); | 455 void ReportWarning(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3); |
470 | 456 |
471 // Report warning message at given location in current script. | 457 // Report warning message at given location in current script. |
472 void ReportWarning(TokenPosition token_pos, | 458 void ReportWarning(TokenPosition token_pos, const char* msg, ...) const |
473 const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4); | 459 PRINTF_ATTRIBUTE(3, 4); |
474 | 460 |
475 void CheckRecursiveInvocation(); | 461 void CheckRecursiveInvocation(); |
476 | 462 |
477 const Instance& EvaluateConstExpr(TokenPosition expr_pos, AstNode* expr); | 463 const Instance& EvaluateConstExpr(TokenPosition expr_pos, AstNode* expr); |
478 StaticGetterNode* RunStaticFieldInitializer(const Field& field, | 464 StaticGetterNode* RunStaticFieldInitializer(const Field& field, |
479 TokenPosition field_ref_pos); | 465 TokenPosition field_ref_pos); |
480 RawObject* EvaluateConstConstructorCall(const Class& type_class, | 466 RawObject* EvaluateConstConstructorCall(const Class& type_class, |
481 const TypeArguments& type_arguments, | 467 const TypeArguments& type_arguments, |
482 const Function& constructor, | 468 const Function& constructor, |
483 ArgumentListNode* arguments); | 469 ArgumentListNode* arguments); |
484 LiteralNode* FoldConstExpr(TokenPosition expr_pos, AstNode* expr); | 470 LiteralNode* FoldConstExpr(TokenPosition expr_pos, AstNode* expr); |
485 | 471 |
486 // Support for parsing of scripts. | 472 // Support for parsing of scripts. |
487 void ParseTopLevel(); | 473 void ParseTopLevel(); |
488 void ParseEnumDeclaration(const GrowableObjectArray& pending_classes, | 474 void ParseEnumDeclaration(const GrowableObjectArray& pending_classes, |
489 const Object& tl_owner, | 475 const Object& tl_owner, |
490 TokenPosition metadata_pos); | 476 TokenPosition metadata_pos); |
491 void ParseEnumDefinition(const Class& cls); | 477 void ParseEnumDefinition(const Class& cls); |
492 void ParseClassDeclaration(const GrowableObjectArray& pending_classes, | 478 void ParseClassDeclaration(const GrowableObjectArray& pending_classes, |
493 const Object& tl_owner, | 479 const Object& tl_owner, |
494 TokenPosition metadata_pos); | 480 TokenPosition metadata_pos); |
495 void ParseClassDefinition(const Class& cls); | 481 void ParseClassDefinition(const Class& cls); |
496 void ParseMixinAppAlias(const GrowableObjectArray& pending_classes, | 482 void ParseMixinAppAlias(const GrowableObjectArray& pending_classes, |
497 const Object& tl_owner, | 483 const Object& tl_owner, |
498 TokenPosition metadata_pos); | 484 TokenPosition metadata_pos); |
499 void ParseTypedef(const GrowableObjectArray& pending_classes, | 485 void ParseTypedef(const GrowableObjectArray& pending_classes, |
500 const Object& tl_owner, | 486 const Object& tl_owner, |
501 TokenPosition metadata_pos); | 487 TokenPosition metadata_pos); |
502 void ParseTopLevelVariable(TopLevel* top_level, | 488 void ParseTopLevelVariable(TopLevel* top_level, |
503 const Object& owner, TokenPosition metadata_pos); | 489 const Object& owner, |
| 490 TokenPosition metadata_pos); |
504 void ParseTopLevelFunction(TopLevel* top_level, | 491 void ParseTopLevelFunction(TopLevel* top_level, |
505 const Object& owner, TokenPosition metadata_pos); | 492 const Object& owner, |
| 493 TokenPosition metadata_pos); |
506 void ParseTopLevelAccessor(TopLevel* top_level, | 494 void ParseTopLevelAccessor(TopLevel* top_level, |
507 const Object& owner, TokenPosition metadata_pos); | 495 const Object& owner, |
| 496 TokenPosition metadata_pos); |
508 RawArray* EvaluateMetadata(); | 497 RawArray* EvaluateMetadata(); |
509 | 498 |
510 RawFunction::AsyncModifier ParseFunctionModifier(); | 499 RawFunction::AsyncModifier ParseFunctionModifier(); |
511 | 500 |
512 // Support for parsing libraries. | 501 // Support for parsing libraries. |
513 RawObject* CallLibraryTagHandler(Dart_LibraryTag tag, | 502 RawObject* CallLibraryTagHandler(Dart_LibraryTag tag, |
514 TokenPosition token_pos, | 503 TokenPosition token_pos, |
515 const String& url); | 504 const String& url); |
516 void ParseIdentList(GrowableObjectArray* names); | 505 void ParseIdentList(GrowableObjectArray* names); |
517 void ParseLibraryDefinition(const Object& tl_owner); | 506 void ParseLibraryDefinition(const Object& tl_owner); |
518 void ParseLibraryName(); | 507 void ParseLibraryName(); |
519 void ParseLibraryImportExport(const Object& tl_owner, | 508 void ParseLibraryImportExport(const Object& tl_owner, |
520 TokenPosition metadata_pos); | 509 TokenPosition metadata_pos); |
521 void ParseLibraryPart(); | 510 void ParseLibraryPart(); |
522 void ParsePartHeader(); | 511 void ParsePartHeader(); |
523 void ParseLibraryNameObsoleteSyntax(); | 512 void ParseLibraryNameObsoleteSyntax(); |
524 void ParseLibraryImportObsoleteSyntax(); | 513 void ParseLibraryImportObsoleteSyntax(); |
525 void ParseLibraryIncludeObsoleteSyntax(); | 514 void ParseLibraryIncludeObsoleteSyntax(); |
526 | 515 |
527 void ResolveType(ClassFinalizer::FinalizationKind finalization, | 516 void ResolveType(ClassFinalizer::FinalizationKind finalization, |
528 AbstractType* type); | 517 AbstractType* type); |
529 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, | 518 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, |
530 bool allow_deferred_type = false, | 519 bool allow_deferred_type = false, |
531 bool consume_unresolved_prefix = true); | 520 bool consume_unresolved_prefix = true); |
532 RawAbstractType* ParseType( | 521 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, |
533 ClassFinalizer::FinalizationKind finalization, | 522 bool allow_deferred_type, |
534 bool allow_deferred_type, | 523 bool consume_unresolved_prefix, |
535 bool consume_unresolved_prefix, | 524 LibraryPrefix* prefix); |
536 LibraryPrefix* prefix); | |
537 | 525 |
538 void ParseTypeParameters(bool parameterizing_class); | 526 void ParseTypeParameters(bool parameterizing_class); |
539 RawTypeArguments* ParseTypeArguments( | 527 RawTypeArguments* ParseTypeArguments( |
540 ClassFinalizer::FinalizationKind finalization); | 528 ClassFinalizer::FinalizationKind finalization); |
541 void ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method); | 529 void ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method); |
542 void ParseFieldDefinition(ClassDesc* members, MemberDesc* field); | 530 void ParseFieldDefinition(ClassDesc* members, MemberDesc* field); |
543 void CheckMemberNameConflict(ClassDesc* members, MemberDesc* member); | 531 void CheckMemberNameConflict(ClassDesc* members, MemberDesc* member); |
544 void ParseClassMemberDefinition(ClassDesc* members, | 532 void ParseClassMemberDefinition(ClassDesc* members, |
545 TokenPosition metadata_pos); | 533 TokenPosition metadata_pos); |
546 void ParseFormalParameter(bool allow_explicit_default_value, | 534 void ParseFormalParameter(bool allow_explicit_default_value, |
547 bool evaluate_metadata, | 535 bool evaluate_metadata, |
548 ParamList* params); | 536 ParamList* params); |
549 void ParseFormalParameters(bool allow_explicit_default_values, | 537 void ParseFormalParameters(bool allow_explicit_default_values, |
550 bool evaluate_metadata, | 538 bool evaluate_metadata, |
551 ParamList* params); | 539 ParamList* params); |
552 void ParseFormalParameterList(bool allow_explicit_default_values, | 540 void ParseFormalParameterList(bool allow_explicit_default_values, |
553 bool evaluate_metadata, | 541 bool evaluate_metadata, |
554 ParamList* params); | 542 ParamList* params); |
555 void CheckFieldsInitialized(const Class& cls); | 543 void CheckFieldsInitialized(const Class& cls); |
556 void AddImplicitConstructor(const Class& cls); | 544 void AddImplicitConstructor(const Class& cls); |
557 void CheckConstructors(ClassDesc* members); | 545 void CheckConstructors(ClassDesc* members); |
558 AstNode* ParseExternalInitializedField(const Field& field); | 546 AstNode* ParseExternalInitializedField(const Field& field); |
559 void ParseInitializedInstanceFields( | 547 void ParseInitializedInstanceFields( |
560 const Class& cls, | 548 const Class& cls, |
561 LocalVariable* receiver, | 549 LocalVariable* receiver, |
562 GrowableArray<Field*>* initialized_fields); | 550 GrowableArray<Field*>* initialized_fields); |
563 AstNode* CheckDuplicateFieldInit( | 551 AstNode* CheckDuplicateFieldInit(TokenPosition init_pos, |
564 TokenPosition init_pos, | 552 GrowableArray<Field*>* initialized_fields, |
565 GrowableArray<Field*>* initialized_fields, | 553 AstNode* instance, |
566 AstNode* instance, | 554 Field* field, |
567 Field* field, | 555 AstNode* init_value); |
568 AstNode* init_value); | |
569 StaticCallNode* GenerateSuperConstructorCall( | 556 StaticCallNode* GenerateSuperConstructorCall( |
570 const Class& cls, | 557 const Class& cls, |
571 TokenPosition supercall_pos, | 558 TokenPosition supercall_pos, |
572 LocalVariable* receiver, | 559 LocalVariable* receiver, |
573 ArgumentListNode* forwarding_args); | 560 ArgumentListNode* forwarding_args); |
574 StaticCallNode* ParseSuperInitializer( | 561 StaticCallNode* ParseSuperInitializer(const Class& cls, |
575 const Class& cls, | 562 LocalVariable* receiver); |
576 LocalVariable* receiver); | |
577 AstNode* ParseInitializer(const Class& cls, | 563 AstNode* ParseInitializer(const Class& cls, |
578 LocalVariable* receiver, | 564 LocalVariable* receiver, |
579 GrowableArray<Field*>* initialized_fields); | 565 GrowableArray<Field*>* initialized_fields); |
580 void ParseConstructorRedirection(const Class& cls, LocalVariable* receiver); | 566 void ParseConstructorRedirection(const Class& cls, LocalVariable* receiver); |
581 void ParseInitializers(const Class& cls, | 567 void ParseInitializers(const Class& cls, |
582 LocalVariable* receiver, | 568 LocalVariable* receiver, |
583 GrowableArray<Field*>* initialized_fields); | 569 GrowableArray<Field*>* initialized_fields); |
584 String& ParseNativeDeclaration(); | 570 String& ParseNativeDeclaration(); |
585 void ParseInterfaceList(const Class& cls); | 571 void ParseInterfaceList(const Class& cls); |
586 RawAbstractType* ParseMixins(const AbstractType& super_type); | 572 RawAbstractType* ParseMixins(const AbstractType& super_type); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 void OpenAsyncGeneratorClosure(); | 642 void OpenAsyncGeneratorClosure(); |
657 SequenceNode* CloseAsyncGeneratorClosure(SequenceNode* body); | 643 SequenceNode* CloseAsyncGeneratorClosure(SequenceNode* body); |
658 | 644 |
659 void OpenAsyncTryBlock(); | 645 void OpenAsyncTryBlock(); |
660 SequenceNode* CloseBlock(); | 646 SequenceNode* CloseBlock(); |
661 SequenceNode* CloseAsyncFunction(const Function& closure, | 647 SequenceNode* CloseAsyncFunction(const Function& closure, |
662 SequenceNode* closure_node); | 648 SequenceNode* closure_node); |
663 | 649 |
664 SequenceNode* CloseAsyncClosure(SequenceNode* body); | 650 SequenceNode* CloseAsyncClosure(SequenceNode* body); |
665 SequenceNode* CloseAsyncTryBlock(SequenceNode* try_block); | 651 SequenceNode* CloseAsyncTryBlock(SequenceNode* try_block); |
666 SequenceNode* CloseAsyncGeneratorTryBlock(SequenceNode *body); | 652 SequenceNode* CloseAsyncGeneratorTryBlock(SequenceNode* body); |
667 | 653 |
668 void AddAsyncClosureParameters(ParamList* params); | 654 void AddAsyncClosureParameters(ParamList* params); |
669 void AddContinuationVariables(); | 655 void AddContinuationVariables(); |
670 void AddAsyncClosureVariables(); | 656 void AddAsyncClosureVariables(); |
671 void AddAsyncGeneratorVariables(); | 657 void AddAsyncGeneratorVariables(); |
672 | 658 |
673 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); | 659 LocalVariable* LookupReceiver(LocalScope* from_scope, bool test_only); |
674 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, | 660 LocalVariable* LookupTypeArgumentsParameter(LocalScope* from_scope, |
675 bool test_only); | 661 bool test_only); |
676 void CaptureInstantiator(); | 662 void CaptureInstantiator(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 bool is_async, | 713 bool is_async, |
728 LocalVariable* exception_var, | 714 LocalVariable* exception_var, |
729 LocalVariable* stack_trace_var, | 715 LocalVariable* stack_trace_var, |
730 LocalVariable* rethrow_exception_var, | 716 LocalVariable* rethrow_exception_var, |
731 LocalVariable* rethrow_stack_trace_var); | 717 LocalVariable* rethrow_stack_trace_var); |
732 // Push try block onto the stack of try blocks in scope. | 718 // Push try block onto the stack of try blocks in scope. |
733 void PushTry(Block* try_block); | 719 void PushTry(Block* try_block); |
734 // Pop the inner most try block from the stack. | 720 // Pop the inner most try block from the stack. |
735 TryStack* PopTry(); | 721 TryStack* PopTry(); |
736 // Collect saved try context variables if await or yield is in try block. | 722 // Collect saved try context variables if await or yield is in try block. |
737 void CheckAsyncOpInTryBlock( | 723 void CheckAsyncOpInTryBlock(LocalVariable** saved_try_ctx, |
738 LocalVariable** saved_try_ctx, | 724 LocalVariable** async_saved_try_ctx, |
739 LocalVariable** async_saved_try_ctx, | 725 LocalVariable** outer_saved_try_ctx, |
740 LocalVariable** outer_saved_try_ctx, | 726 LocalVariable** outer_async_saved_try_ctx) const; |
741 LocalVariable** outer_async_saved_try_ctx) const; | |
742 // Add specified node to try block list so that it can be patched with | 727 // Add specified node to try block list so that it can be patched with |
743 // inlined finally code if needed. | 728 // inlined finally code if needed. |
744 void AddNodeForFinallyInlining(AstNode* node); | 729 void AddNodeForFinallyInlining(AstNode* node); |
745 void RemoveNodesForFinallyInlining(SourceLabel* label); | 730 void RemoveNodesForFinallyInlining(SourceLabel* label); |
746 // Add the inlined finally clause to the specified node. | 731 // Add the inlined finally clause to the specified node. |
747 void AddFinallyClauseToNode(bool is_async, | 732 void AddFinallyClauseToNode(bool is_async, |
748 AstNode* node, | 733 AstNode* node, |
749 InlinedFinallyNode* finally_clause); | 734 InlinedFinallyNode* finally_clause); |
750 AstNode* ParseTryStatement(String* label_name); | 735 AstNode* ParseTryStatement(String* label_name); |
751 RawAbstractType* ParseConstFinalVarOrType( | 736 RawAbstractType* ParseConstFinalVarOrType( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 const String& field_name, | 818 const String& field_name, |
834 TokenPosition ident_pos); | 819 TokenPosition ident_pos); |
835 | 820 |
836 LocalVariable* LookupLocalScope(const String& ident); | 821 LocalVariable* LookupLocalScope(const String& ident); |
837 void CheckInstanceFieldAccess(TokenPosition field_pos, | 822 void CheckInstanceFieldAccess(TokenPosition field_pos, |
838 const String& field_name); | 823 const String& field_name); |
839 bool ParsingStaticMember() const; | 824 bool ParsingStaticMember() const; |
840 const AbstractType* ReceiverType(const Class& cls); | 825 const AbstractType* ReceiverType(const Class& cls); |
841 bool IsInstantiatorRequired() const; | 826 bool IsInstantiatorRequired() const; |
842 bool ResolveIdentInLocalScope(TokenPosition ident_pos, | 827 bool ResolveIdentInLocalScope(TokenPosition ident_pos, |
843 const String &ident, | 828 const String& ident, |
844 AstNode** node, | 829 AstNode** node, |
845 intptr_t* function_level); | 830 intptr_t* function_level); |
846 static const bool kResolveLocally = true; | 831 static const bool kResolveLocally = true; |
847 static const bool kResolveIncludingImports = false; | 832 static const bool kResolveIncludingImports = false; |
848 | 833 |
849 // Resolve a primary identifier in the library or prefix scope and | 834 // Resolve a primary identifier in the library or prefix scope and |
850 // generate the corresponding AstNode. | 835 // generate the corresponding AstNode. |
851 AstNode* ResolveIdentInCurrentLibraryScope(TokenPosition ident_pos, | 836 AstNode* ResolveIdentInCurrentLibraryScope(TokenPosition ident_pos, |
852 const String& ident); | 837 const String& ident); |
853 AstNode* ResolveIdentInPrefixScope(TokenPosition ident_pos, | 838 AstNode* ResolveIdentInPrefixScope(TokenPosition ident_pos, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 | 902 |
918 RawInstance* TryCanonicalize(const Instance& instance, | 903 RawInstance* TryCanonicalize(const Instance& instance, |
919 TokenPosition token_pos); | 904 TokenPosition token_pos); |
920 void CacheConstantValue(TokenPosition token_pos, const Instance& value); | 905 void CacheConstantValue(TokenPosition token_pos, const Instance& value); |
921 bool GetCachedConstant(TokenPosition token_pos, Instance* value); | 906 bool GetCachedConstant(TokenPosition token_pos, Instance* value); |
922 | 907 |
923 Thread* thread() const { return thread_; } | 908 Thread* thread() const { return thread_; } |
924 Isolate* isolate() const { return isolate_; } | 909 Isolate* isolate() const { return isolate_; } |
925 Zone* zone() const { return thread_->zone(); } | 910 Zone* zone() const { return thread_->zone(); } |
926 | 911 |
927 Thread* thread_; // Cached current thread. | 912 Thread* thread_; // Cached current thread. |
928 Isolate* isolate_; // Cached current isolate. | 913 Isolate* isolate_; // Cached current isolate. |
929 | 914 |
930 Script& script_; | 915 Script& script_; |
931 TokenStream::Iterator tokens_iterator_; | 916 TokenStream::Iterator tokens_iterator_; |
932 Token::Kind token_kind_; // Cached token kind for current token. | 917 Token::Kind token_kind_; // Cached token kind for current token. |
933 TokenPosition prev_token_pos_; | 918 TokenPosition prev_token_pos_; |
934 Block* current_block_; | 919 Block* current_block_; |
935 | 920 |
936 // is_top_level_ is true if parsing the "top level" of a compilation unit, | 921 // is_top_level_ is true if parsing the "top level" of a compilation unit, |
937 // that is class definitions, function type aliases, global functions, | 922 // that is class definitions, function type aliases, global functions, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 | 974 |
990 intptr_t recursion_counter_; | 975 intptr_t recursion_counter_; |
991 friend class RecursionChecker; | 976 friend class RecursionChecker; |
992 | 977 |
993 DISALLOW_COPY_AND_ASSIGN(Parser); | 978 DISALLOW_COPY_AND_ASSIGN(Parser); |
994 }; | 979 }; |
995 | 980 |
996 } // namespace dart | 981 } // namespace dart |
997 | 982 |
998 #endif // RUNTIME_VM_PARSER_H_ | 983 #endif // RUNTIME_VM_PARSER_H_ |
OLD | NEW |