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

Side by Side Diff: pkg/compiler/lib/src/js_model/closure_visitors.dart

Issue 2991903002: Add Closure call method to created closure class (Closed)
Patch Set: . Created 3 years, 4 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
« no previous file with comments | « pkg/compiler/lib/src/js_model/closure.dart ('k') | pkg/compiler/lib/src/js_model/elements.dart » ('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) 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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import 'closure.dart'; 8 import 'closure.dart';
9 9
10 /// This builder walks the code to determine what variables are captured/free at 10 /// This builder walks the code to determine what variables are captured/free at
11 /// various points to build CapturedScope that can respond to queries 11 /// various points to build CapturedScope that can respond to queries
12 /// about how a particular variable is being used at any point in the code. 12 /// about how a particular variable is being used at any point in the code.
13 class CapturedScopeBuilder extends ir.Visitor { 13 class CapturedScopeBuilder extends ir.Visitor {
14 ir.TreeNode _currentLocalFunction; 14 ir.TreeNode _currentLocalFunction;
15 15
16 ClosureModel _model; 16 ClosureModel _model;
17 17
18 /// A map of each visited call node with the associated information about what 18 /// A map of each visited call node with the associated information about what
19 /// variables are captured/used. Each ir.Node key corresponds to a scope that 19 /// variables are captured/used. Each ir.Node key corresponds to a scope that
20 /// was encountered while visiting a closure (initially called through 20 /// was encountered while visiting a closure (initially called through
21 /// [translateLazyIntializer] or [translateConstructorOrProcedure]). 21 /// [translateLazyIntializer] or [translateConstructorOrProcedure]).
22 Map<ir.Node, KernelCapturedScope> get _scopesCapturedInClosureMap => 22 Map<ir.Node, KernelCapturedScope> get _scopesCapturedInClosureMap =>
23 _model.capturedScopesMap; 23 _model.capturedScopesMap;
24 24
25 /// A map of the nodes that we have flagged as necessary to generate closure 25 /// A map of the nodes that we have flagged as necessary to generate closure
26 /// classes for in a later stage. We map that node to information ascertained 26 /// classes for in a later stage. We map that node to information ascertained
27 /// about variable usage in the surrounding scope. 27 /// about variable usage in the surrounding scope.
28 Map<ir.TreeNode /* ir.Field | ir.FunctionNode */, KernelScopeInfo> 28 Map<ir.FunctionNode, KernelScopeInfo> get _closuresToGenerate =>
29 get _closuresToGenerate => _model.closuresToGenerate; 29 _model.closuresToGenerate;
30 30
31 /// The local variables that have been declared in the current scope. 31 /// The local variables that have been declared in the current scope.
32 List<ir.VariableDeclaration> _scopeVariables; 32 List<ir.VariableDeclaration> _scopeVariables;
33 33
34 /// Pointer to the context in which this closure is executed. 34 /// Pointer to the context in which this closure is executed.
35 /// For example, in the expression `var foo = () => 3 + i;`, the executable 35 /// For example, in the expression `var foo = () => 3 + i;`, the executable
36 /// context as we walk the nodes in that expression is the ir.Field `foo`. 36 /// context as we walk the nodes in that expression is the ir.Field `foo`.
37 ir.Node _executableContext; 37 ir.Node _executableContext;
38 38
39 /// A flag to indicate if we are currently inside a closure. 39 /// A flag to indicate if we are currently inside a closure.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 259
260 void translateConstructorOrProcedure(ir.Node constructorOrProcedure) { 260 void translateConstructorOrProcedure(ir.Node constructorOrProcedure) {
261 constructorOrProcedure.accept(this); 261 constructorOrProcedure.accept(this);
262 } 262 }
263 263
264 void visitFunctionNode(ir.FunctionNode functionNode) { 264 void visitFunctionNode(ir.FunctionNode functionNode) {
265 visitInvokable(functionNode); 265 visitInvokable(functionNode);
266 } 266 }
267 } 267 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_model/closure.dart ('k') | pkg/compiler/lib/src/js_model/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698