Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: runtime/vm/kernel_to_il.h

Issue 2477563003: VM: [Kernel] Set types on [LocalVariable] if they were introduced by [VariableDeclaration]s (Closed)
Patch Set: addressed comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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_TO_IL_H_ 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ 6 #define RUNTIME_VM_KERNEL_TO_IL_H_
7 7
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/hash_map.h" 9 #include "vm/hash_map.h"
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 zone_(helper->zone()), 289 zone_(helper->zone()),
290 result_(AbstractType::Handle(helper->zone())), 290 result_(AbstractType::Handle(helper->zone())),
291 finalize_(finalize) {} 291 finalize_(finalize) {}
292 292
293 // Can return a malformed type. 293 // Can return a malformed type.
294 AbstractType& TranslateType(DartType* node); 294 AbstractType& TranslateType(DartType* node);
295 295
296 // Can return a malformed type. 296 // Can return a malformed type.
297 AbstractType& TranslateTypeWithoutFinalization(DartType* node); 297 AbstractType& TranslateTypeWithoutFinalization(DartType* node);
298 298
299 // Is guaranteed to be not malformed.
300 const AbstractType& TranslateVariableType(VariableDeclaration* variable);
301
299 302
300 virtual void VisitDefaultDartType(DartType* node) { UNREACHABLE(); } 303 virtual void VisitDefaultDartType(DartType* node) { UNREACHABLE(); }
301 304
302 virtual void VisitInvalidType(InvalidType* node); 305 virtual void VisitInvalidType(InvalidType* node);
303 306
304 virtual void VisitFunctionType(FunctionType* node); 307 virtual void VisitFunctionType(FunctionType* node);
305 308
306 virtual void VisitTypeParameterType(TypeParameterType* node); 309 virtual void VisitTypeParameterType(TypeParameterType* node);
307 310
308 virtual void VisitInterfaceType(InterfaceType* node); 311 virtual void VisitInterfaceType(InterfaceType* node);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 490
488 491
489 class ScopeBuilder : public RecursiveVisitor { 492 class ScopeBuilder : public RecursiveVisitor {
490 public: 493 public:
491 ScopeBuilder(ParsedFunction* parsed_function, TreeNode* node) 494 ScopeBuilder(ParsedFunction* parsed_function, TreeNode* node)
492 : result_(NULL), 495 : result_(NULL),
493 parsed_function_(parsed_function), 496 parsed_function_(parsed_function),
494 node_(node), 497 node_(node),
495 zone_(Thread::Current()->zone()), 498 zone_(Thread::Current()->zone()),
496 translation_helper_(Thread::Current(), zone_, Isolate::Current()), 499 translation_helper_(Thread::Current(), zone_, Isolate::Current()),
500 type_translator_(&translation_helper_, &active_class_),
497 current_function_scope_(NULL), 501 current_function_scope_(NULL),
498 scope_(NULL), 502 scope_(NULL),
499 depth_(0), 503 depth_(0),
500 name_index_(0) {} 504 name_index_(0) {}
501 505
502 virtual ~ScopeBuilder() {} 506 virtual ~ScopeBuilder() {}
503 507
504 ScopeBuildingResult* BuildScopes(); 508 ScopeBuildingResult* BuildScopes();
505 509
506 virtual void VisitName(Name* node) { /* NOP */ 510 virtual void VisitName(Name* node) { /* NOP */
(...skipping 20 matching lines...) Expand all
527 virtual void VisitAssertStatement(AssertStatement* node); 531 virtual void VisitAssertStatement(AssertStatement* node);
528 532
529 virtual void VisitFunctionNode(FunctionNode* node); 533 virtual void VisitFunctionNode(FunctionNode* node);
530 534
531 virtual void VisitConstructor(Constructor* node); 535 virtual void VisitConstructor(Constructor* node);
532 536
533 private: 537 private:
534 void EnterScope(TreeNode* node); 538 void EnterScope(TreeNode* node);
535 void ExitScope(); 539 void ExitScope();
536 540
537 LocalVariable* MakeVariable(const dart::String& name); 541 const Type& TranslateVariableType(VariableDeclaration* variable);
538 LocalVariable* MakeVariable(const dart::String& name, const Type& type); 542 LocalVariable* MakeVariable(const dart::String& name,
543 const AbstractType& type);
539 544
540 void AddParameters(FunctionNode* function, intptr_t pos = 0); 545 void AddParameters(FunctionNode* function, intptr_t pos = 0);
541 void AddParameter(VariableDeclaration* declaration, intptr_t pos); 546 void AddParameter(VariableDeclaration* declaration, intptr_t pos);
542 void AddVariable(VariableDeclaration* declaration); 547 void AddVariable(VariableDeclaration* declaration);
543 void AddExceptionVariable(GrowableArray<LocalVariable*>* variables, 548 void AddExceptionVariable(GrowableArray<LocalVariable*>* variables,
544 const char* prefix, intptr_t nesting_depth); 549 const char* prefix, intptr_t nesting_depth);
545 void AddTryVariables(); 550 void AddTryVariables();
546 void AddCatchVariables(); 551 void AddCatchVariables();
547 void AddIteratorVariable(); 552 void AddIteratorVariable();
548 void AddSwitchVariable(); 553 void AddSwitchVariable();
(...skipping 25 matching lines...) Expand all
574 intptr_t try_; 579 intptr_t try_;
575 intptr_t catch_; 580 intptr_t catch_;
576 intptr_t finally_; 581 intptr_t finally_;
577 intptr_t for_in_; 582 intptr_t for_in_;
578 }; 583 };
579 584
580 ScopeBuildingResult* result_; 585 ScopeBuildingResult* result_;
581 ParsedFunction* parsed_function_; 586 ParsedFunction* parsed_function_;
582 TreeNode* node_; 587 TreeNode* node_;
583 588
589 ActiveClass active_class_;
590
584 Zone* zone_; 591 Zone* zone_;
585 TranslationHelper translation_helper_; 592 TranslationHelper translation_helper_;
586 593 DartTypeTranslator type_translator_;
587 594
588 FunctionNode* current_function_node_; 595 FunctionNode* current_function_node_;
589 LocalScope* current_function_scope_; 596 LocalScope* current_function_scope_;
590 LocalScope* scope_; 597 LocalScope* scope_;
591 DepthState depth_; 598 DepthState depth_;
592 599
593 intptr_t name_index_; 600 intptr_t name_index_;
594 }; 601 };
595 602
596 603
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 friend class SwitchBlock; 899 friend class SwitchBlock;
893 friend class TryCatchBlock; 900 friend class TryCatchBlock;
894 friend class TryFinallyBlock; 901 friend class TryFinallyBlock;
895 }; 902 };
896 903
897 } // namespace kernel 904 } // namespace kernel
898 } // namespace dart 905 } // namespace dart
899 906
900 907
901 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ 908 #endif // RUNTIME_VM_KERNEL_TO_IL_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698