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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2623303002: Compute sourceElement for closures (Closed)
Patch Set: fix Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index aab65197ed7773c717ffa73758116b7186b16cbd..f402eaaef558a5362fc4fc913ceb6013766a5ab3 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -497,12 +497,33 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
push(trap);
}
- /// Returns the current source element.
+ /// Returns the current source element. This is used by the type builder.
///
/// The returned element is a declaration element.
// TODO(efortuna): Update this when we implement inlining.
+ // TODO(sra): Re-implement type builder using Kernel types and the
+ // `target` for context.
@override
- Element get sourceElement => astAdapter.getElement(target);
+ Element get sourceElement => _sourceElementForTarget(target);
+
+ Element _sourceElementForTarget(ir.Node target) {
+ // For closure-converted (i.e. local functions) the source element is the
+ // 'call' method of the class that represents the closure.
+ if (target is ir.FunctionExpression) {
+ LocalFunctionElement element = astAdapter.getElement(target);
+ ClosureClassMap classMap = compiler.closureToClassMapper
+ .getClosureToClassMapping(element.resolvedAst);
+ return classMap.callElement;
+ }
+ if (target is ir.FunctionDeclaration) {
+ LocalFunctionElement element = astAdapter.getElement(target);
+ ClosureClassMap classMap = compiler.closureToClassMapper
+ .getClosureToClassMapping(element.resolvedAst);
+ return classMap.callElement;
+ }
+ Element element = astAdapter.getElement(target);
+ return element;
+ }
@override
void visitBlock(ir.Block block) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698