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

Side by Side Diff: frog/gen.dart

Issue 9653021: Add support for implicitly concatenating adjacent string literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added test case. Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « frog/analyze.dart ('k') | frog/minfrog » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Top level generator object for writing code and keeping track of 6 * Top level generator object for writing code and keeping track of
7 * dependencies. 7 * dependencies.
8 * 8 *
9 * Should have two compilation models, but only one implemented so far. 9 * Should have two compilation models, but only one implemented so far.
10 * 10 *
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 2289
2290 _isUnaryIncrement(Expression item) { 2290 _isUnaryIncrement(Expression item) {
2291 if (item is UnaryExpression) { 2291 if (item is UnaryExpression) {
2292 UnaryExpression u = item; 2292 UnaryExpression u = item;
2293 return u.op.kind == TokenKind.INCR || u.op.kind == TokenKind.DECR; 2293 return u.op.kind == TokenKind.INCR || u.op.kind == TokenKind.DECR;
2294 } else { 2294 } else {
2295 return false; 2295 return false;
2296 } 2296 }
2297 } 2297 }
2298 2298
2299 visitStringConcatExpression(StringConcatExpression node) {
2300 var items = [];
2301 for (var item in node.strings) {
2302 Value val = visitValue(item);
2303 assert(val.type.isString);
2304 items.add(val.code);
2305 }
2306 return new Value(world.stringType, '(${Strings.join(items, " + ")})',
2307 node.span);
2308 }
2309
2299 visitStringInterpExpression(StringInterpExpression node) { 2310 visitStringInterpExpression(StringInterpExpression node) {
2300 var items = []; 2311 var items = [];
2301 for (var item in node.pieces) { 2312 for (var item in node.pieces) {
2302 var val = visitValue(item); 2313 var val = visitValue(item);
2303 val.invoke(this, 'toString', item, Arguments.EMPTY); 2314 val.invoke(this, 'toString', item, Arguments.EMPTY);
2304 // TODO(jimhug): Ensure this solves all precedence problems. 2315 // TODO(jimhug): Ensure this solves all precedence problems.
2305 // TODO(jmesserly): We could be smarter about prefix/postfix, but we'd 2316 // TODO(jmesserly): We could be smarter about prefix/postfix, but we'd
2306 // need to know if it will compile to a ++ or to some sort of += form. 2317 // need to know if it will compile to a ++ or to some sort of += form.
2307 var code = val.code; 2318 var code = val.code;
2308 if (_expressionNeedsParens(item)) { 2319 if (_expressionNeedsParens(item)) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 return true; 2460 return true;
2450 } 2461 }
2451 2462
2452 } 2463 }
2453 2464
2454 class ReturnKind { 2465 class ReturnKind {
2455 static final int IGNORE = 1; 2466 static final int IGNORE = 1;
2456 static final int POST = 2; 2467 static final int POST = 2;
2457 static final int PRE = 3; 2468 static final int PRE = 3;
2458 } 2469 }
OLDNEW
« no previous file with comments | « frog/analyze.dart ('k') | frog/minfrog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698