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

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 2981423003: Move .getLocalFunction from KernelToElementMap to KernelToLocalsMap (Closed)
Patch Set: Updated cf. comments 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 | « no previous file | pkg/compiler/lib/src/js_model/closure.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) 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 import 'common/names.dart' show Identifiers; 5 import 'common/names.dart' show Identifiers;
6 import 'common/resolution.dart' show ParsingContext, Resolution; 6 import 'common/resolution.dart' show ParsingContext, Resolution;
7 import 'common/tasks.dart' show CompilerTask, Measurer; 7 import 'common/tasks.dart' show CompilerTask, Measurer;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart'; 10 import 'constants/expressions.dart';
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 this.node, String name, Compiler compiler, LocalFunctionElement closure) 475 this.node, String name, Compiler compiler, LocalFunctionElement closure)
476 : this.methodElement = closure, 476 : this.methodElement = closure,
477 super( 477 super(
478 name, 478 name,
479 closure.compilationUnit, 479 closure.compilationUnit,
480 // By assigning a fresh class-id we make sure that the hashcode 480 // By assigning a fresh class-id we make sure that the hashcode
481 // is unique, but also emit closure classes after all other 481 // is unique, but also emit closure classes after all other
482 // classes (since the emitter sorts classes by their id). 482 // classes (since the emitter sorts classes by their id).
483 compiler.idGenerator.getNextFreeId(), 483 compiler.idGenerator.getNextFreeId(),
484 STATE_DONE) { 484 STATE_DONE) {
485 ClassElement superclass = methodElement.isInstanceMember 485 ClassElement superclass = compiler.resolution.commonElements.closureClass;
486 ? compiler.resolution.commonElements.boundClosureClass
487 : compiler.resolution.commonElements.closureClass;
488 superclass.ensureResolved(compiler.resolution); 486 superclass.ensureResolved(compiler.resolution);
489 supertype = superclass.thisType; 487 supertype = superclass.thisType;
490 interfaces = const Link<ResolutionDartType>(); 488 interfaces = const Link<ResolutionDartType>();
491 thisType = rawType = new ResolutionInterfaceType(this); 489 thisType = rawType = new ResolutionInterfaceType(this);
492 allSupertypesAndSelf = 490 allSupertypesAndSelf =
493 superclass.allSupertypesAndSelf.extendClass(thisType); 491 superclass.allSupertypesAndSelf.extendClass(thisType);
494 callType = methodElement.type; 492 callType = methodElement.type;
495 } 493 }
496 494
497 Iterable<ClosureFieldElement> get closureFields => _closureFields; 495 Iterable<ClosureFieldElement> get closureFields => _closureFields;
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 } 1370 }
1373 1371
1374 JavaScriptBackend get backend => compiler.backend; 1372 JavaScriptBackend get backend => compiler.backend;
1375 1373
1376 ClosureClassMap globalizeClosure( 1374 ClosureClassMap globalizeClosure(
1377 FunctionExpression node, LocalFunctionElement element) { 1375 FunctionExpression node, LocalFunctionElement element) {
1378 String closureName = computeClosureName(element); 1376 String closureName = computeClosureName(element);
1379 ClosureClassElement globalizedElement = 1377 ClosureClassElement globalizedElement =
1380 new ClosureClassElement(node, closureName, compiler, element); 1378 new ClosureClassElement(node, closureName, compiler, element);
1381 // Extend [globalizedElement] as an instantiated class in the closed world. 1379 // Extend [globalizedElement] as an instantiated class in the closed world.
1382 closedWorldRefiner.registerClosureClass(globalizedElement, false); 1380 closedWorldRefiner.registerClosureClass(globalizedElement);
1383 MethodElement callElement = new SynthesizedCallMethodElementX( 1381 MethodElement callElement = new SynthesizedCallMethodElementX(
1384 Identifiers.call, element, globalizedElement, node, elements); 1382 Identifiers.call, element, globalizedElement, node, elements);
1385 backend.mirrorsDataBuilder.maybeMarkClosureAsNeededForReflection( 1383 backend.mirrorsDataBuilder.maybeMarkClosureAsNeededForReflection(
1386 globalizedElement, callElement, element); 1384 globalizedElement, callElement, element);
1387 MemberElement enclosing = element.memberContext; 1385 MemberElement enclosing = element.memberContext;
1388 enclosing.nestedClosures.add(callElement); 1386 enclosing.nestedClosures.add(callElement);
1389 globalizedElement.addMember(callElement, reporter); 1387 globalizedElement.addMember(callElement, reporter);
1390 globalizedElement.computeAllClassMembers(compiler.resolution); 1388 globalizedElement.computeAllClassMembers(compiler.resolution);
1391 // The nested function's 'this' is the same as the one for the outer 1389 // The nested function's 'this' is the same as the one for the outer
1392 // function. It could be [null] if we are inside a static method. 1390 // function. It could be [null] if we are inside a static method.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 /// 1539 ///
1542 /// Move the below classes to a JS model eventually. 1540 /// Move the below classes to a JS model eventually.
1543 /// 1541 ///
1544 abstract class JSEntity implements MemberEntity { 1542 abstract class JSEntity implements MemberEntity {
1545 Local get declaredEntity; 1543 Local get declaredEntity;
1546 } 1544 }
1547 1545
1548 abstract class PrivatelyNamedJSEntity implements JSEntity { 1546 abstract class PrivatelyNamedJSEntity implements JSEntity {
1549 Entity get rootOfScope; 1547 Entity get rootOfScope;
1550 } 1548 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_model/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698