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

Unified Diff: sdk/lib/_internal/compiler/implementation/js/printer.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/printer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js/printer.dart b/sdk/lib/_internal/compiler/implementation/js/printer.dart
index 975cbf6dd43ba44f12bd45edf1f812c0c35fb082..eea5bdbecc87873a865ea9fc0445bae3b1481234 100644
--- a/sdk/lib/_internal/compiler/implementation/js/printer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js/printer.dart
@@ -878,17 +878,24 @@ class Printer implements NodeVisitor {
outLn(node.code);
}
- visitJSExpression(JSExpression node) {
- compiler.internalError(NO_LOCATION_SPANNABLE,
- 'JSPrinter should never see a JSExpression.');
+ visitInterpolatedNode(InterpolatedNode node) {
+ out('#${node.name}');
}
- visitInterpolatedExpression(InterpolatedExpression node) {
- visit(node.value);
- }
+ visitInterpolatedExpression(InterpolatedExpression node) =>
+ visitInterpolatedNode(node);
+
+ visitInterpolatedLiteral(InterpolatedLiteral node) =>
+ visitInterpolatedNode(node);
+
+ visitInterpolatedParameter(InterpolatedParameter node) =>
+ visitInterpolatedNode(node);
+
+ visitInterpolatedSelector(InterpolatedSelector node) =>
+ visitInterpolatedNode(node);
visitInterpolatedStatement(InterpolatedStatement node) {
- visit(node.value);
+ outLn('#${node.name}');
}
void visitComment(Comment node) {
@@ -1103,6 +1110,12 @@ class MinifyRenamer implements LocalNamer {
// use the same namespace for arguments and variables, starting with A, and
// moving on to a0, a1, etc.
String declareVariable(String oldName) {
+ // Variables of this $form$ are used in pattern matching JS exceptions, so
+ // should not be renamed.
+ // TODO(sra): Introduce a way for indicating in the JS text which varaibles
floitsch 2014/04/22 16:11:18 variables
sra1 2014/04/23 02:33:50 Done.
+ // should not be renamed.
+ if (oldName.startsWith(r'$') && oldName.endsWith(r'$')) return oldName;
+
var newName;
if (variableNumber + parameterNumber < LOWER_CASE_LETTERS) {
// Variables start from z and go backwards, for better gzipability.

Powered by Google App Engine
This is Rietveld 408576698