OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend | 5 /// This file declares a "shadow hierarchy" of concrete classes which extend |
6 /// the kernel class hierarchy, adding methods and fields needed by the | 6 /// the kernel class hierarchy, adding methods and fields needed by the |
7 /// BodyBuilder. | 7 /// BodyBuilder. |
8 /// | 8 /// |
9 /// Instances of these classes may be created using the factory methods in | 9 /// Instances of these classes may be created using the factory methods in |
10 /// `ast_factory.dart`. | 10 /// `ast_factory.dart`. |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 Member interfaceMember; | 1069 Member interfaceMember; |
1070 if (receiverType is InterfaceType) { | 1070 if (receiverType is InterfaceType) { |
1071 interfaceMember = inferrer.classHierarchy | 1071 interfaceMember = inferrer.classHierarchy |
1072 .getInterfaceMember(receiverType.classNode, name); | 1072 .getInterfaceMember(receiverType.classNode, name); |
1073 if (interfaceMember is Procedure) { | 1073 if (interfaceMember is Procedure) { |
1074 // Our non-strong golden files currently don't include interface | 1074 // Our non-strong golden files currently don't include interface |
1075 // targets, so we can't store the interface target without causing tests | 1075 // targets, so we can't store the interface target without causing tests |
1076 // to fail. TODO(paulberry): fix this. | 1076 // to fail. TODO(paulberry): fix this. |
1077 if (inferrer.strongMode) { | 1077 if (inferrer.strongMode) { |
1078 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, | 1078 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, |
1079 'target', new InstrumentationValueForProcedure(interfaceMember)); | 1079 'target', new InstrumentationValueForMember(interfaceMember)); |
1080 interfaceTarget = interfaceMember; | 1080 interfaceTarget = interfaceMember; |
1081 } | 1081 } |
1082 isOverloadedArithmeticOperator = inferrer.typeSchemaEnvironment | 1082 isOverloadedArithmeticOperator = inferrer.typeSchemaEnvironment |
1083 .isOverloadedArithmeticOperator(interfaceMember); | 1083 .isOverloadedArithmeticOperator(interfaceMember); |
1084 } | 1084 } |
1085 } | 1085 } |
1086 var calleeType = | 1086 var calleeType = |
1087 inferrer.getCalleeFunctionType(interfaceMember, receiverType, name); | 1087 inferrer.getCalleeFunctionType(interfaceMember, receiverType, name); |
1088 var inferredType = inferrer.inferInvocation(typeContext, typeNeeded, | 1088 var inferredType = inferrer.inferInvocation(typeContext, typeNeeded, |
1089 fileOffset, calleeType, calleeType.returnType, arguments, | 1089 fileOffset, calleeType, calleeType.returnType, arguments, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 // are disallowed here. | 1149 // are disallowed here. |
1150 // - The inference dependency of the identifier is the referent if the | 1150 // - The inference dependency of the identifier is the referent if the |
1151 // referent is a candidate for inference. Otherwise there are no | 1151 // referent is a candidate for inference. Otherwise there are no |
1152 // inference dependencies. | 1152 // inference dependencies. |
1153 // TODO(paulberry): implement the proper logic here. | 1153 // TODO(paulberry): implement the proper logic here. |
1154 } | 1154 } |
1155 | 1155 |
1156 @override | 1156 @override |
1157 DartType _inferExpression( | 1157 DartType _inferExpression( |
1158 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 1158 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
1159 // TODO(scheglov): implement. | 1159 typeNeeded = |
1160 return typeNeeded ? const DynamicType() : null; | 1160 inferrer.listener.propertyGetEnter(this, typeContext) || typeNeeded; |
| 1161 // First infer the receiver so we can look up the getter that was invoked. |
| 1162 var receiverType = inferrer.inferExpression(receiver, null, true); |
| 1163 Member interfaceMember; |
| 1164 if (receiverType is InterfaceType) { |
| 1165 interfaceMember = inferrer.classHierarchy |
| 1166 .getInterfaceMember(receiverType.classNode, name); |
| 1167 // Our non-strong golden files currently don't include interface targets, |
| 1168 // so we can't store the interface target without causing tests to fail. |
| 1169 // TODO(paulberry): fix this. |
| 1170 if (inferrer.strongMode) { |
| 1171 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, |
| 1172 'target', new InstrumentationValueForMember(interfaceMember)); |
| 1173 interfaceTarget = interfaceMember; |
| 1174 } |
| 1175 } |
| 1176 var inferredType = |
| 1177 inferrer.getCalleeType(interfaceMember, receiverType, name); |
| 1178 // TODO(paulberry): Infer tear-off type arguments if appropriate. |
| 1179 inferrer.listener.propertyGetExit(this, inferredType); |
| 1180 return typeNeeded ? inferredType : null; |
1161 } | 1181 } |
1162 } | 1182 } |
1163 | 1183 |
1164 /// Shadow object for [PropertyGet]. | 1184 /// Shadow object for [PropertyGet]. |
1165 class KernelPropertySet extends PropertySet implements KernelExpression { | 1185 class KernelPropertySet extends PropertySet implements KernelExpression { |
1166 KernelPropertySet(Expression receiver, Name name, Expression value, | 1186 KernelPropertySet(Expression receiver, Name name, Expression value, |
1167 [Member interfaceTarget]) | 1187 [Member interfaceTarget]) |
1168 : super(receiver, name, value, interfaceTarget); | 1188 : super(receiver, name, value, interfaceTarget); |
1169 | 1189 |
1170 KernelPropertySet.byReference(Expression receiver, Name name, | 1190 KernelPropertySet.byReference(Expression receiver, Name name, |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 : inferrer.coreTypes.iterableClass); | 1901 : inferrer.coreTypes.iterableClass); |
1882 } | 1902 } |
1883 var inferredType = inferrer.inferExpression( | 1903 var inferredType = inferrer.inferExpression( |
1884 expression, typeContext, closureContext != null); | 1904 expression, typeContext, closureContext != null); |
1885 closureContext.handleYield(inferrer, isYieldStar, inferredType); | 1905 closureContext.handleYield(inferrer, isYieldStar, inferredType); |
1886 inferrer.listener.yieldStatementExit(this); | 1906 inferrer.listener.yieldStatementExit(this); |
1887 } | 1907 } |
1888 } | 1908 } |
1889 | 1909 |
1890 class _UnfinishedCascade extends Expression { | 1910 class _UnfinishedCascade extends Expression { |
1891 getStaticType(types) { | |
1892 return internalError("Internal error: Unsupported operation."); | |
1893 } | |
1894 | |
1895 accept(v) { | 1911 accept(v) { |
1896 return internalError("Internal error: Unsupported operation."); | 1912 return internalError("Internal error: Unsupported operation."); |
1897 } | 1913 } |
1898 | 1914 |
1899 accept1(v, arg) { | 1915 accept1(v, arg) { |
1900 return internalError("Internal error: Unsupported operation."); | 1916 return internalError("Internal error: Unsupported operation."); |
1901 } | 1917 } |
1902 | 1918 |
| 1919 getStaticType(types) { |
| 1920 return internalError("Internal error: Unsupported operation."); |
| 1921 } |
| 1922 |
| 1923 transformChildren(v) { |
| 1924 return internalError("Internal error: Unsupported operation."); |
| 1925 } |
| 1926 |
1903 visitChildren(v) { | 1927 visitChildren(v) { |
1904 return internalError("Internal error: Unsupported operation."); | 1928 return internalError("Internal error: Unsupported operation."); |
1905 } | 1929 } |
1906 | |
1907 transformChildren(v) { | |
1908 return internalError("Internal error: Unsupported operation."); | |
1909 } | |
1910 } | 1930 } |
OLD | NEW |