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

Unified Diff: lib/compiler/implementation/closure.dart

Issue 10911062: Codegen support for the argument definition test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/compile_time_constants.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/closure.dart
===================================================================
--- lib/compiler/implementation/closure.dart (revision 11813)
+++ lib/compiler/implementation/closure.dart (working copy)
@@ -19,7 +19,7 @@
String get name => "Closure Simplifier";
ClosureClassMap computeClosureToClassMapping(FunctionExpression node,
- TreeElements elements) {
+ TreeElements elements) {
return measure(() {
ClosureClassMap cached = closureMappingCache[node];
if (cached !== null) return cached;
@@ -141,6 +141,10 @@
final Set<Element> usedVariablesInTry;
+ // A map from the parameter element to the variable element that
+ // holds the sentinel check.
+ final Map<Element, Element> parametersWithSentinel;
+
ClosureClassMap(this.closureElement,
this.closureClassElement,
this.callElement,
@@ -148,7 +152,8 @@
: this.freeVariableMapping = new Map<Element, Element>(),
this.capturedFieldMapping = new Map<Element, Element>(),
this.capturingScopes = new Map<Node, ClosureScope>(),
- this.usedVariablesInTry = new Set<Element>();
+ this.usedVariablesInTry = new Set<Element>(),
+ this.parametersWithSentinel = new Map<Element, Element>();
bool isClosure() => closureElement !== null;
}
@@ -312,6 +317,22 @@
useLocal(closureData.thisElement);
} else if (node.isSuperCall) {
useLocal(closureData.thisElement);
+ } else if (node.isOperator
+ && node.argumentsNode is Prefix
+ && node.selector.source.stringValue == '?') {
+ Element parameter = elements[node.receiver];
+ FunctionElement enclosing = parameter.enclosingElement;
+ FunctionExpression function = enclosing.parseNode(compiler);
+ ClosureClassMap cached = closureMappingCache[function];
+ if (!cached.parametersWithSentinel.containsKey(parameter)) {
+ SourceString parameterName = parameter.name;
+ String name = '${parameterName.slowToString()}_check';
+ Element newElement = new Element(new SourceString(name),
+ ElementKind.VARIABLE,
+ enclosing);
+ useLocal(newElement);
+ cached.parametersWithSentinel[parameter] = newElement;
+ }
}
node.visitChildren(this);
}
@@ -478,6 +499,7 @@
}
closureData = new ClosureClassMap(null, null, null, thisElement);
}
+ closureMappingCache[node] = closureData;
inNewScope(node, () {
// We have to declare the implicit 'this' parameter.
@@ -501,7 +523,6 @@
if (node.body !== null) node.body.accept(this);
});
- closureMappingCache[node] = closureData;
ClosureClassMap savedClosureData = closureData;
bool savedInsideClosure = insideClosure;
« no previous file with comments | « no previous file | lib/compiler/implementation/compile_time_constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698