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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js/nodes.dart

Issue 12499005: dart2js: Create noSuchMethod handlers at runtime to reduce overhead. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reordered some stuff due to code review feedback Created 7 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
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 part of js; 5 part of js;
6 6
7 abstract class NodeVisitor<T> { 7 abstract class NodeVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 toExpression(object), 1054 toExpression(object),
1055 toStatement(statement)); 1055 toStatement(statement));
1056 } 1056 }
1057 1057
1058 For for_(init, condition, update, statement) { 1058 For for_(init, condition, update, statement) {
1059 return new For( 1059 return new For(
1060 toExpression(init), toExpression(condition), toExpression(update), 1060 toExpression(init), toExpression(condition), toExpression(update),
1061 toStatement(statement)); 1061 toStatement(statement));
1062 } 1062 }
1063 1063
1064 While while_(condition, statement) {
1065 return new While(
1066 toExpression(condition), toStatement(statement));
1067 }
1068
1064 Try try_(body, {catchPart, finallyPart}) { 1069 Try try_(body, {catchPart, finallyPart}) {
1065 if (catchPart != null) catchPart = toStatement(catchPart); 1070 if (catchPart != null) catchPart = toStatement(catchPart);
1066 if (finallyPart != null) finallyPart = toStatement(finallyPart); 1071 if (finallyPart != null) finallyPart = toStatement(finallyPart);
1067 return new Try(toStatement(body), catchPart, finallyPart); 1072 return new Try(toStatement(body), catchPart, finallyPart);
1068 } 1073 }
1069 1074
1070 Comment comment(String text) => new Comment(text); 1075 Comment comment(String text) => new Comment(text);
1071 } 1076 }
1072 1077
1073 const JsBuilder js = const JsBuilder(); 1078 const JsBuilder js = const JsBuilder();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // ABCDEFGH 1189 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // ABCDEFGH
1185 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // IJKLMNOP 1190 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // IJKLMNOP
1186 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // QRSTUVWX 1191 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // QRSTUVWX
1187 ALPHA, ALPHA, LSQUARE, OTHER, RSQUARE, SYMBOL, ALPHA, OTHER, // YZ[\]^_' 1192 ALPHA, ALPHA, LSQUARE, OTHER, RSQUARE, SYMBOL, ALPHA, OTHER, // YZ[\]^_'
1188 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // abcdefgh 1193 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // abcdefgh
1189 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // ijklmnop 1194 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // ijklmnop
1190 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // qrstuvwx 1195 ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // qrstuvwx
1191 ALPHA, ALPHA, LBRACE, SYMBOL, RBRACE, SYMBOL]; // yz{|}~ 1196 ALPHA, ALPHA, LBRACE, SYMBOL, RBRACE, SYMBOL]; // yz{|}~
1192 1197
1193 static final BINARY_OPERATORS = [ 1198 static final BINARY_OPERATORS = [
1194 '+', '-', '*', '/', '%', '^', '|', '&', '||', '&&', 1199 '+', '-', '*', '/', '%', '^', '|', '&', '||', '&&', '<<', '>>', '>>>',
1195 '<<', '>>', '+=', '-=', '*=', '/=', '^=', '|=', '&=', '<<=', '>>=', 1200 '+=', '-=', '*=', '/=', '%=', '^=', '|=', '&=', '<<=', '>>=', '>>>=',
1196 '=', '!=', '==', '!==', '===', '<', '<=', '>=', '>'].toSet(); 1201 '=', '!=', '==', '!==', '===', '<', '<=', '>=', '>'].toSet();
1197 static final UNARY_OPERATORS = ['++', '--', '+', '-', '~', '!'].toSet(); 1202 static final UNARY_OPERATORS = ['++', '--', '+', '-', '~', '!'].toSet();
1198 1203
1199 // For sanity we only allow \\, \', \" and \n in string literals. 1204 // For sanity we only allow \\, \', \" and \n in string literals.
1200 static final STRING_LITERAL_PATTERN = 1205 static final STRING_LITERAL_PATTERN =
1201 new RegExp('^[\'"](?:[^\\\\]|\\\\[\\\\n\'"])*[\'"]\$'); 1206 new RegExp('^[\'"](?:[^\\\\]|\\\\[\\\\n\'"])*[\'"]\$');
1202 1207
1203 static int category(int code) { 1208 static int category(int code) {
1204 if (code >= CATEGORIES.length) return OTHER; 1209 if (code >= CATEGORIES.length) return OTHER;
1205 return CATEGORIES[code]; 1210 return CATEGORIES[code];
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 } 1429 }
1425 1430
1426 Expression parseRelation() { 1431 Expression parseRelation() {
1427 Expression lhs = parseBinary(); 1432 Expression lhs = parseBinary();
1428 String relation = lastToken; 1433 String relation = lastToken;
1429 // The lexer returns "=" as a relational operator because it looks a bit 1434 // The lexer returns "=" as a relational operator because it looks a bit
1430 // like ==, <=, etc. But we don't want to handle it here (that would give 1435 // like ==, <=, etc. But we don't want to handle it here (that would give
1431 // it the wrong prescedence), so we just return if we see it. 1436 // it the wrong prescedence), so we just return if we see it.
1432 if (relation == "=" || !acceptCategory(RELATION)) return lhs; 1437 if (relation == "=" || !acceptCategory(RELATION)) return lhs;
1433 Expression rhs = parseBinary(); 1438 Expression rhs = parseBinary();
1434 if (relation == "<<=" || relation == ">>=") { 1439 if (relation == "<<=" || relation == ">>=" || relation == ">>>=") {
1435 return new Assignment.compound(lhs, 1440 return new Assignment.compound(lhs,
1436 relation.substring(0, relation.length - 1), 1441 relation.substring(0, relation.length - 1),
1437 rhs); 1442 rhs);
1438 } else { 1443 } else {
1439 // Regular binary operation. 1444 // Regular binary operation.
1440 return new Binary(relation, lhs, rhs); 1445 return new Binary(relation, lhs, rhs);
1441 } 1446 }
1442 } 1447 }
1443 1448
1444 Expression parseConditional() { 1449 Expression parseConditional() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1488
1484 Expression expression() { 1489 Expression expression() {
1485 Expression expression = parseVarDeclarationOrExpression(); 1490 Expression expression = parseVarDeclarationOrExpression();
1486 if (lastCategory != NONE || position != src.length) { 1491 if (lastCategory != NONE || position != src.length) {
1487 throw new MiniJsParserError( 1492 throw new MiniJsParserError(
1488 this, "Unparsed junk: ${categoryToString(lastCategory)}"); 1493 this, "Unparsed junk: ${categoryToString(lastCategory)}");
1489 } 1494 }
1490 return expression; 1495 return expression;
1491 } 1496 }
1492 } 1497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698