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

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

Issue 520223002: Fix scoping async functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase + added comment Created 6 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/ast_transformer.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_AST_TRANSFORMER_H_ 5 #ifndef VM_AST_TRANSFORMER_H_
6 #define VM_AST_TRANSFORMER_H_ 6 #define VM_AST_TRANSFORMER_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 10
(...skipping 23 matching lines...) Expand all
34 // t_2 = :result_param; 34 // t_2 = :result_param;
35 // t_3 = foo(); 35 // t_3 = foo();
36 // t_4 = t_2.operator+(t_3); 36 // t_4 = t_2.operator+(t_3);
37 // 37 //
38 // and a resulting expression of a load of t_4. 38 // and a resulting expression of a load of t_4.
39 // 39 //
40 class AwaitTransformer : public AstNodeVisitor { 40 class AwaitTransformer : public AstNodeVisitor {
41 public: 41 public:
42 AwaitTransformer(SequenceNode* preamble, 42 AwaitTransformer(SequenceNode* preamble,
43 const Library& library, 43 const Library& library,
44 ParsedFunction* const parsed_function) 44 ParsedFunction* const parsed_function,
45 : preamble_(preamble), 45 LocalScope* function_top);
46 temp_cnt_(0),
47 library_(library),
48 parsed_function_(parsed_function),
49 isolate_(Isolate::Current()) {
50 // We later on save the continuation context and modify the jump counter
51 // from within the preamble context (in the FlowGraphBuilder). Look up the
52 // needed variables to get their corresponding aliases.
53 preamble->scope()->LookupVariable(Symbols::AwaitContextVar(), false);
54 preamble->scope()->LookupVariable(Symbols::AwaitJumpVar(), false);
55 }
56 46
57 #define DECLARE_VISIT(BaseName) \ 47 #define DECLARE_VISIT(BaseName) \
58 virtual void Visit##BaseName##Node(BaseName##Node* node); 48 virtual void Visit##BaseName##Node(BaseName##Node* node);
59 49
60 FOR_EACH_NODE(DECLARE_VISIT) 50 FOR_EACH_NODE(DECLARE_VISIT)
61 #undef DECLARE_VISIT 51 #undef DECLARE_VISIT
62 52
63 AstNode* Transform(AstNode* expr); 53 AstNode* Transform(AstNode* expr);
64 54
65 private: 55 private:
66 LocalVariable* EnsureCurrentTempVar(); 56 LocalVariable* EnsureCurrentTempVar();
67 LocalVariable* AddToPreambleNewTempVar(AstNode* node); 57 LocalVariable* AddToPreambleNewTempVar(AstNode* node);
68 ArgumentListNode* TransformArguments(ArgumentListNode* node); 58 ArgumentListNode* TransformArguments(ArgumentListNode* node);
69 AstNode* LazyTransform(const Token::Kind kind, 59 AstNode* LazyTransform(const Token::Kind kind,
70 AstNode* new_left, 60 AstNode* new_left,
71 AstNode* right); 61 AstNode* right);
62 LocalScope* ChainNewScope(LocalScope* parent);
63 LocalVariable* GetVariableInScope(LocalScope* scope, const String& symbol);
72 64
73 void NextTempVar() { temp_cnt_++; } 65 void NextTempVar() { temp_cnt_++; }
74 66
75 Isolate* isolate() const { return isolate_; } 67 Isolate* isolate() const { return isolate_; }
76 68
77 SequenceNode* preamble_; 69 SequenceNode* preamble_;
78 int32_t temp_cnt_; 70 int32_t temp_cnt_;
79 AstNode* result_; 71 AstNode* result_;
80 const Library& library_; 72 const Library& library_;
81 ParsedFunction* const parsed_function_; 73 ParsedFunction* const parsed_function_;
74 LocalScope* function_top_;
82 75
83 Isolate* isolate_; 76 Isolate* isolate_;
84 77
85 DISALLOW_COPY_AND_ASSIGN(AwaitTransformer); 78 DISALLOW_COPY_AND_ASSIGN(AwaitTransformer);
86 }; 79 };
87 80
88 } // namespace dart 81 } // namespace dart
89 82
90 #endif // VM_AST_TRANSFORMER_H_ 83 #endif // VM_AST_TRANSFORMER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/ast_transformer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698