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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 237583014: JS templates (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleanup Created 6 years, 8 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
Index: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
index 6866b254348c46b31d8d3432935bfee756289371..207b9575b85a03f00a7ad5b03d5e564f9bab1415 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
@@ -355,9 +355,7 @@ class NativeEmitter {
FunctionSignature parameters = member.functionSignature;
Element converter =
compiler.findHelper('convertDartClosureToJS');
- String closureConverter = backend.namer.isolateAccess(converter);
- Set<String> stubParameterNames = new Set<String>.from(
- stubParameters.map((param) => param.name));
+ jsAst.Expression closureConverter = backend.namer.elementAccess(converter);
parameters.forEachParameter((ParameterElement parameter) {
String name = parameter.name;
// If [name] is not in [stubParameters], then the parameter is an optional
@@ -371,7 +369,8 @@ class NativeEmitter {
FunctionType functionType = type;
int arity = functionType.computeArity();
statements.add(
- js('$name = $closureConverter($name, $arity)').toStatement());
+ js.statement('# = #(#, $arity)',
+ [name, closureConverter, name]));
break;
}
}
@@ -418,7 +417,9 @@ class NativeEmitter {
arguments = argumentsBuffer.sublist(0,
indexOfLastOptionalArgumentInParameters + 1);
}
- statements.add(new jsAst.Return(receiver[target](arguments)));
+ //statements.add(new jsAst.Return(receiver[target](arguments)));
floitsch 2014/04/22 16:11:18 dead code.
sra1 2014/04/23 02:33:50 Done.
+ statements.add(
+ js.statement('return #.#(#)', [receiver, target, arguments]));
return statements;
}
@@ -477,17 +478,12 @@ class NativeEmitter {
// If we have any properties to add to Object.prototype, we run
// through them and add them using defineProperty.
if (!objectProperties.isEmpty) {
- jsAst.Expression init =
- js.fun(['table'],
- new jsAst.ForIn(
- new jsAst.VariableDeclarationList(
- [new jsAst.VariableInitialization(
- new jsAst.VariableDeclaration('key'),
- null)]),
- js('table'),
- new jsAst.ExpressionStatement(
- js('$defPropName(Object.prototype, key, table[key])'))))(
- new jsAst.ObjectInitializer(objectProperties));
+ jsAst.Expression init = js('''
+ (function(table) {
+ for(var key in table)
+ $defPropName(Object.prototype, key, table[key]);
floitsch 2014/04/22 16:11:18 We could make defPropAccess a template, and thus a
sra1 2014/04/23 02:33:50 Done.
+ })(#)''',
+ new jsAst.ObjectInitializer(objectProperties));
if (emitter.compiler.enableMinification) targetBuffer.add(';');
targetBuffer.add(jsAst.prettyPrint(

Powered by Google App Engine
This is Rietveld 408576698