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

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

Issue 750323003: Remove js.ArrayElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 6 years 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 | « no previous file | pkg/compiler/lib/src/js/nodes.dart » ('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; 8 part of js;
9 9
10 10
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 /// 321 ///
322 /// Note that this function only puts quotes around [value]. It does not do 322 /// Note that this function only puts quotes around [value]. It does not do
323 /// any escaping, so use only when you can guarantee that [value] does not 323 /// any escaping, so use only when you can guarantee that [value] does not
324 /// contain newlines or backslashes. For escaping the string use 324 /// contain newlines or backslashes. For escaping the string use
325 /// [escapedString]. 325 /// [escapedString].
326 LiteralString string(String value) => new LiteralString('"$value"'); 326 LiteralString string(String value) => new LiteralString('"$value"');
327 327
328 LiteralNumber number(num value) => new LiteralNumber('$value'); 328 LiteralNumber number(num value) => new LiteralNumber('$value');
329 329
330 ArrayInitializer numArray(Iterable<int> list) => 330 ArrayInitializer numArray(Iterable<int> list) =>
331 new ArrayInitializer.from(list.map(number)); 331 new ArrayInitializer(list.map(number).toList());
332 332
333 ArrayInitializer stringArray(Iterable<String> list) => 333 ArrayInitializer stringArray(Iterable<String> list) =>
334 new ArrayInitializer.from(list.map(string)); 334 new ArrayInitializer(list.map(string).toList());
335 335
336 Comment comment(String text) => new Comment(text); 336 Comment comment(String text) => new Comment(text);
337 337
338 Call propertyCall(Expression receiver, 338 Call propertyCall(Expression receiver,
339 String fieldName, 339 String fieldName,
340 List<Expression> arguments) { 340 List<Expression> arguments) {
341 return new Call(new PropertyAccess.field(receiver, fieldName), arguments); 341 return new Call(new PropertyAccess.field(receiver, fieldName), arguments);
342 } 342 }
343 } 343 }
344 344
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 Expression expression = parseExpression(); 720 Expression expression = parseExpression();
721 expectCategory(RPAREN); 721 expectCategory(RPAREN);
722 return expression; 722 return expression;
723 } else if (acceptCategory(STRING)) { 723 } else if (acceptCategory(STRING)) {
724 return new LiteralString(last); 724 return new LiteralString(last);
725 } else if (acceptCategory(NUMERIC)) { 725 } else if (acceptCategory(NUMERIC)) {
726 return new LiteralNumber(last); 726 return new LiteralNumber(last);
727 } else if (acceptCategory(LBRACE)) { 727 } else if (acceptCategory(LBRACE)) {
728 return parseObjectInitializer(); 728 return parseObjectInitializer();
729 } else if (acceptCategory(LSQUARE)) { 729 } else if (acceptCategory(LSQUARE)) {
730 var values = <ArrayElement>[]; 730 var values = <Expression>[];
731 if (!acceptCategory(RSQUARE)) { 731
732 do { 732 while (true) {
733 values.add(new ArrayElement(values.length, parseAssignment())); 733 if (acceptCategory(COMMA)) {
734 } while (acceptCategory(COMMA)); 734 values.add(new ArrayHole());
735 expectCategory(RSQUARE); 735 continue;
736 }
737 if (acceptCategory(RSQUARE)) break;
738 values.add(parseAssignment());
739 if (acceptCategory(RSQUARE)) break;
740 expectCategory(COMMA);
736 } 741 }
737 return new ArrayInitializer(values.length, values); 742 return new ArrayInitializer(values);
738 } else if (last != null && last.startsWith("/")) { 743 } else if (last != null && last.startsWith("/")) {
739 String regexp = getDelimited(lastPosition); 744 String regexp = getDelimited(lastPosition);
740 getToken(); 745 getToken();
741 String flags = lastToken; 746 String flags = lastToken;
742 if (!acceptCategory(ALPHA)) flags = ""; 747 if (!acceptCategory(ALPHA)) flags = "";
743 Expression expression = new RegExpLiteral(regexp + flags); 748 Expression expression = new RegExpLiteral(regexp + flags);
744 return expression; 749 return expression;
745 } else if (acceptCategory(HASH)) { 750 } else if (acceptCategory(HASH)) {
746 var nameOrPosition = parseHash(); 751 var nameOrPosition = parseHash();
747 InterpolatedExpression expression = 752 InterpolatedExpression expression =
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 Catch parseCatch() { 1236 Catch parseCatch() {
1232 expectCategory(LPAREN); 1237 expectCategory(LPAREN);
1233 String identifier = lastToken; 1238 String identifier = lastToken;
1234 expectCategory(ALPHA); 1239 expectCategory(ALPHA);
1235 expectCategory(RPAREN); 1240 expectCategory(RPAREN);
1236 expectCategory(LBRACE); 1241 expectCategory(LBRACE);
1237 Block body = parseBlock(); 1242 Block body = parseBlock();
1238 return new Catch(new VariableDeclaration(identifier), body); 1243 return new Catch(new VariableDeclaration(identifier), body);
1239 } 1244 }
1240 } 1245 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698