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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.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/ssa/codegen.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
index 96234813207aa998b060fb2cc7b38ddd8f868b7e..9bec5aa0b920833ca4eac39dcfd71779e2c25381 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
@@ -1649,10 +1649,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
} else {
methodName = backend.namer.getNameOfInstanceMember(superMethod);
}
- js.PropertyAccess method =
- backend.namer.elementAccess(superClass)['prototype'][methodName];
- push(jsPropertyCall(
- method, "call", visitArguments(node.inputs, start: 0)), node);
+ push(js.js('#.prototype.#.call(#)', [
floitsch 2014/04/22 16:11:18 can we import with show 'js', so that we don't hav
sra1 2014/04/23 02:33:50 Then we would have to change the current import na
+ backend.namer.elementAccess(superClass),
+ methodName, visitArguments(node.inputs, start: 0)]),
+ node);
}
}
@@ -1725,22 +1725,23 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
visitForeign(HForeign node) {
List<HInstruction> inputs = node.inputs;
if (node.isJsStatement()) {
- if (!inputs.isEmpty) {
- compiler.internalError(node, "Foreign statement with inputs.");
+ //if (!inputs.isEmpty) {
floitsch 2014/04/22 16:11:18 dead code.
sra1 2014/04/23 02:33:50 Done.
+ // compiler.internalError(node, "Foreign statement with inputs.");
+ //}
+ //pushStatement(node.codeTemplate.ast, node);
+ List<js.Expression> interpolatedExpressions = <js.Expression>[];
+ for (int i = 0; i < inputs.length; i++) {
+ use(inputs[i]);
+ interpolatedExpressions.add(pop());
}
- pushStatement(node.codeAst, node);
+ pushStatement(node.codeTemplate.instantiate(interpolatedExpressions));
} else {
- if (!inputs.isEmpty) {
- List<js.Expression> interpolatedExpressions = <js.Expression>[];
- for (int i = 0; i < inputs.length; i++) {
- use(inputs[i]);
- interpolatedExpressions.add(pop());
- }
- var visitor = new js.UninterpolateJSExpression(interpolatedExpressions);
- push(visitor.visit(node.codeAst), node);
- } else {
- push(node.codeAst, node);
+ List<js.Expression> interpolatedExpressions = <js.Expression>[];
+ for (int i = 0; i < inputs.length; i++) {
+ use(inputs[i]);
+ interpolatedExpressions.add(pop());
}
+ push(node.codeTemplate.instantiate(interpolatedExpressions));
}
// TODO(sra): Tell world.nativeEnqueuer about the types created here.
@@ -2623,13 +2624,13 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
if (!optionalParameterTypes.isEmpty) {
arguments.add(new js.ArrayInitializer.from(optionalParameterTypes));
}
- push(accessHelper('buildFunctionType')(arguments));
+ push(js.js('#(#)', [accessHelper('buildFunctionType'), arguments]));
} else {
var arguments = [
returnType,
new js.ArrayInitializer.from(parameterTypes),
new js.ObjectInitializer(namedParameters)];
- push(accessHelper('buildNamedFunctionType')(arguments));
+ push(js.js('#(#)', [accessHelper('buildNamedFunctionType'), arguments]));
}
}
@@ -2644,17 +2645,18 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
int index = RuntimeTypes.getTypeVariableIndex(element);
js.Expression receiver = pop();
js.Expression helper = backend.namer.elementAccess(helperElement);
- push(helper(js.js(r'#.$builtinTypeInfo && #.$builtinTypeInfo[#]',
- [receiver, receiver, js.js.toExpression(index)])));
+ push(js.js(r'#(#.$builtinTypeInfo && #.$builtinTypeInfo[#])',
+ [helper, receiver, receiver, js.js.number(index)]));
} else {
backend.emitter.registerReadTypeVariable(element);
- push(
- js.js('#.${backend.namer.readTypeVariableName(element)}()', pop()));
+ push(js.js('#.#()',
+ [pop(), backend.namer.readTypeVariableName(element)]));
}
} else {
- push(
+ push(js.js('#(#)', [
backend.namer.elementAccess(
- compiler.findHelper('convertRtiToRuntimeType'))(pop()));
+ compiler.findHelper('convertRtiToRuntimeType')),
+ pop()]));
}
}
@@ -2671,15 +2673,15 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
if (!typeArguments.isEmpty) {
arguments.add(new js.ArrayInitializer.from(typeArguments));
}
- push(accessHelper('buildInterfaceType')(arguments));
+ push(js.js('#(#)', [accessHelper('buildInterfaceType'), arguments]));
}
void visitVoidType(HVoidType node) {
- push(accessHelper('getVoidRuntimeType')());
+ push(js.js('#()', accessHelper('getVoidRuntimeType')));
}
void visitDynamicType(HDynamicType node) {
- push(accessHelper('getDynamicRuntimeType')());
+ push(js.js('#()', accessHelper('getDynamicRuntimeType')));
}
js.PropertyAccess accessHelper(String name) {

Powered by Google App Engine
This is Rietveld 408576698