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

Side by Side Diff: pkg/compiler/lib/src/resolution/semantic_visitor.dart

Issue 1120633002: Refactor index operator in SimpleTypeInferrer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 5 years, 7 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dart2js.semantics_visitor; 5 library dart2js.semantics_visitor;
6 6
7 import '../constants/expressions.dart'; 7 import '../constants/expressions.dart';
8 import '../dart2jslib.dart' show invariant; 8 import '../dart2jslib.dart' show invariant;
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 /// m(a) => super + a; 1216 /// m(a) => super + a;
1217 /// } 1217 /// }
1218 /// 1218 ///
1219 R visitSuperBinary( 1219 R visitSuperBinary(
1220 Send node, 1220 Send node,
1221 FunctionElement function, 1221 FunctionElement function,
1222 BinaryOperator operator, 1222 BinaryOperator operator,
1223 Node argument, 1223 Node argument,
1224 A arg); 1224 A arg);
1225 1225
1226 /// Binary operation on the unresolved super [element].
1227 ///
1228 /// For instance
1229 /// class B {
1230 /// }
1231 /// class C extends B {
1232 /// m() => super + 42;
1233 /// }
1234 ///
1235 R visitUnresolvedSuperBinary(
1236 Send node,
1237 Element element,
1238 BinaryOperator operator,
1239 Node argument,
1240 A arg);
1241
1226 /// Index expression `receiver[index]`. 1242 /// Index expression `receiver[index]`.
1227 /// 1243 ///
1228 /// For instance: 1244 /// For instance:
1229 /// lookup(a, b) => a[b]; 1245 /// lookup(a, b) => a[b];
1230 /// 1246 ///
1231 R visitIndex( 1247 R visitIndex(
1232 Send node, 1248 Send node,
1233 Node receiver, 1249 Node receiver,
1234 Node index, 1250 Node index,
1235 A arg); 1251 A arg);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 /// class C extends B { 1286 /// class C extends B {
1271 /// m(a) => super[a]; 1287 /// m(a) => super[a];
1272 /// } 1288 /// }
1273 /// 1289 ///
1274 R visitSuperIndex( 1290 R visitSuperIndex(
1275 Send node, 1291 Send node,
1276 FunctionElement function, 1292 FunctionElement function,
1277 Node index, 1293 Node index,
1278 A arg); 1294 A arg);
1279 1295
1296 /// Index expression `super[index]` where 'operator []' is unresolved.
1297 ///
1298 /// For instance:
1299 /// class B {}
1300 /// class C extends B {
1301 /// m(a) => super[a];
1302 /// }
1303 ///
1304 R visitUnresolvedSuperIndex(
1305 Send node,
1306 Element element,
1307 Node index,
1308 A arg);
1309
1280 /// Prefix operation on an index expression `operator super[index]` where 1310 /// Prefix operation on an index expression `operator super[index]` where
1281 /// 'operator []' is implemented on a superclass by [indexFunction] and 1311 /// 'operator []' is implemented on a superclass by [indexFunction] and
1282 /// 'operator []=' is implemented on by [indexSetFunction] and the operation 1312 /// 'operator []=' is implemented on by [indexSetFunction] and the operation
1283 /// is defined by [operator]. 1313 /// is defined by [operator].
1284 /// 1314 ///
1285 /// For instance: 1315 /// For instance:
1286 /// class B { 1316 /// class B {
1287 /// operator [](_) => null; 1317 /// operator [](_) => null;
1288 /// operator []=(a, b) {} 1318 /// operator []=(a, b) {}
1289 /// } 1319 /// }
1290 /// class C extends B { 1320 /// class C extends B {
1291 /// m(a) => --super[a]; 1321 /// m(a) => --super[a];
1292 /// } 1322 /// }
1293 /// 1323 ///
1294 R visitSuperIndexPrefix( 1324 R visitSuperIndexPrefix(
1295 Send node, 1325 Send node,
1296 FunctionElement indexFunction, 1326 MethodElement indexFunction,
1297 FunctionElement indexSetFunction, 1327 MethodElement indexSetFunction,
1298 Node index, 1328 Node index,
1299 IncDecOperator operator, 1329 IncDecOperator operator,
1300 A arg); 1330 A arg);
1301 1331
1302 /// Postfix operation on an index expression `super[index] operator` where 1332 /// Postfix operation on an index expression `super[index] operator` where
1303 /// 'operator []' is implemented on a superclass by [indexFunction] and 1333 /// 'operator []' is implemented on a superclass by [indexFunction] and
1304 /// 'operator []=' is implemented on by [indexSetFunction] and the operation 1334 /// 'operator []=' is implemented on by [indexSetFunction] and the operation
1305 /// is defined by [operator]. 1335 /// is defined by [operator].
1306 /// 1336 ///
1307 /// For instance: 1337 /// For instance:
1308 /// class B { 1338 /// class B {
1309 /// operator [](_) => null; 1339 /// operator [](_) => null;
1310 /// operator []=(a, b) {} 1340 /// operator []=(a, b) {}
1311 /// } 1341 /// }
1312 /// class C extends B { 1342 /// class C extends B {
1313 /// m(a) => super[a]++; 1343 /// m(a) => super[a]++;
1314 /// } 1344 /// }
1315 /// 1345 ///
1316 R visitSuperIndexPostfix( 1346 R visitSuperIndexPostfix(
1317 Send node, 1347 Send node,
1318 FunctionElement indexFunction, 1348 MethodElement indexFunction,
1319 FunctionElement indexSetFunction, 1349 MethodElement indexSetFunction,
1320 Node index, 1350 Node index,
1321 IncDecOperator operator, 1351 IncDecOperator operator,
1322 A arg); 1352 A arg);
1323 1353
1324 /// Index expression `super[index]` where 'operator []' is unresolved. 1354 /// Prefix operation on an index expression `operator super[index]` where
1355 /// 'operator []' and maybe also 'operator []=' is unresolved and the
1356 /// operation is defined by [operator].
1325 /// 1357 ///
1326 /// For instance: 1358 /// For instance:
1327 /// class B {} 1359 /// class B {}
1328 /// class C extends B { 1360 /// class C extends B {
1329 /// m(a) => super[a]; 1361 /// m(a) => --super[a];
1330 /// } 1362 /// }
1331 /// 1363 ///
1332 R visitUnresolvedSuperIndex( 1364 R visitUnresolvedSuperGetterIndexPrefix(
1333 Send node, 1365 Send node,
1334 Element element, 1366 Element element,
1335 Node index, 1367 Node index,
1368 IncDecOperator operator,
1369 A arg);
1370
1371 /// Postfix operation on an index expression `super[index] operator` where
1372 /// 'operator []' and maybe also 'operator []=' is unresolved and the
1373 /// operation is defined by [operator].
1374 ///
1375 /// For instance:
1376 /// class B {}
1377 /// class C extends B {
1378 /// m(a) => super[a]++;
1379 /// }
1380 ///
1381 R visitUnresolvedSuperGetterIndexPostfix(
1382 Send node,
1383 Element element,
1384 Node index,
1385 IncDecOperator operator,
1336 A arg); 1386 A arg);
1337 1387
1338 /// Prefix operation on an index expression `operator super[index]` where 1388 /// Prefix operation on an index expression `operator super[index]` where
1339 /// 'operator []' or 'operator []=' is unresolved and the operation 1389 /// 'operator []' is implemented on a superclass by [indexFunction] and
1340 /// is defined by [operator]. 1390 /// 'operator []=' is unresolved and the operation is defined by [operator].
1341 /// 1391 ///
1342 /// For instance: 1392 /// For instance:
1343 /// class B {} 1393 /// class B {}
1344 /// class C extends B { 1394 /// class C extends B {
1345 /// m(a) => --super[a]; 1395 /// m(a) => --super[a];
1346 /// } 1396 /// }
1347 /// 1397 ///
1348 R errorUnresolvedSuperIndexPrefix( 1398 R visitUnresolvedSuperSetterIndexPrefix(
1349 Send node, 1399 Send node,
1350 Element function, 1400 MethodElement indexFunction,
1401 Element element,
1351 Node index, 1402 Node index,
1352 IncDecOperator operator, 1403 IncDecOperator operator,
1353 A arg); 1404 A arg);
1354 1405
1355 /// Postfix operation on an index expression `super[index] operator` where 1406 /// Postfix operation on an index expression `super[index] operator` where
1356 /// 'operator []' or 'operator []=' is unresolved and the operation 1407 /// 'operator []' is implemented on a superclass by [indexFunction] and
1357 /// is defined by [operator]. 1408 /// 'operator []=' is unresolved and the operation is defined by [operator].
1358 /// 1409 ///
1359 /// For instance: 1410 /// For instance:
1360 /// class B {} 1411 /// class B {}
1361 /// class C extends B { 1412 /// class C extends B {
1362 /// m(a) => super[a]++; 1413 /// m(a) => super[a]++;
1363 /// } 1414 /// }
1364 /// 1415 ///
1365 R errorUnresolvedSuperIndexPostfix( 1416 R visitUnresolvedSuperSetterIndexPostfix(
1366 Send node, 1417 Send node,
1367 Element function, 1418 MethodElement indexFunction,
1419 Element element,
1368 Node index, 1420 Node index,
1369 IncDecOperator operator, 1421 IncDecOperator operator,
1370 A arg); 1422 A arg);
1371 1423
1372 /// Binary expression `left == right`. 1424 /// Binary expression `left == right`.
1373 /// 1425 ///
1374 /// For instance: 1426 /// For instance:
1375 /// neq(a, b) => a != b; 1427 /// neq(a, b) => a != b;
1376 /// 1428 ///
1377 R visitNotEquals( 1429 R visitNotEquals(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 /// class C extends B { 1500 /// class C extends B {
1449 /// m(a) => -super; 1501 /// m(a) => -super;
1450 /// } 1502 /// }
1451 /// 1503 ///
1452 R visitSuperUnary( 1504 R visitSuperUnary(
1453 Send node, 1505 Send node,
1454 UnaryOperator operator, 1506 UnaryOperator operator,
1455 FunctionElement function, 1507 FunctionElement function,
1456 A arg); 1508 A arg);
1457 1509
1510 /// Unary operation on the unresolved super [element].
1511 ///
1512 /// For instance
1513 /// class B {
1514 /// }
1515 /// class C extends B {
1516 /// m() => -super;
1517 /// }
1518 ///
1519 R visitUnresolvedSuperUnary(
1520 Send node,
1521 UnaryOperator operator,
1522 Element element,
1523 A arg);
1524
1458 /// Unary expression `!expression`. 1525 /// Unary expression `!expression`.
1459 /// 1526 ///
1460 /// For instance: 1527 /// For instance:
1461 /// not(a) => !a; 1528 /// not(a) => !a;
1462 /// 1529 ///
1463 R visitNot( 1530 R visitNot(
1464 Send node, 1531 Send node,
1465 Node expression, 1532 Node expression,
1466 A arg); 1533 A arg);
1467 1534
(...skipping 20 matching lines...) Expand all
1488 /// m(a, b) => super[a] = b; 1555 /// m(a, b) => super[a] = b;
1489 /// } 1556 /// }
1490 /// 1557 ///
1491 R visitSuperIndexSet( 1558 R visitSuperIndexSet(
1492 SendSet node, 1559 SendSet node,
1493 FunctionElement function, 1560 FunctionElement function,
1494 Node index, 1561 Node index,
1495 Node rhs, 1562 Node rhs,
1496 A arg); 1563 A arg);
1497 1564
1565 /// Index set expression `super[index] = rhs` where `operator []=` is
1566 /// undefined.
1567 ///
1568 /// For instance
1569 /// class B {
1570 /// }
1571 /// class C extends B {
1572 /// m() => super[1] = 42;
1573 /// }
1574 ///
1575 R visitUnresolvedSuperIndexSet(
1576 Send node,
1577 Element element,
1578 Node index,
1579 Node rhs,
1580 A arg);
1581
1498 /// Logical and, &&, expression with operands [left] and [right]. 1582 /// Logical and, &&, expression with operands [left] and [right].
1499 /// 1583 ///
1500 /// For instance 1584 /// For instance
1501 /// m() => left && right; 1585 /// m() => left && right;
1502 /// 1586 ///
1503 R visitLogicalAnd( 1587 R visitLogicalAnd(
1504 Send node, 1588 Send node,
1505 Node left, 1589 Node left,
1506 Node right, 1590 Node right,
1507 A arg); 1591 A arg);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 /// For instance: 2047 /// For instance:
1964 /// m(rhs) => dynamic += rhs; 2048 /// m(rhs) => dynamic += rhs;
1965 /// 2049 ///
1966 R errorDynamicTypeLiteralCompound( 2050 R errorDynamicTypeLiteralCompound(
1967 Send node, 2051 Send node,
1968 ConstantExpression constant, 2052 ConstantExpression constant,
1969 AssignmentOperator operator, 2053 AssignmentOperator operator,
1970 Node rhs, 2054 Node rhs,
1971 A arg); 2055 A arg);
1972 2056
1973 /// Compound assignment expression of [rhs] with [operator] on the index 2057 /// Compound index assignment of [rhs] with [operator] to [index] on the
1974 /// operators of [receiver] whose getter and setter are defined by 2058 /// index operators of [receiver] whose getter and setter are defined by
1975 /// [getterSelector] and [setterSelector], respectively. 2059 /// [getterSelector] and [setterSelector], respectively.
1976 /// 2060 ///
1977 /// For instance: 2061 /// For instance:
1978 /// m(receiver, index, rhs) => receiver[index] += rhs; 2062 /// m(receiver, index, rhs) => receiver[index] += rhs;
1979 /// 2063 ///
1980 R visitCompoundIndexSet( 2064 R visitCompoundIndexSet(
1981 SendSet node, 2065 SendSet node,
1982 Node receiver, 2066 Node receiver,
1983 Node index, 2067 Node index,
1984 AssignmentOperator operator, 2068 AssignmentOperator operator,
1985 Node rhs, 2069 Node rhs,
1986 A arg); 2070 A arg);
1987 2071
1988 /// Compound assignment expression of [rhs] with [operator] on the index 2072 /// Compound index assignment of [rhs] with [operator] to [index] on the index
1989 /// operators of a super class defined by [getter] and [setter]. 2073 /// operators of a super class defined by [getter] and [setter].
1990 /// 2074 ///
1991 /// For instance: 2075 /// For instance:
1992 /// class B { 2076 /// class B {
1993 /// operator [](index) {} 2077 /// operator [](index) {}
1994 /// operator [](index, value) {} 2078 /// operator [](index, value) {}
1995 /// } 2079 /// }
1996 /// class C extends B { 2080 /// class C extends B {
1997 /// m(index, rhs) => super[index] += rhs; 2081 /// m(index, rhs) => super[index] += rhs;
1998 /// } 2082 /// }
1999 /// 2083 ///
2000 R visitSuperCompoundIndexSet( 2084 R visitSuperCompoundIndexSet(
2001 SendSet node, 2085 SendSet node,
2002 FunctionElement getter, 2086 MethodElement getter,
2003 FunctionElement setter, 2087 MethodElement setter,
2004 Node index, 2088 Node index,
2005 AssignmentOperator operator, 2089 AssignmentOperator operator,
2006 Node rhs, 2090 Node rhs,
2091 A arg);
2092
2093 /// Compound index assignment of [rhs] with [operator] to [index] on a super
2094 /// super class where the index getter is undefined. The index setter might
2095 /// also be undefined.
2096 ///
2097 /// For instance
2098 /// class B {
2099 /// }
2100 /// class C extends B {
2101 /// m() => super[1] += 42;
2102 /// }
2103 ///
2104 R visitUnresolvedSuperGetterCompoundIndexSet(
2105 Send node,
2106 Element element,
2107 Node index,
2108 AssignmentOperator operator,
2109 Node rhs,
2110 A arg);
2111
2112 /// Compound index assignment of [rhs] with [operator] to [index] on a super
2113 /// super class where the index getter is defined by [getter] but the index
2114 /// setter is undefined.
2115 ///
2116 /// For instance
2117 /// class B {
2118 /// operator [](index) => 42;
2119 /// }
2120 /// class C extends B {
2121 /// m() => super[1] += 42;
2122 /// }
2123 ///
2124 R visitUnresolvedSuperSetterCompoundIndexSet(
2125 Send node,
2126 MethodElement getter,
2127 Element element,
2128 Node index,
2129 AssignmentOperator operator,
2130 Node rhs,
2007 A arg); 2131 A arg);
2008 2132
2009 /// Prefix expression with [operator] of the property on [receiver] whose 2133 /// Prefix expression with [operator] of the property on [receiver] whose
2010 /// getter and setter are defined by [getterSelector] and [setterSelector], 2134 /// getter and setter are defined by [getterSelector] and [setterSelector],
2011 /// respectively. 2135 /// respectively.
2012 /// 2136 ///
2013 /// For instance: 2137 /// For instance:
2014 /// m(receiver) => ++receiver.foo; 2138 /// m(receiver) => ++receiver.foo;
2015 /// 2139 ///
2016 R visitDynamicPropertyPrefix( 2140 R visitDynamicPropertyPrefix(
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 /// m6() => C.unresolved++; 2959 /// m6() => C.unresolved++;
2836 /// m7() => prefix.C.unresolved++; 2960 /// m7() => prefix.C.unresolved++;
2837 /// 2961 ///
2838 // TODO(johnniwinther): Split the cases in which a prefix is resolved. 2962 // TODO(johnniwinther): Split the cases in which a prefix is resolved.
2839 R errorUnresolvedPostfix( 2963 R errorUnresolvedPostfix(
2840 Send node, 2964 Send node,
2841 Element element, 2965 Element element,
2842 IncDecOperator operator, 2966 IncDecOperator operator,
2843 A arg); 2967 A arg);
2844 2968
2845 /// Index set operation on the unresolved super [element].
2846 ///
2847 /// For instance
2848 /// class B {
2849 /// }
2850 /// class C extends B {
2851 /// m() => super[1] = 42;
2852 /// }
2853 ///
2854 R errorUnresolvedSuperIndexSet(
2855 Send node,
2856 Element element,
2857 Node index,
2858 Node rhs,
2859 A arg);
2860
2861 /// Compound index set operation on the unresolved super [element].
2862 ///
2863 /// For instance
2864 /// class B {
2865 /// }
2866 /// class C extends B {
2867 /// m() => super[1] += 42;
2868 /// }
2869 ///
2870 // TODO(johnniwinther): Split this case into unresolved getter/setter cases.
2871 R errorUnresolvedSuperCompoundIndexSet(
2872 Send node,
2873 Element element,
2874 Node index,
2875 AssignmentOperator operator,
2876 Node rhs,
2877 A arg);
2878
2879 /// Unary operation on the unresolved super [element].
2880 ///
2881 /// For instance
2882 /// class B {
2883 /// }
2884 /// class C extends B {
2885 /// m() => -super;
2886 /// }
2887 ///
2888 R visitUnresolvedSuperUnary(
2889 Send node,
2890 UnaryOperator operator,
2891 Element element,
2892 A arg);
2893
2894 /// Binary operation on the unresolved super [element].
2895 ///
2896 /// For instance
2897 /// class B {
2898 /// }
2899 /// class C extends B {
2900 /// m() => super + 42;
2901 /// }
2902 ///
2903 R visitUnresolvedSuperBinary(
2904 Send node,
2905 Element element,
2906 BinaryOperator operator,
2907 Node argument,
2908 A arg);
2909
2910 /// Invocation of an undefined unary [operator] on [expression]. 2969 /// Invocation of an undefined unary [operator] on [expression].
2911 R errorUndefinedUnaryExpression( 2970 R errorUndefinedUnaryExpression(
2912 Send node, 2971 Send node,
2913 Operator operator, 2972 Operator operator,
2914 Node expression, 2973 Node expression,
2915 A arg); 2974 A arg);
2916 2975
2917 /// Invocation of an undefined unary [operator] with operands 2976 /// Invocation of an undefined unary [operator] with operands
2918 /// [left] and [right]. 2977 /// [left] and [right].
2919 R errorUndefinedBinaryExpression( 2978 R errorUndefinedBinaryExpression(
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 /// C() : this._(42); 3689 /// C() : this._(42);
3631 /// } 3690 /// }
3632 /// 3691 ///
3633 R errorUnresolvedThisConstructorInvoke( 3692 R errorUnresolvedThisConstructorInvoke(
3634 Send node, 3693 Send node,
3635 Element element, 3694 Element element,
3636 NodeList arguments, 3695 NodeList arguments,
3637 Selector selector, 3696 Selector selector,
3638 A arg); 3697 A arg);
3639 } 3698 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/access_semantics.dart ('k') | pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698