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

Side by Side Diff: lib/src/js/builder.dart

Issue 1183453005: fixes #226 super == and fixes #227 escape \r \f (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/misc.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Utilities for building JS ASTs at runtime. Contains a builder class 5 // Utilities for building JS ASTs at runtime. Contains a builder class
6 // and a parser that parses part of the language. 6 // and a parser that parses part of the language.
7 7
8 part of js_ast; 8 part of js_ast;
9 9
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 Template statementTemplateYielding(Node ast) { 293 Template statementTemplateYielding(Node ast) {
294 return new Template.withStatementResult(ast); 294 return new Template.withStatementResult(ast);
295 } 295 }
296 296
297 /// Creates a literal js string from [value]. 297 /// Creates a literal js string from [value].
298 LiteralString escapedString(String value, [String quote = '"']) { 298 LiteralString escapedString(String value, [String quote = '"']) {
299 // Start by escaping the backslashes. 299 // Start by escaping the backslashes.
300 String escaped = value.replaceAll('\\', '\\\\'); 300 String escaped = value.replaceAll('\\', '\\\\');
301 // Do not escape unicode characters and ' because they are allowed in the 301 // Do not escape unicode characters and ' because they are allowed in the
302 // string literal anyway. 302 // string literal anyway.
303 escaped = escaped.replaceAllMapped(new RegExp('\n|$quote|\b|\t|\v'), (m) { 303 var re = new RegExp('\n|\r|$quote|\b|\f|\t|\v');
304 escaped = escaped.replaceAllMapped(re, (m) {
304 switch (m.group(0)) { 305 switch (m.group(0)) {
305 case "\n" : return r"\n"; 306 case "\n" : return r"\n";
307 case "\r" : return r"\r";
306 // Quotes are only replaced if they conflict with the containing quote 308 // Quotes are only replaced if they conflict with the containing quote
307 case '"': return r'\"'; 309 case '"': return r'\"';
308 case "'": return r"\'"; 310 case "'": return r"\'";
309 case "`": return r"\`"; 311 case "`": return r"\`";
310 case "\b" : return r"\b"; 312 case "\b" : return r"\b";
311 case "\t" : return r"\t"; 313 case "\t" : return r"\t";
312 case "\f" : return r"\f"; 314 case "\f" : return r"\f";
313 case "\v" : return r"\v"; 315 case "\v" : return r"\v";
314 } 316 }
315 }); 317 });
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 expectCategory(RSQUARE); 1568 expectCategory(RSQUARE);
1567 return expr; 1569 return expr;
1568 } else if (acceptCategory(HASH)) { 1570 } else if (acceptCategory(HASH)) {
1569 return parseInterpolatedExpression(); 1571 return parseInterpolatedExpression();
1570 } else { 1572 } else {
1571 error('Expected property name'); 1573 error('Expected property name');
1572 return null; 1574 return null;
1573 } 1575 }
1574 } 1576 }
1575 } 1577 }
OLDNEW
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/misc.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698