OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// ERROR HANDLING | 6 /// ERROR HANDLING |
7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
8 /// | 8 /// |
9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 } | 1299 } |
1300 | 1300 |
1301 transformChildren(Transformer v) { | 1301 transformChildren(Transformer v) { |
1302 if (promotedType != null) { | 1302 if (promotedType != null) { |
1303 promotedType = v.visitDartType(promotedType); | 1303 promotedType = v.visitDartType(promotedType); |
1304 } | 1304 } |
1305 } | 1305 } |
1306 } | 1306 } |
1307 | 1307 |
1308 /// Assign a local variable or function parameter. | 1308 /// Assign a local variable or function parameter. |
| 1309 /// |
| 1310 /// Evaluates to the value of [value]. |
1309 class VariableSet extends Expression { | 1311 class VariableSet extends Expression { |
1310 VariableDeclaration variable; | 1312 VariableDeclaration variable; |
1311 Expression value; | 1313 Expression value; |
1312 | 1314 |
1313 VariableSet(this.variable, this.value) { | 1315 VariableSet(this.variable, this.value) { |
1314 value?.parent = this; | 1316 value?.parent = this; |
1315 } | 1317 } |
1316 | 1318 |
1317 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1319 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
1318 | 1320 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 if (receiver != null) { | 1382 if (receiver != null) { |
1381 receiver = receiver.accept(v); | 1383 receiver = receiver.accept(v); |
1382 receiver?.parent = this; | 1384 receiver?.parent = this; |
1383 } | 1385 } |
1384 } | 1386 } |
1385 } | 1387 } |
1386 | 1388 |
1387 /// Expression of form `x.field = value`. | 1389 /// Expression of form `x.field = value`. |
1388 /// | 1390 /// |
1389 /// This may invoke a setter or assign a field. | 1391 /// This may invoke a setter or assign a field. |
| 1392 /// |
| 1393 /// Evaluates to the value of [value]. |
1390 class PropertySet extends Expression { | 1394 class PropertySet extends Expression { |
1391 Expression receiver; | 1395 Expression receiver; |
1392 Name name; | 1396 Name name; |
1393 Expression value; | 1397 Expression value; |
1394 | 1398 |
1395 _MemberAccessor _interfaceTargetReference; | 1399 _MemberAccessor _interfaceTargetReference; |
1396 | 1400 |
1397 PropertySet(this.receiver, this.name, this.value, [Member interfaceTarget]) { | 1401 PropertySet(this.receiver, this.name, this.value, [Member interfaceTarget]) { |
1398 receiver?.parent = this; | 1402 receiver?.parent = this; |
1399 value?.parent = this; | 1403 value?.parent = this; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 DartType getStaticType(TypeEnvironment types) { | 1458 DartType getStaticType(TypeEnvironment types) { |
1455 Class superclass = target.enclosingClass; | 1459 Class superclass = target.enclosingClass; |
1456 var receiverType = receiver.getStaticTypeAsInstanceOf(superclass, types); | 1460 var receiverType = receiver.getStaticTypeAsInstanceOf(superclass, types); |
1457 return Substitution | 1461 return Substitution |
1458 .fromInterfaceType(receiverType) | 1462 .fromInterfaceType(receiverType) |
1459 .substituteType(target.getterType); | 1463 .substituteType(target.getterType); |
1460 } | 1464 } |
1461 } | 1465 } |
1462 | 1466 |
1463 /// Directly assign a field, or call a setter. | 1467 /// Directly assign a field, or call a setter. |
| 1468 /// |
| 1469 /// Evaluates to the value of [value]. |
1464 class DirectPropertySet extends Expression { | 1470 class DirectPropertySet extends Expression { |
1465 Expression receiver; | 1471 Expression receiver; |
1466 Member target; | 1472 Member target; |
1467 Expression value; | 1473 Expression value; |
1468 | 1474 |
1469 DirectPropertySet(this.receiver, this.target, this.value) { | 1475 DirectPropertySet(this.receiver, this.target, this.value) { |
1470 receiver?.parent = this; | 1476 receiver?.parent = this; |
1471 value?.parent = this; | 1477 value?.parent = this; |
1472 } | 1478 } |
1473 | 1479 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 visitChildren(Visitor v) { | 1579 visitChildren(Visitor v) { |
1574 name?.accept(v); | 1580 name?.accept(v); |
1575 } | 1581 } |
1576 | 1582 |
1577 transformChildren(Transformer v) {} | 1583 transformChildren(Transformer v) {} |
1578 } | 1584 } |
1579 | 1585 |
1580 /// Expression of form `super.field = value`. | 1586 /// Expression of form `super.field = value`. |
1581 /// | 1587 /// |
1582 /// This may invoke a setter or assign a field. | 1588 /// This may invoke a setter or assign a field. |
| 1589 /// |
| 1590 /// Evaluates to the value of [value]. |
1583 class SuperPropertySet extends Expression { | 1591 class SuperPropertySet extends Expression { |
1584 Name name; | 1592 Name name; |
1585 Expression value; | 1593 Expression value; |
1586 _MemberAccessor _interfaceTargetReference; | 1594 _MemberAccessor _interfaceTargetReference; |
1587 | 1595 |
1588 SuperPropertySet(this.name, this.value, [Member interfaceTarget]) { | 1596 SuperPropertySet(this.name, this.value, [Member interfaceTarget]) { |
1589 value?.parent = this; | 1597 value?.parent = this; |
1590 _interfaceTargetReference = interfaceTarget?._setterInterface; | 1598 _interfaceTargetReference = interfaceTarget?._setterInterface; |
1591 } | 1599 } |
1592 | 1600 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 accept(ExpressionVisitor v) => v.visitStaticGet(this); | 1633 accept(ExpressionVisitor v) => v.visitStaticGet(this); |
1626 | 1634 |
1627 visitChildren(Visitor v) { | 1635 visitChildren(Visitor v) { |
1628 target?.acceptReference(v); | 1636 target?.acceptReference(v); |
1629 } | 1637 } |
1630 | 1638 |
1631 transformChildren(Transformer v) {} | 1639 transformChildren(Transformer v) {} |
1632 } | 1640 } |
1633 | 1641 |
1634 /// Assign a static field or call a static setter. | 1642 /// Assign a static field or call a static setter. |
| 1643 /// |
| 1644 /// Evaluates to the value of [value]. |
1635 class StaticSet extends Expression { | 1645 class StaticSet extends Expression { |
1636 /// A mutable static field or a static setter. | 1646 /// A mutable static field or a static setter. |
1637 Member target; | 1647 Member target; |
1638 Expression value; | 1648 Expression value; |
1639 | 1649 |
1640 StaticSet(this.target, this.value) { | 1650 StaticSet(this.target, this.value) { |
1641 value?.parent = this; | 1651 value?.parent = this; |
1642 } | 1652 } |
1643 | 1653 |
1644 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1654 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 | 3641 |
3632 @override | 3642 @override |
3633 defaultTreeNode(TreeNode node) { | 3643 defaultTreeNode(TreeNode node) { |
3634 if (node == child) { | 3644 if (node == child) { |
3635 return replacement; | 3645 return replacement; |
3636 } else { | 3646 } else { |
3637 return node; | 3647 return node; |
3638 } | 3648 } |
3639 } | 3649 } |
3640 } | 3650 } |
OLD | NEW |