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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1263593003: restore arrow function bind this workaround (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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 | « lib/runtime/dart/isolate.js ('k') | lib/src/codegen/js_printer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 608628ea1af0dbea81b5dc626514f7ff42d5ebd1..a20b3799c0412b9e9cc952b87c0753909900112e 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -1289,12 +1289,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
}
var fn = _visit(func.functionExpression);
- var jsThis = new _JsThisFinder();
- fn.accept(jsThis);
var name = new JS.Identifier(func.name.name);
JS.Statement declareFn;
- if (jsThis.found) {
+ if (JS.This.foundIn(fn)) {
declareFn = js.statement('let # = #.bind(this);', [name, fn]);
} else {
declareFn = new JS.FunctionDeclaration(name, fn);
@@ -2824,7 +2822,9 @@ class JSGenerator extends CodeGenerator {
new JSCodegenVisitor(compiler, library, _extensionTypes, fields);
var module = codegen.emitLibrary(unit);
var out = compiler.getOutputPath(library.source.uri);
- return writeJsLibrary(module, out, emitSourceMaps: options.emitSourceMaps);
+ return writeJsLibrary(module, out,
+ emitSourceMaps: options.emitSourceMaps,
+ arrowFnBindThisWorkaround: options.arrowFnBindThisWorkaround);
}
}
@@ -2859,13 +2859,3 @@ class TemporaryVariableElement extends LocalVariableElementImpl {
int get hashCode => identityHashCode(this);
bool operator ==(Object other) => identical(this, other);
}
-
-class _JsThisFinder extends JS.BaseVisitor {
- bool found = false;
- visitThis(JS.This node) {
- found = true;
- }
- visitNode(JS.Node node) {
- if (!found) super.visitNode(node);
- }
-}
« no previous file with comments | « lib/runtime/dart/isolate.js ('k') | lib/src/codegen/js_printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698