OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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_KERNEL_BINARY_FLOWGRAPH_H_ | 5 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "vm/kernel.h" | 12 #include "vm/kernel.h" |
13 #include "vm/kernel_binary.h" | 13 #include "vm/kernel_binary.h" |
14 #include "vm/kernel_to_il.h" | 14 #include "vm/kernel_to_il.h" |
15 #include "vm/object.h" | 15 #include "vm/object.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 namespace kernel { | 18 namespace kernel { |
19 | 19 |
20 class StreamingDartTypeTranslator { | 20 class StreamingDartTypeTranslator { |
21 public: | 21 public: |
22 StreamingDartTypeTranslator(StreamingFlowGraphBuilder* builder, | 22 StreamingDartTypeTranslator(StreamingFlowGraphBuilder* builder, |
23 bool finalize = false); | 23 bool finalize = false); |
24 | 24 |
25 // Can return a malformed type. | 25 // Can return a malformed type. |
26 AbstractType& BuildType(); | 26 AbstractType& BuildType(); |
| 27 // Can return a malformed type. |
| 28 AbstractType& BuildTypeWithoutFinalization(); |
27 // Is guaranteed to be not malformed. | 29 // Is guaranteed to be not malformed. |
28 AbstractType& BuildVariableType(); | 30 AbstractType& BuildVariableType(); |
29 | 31 |
30 // Will return `TypeArguments::null()` in case any of the arguments are | 32 // Will return `TypeArguments::null()` in case any of the arguments are |
31 // malformed. | 33 // malformed. |
32 const TypeArguments& BuildTypeArguments(intptr_t length); | 34 const TypeArguments& BuildTypeArguments(intptr_t length); |
33 | 35 |
34 // Will return `TypeArguments::null()` in case any of the arguments are | 36 // Will return `TypeArguments::null()` in case any of the arguments are |
35 // malformed. | 37 // malformed. |
36 const TypeArguments& BuildInstantiatedTypeArguments( | 38 const TypeArguments& BuildInstantiatedTypeArguments( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 intptr_t kernel_offset, | 96 intptr_t kernel_offset, |
95 const uint8_t* buffer, | 97 const uint8_t* buffer, |
96 intptr_t buffer_length); | 98 intptr_t buffer_length); |
97 | 99 |
98 virtual ~StreamingScopeBuilder(); | 100 virtual ~StreamingScopeBuilder(); |
99 | 101 |
100 ScopeBuildingResult* BuildScopes(); | 102 ScopeBuildingResult* BuildScopes(); |
101 | 103 |
102 private: | 104 private: |
103 void VisitField(); | 105 void VisitField(); |
104 void ReadFieldUntilAnnotation(TokenPosition* position, | |
105 TokenPosition* end_position, | |
106 word* flags, | |
107 intptr_t* parent_offset); | |
108 | 106 |
109 /** | |
110 * Will read until the function node; as this is optional, will return the tag | |
111 * (i.e. either kSomething or kNothing). | |
112 */ | |
113 Tag ReadProcedureUntilFunctionNode(word* kind, intptr_t* parent_offset); | |
114 void GetTypeParameterInfoForPossibleProcedure( | |
115 intptr_t outermost_kernel_offset, | |
116 bool* member_is_procedure, | |
117 bool* is_factory_procedure, | |
118 intptr_t* member_type_parameters, | |
119 intptr_t* member_type_parameters_offset_start); | |
120 void VisitProcedure(); | 107 void VisitProcedure(); |
121 | 108 |
122 /** | |
123 * Will return binary offset of parent class. | |
124 */ | |
125 intptr_t ReadConstructorUntilFunctionNode(); | |
126 void VisitConstructor(); | 109 void VisitConstructor(); |
127 | 110 |
128 void ReadClassUntilTypeParameters(); | |
129 void ReadClassUntilFields(); | |
130 | |
131 void ReadFunctionNodeUntilTypeParameters(word* async_marker, | |
132 word* dart_async_marker); | |
133 void VisitFunctionNode(); | 111 void VisitFunctionNode(); |
134 | |
135 void DiscoverEnclosingElements(Zone* zone, | |
136 const Function& function, | |
137 Function* outermost_function, | |
138 intptr_t* outermost_kernel_offset, | |
139 intptr_t* parent_class_offset); | |
140 intptr_t GetParentOffset(intptr_t offset); | |
141 void GetTypeParameterInfoForClass(intptr_t class_offset, | |
142 intptr_t* type_paremeter_counts, | |
143 intptr_t* type_paremeter_offset); | |
144 void VisitNode(); | 112 void VisitNode(); |
145 void VisitInitializer(); | 113 void VisitInitializer(); |
146 void VisitExpression(); | 114 void VisitExpression(); |
147 void VisitStatement(); | 115 void VisitStatement(); |
148 void VisitArguments(); | 116 void VisitArguments(); |
149 void VisitVariableDeclaration(); | 117 void VisitVariableDeclaration(); |
150 void VisitDartType(); | 118 void VisitDartType(); |
151 void VisitInterfaceType(bool simple); | 119 void VisitInterfaceType(bool simple); |
152 void VisitFunctionType(bool simple); | 120 void VisitFunctionType(bool simple); |
153 void VisitTypeParameterType(); | 121 void VisitTypeParameterType(); |
(...skipping 20 matching lines...) Expand all Loading... |
174 | 142 |
175 void AddExceptionVariable(GrowableArray<LocalVariable*>* variables, | 143 void AddExceptionVariable(GrowableArray<LocalVariable*>* variables, |
176 const char* prefix, | 144 const char* prefix, |
177 intptr_t nesting_depth); | 145 intptr_t nesting_depth); |
178 | 146 |
179 void AddTryVariables(); | 147 void AddTryVariables(); |
180 void AddCatchVariables(); | 148 void AddCatchVariables(); |
181 void AddIteratorVariable(); | 149 void AddIteratorVariable(); |
182 void AddSwitchVariable(); | 150 void AddSwitchVariable(); |
183 | 151 |
184 StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset); | |
185 | |
186 // Record an assignment or reference to a variable. If the occurrence is | 152 // Record an assignment or reference to a variable. If the occurrence is |
187 // in a nested function, ensure that the variable is handled properly as a | 153 // in a nested function, ensure that the variable is handled properly as a |
188 // captured variable. | 154 // captured variable. |
189 void LookupVariable(intptr_t declaration_binary_offest); | 155 void LookupVariable(intptr_t declaration_binary_offest); |
190 | 156 |
191 const dart::String& GenerateName(const char* prefix, intptr_t suffix); | 157 const dart::String& GenerateName(const char* prefix, intptr_t suffix); |
192 | 158 |
193 void HandleSpecialLoad(LocalVariable** variable, const dart::String& symbol); | 159 void HandleSpecialLoad(LocalVariable** variable, const dart::String& symbol); |
194 void LookupCapturedVariableByName(LocalVariable** variable, | 160 void LookupCapturedVariableByName(LocalVariable** variable, |
195 const dart::String& name); | 161 const dart::String& name); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 195 |
230 bool needs_expr_temp_; | 196 bool needs_expr_temp_; |
231 TokenPosition first_body_token_position_; | 197 TokenPosition first_body_token_position_; |
232 | 198 |
233 StreamingFlowGraphBuilder* builder_; | 199 StreamingFlowGraphBuilder* builder_; |
234 StreamingDartTypeTranslator type_translator_; | 200 StreamingDartTypeTranslator type_translator_; |
235 | 201 |
236 word unused_word; | 202 word unused_word; |
237 intptr_t unused_intptr; | 203 intptr_t unused_intptr; |
238 TokenPosition unused_tokenposition; | 204 TokenPosition unused_tokenposition; |
| 205 NameIndex unused_nameindex; |
239 }; | 206 }; |
240 | 207 |
241 | 208 |
| 209 // There are several cases when we are compiling constant expressions: |
| 210 // |
| 211 // * constant field initializers: |
| 212 // const FieldName = <expr>; |
| 213 // |
| 214 // * constant expressions: |
| 215 // const [<expr>, ...] |
| 216 // const {<expr> : <expr>, ...} |
| 217 // const Constructor(<expr>, ...) |
| 218 // |
| 219 // * constant default parameters: |
| 220 // f(a, [b = <expr>]) |
| 221 // f(a, {b: <expr>}) |
| 222 // |
| 223 // * constant values to compare in a [SwitchCase] |
| 224 // case <expr>: |
| 225 // |
| 226 // In all cases `<expr>` must be recursively evaluated and canonicalized at |
| 227 // compile-time. |
242 class StreamingConstantEvaluator { | 228 class StreamingConstantEvaluator { |
243 public: | 229 public: |
244 explicit StreamingConstantEvaluator(StreamingFlowGraphBuilder* builder); | 230 explicit StreamingConstantEvaluator(StreamingFlowGraphBuilder* builder); |
245 | 231 |
246 virtual ~StreamingConstantEvaluator() {} | 232 virtual ~StreamingConstantEvaluator() {} |
247 | 233 |
248 Instance& EvaluateExpression(intptr_t offset, bool reset_position = true); | 234 Instance& EvaluateExpression(intptr_t offset, bool reset_position = true); |
249 Instance& EvaluateListLiteral(intptr_t offset, bool reset_position = true); | 235 Instance& EvaluateListLiteral(intptr_t offset, bool reset_position = true); |
250 Instance& EvaluateMapLiteral(intptr_t offset, bool reset_position = true); | 236 Instance& EvaluateMapLiteral(intptr_t offset, bool reset_position = true); |
251 Instance& EvaluateConstructorInvocation(intptr_t offset, | 237 Instance& EvaluateConstructorInvocation(intptr_t offset, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 StreamingFlowGraphBuilder(FlowGraphBuilder* flow_graph_builder, | 307 StreamingFlowGraphBuilder(FlowGraphBuilder* flow_graph_builder, |
322 const uint8_t* buffer, | 308 const uint8_t* buffer, |
323 intptr_t buffer_length) | 309 intptr_t buffer_length) |
324 : flow_graph_builder_(flow_graph_builder), | 310 : flow_graph_builder_(flow_graph_builder), |
325 translation_helper_(flow_graph_builder->translation_helper_), | 311 translation_helper_(flow_graph_builder->translation_helper_), |
326 zone_(flow_graph_builder->zone_), | 312 zone_(flow_graph_builder->zone_), |
327 reader_(new Reader(buffer, buffer_length)), | 313 reader_(new Reader(buffer, buffer_length)), |
328 constant_evaluator_(this), | 314 constant_evaluator_(this), |
329 type_translator_(this, /* finalize= */ true) {} | 315 type_translator_(this, /* finalize= */ true) {} |
330 | 316 |
331 ~StreamingFlowGraphBuilder() { delete reader_; } | |
332 | |
333 Fragment BuildExpressionAt(intptr_t kernel_offset); | |
334 Fragment BuildStatementAt(intptr_t kernel_offset); | |
335 | |
336 private: | |
337 StreamingFlowGraphBuilder(TranslationHelper* translation_helper, | 317 StreamingFlowGraphBuilder(TranslationHelper* translation_helper, |
338 Zone* zone, | 318 Zone* zone, |
339 const uint8_t* buffer, | 319 const uint8_t* buffer, |
340 intptr_t buffer_length) | 320 intptr_t buffer_length) |
341 : flow_graph_builder_(NULL), | 321 : flow_graph_builder_(NULL), |
342 translation_helper_(*translation_helper), | 322 translation_helper_(*translation_helper), |
343 zone_(zone), | 323 zone_(zone), |
344 reader_(new Reader(buffer, buffer_length)), | 324 reader_(new Reader(buffer, buffer_length)), |
345 constant_evaluator_(this), | 325 constant_evaluator_(this), |
346 type_translator_(this, /* finalize= */ true) {} | 326 type_translator_(this, /* finalize= */ true) {} |
347 | 327 |
| 328 ~StreamingFlowGraphBuilder() { delete reader_; } |
| 329 |
| 330 FlowGraph* BuildGraph(intptr_t kernel_offset); |
| 331 |
| 332 Fragment BuildStatementAt(intptr_t kernel_offset); |
| 333 RawObject* BuildParameterDescriptor(intptr_t kernel_offset); |
| 334 RawObject* EvaluateMetadata(intptr_t kernel_offset); |
| 335 |
| 336 private: |
| 337 void DiscoverEnclosingElements(Zone* zone, |
| 338 const Function& function, |
| 339 Function* outermost_function, |
| 340 intptr_t* outermost_kernel_offset, |
| 341 intptr_t* parent_class_offset); |
| 342 intptr_t GetParentOffset(intptr_t offset); |
| 343 void GetTypeParameterInfoForClass(intptr_t class_offset, |
| 344 intptr_t* type_paremeter_counts, |
| 345 intptr_t* type_paremeter_offset); |
| 346 void ReadClassUntilFields(); |
| 347 void ReadClassUntilTypeParameters(); |
| 348 /** |
| 349 * Will return binary offset of parent class. |
| 350 */ |
| 351 intptr_t ReadConstructorUntilFunctionNode(); |
| 352 /** |
| 353 * Will read until the function node; as this is optional, will return the tag |
| 354 * (i.e. either kSomething or kNothing). |
| 355 */ |
| 356 Tag ReadProcedureUntilFunctionNode(word* kind, intptr_t* parent_offset); |
| 357 |
| 358 void ReadFieldUntilAnnotation(NameIndex* canonical_name, |
| 359 TokenPosition* position, |
| 360 TokenPosition* end_position, |
| 361 word* flags, |
| 362 intptr_t* parent_offset); |
| 363 void GetTypeParameterInfoForPossibleProcedure( |
| 364 intptr_t outermost_kernel_offset, |
| 365 bool* member_is_procedure, |
| 366 bool* is_factory_procedure, |
| 367 intptr_t* member_type_parameters, |
| 368 intptr_t* member_type_parameters_offset_start); |
| 369 void ReadFunctionNodeUntilTypeParameters(TokenPosition* position, |
| 370 TokenPosition* end_position, |
| 371 word* async_marker, |
| 372 word* dart_async_marker); |
| 373 /** |
| 374 * Will return kernel offset for parent class if reading a constructor. |
| 375 * Will otherwise return -1. |
| 376 */ |
| 377 intptr_t ReadUntilFunctionNode(); |
| 378 StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset); |
| 379 |
| 380 FlowGraph* BuildGraphOfStaticFieldInitializer(); |
| 381 FlowGraph* BuildGraphOfFieldAccessor(LocalVariable* setter_value); |
| 382 void SetupDefaultParameterValues(); |
| 383 Fragment BuildFieldInitializer(NameIndex canonical_name); |
| 384 Fragment BuildInitializers(intptr_t constructor_class_parent_offset); |
| 385 FlowGraph* BuildGraphOfImplicitClosureFunction(const Function& function); |
| 386 FlowGraph* BuildGraphOfFunction( |
| 387 bool is_in_builtin_library_toplevel, |
| 388 intptr_t constructor_class_parent_offset = -1); |
| 389 Fragment BuildGetMainClosure(); |
| 390 |
348 Fragment BuildExpression(TokenPosition* position = NULL); | 391 Fragment BuildExpression(TokenPosition* position = NULL); |
349 Fragment BuildStatement(); | 392 Fragment BuildStatement(); |
350 | 393 |
351 intptr_t ReaderOffset(); | 394 intptr_t ReaderOffset(); |
352 void SetOffset(intptr_t offset); | 395 void SetOffset(intptr_t offset); |
353 void SkipBytes(intptr_t skip); | 396 void SkipBytes(intptr_t skip); |
354 bool ReadBool(); | 397 bool ReadBool(); |
355 uint8_t ReadByte(); | 398 uint8_t ReadByte(); |
356 uint32_t ReadUInt(); | 399 uint32_t ReadUInt(); |
357 uint32_t PeekUInt(); | 400 uint32_t PeekUInt(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 void catch_depth_dec(); | 435 void catch_depth_dec(); |
393 void try_depth_inc(); | 436 void try_depth_inc(); |
394 void try_depth_dec(); | 437 void try_depth_dec(); |
395 intptr_t CurrentTryIndex(); | 438 intptr_t CurrentTryIndex(); |
396 intptr_t AllocateTryIndex(); | 439 intptr_t AllocateTryIndex(); |
397 LocalVariable* CurrentException(); | 440 LocalVariable* CurrentException(); |
398 LocalVariable* CurrentStackTrace(); | 441 LocalVariable* CurrentStackTrace(); |
399 CatchBlock* catch_block(); | 442 CatchBlock* catch_block(); |
400 ActiveClass* active_class(); | 443 ActiveClass* active_class(); |
401 ScopeBuildingResult* scopes(); | 444 ScopeBuildingResult* scopes(); |
| 445 void set_scopes(ScopeBuildingResult* scope); |
402 ParsedFunction* parsed_function(); | 446 ParsedFunction* parsed_function(); |
403 TryFinallyBlock* try_finally_block(); | 447 TryFinallyBlock* try_finally_block(); |
404 SwitchBlock* switch_block(); | 448 SwitchBlock* switch_block(); |
405 BreakableBlock* breakable_block(); | 449 BreakableBlock* breakable_block(); |
406 GrowableArray<YieldContinuation>& yield_continuations(); | 450 GrowableArray<YieldContinuation>& yield_continuations(); |
407 Value* stack(); | 451 Value* stack(); |
408 Value* Pop(); | 452 Value* Pop(); |
409 | 453 |
410 Tag PeekArgumentsFirstPositionalTag(); | 454 Tag PeekArgumentsFirstPositionalTag(); |
411 const TypeArguments& PeekArgumentsInstantiatedType(const dart::Class& klass); | 455 const TypeArguments& PeekArgumentsInstantiatedType(const dart::Class& klass); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 Fragment BuildStringConcatenation(TokenPosition* position); | 574 Fragment BuildStringConcatenation(TokenPosition* position); |
531 Fragment BuildIsExpression(TokenPosition* position); | 575 Fragment BuildIsExpression(TokenPosition* position); |
532 Fragment BuildAsExpression(TokenPosition* position); | 576 Fragment BuildAsExpression(TokenPosition* position); |
533 Fragment BuildSymbolLiteral(TokenPosition* position); | 577 Fragment BuildSymbolLiteral(TokenPosition* position); |
534 Fragment BuildTypeLiteral(TokenPosition* position); | 578 Fragment BuildTypeLiteral(TokenPosition* position); |
535 Fragment BuildThisExpression(TokenPosition* position); | 579 Fragment BuildThisExpression(TokenPosition* position); |
536 Fragment BuildRethrow(TokenPosition* position); | 580 Fragment BuildRethrow(TokenPosition* position); |
537 Fragment BuildThrow(TokenPosition* position); | 581 Fragment BuildThrow(TokenPosition* position); |
538 Fragment BuildListLiteral(bool is_const, TokenPosition* position); | 582 Fragment BuildListLiteral(bool is_const, TokenPosition* position); |
539 Fragment BuildMapLiteral(bool is_const, TokenPosition* position); | 583 Fragment BuildMapLiteral(bool is_const, TokenPosition* position); |
| 584 Fragment BuildFunctionExpression(); |
540 Fragment BuildLet(TokenPosition* position); | 585 Fragment BuildLet(TokenPosition* position); |
541 Fragment BuildBigIntLiteral(TokenPosition* position); | 586 Fragment BuildBigIntLiteral(TokenPosition* position); |
542 Fragment BuildStringLiteral(TokenPosition* position); | 587 Fragment BuildStringLiteral(TokenPosition* position); |
543 Fragment BuildIntLiteral(uint8_t payload, TokenPosition* position); | 588 Fragment BuildIntLiteral(uint8_t payload, TokenPosition* position); |
544 Fragment BuildIntLiteral(bool is_negative, TokenPosition* position); | 589 Fragment BuildIntLiteral(bool is_negative, TokenPosition* position); |
545 Fragment BuildDoubleLiteral(TokenPosition* position); | 590 Fragment BuildDoubleLiteral(TokenPosition* position); |
546 Fragment BuildBoolLiteral(bool value, TokenPosition* position); | 591 Fragment BuildBoolLiteral(bool value, TokenPosition* position); |
547 Fragment BuildNullLiteral(TokenPosition* position); | 592 Fragment BuildNullLiteral(TokenPosition* position); |
548 | 593 |
549 Fragment BuildInvalidStatement(); | 594 Fragment BuildInvalidStatement(); |
550 Fragment BuildExpressionStatement(); | 595 Fragment BuildExpressionStatement(); |
551 Fragment BuildBlock(); | 596 Fragment BuildBlock(); |
552 Fragment BuildEmptyStatement(); | 597 Fragment BuildEmptyStatement(); |
553 Fragment BuildAssertStatement(); | 598 Fragment BuildAssertStatement(); |
554 Fragment BuildLabeledStatement(); | 599 Fragment BuildLabeledStatement(); |
555 Fragment BuildBreakStatement(); | 600 Fragment BuildBreakStatement(); |
556 Fragment BuildWhileStatement(); | 601 Fragment BuildWhileStatement(); |
557 Fragment BuildDoStatement(); | 602 Fragment BuildDoStatement(); |
558 Fragment BuildForStatement(); | 603 Fragment BuildForStatement(); |
559 Fragment BuildForInStatement(bool async); | 604 Fragment BuildForInStatement(bool async); |
560 Fragment BuildSwitchStatement(); | 605 Fragment BuildSwitchStatement(); |
561 Fragment BuildContinueSwitchStatement(); | 606 Fragment BuildContinueSwitchStatement(); |
562 Fragment BuildIfStatement(); | 607 Fragment BuildIfStatement(); |
563 Fragment BuildReturnStatement(); | 608 Fragment BuildReturnStatement(); |
564 Fragment BuildTryCatch(); | 609 Fragment BuildTryCatch(); |
565 Fragment BuildTryFinally(); | 610 Fragment BuildTryFinally(); |
566 Fragment BuildYieldStatement(); | 611 Fragment BuildYieldStatement(); |
567 Fragment BuildVariableDeclaration(); | 612 Fragment BuildVariableDeclaration(); |
| 613 Fragment BuildFunctionDeclaration(); |
| 614 Fragment BuildFunctionNode(intptr_t parent_kernel_offset, |
| 615 TokenPosition parent_position, |
| 616 bool declaration, |
| 617 intptr_t variable_offeset); |
| 618 void SetupFunctionParameters(const dart::Class& klass, |
| 619 const dart::Function& function, |
| 620 bool is_method, |
| 621 bool is_closure); |
568 | 622 |
569 FlowGraphBuilder* flow_graph_builder_; | 623 FlowGraphBuilder* flow_graph_builder_; |
570 TranslationHelper& translation_helper_; | 624 TranslationHelper& translation_helper_; |
571 Zone* zone_; | 625 Zone* zone_; |
572 Reader* reader_; | 626 Reader* reader_; |
573 StreamingConstantEvaluator constant_evaluator_; | 627 StreamingConstantEvaluator constant_evaluator_; |
574 StreamingDartTypeTranslator type_translator_; | 628 StreamingDartTypeTranslator type_translator_; |
575 | 629 |
| 630 word unused_word; |
| 631 intptr_t unused_intptr; |
| 632 TokenPosition unused_tokenposition; |
| 633 NameIndex unused_nameindex; |
| 634 |
576 friend class StreamingConstantEvaluator; | 635 friend class StreamingConstantEvaluator; |
577 friend class StreamingDartTypeTranslator; | 636 friend class StreamingDartTypeTranslator; |
578 friend class StreamingScopeBuilder; | 637 friend class StreamingScopeBuilder; |
579 }; | 638 }; |
580 | 639 |
581 // A helper class that saves the current reader position, goes to another reader | 640 // A helper class that saves the current reader position, goes to another reader |
582 // position, and upon destruction, resets to the original reader position. | 641 // position, and upon destruction, resets to the original reader position. |
583 class AlternativeReadingScope { | 642 class AlternativeReadingScope { |
584 public: | 643 public: |
585 AlternativeReadingScope(Reader* reader, intptr_t new_position) | 644 AlternativeReadingScope(Reader* reader, intptr_t new_position) |
586 : reader_(reader), saved_offset_(reader_->offset()) { | 645 : reader_(reader), saved_offset_(reader_->offset()) { |
587 reader_->set_offset(new_position); | 646 reader_->set_offset(new_position); |
588 } | 647 } |
589 | 648 |
590 explicit AlternativeReadingScope(Reader* reader) | 649 explicit AlternativeReadingScope(Reader* reader) |
591 : reader_(reader), saved_offset_(reader_->offset()) {} | 650 : reader_(reader), saved_offset_(reader_->offset()) {} |
592 | 651 |
593 ~AlternativeReadingScope() { reader_->set_offset(saved_offset_); } | 652 ~AlternativeReadingScope() { reader_->set_offset(saved_offset_); } |
594 | 653 |
595 private: | 654 private: |
596 Reader* reader_; | 655 Reader* reader_; |
597 intptr_t saved_offset_; | 656 intptr_t saved_offset_; |
598 }; | 657 }; |
599 | 658 |
600 } // namespace kernel | 659 } // namespace kernel |
601 } // namespace dart | 660 } // namespace dart |
602 | 661 |
603 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 662 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
604 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 663 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
OLD | NEW |