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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 12525007: Record dependency information to implement first version of dependency (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement;
9 Set<Node> get superUses;
10 Set<Element> get backendDependencies;
11
8 Element operator[](Node node); 12 Element operator[](Node node);
9 Selector getSelector(Send send); 13 Selector getSelector(Send send);
10 Selector getGetterSelectorInComplexSendSet(SendSet node); 14 Selector getGetterSelectorInComplexSendSet(SendSet node);
11 Selector getOperatorSelectorInComplexSendSet(SendSet node); 15 Selector getOperatorSelectorInComplexSendSet(SendSet node);
12 Selector getIteratorSelector(ForIn node); 16 Selector getIteratorSelector(ForIn node);
13 Selector getMoveNextSelector(ForIn node); 17 Selector getMoveNextSelector(ForIn node);
14 Selector getCurrentSelector(ForIn node); 18 Selector getCurrentSelector(ForIn node);
15 DartType getType(Node node); 19 DartType getType(Node node);
16 bool isParameterChecked(Element element); 20 bool isParameterChecked(Element element);
17 Set<Node> get superUses; 21 void registerBackendDependency(Element element);
18 } 22 }
19 23
20 class TreeElementMapping implements TreeElements { 24 class TreeElementMapping implements TreeElements {
21 final Element currentElement; 25 final Element currentElement;
22 final Map<Spannable, Selector> selectors = 26 final Map<Spannable, Selector> selectors =
23 new LinkedHashMap<Spannable, Selector>(); 27 new LinkedHashMap<Spannable, Selector>();
24 final Map<Node, DartType> types = new LinkedHashMap<Node, DartType>(); 28 final Map<Node, DartType> types = new LinkedHashMap<Node, DartType>();
25 final Set<Element> checkedParameters = new Set<Element>(); 29 final Set<Element> checkedParameters = new LinkedHashSet<Element>();
26 final Set<Node> superUses = new Set<Node>(); 30 final Set<Node> superUses = new LinkedHashSet<Node>();
31 final Set<Element> backendDependencies = new LinkedHashSet<Element>();
32 final int hashCode = ++hashCodeCounter;
33 static int hashCodeCounter = 0;
27 34
28 TreeElementMapping(this.currentElement); 35 TreeElementMapping(this.currentElement);
29 36
30 operator []=(Node node, Element element) { 37 operator []=(Node node, Element element) {
31 assert(invariant(node, () { 38 assert(invariant(node, () {
32 if (node is FunctionExpression) { 39 if (node is FunctionExpression) {
33 return !node.modifiers.isExternal(); 40 return !node.modifiers.isExternal();
34 } 41 }
35 return true; 42 return true;
36 })); 43 }));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 selectors[node.inToken] = selector; 118 selectors[node.inToken] = selector;
112 } 119 }
113 120
114 Selector getCurrentSelector(ForIn node) { 121 Selector getCurrentSelector(ForIn node) {
115 return selectors[node.inToken]; 122 return selectors[node.inToken];
116 } 123 }
117 124
118 bool isParameterChecked(Element element) { 125 bool isParameterChecked(Element element) {
119 return checkedParameters.contains(element); 126 return checkedParameters.contains(element);
120 } 127 }
128
129 void registerBackendDependency(Element element) {
130 backendDependencies.add(element);
131 }
132
133 String toString() => 'TreeElementMapping($currentElement)';
121 } 134 }
122 135
123 class ResolverTask extends CompilerTask { 136 class ResolverTask extends CompilerTask {
124 ResolverTask(Compiler compiler) : super(compiler); 137 ResolverTask(Compiler compiler) : super(compiler);
125 138
126 String get name => 'Resolver'; 139 String get name => 'Resolver';
127 140
128 TreeElements resolve(Element element) { 141 TreeElements resolve(Element element) {
129 return measure(() { 142 return measure(() {
130 if (Elements.isErroneousElement(element)) return null; 143 if (Elements.isErroneousElement(element)) return null;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 error(element.modifiers.getStatic(), 446 error(element.modifiers.getStatic(),
434 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC); 447 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC);
435 } 448 }
436 ResolverVisitor visitor = visitorFor(element); 449 ResolverVisitor visitor = visitorFor(element);
437 initializerDo(tree, visitor.visit); 450 initializerDo(tree, visitor.visit);
438 451
439 if (Elements.isStaticOrTopLevelField(element)) { 452 if (Elements.isStaticOrTopLevelField(element)) {
440 if (tree.asSendSet() != null) { 453 if (tree.asSendSet() != null) {
441 // TODO(ngeoffray): We could do better here by using the 454 // TODO(ngeoffray): We could do better here by using the
442 // constant handler to figure out if it's a lazy field or not. 455 // constant handler to figure out if it's a lazy field or not.
443 compiler.backend.registerLazyField(); 456 compiler.backend.registerLazyField(visitor.mapping);
444 } 457 }
445 } 458 }
446 459
447 // Perform various checks as side effect of "computing" the type. 460 // Perform various checks as side effect of "computing" the type.
448 element.computeType(compiler); 461 element.computeType(compiler);
449 462
450 return visitor.mapping; 463 return visitor.mapping;
451 } 464 }
452 465
453 TreeElements resolveParameter(Element element) { 466 TreeElements resolveParameter(Element element) {
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 new TypedefType.userProvidedBadType(typdef, arguments.toLink())); 1544 new TypedefType.userProvidedBadType(typdef, arguments.toLink()));
1532 } else { 1545 } else {
1533 if (arguments.isEmpty) { 1546 if (arguments.isEmpty) {
1534 type = typdef.rawType; 1547 type = typdef.rawType;
1535 } else { 1548 } else {
1536 type = new TypedefType(typdef, arguments.toLink()); 1549 type = new TypedefType(typdef, arguments.toLink());
1537 } 1550 }
1538 } 1551 }
1539 } else if (element.isTypeVariable()) { 1552 } else if (element.isTypeVariable()) {
1540 if (enclosingElement.isInStaticMember()) { 1553 if (enclosingElement.isInStaticMember()) {
1541 compiler.backend.registerThrowRuntimeError(); 1554 compiler.backend.registerThrowRuntimeError(mapping);
1542 compiler.reportWarning(node, 1555 compiler.reportWarning(node,
1543 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER.message( 1556 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER.message(
1544 {'typeVariableName': node})); 1557 {'typeVariableName': node}));
1545 type = new MalformedType( 1558 type = new MalformedType(
1546 new ErroneousElementX( 1559 new ErroneousElementX(
1547 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, 1560 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
1548 {'typeVariableName': node}, 1561 {'typeVariableName': node},
1549 typeName.source, enclosingElement), 1562 typeName.source, enclosingElement),
1550 element.computeType(compiler)); 1563 element.computeType(compiler));
1551 } else { 1564 } else {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 error(node, MessageKind.INVALID_USE_OF_SUPER); 1735 error(node, MessageKind.INVALID_USE_OF_SUPER);
1723 } 1736 }
1724 return null; 1737 return null;
1725 } else { 1738 } else {
1726 Element element = lookup(node, node.source); 1739 Element element = lookup(node, node.source);
1727 if (element == null) { 1740 if (element == null) {
1728 if (!inInstanceContext) { 1741 if (!inInstanceContext) {
1729 element = warnAndCreateErroneousElement(node, node.source, 1742 element = warnAndCreateErroneousElement(node, node.source,
1730 MessageKind.CANNOT_RESOLVE, 1743 MessageKind.CANNOT_RESOLVE,
1731 {'name': node}); 1744 {'name': node});
1732 compiler.backend.registerThrowNoSuchMethod(); 1745 compiler.backend.registerThrowNoSuchMethod(mapping);
1733 } 1746 }
1734 } else if (element.isErroneous()) { 1747 } else if (element.isErroneous()) {
1735 // Use the erroneous element. 1748 // Use the erroneous element.
1736 } else { 1749 } else {
1737 if ((element.kind.category & allowedCategory) == 0) { 1750 if ((element.kind.category & allowedCategory) == 0) {
1738 // TODO(ahe): Improve error message. Need UX input. 1751 // TODO(ahe): Improve error message. Need UX input.
1739 error(node, MessageKind.GENERIC, 1752 error(node, MessageKind.GENERIC,
1740 {'text': "is not an expression $element"}); 1753 {'text': "is not an expression $element"});
1741 } 1754 }
1742 } 1755 }
1743 if (!Elements.isUnresolved(element) && element.isClass()) { 1756 if (!Elements.isUnresolved(element) && element.isClass()) {
1744 ClassElement classElement = element; 1757 ClassElement classElement = element;
1745 classElement.ensureResolved(compiler); 1758 classElement.ensureResolved(compiler);
1746 } 1759 }
1747 return useElement(node, element); 1760 return useElement(node, element);
1748 } 1761 }
1749 } 1762 }
1750 1763
1751 Element visitTypeAnnotation(TypeAnnotation node) { 1764 Element visitTypeAnnotation(TypeAnnotation node) {
1752 DartType type = resolveTypeAnnotation(node); 1765 DartType type = resolveTypeAnnotation(node);
1753 if (type != null) { 1766 if (type != null) {
1754 if (inCheckContext) { 1767 if (inCheckContext) {
1755 compiler.enqueuer.resolution.registerIsCheck(type); 1768 compiler.enqueuer.resolution.registerIsCheck(type, mapping);
1756 } 1769 }
1757 return type.element; 1770 return type.element;
1758 } 1771 }
1759 return null; 1772 return null;
1760 } 1773 }
1761 1774
1762 Element defineElement(Node node, Element element, 1775 Element defineElement(Node node, Element element,
1763 {bool doAddToScope: true}) { 1776 {bool doAddToScope: true}) {
1764 compiler.ensure(element != null); 1777 compiler.ensure(element != null);
1765 mapping[node] = element; 1778 mapping[node] = element;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 enclosingElement = function; 1944 enclosingElement = function;
1932 // Run the body in a fresh statement scope. 1945 // Run the body in a fresh statement scope.
1933 StatementScope oldStatementScope = statementScope; 1946 StatementScope oldStatementScope = statementScope;
1934 statementScope = new StatementScope(); 1947 statementScope = new StatementScope();
1935 visit(node.body); 1948 visit(node.body);
1936 statementScope = oldStatementScope; 1949 statementScope = oldStatementScope;
1937 1950
1938 scope = oldScope; 1951 scope = oldScope;
1939 enclosingElement = previousEnclosingElement; 1952 enclosingElement = previousEnclosingElement;
1940 1953
1941 world.registerInstantiatedClass(compiler.functionClass); 1954 world.registerInstantiatedClass(compiler.functionClass, mapping);
1942 } 1955 }
1943 1956
1944 visitIf(If node) { 1957 visitIf(If node) {
1945 visit(node.condition); 1958 visit(node.condition);
1946 visit(node.thenPart); 1959 visit(node.thenPart);
1947 visit(node.elsePart); 1960 visit(node.elsePart);
1948 } 1961 }
1949 1962
1950 static bool isLogicalOperator(Identifier op) { 1963 static bool isLogicalOperator(Identifier op) {
1951 String str = op.source.stringValue; 1964 String str = op.source.stringValue;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 // [target] may be null which means invoking noSuchMethod on 2022 // [target] may be null which means invoking noSuchMethod on
2010 // super. 2023 // super.
2011 if (target == null) { 2024 if (target == null) {
2012 target = warnAndCreateErroneousElement( 2025 target = warnAndCreateErroneousElement(
2013 node, name, MessageKind.NO_SUCH_SUPER_MEMBER, 2026 node, name, MessageKind.NO_SUCH_SUPER_MEMBER,
2014 {'className': currentClass, 'memberName': name}); 2027 {'className': currentClass, 'memberName': name});
2015 // We still need to register the invocation, because we might 2028 // We still need to register the invocation, because we might
2016 // call [:super.noSuchMethod:] that does a 2029 // call [:super.noSuchMethod:] that does a
2017 // [:InvocationMirror.invokeOn:]. 2030 // [:InvocationMirror.invokeOn:].
2018 world.registerDynamicInvocation(selector.name, selector); 2031 world.registerDynamicInvocation(selector.name, selector);
2019 compiler.backend.registerSuperNoSuchMethod(); 2032 compiler.backend.registerSuperNoSuchMethod(mapping);
2020 } 2033 }
2021 } else if (Elements.isUnresolved(resolvedReceiver)) { 2034 } else if (Elements.isUnresolved(resolvedReceiver)) {
2022 return null; 2035 return null;
2023 } else if (resolvedReceiver.isClass()) { 2036 } else if (resolvedReceiver.isClass()) {
2024 ClassElement receiverClass = resolvedReceiver; 2037 ClassElement receiverClass = resolvedReceiver;
2025 receiverClass.ensureResolved(compiler); 2038 receiverClass.ensureResolved(compiler);
2026 if (node.isOperator) { 2039 if (node.isOperator) {
2027 // When the resolved receiver is a class, we can have two cases: 2040 // When the resolved receiver is a class, we can have two cases:
2028 // 1) a static send: C.foo, or 2041 // 1) a static send: C.foo, or
2029 // 2) an operator send, where the receiver is a class literal: 'C + 1'. 2042 // 2) an operator send, where the receiver is a class literal: 'C + 1'.
2030 // The following code that looks up the selector on the resolved 2043 // The following code that looks up the selector on the resolved
2031 // receiver will treat the second as the invocation of a static operator 2044 // receiver will treat the second as the invocation of a static operator
2032 // if the resolved receiver is not null. 2045 // if the resolved receiver is not null.
2033 return null; 2046 return null;
2034 } 2047 }
2035 target = receiverClass.lookupLocalMember(name); 2048 target = receiverClass.lookupLocalMember(name);
2036 if (target == null || target.isInstanceMember()) { 2049 if (target == null || target.isInstanceMember()) {
2037 compiler.backend.registerThrowNoSuchMethod(); 2050 compiler.backend.registerThrowNoSuchMethod(mapping);
2038 // TODO(johnniwinther): With the simplified [TreeElements] invariant, 2051 // TODO(johnniwinther): With the simplified [TreeElements] invariant,
2039 // try to resolve injected elements if [currentClass] is in the patch 2052 // try to resolve injected elements if [currentClass] is in the patch
2040 // library of [receiverClass]. 2053 // library of [receiverClass].
2041 2054
2042 // TODO(karlklose): this should be reported by the caller of 2055 // TODO(karlklose): this should be reported by the caller of
2043 // [resolveSend] to select better warning messages for getters and 2056 // [resolveSend] to select better warning messages for getters and
2044 // setters. 2057 // setters.
2045 MessageKind kind = (target == null) 2058 MessageKind kind = (target == null)
2046 ? MessageKind.METHOD_NOT_FOUND 2059 ? MessageKind.METHOD_NOT_FOUND
2047 : MessageKind.MEMBER_NOT_STATIC; 2060 : MessageKind.MEMBER_NOT_STATIC;
2048 return warnAndCreateErroneousElement(node, name, kind, 2061 return warnAndCreateErroneousElement(node, name, kind,
2049 {'className': receiverClass.name, 2062 {'className': receiverClass.name,
2050 'memberName': name}); 2063 'memberName': name});
2051 } 2064 }
2052 } else if (identical(resolvedReceiver.kind, ElementKind.PREFIX)) { 2065 } else if (identical(resolvedReceiver.kind, ElementKind.PREFIX)) {
2053 PrefixElement prefix = resolvedReceiver; 2066 PrefixElement prefix = resolvedReceiver;
2054 target = prefix.lookupLocalMember(name); 2067 target = prefix.lookupLocalMember(name);
2055 if (Elements.isUnresolved(target)) { 2068 if (Elements.isUnresolved(target)) {
2056 compiler.backend.registerThrowNoSuchMethod(); 2069 compiler.backend.registerThrowNoSuchMethod(mapping);
2057 return warnAndCreateErroneousElement( 2070 return warnAndCreateErroneousElement(
2058 node, name, MessageKind.NO_SUCH_LIBRARY_MEMBER, 2071 node, name, MessageKind.NO_SUCH_LIBRARY_MEMBER,
2059 {'libraryName': prefix.name, 'memberName': name}); 2072 {'libraryName': prefix.name, 'memberName': name});
2060 } else if (target.kind == ElementKind.CLASS) { 2073 } else if (target.kind == ElementKind.CLASS) {
2061 ClassElement classElement = target; 2074 ClassElement classElement = target;
2062 classElement.ensureResolved(compiler); 2075 classElement.ensureResolved(compiler);
2063 } 2076 }
2064 } 2077 }
2065 return target; 2078 return target;
2066 } 2079 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 bool oldSendIsMemberAccess = sendIsMemberAccess; 2174 bool oldSendIsMemberAccess = sendIsMemberAccess;
2162 sendIsMemberAccess = node.isPropertyAccess || node.isCall; 2175 sendIsMemberAccess = node.isPropertyAccess || node.isCall;
2163 Element target = resolveSend(node); 2176 Element target = resolveSend(node);
2164 sendIsMemberAccess = oldSendIsMemberAccess; 2177 sendIsMemberAccess = oldSendIsMemberAccess;
2165 2178
2166 if (!Elements.isUnresolved(target)) { 2179 if (!Elements.isUnresolved(target)) {
2167 if (target.isAbstractField()) { 2180 if (target.isAbstractField()) {
2168 AbstractFieldElement field = target; 2181 AbstractFieldElement field = target;
2169 target = field.getter; 2182 target = field.getter;
2170 if (target == null && !inInstanceContext) { 2183 if (target == null && !inInstanceContext) {
2171 compiler.backend.registerThrowNoSuchMethod(); 2184 compiler.backend.registerThrowNoSuchMethod(mapping);
2172 target = 2185 target =
2173 warnAndCreateErroneousElement(node.selector, field.name, 2186 warnAndCreateErroneousElement(node.selector, field.name,
2174 MessageKind.CANNOT_RESOLVE_GETTER); 2187 MessageKind.CANNOT_RESOLVE_GETTER);
2175 } 2188 }
2176 } else if (target.impliesType() && !sendIsMemberAccess) { 2189 } else if (target.impliesType() && !sendIsMemberAccess) {
2177 compiler.backend.registerTypeLiteral(); 2190 compiler.backend.registerTypeLiteral(mapping);
2178 } 2191 }
2179 } 2192 }
2180 2193
2181 bool resolvedArguments = false; 2194 bool resolvedArguments = false;
2182 if (node.isOperator) { 2195 if (node.isOperator) {
2183 String operatorString = node.selector.asOperator().source.stringValue; 2196 String operatorString = node.selector.asOperator().source.stringValue;
2184 if (operatorString == 'is' || operatorString == 'as') { 2197 if (operatorString == 'is' || operatorString == 'as') {
2185 assert(node.arguments.tail.isEmpty); 2198 assert(node.arguments.tail.isEmpty);
2186 DartType type = resolveTypeTest(node.arguments.head); 2199 DartType type = resolveTypeTest(node.arguments.head);
2187 if (type != null) { 2200 if (type != null) {
2188 if (operatorString == 'as') { 2201 if (operatorString == 'as') {
2189 compiler.enqueuer.resolution.registerAsCheck(type); 2202 compiler.enqueuer.resolution.registerAsCheck(type);
2190 } else { 2203 } else {
2191 compiler.enqueuer.resolution.registerIsCheck(type); 2204 compiler.enqueuer.resolution.registerIsCheck(type, mapping);
2192 } 2205 }
2193 } 2206 }
2194 resolvedArguments = true; 2207 resolvedArguments = true;
2195 } else if (identical(operatorString, '?')) { 2208 } else if (identical(operatorString, '?')) {
2196 Element parameter = mapping[node.receiver]; 2209 Element parameter = mapping[node.receiver];
2197 if (parameter == null 2210 if (parameter == null
2198 || !identical(parameter.kind, ElementKind.PARAMETER)) { 2211 || !identical(parameter.kind, ElementKind.PARAMETER)) {
2199 error(node.receiver, MessageKind.PARAMETER_NAME_EXPECTED); 2212 error(node.receiver, MessageKind.PARAMETER_NAME_EXPECTED);
2200 } else { 2213 } else {
2201 mapping.checkedParameters.add(parameter); 2214 mapping.checkedParameters.add(parameter);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 world.registerJsCall(node, this); 2248 world.registerJsCall(node, this);
2236 } 2249 }
2237 } 2250 }
2238 2251
2239 // TODO(ngeoffray): Warn if target is null and the send is 2252 // TODO(ngeoffray): Warn if target is null and the send is
2240 // unqualified. 2253 // unqualified.
2241 useElement(node, target); 2254 useElement(node, target);
2242 registerSend(selector, target); 2255 registerSend(selector, target);
2243 if (node.isPropertyAccess) { 2256 if (node.isPropertyAccess) {
2244 // It might be the closurization of a method. 2257 // It might be the closurization of a method.
2245 world.registerInstantiatedClass(compiler.functionClass); 2258 world.registerInstantiatedClass(compiler.functionClass, mapping);
2246 } 2259 }
2247 return node.isPropertyAccess ? target : null; 2260 return node.isPropertyAccess ? target : null;
2248 } 2261 }
2249 2262
2250 void warnArgumentMismatch(Send node, Element target) { 2263 void warnArgumentMismatch(Send node, Element target) {
2251 compiler.backend.registerThrowNoSuchMethod(); 2264 compiler.backend.registerThrowNoSuchMethod(mapping);
2252 // TODO(karlklose): we can be more precise about the reason of the 2265 // TODO(karlklose): we can be more precise about the reason of the
2253 // mismatch. 2266 // mismatch.
2254 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS, 2267 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS,
2255 {'methodName': target.name}); 2268 {'methodName': target.name});
2256 } 2269 }
2257 2270
2258 /// Callback for native enqueuer to parse a type. Returns [:null:] on error. 2271 /// Callback for native enqueuer to parse a type. Returns [:null:] on error.
2259 DartType resolveTypeFromString(String typeName) { 2272 DartType resolveTypeFromString(String typeName) {
2260 Element element = scope.lookup(new SourceString(typeName)); 2273 Element element = scope.lookup(new SourceString(typeName));
2261 if (element == null) return null; 2274 if (element == null) return null;
(...skipping 10 matching lines...) Expand all
2272 String source = operatorName.stringValue; 2285 String source = operatorName.stringValue;
2273 bool isComplex = !identical(source, '='); 2286 bool isComplex = !identical(source, '=');
2274 if (!Elements.isUnresolved(target)) { 2287 if (!Elements.isUnresolved(target)) {
2275 if (target.isAbstractField()) { 2288 if (target.isAbstractField()) {
2276 AbstractFieldElement field = target; 2289 AbstractFieldElement field = target;
2277 setter = field.setter; 2290 setter = field.setter;
2278 getter = field.getter; 2291 getter = field.getter;
2279 if (setter == null && !inInstanceContext) { 2292 if (setter == null && !inInstanceContext) {
2280 setter = warnAndCreateErroneousElement( 2293 setter = warnAndCreateErroneousElement(
2281 node.selector, field.name, MessageKind.CANNOT_RESOLVE_SETTER); 2294 node.selector, field.name, MessageKind.CANNOT_RESOLVE_SETTER);
2282 compiler.backend.registerThrowNoSuchMethod(); 2295 compiler.backend.registerThrowNoSuchMethod(mapping);
2283 } 2296 }
2284 if (isComplex && getter == null && !inInstanceContext) { 2297 if (isComplex && getter == null && !inInstanceContext) {
2285 getter = warnAndCreateErroneousElement( 2298 getter = warnAndCreateErroneousElement(
2286 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER); 2299 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER);
2287 compiler.backend.registerThrowNoSuchMethod(); 2300 compiler.backend.registerThrowNoSuchMethod(mapping);
2288 } 2301 }
2289 } else if (target.impliesType()) { 2302 } else if (target.impliesType()) {
2290 compiler.backend.registerThrowNoSuchMethod(); 2303 compiler.backend.registerThrowNoSuchMethod(mapping);
2291 } else if (target.modifiers.isFinal() || target.modifiers.isConst()) { 2304 } else if (target.modifiers.isFinal() || target.modifiers.isConst()) {
2292 setter = warnAndCreateErroneousElement( 2305 setter = warnAndCreateErroneousElement(
2293 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER); 2306 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER);
2294 compiler.backend.registerThrowNoSuchMethod(); 2307 compiler.backend.registerThrowNoSuchMethod(mapping);
2295 } else if (isComplex && target.name == const SourceString('[]=')) { 2308 } else if (isComplex && target.name == const SourceString('[]=')) {
2296 getter = target.getEnclosingClass().lookupMember( 2309 getter = target.getEnclosingClass().lookupMember(
2297 const SourceString('[]')); 2310 const SourceString('[]'));
2298 if (getter == null) { 2311 if (getter == null) {
2299 getter = warnAndCreateErroneousElement( 2312 getter = warnAndCreateErroneousElement(
2300 node, setter.name, MessageKind.CANNOT_RESOLVE_INDEX); 2313 node, setter.name, MessageKind.CANNOT_RESOLVE_INDEX);
2301 compiler.backend.registerThrowNoSuchMethod(); 2314 compiler.backend.registerThrowNoSuchMethod(mapping);
2302 } 2315 }
2303 } 2316 }
2304 } 2317 }
2305 2318
2306 visit(node.argumentsNode); 2319 visit(node.argumentsNode);
2307 2320
2308 // TODO(ngeoffray): Check if the target can be assigned. 2321 // TODO(ngeoffray): Check if the target can be assigned.
2309 // TODO(ngeoffray): Warn if target is null and the send is 2322 // TODO(ngeoffray): Warn if target is null and the send is
2310 // unqualified. 2323 // unqualified.
2311 2324
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 // the use of classes. Wouldn't it be simpler if we just did? 2369 // the use of classes. Wouldn't it be simpler if we just did?
2357 if (!target.isClass()) { 2370 if (!target.isClass()) {
2358 // [target] might be the implementation element and only declaration 2371 // [target] might be the implementation element and only declaration
2359 // elements may be registered. 2372 // elements may be registered.
2360 world.registerStaticUse(target.declaration); 2373 world.registerStaticUse(target.declaration);
2361 } 2374 }
2362 } 2375 }
2363 } 2376 }
2364 2377
2365 visitLiteralInt(LiteralInt node) { 2378 visitLiteralInt(LiteralInt node) {
2366 world.registerInstantiatedClass(compiler.intClass); 2379 world.registerInstantiatedClass(compiler.intClass, mapping);
2367 } 2380 }
2368 2381
2369 visitLiteralDouble(LiteralDouble node) { 2382 visitLiteralDouble(LiteralDouble node) {
2370 world.registerInstantiatedClass(compiler.doubleClass); 2383 world.registerInstantiatedClass(compiler.doubleClass, mapping);
2371 } 2384 }
2372 2385
2373 visitLiteralBool(LiteralBool node) { 2386 visitLiteralBool(LiteralBool node) {
2374 world.registerInstantiatedClass(compiler.boolClass); 2387 world.registerInstantiatedClass(compiler.boolClass, mapping);
2375 } 2388 }
2376 2389
2377 visitLiteralString(LiteralString node) { 2390 visitLiteralString(LiteralString node) {
2378 world.registerInstantiatedClass(compiler.stringClass); 2391 world.registerInstantiatedClass(compiler.stringClass, mapping);
2379 } 2392 }
2380 2393
2381 visitLiteralNull(LiteralNull node) { 2394 visitLiteralNull(LiteralNull node) {
2382 world.registerInstantiatedClass(compiler.nullClass); 2395 world.registerInstantiatedClass(compiler.nullClass, mapping);
2383 } 2396 }
2384 2397
2385 visitStringJuxtaposition(StringJuxtaposition node) { 2398 visitStringJuxtaposition(StringJuxtaposition node) {
2386 world.registerInstantiatedClass(compiler.stringClass); 2399 world.registerInstantiatedClass(compiler.stringClass, mapping);
2387 node.visitChildren(this); 2400 node.visitChildren(this);
2388 } 2401 }
2389 2402
2390 visitNodeList(NodeList node) { 2403 visitNodeList(NodeList node) {
2391 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { 2404 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) {
2392 visit(link.head); 2405 visit(link.head);
2393 } 2406 }
2394 } 2407 }
2395 2408
2396 visitOperator(Operator node) { 2409 visitOperator(Operator node) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 { // This entire block is temporary code per the above TODO. 2445 { // This entire block is temporary code per the above TODO.
2433 FunctionElement targetImplementation = redirectionTarget.implementation; 2446 FunctionElement targetImplementation = redirectionTarget.implementation;
2434 FunctionExpression function = targetImplementation.parseNode(compiler); 2447 FunctionExpression function = targetImplementation.parseNode(compiler);
2435 if (function.body != null && function.body.asReturn() != null 2448 if (function.body != null && function.body.asReturn() != null
2436 && function.body.asReturn().isRedirectingFactoryBody) { 2449 && function.body.asReturn().isRedirectingFactoryBody) {
2437 unimplemented(node.expression, 'redirecing to redirecting factory'); 2450 unimplemented(node.expression, 'redirecing to redirecting factory');
2438 } 2451 }
2439 } 2452 }
2440 world.registerStaticUse(redirectionTarget); 2453 world.registerStaticUse(redirectionTarget);
2441 world.registerInstantiatedClass( 2454 world.registerInstantiatedClass(
2442 redirectionTarget.enclosingElement.declaration); 2455 redirectionTarget.enclosingElement.declaration, mapping);
2443 } 2456 }
2444 2457
2445 visitThrow(Throw node) { 2458 visitThrow(Throw node) {
2446 if (!inCatchBlock && node.expression == null) { 2459 if (!inCatchBlock && node.expression == null) {
2447 error(node, MessageKind.THROW_WITHOUT_EXPRESSION); 2460 error(node, MessageKind.THROW_WITHOUT_EXPRESSION);
2448 } 2461 }
2449 compiler.backend.registerThrow(); 2462 compiler.backend.registerThrow(mapping);
2450 visit(node.expression); 2463 visit(node.expression);
2451 } 2464 }
2452 2465
2453 visitVariableDefinitions(VariableDefinitions node) { 2466 visitVariableDefinitions(VariableDefinitions node) {
2454 VariableDefinitionsVisitor visitor = 2467 VariableDefinitionsVisitor visitor =
2455 new VariableDefinitionsVisitor(compiler, node, this, 2468 new VariableDefinitionsVisitor(compiler, node, this,
2456 ElementKind.VARIABLE); 2469 ElementKind.VARIABLE);
2457 // Ensure that we set the type of the [VariableListElement] since it depends 2470 // Ensure that we set the type of the [VariableListElement] since it depends
2458 // on the current scope. If the current scope is a [MethodScope] or 2471 // on the current scope. If the current scope is a [MethodScope] or
2459 // [BlockScope] it will not be available for the 2472 // [BlockScope] it will not be available for the
(...skipping 21 matching lines...) Expand all
2481 visitNewExpression(NewExpression node) { 2494 visitNewExpression(NewExpression node) {
2482 Node selector = node.send.selector; 2495 Node selector = node.send.selector;
2483 FunctionElement constructor = resolveConstructor(node); 2496 FunctionElement constructor = resolveConstructor(node);
2484 resolveSelector(node.send); 2497 resolveSelector(node.send);
2485 resolveArguments(node.send.argumentsNode); 2498 resolveArguments(node.send.argumentsNode);
2486 useElement(node.send, constructor); 2499 useElement(node.send, constructor);
2487 if (Elements.isUnresolved(constructor)) return constructor; 2500 if (Elements.isUnresolved(constructor)) return constructor;
2488 Selector callSelector = mapping.getSelector(node.send); 2501 Selector callSelector = mapping.getSelector(node.send);
2489 if (!callSelector.applies(constructor, compiler)) { 2502 if (!callSelector.applies(constructor, compiler)) {
2490 warnArgumentMismatch(node.send, constructor); 2503 warnArgumentMismatch(node.send, constructor);
2491 compiler.backend.registerThrowNoSuchMethod(); 2504 compiler.backend.registerThrowNoSuchMethod(mapping);
2492 } 2505 }
2493 compiler.withCurrentElement(constructor, () { 2506 compiler.withCurrentElement(constructor, () {
2494 FunctionExpression tree = constructor.parseNode(compiler); 2507 FunctionExpression tree = constructor.parseNode(compiler);
2495 compiler.resolver.resolveConstructorImplementation(constructor, tree); 2508 compiler.resolver.resolveConstructorImplementation(constructor, tree);
2496 }); 2509 });
2497 2510
2498 if (constructor.defaultImplementation != constructor) { 2511 if (constructor.defaultImplementation != constructor) {
2499 // Support for deprecated interface support. 2512 // Support for deprecated interface support.
2500 // TODO(ngeoffray): Remove once we remove such support. 2513 // TODO(ngeoffray): Remove once we remove such support.
2501 world.registerStaticUse(constructor.declaration); 2514 world.registerStaticUse(constructor.declaration);
2502 world.registerInstantiatedClass( 2515 world.registerInstantiatedClass(
2503 constructor.getEnclosingClass().declaration); 2516 constructor.getEnclosingClass().declaration, mapping);
2504 constructor = constructor.defaultImplementation; 2517 constructor = constructor.defaultImplementation;
2505 } 2518 }
2506 // [constructor.defaultImplementation] might be the implementation element 2519 // [constructor.defaultImplementation] might be the implementation element
2507 // and only declaration elements may be registered. 2520 // and only declaration elements may be registered.
2508 world.registerStaticUse(constructor.declaration); 2521 world.registerStaticUse(constructor.declaration);
2509 ClassElement cls = constructor.getEnclosingClass(); 2522 ClassElement cls = constructor.getEnclosingClass();
2510 // [cls] might be the implementation element and only declaration elements 2523 // [cls] might be the implementation element and only declaration elements
2511 // may be registered. 2524 // may be registered.
2512 world.registerInstantiatedType(mapping.getType(node)); 2525 world.registerInstantiatedType(mapping.getType(node));
2513 if (cls.isAbstract(compiler)) { 2526 if (cls.isAbstract(compiler)) {
2514 compiler.backend.registerAbstractClassInstantiation(); 2527 compiler.backend.registerAbstractClassInstantiation(mapping);
2515 } 2528 }
2516 // [cls] might be the declaration element and we want to include injected 2529 // [cls] might be the declaration element and we want to include injected
2517 // members. 2530 // members.
2518 cls.implementation.forEachInstanceField( 2531 cls.implementation.forEachInstanceField(
2519 (ClassElement enclosingClass, Element member) { 2532 (ClassElement enclosingClass, Element member) {
2520 world.addToWorkList(member); 2533 world.addToWorkList(member);
2521 }, 2534 },
2522 includeBackendMembers: false, 2535 includeBackendMembers: false,
2523 includeSuperMembers: true); 2536 includeSuperMembers: true);
2524 return null; 2537 return null;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 } 2576 }
2564 } 2577 }
2565 2578
2566 DartType resolveTypeAnnotation(TypeAnnotation node) { 2579 DartType resolveTypeAnnotation(TypeAnnotation node) {
2567 Function report = typeRequired ? error : warning; 2580 Function report = typeRequired ? error : warning;
2568 DartType type = typeResolver.resolveTypeAnnotation( 2581 DartType type = typeResolver.resolveTypeAnnotation(
2569 node, scope, enclosingElement, 2582 node, scope, enclosingElement,
2570 onFailure: report, whenResolved: useType); 2583 onFailure: report, whenResolved: useType);
2571 if (type == null) return null; 2584 if (type == null) return null;
2572 if (inCheckContext) { 2585 if (inCheckContext) {
2573 compiler.enqueuer.resolution.registerIsCheck(type); 2586 compiler.enqueuer.resolution.registerIsCheck(type, mapping);
2574 } 2587 }
2575 if (typeRequired || inCheckContext) { 2588 if (typeRequired || inCheckContext) {
2576 if (type is InterfaceType) { 2589 if (type is InterfaceType) {
2577 InterfaceType itf = type; 2590 InterfaceType itf = type;
2578 itf.typeArguments.forEach((DartType argument) { 2591 itf.typeArguments.forEach((DartType argument) {
2579 analyzeTypeArgument(type, argument); 2592 analyzeTypeArgument(type, argument);
2580 }); 2593 });
2581 } 2594 }
2582 // TODO(ngeoffray): Also handle T a (in checked mode). 2595 // TODO(ngeoffray): Also handle T a (in checked mode).
2583 } 2596 }
2584 return type; 2597 return type;
2585 } 2598 }
2586 2599
2587 visitModifiers(Modifiers node) { 2600 visitModifiers(Modifiers node) {
2588 // TODO(ngeoffray): Implement this. 2601 // TODO(ngeoffray): Implement this.
2589 unimplemented(node, 'modifiers'); 2602 unimplemented(node, 'modifiers');
2590 } 2603 }
2591 2604
2592 visitLiteralList(LiteralList node) { 2605 visitLiteralList(LiteralList node) {
2593 world.registerInstantiatedClass(compiler.listClass); 2606 world.registerInstantiatedClass(compiler.listClass, mapping);
2594 NodeList arguments = node.typeArguments; 2607 NodeList arguments = node.typeArguments;
2595 if (arguments != null) { 2608 if (arguments != null) {
2596 Link<Node> nodes = arguments.nodes; 2609 Link<Node> nodes = arguments.nodes;
2597 if (nodes.isEmpty) { 2610 if (nodes.isEmpty) {
2598 error(arguments, MessageKind.MISSING_TYPE_ARGUMENT); 2611 error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
2599 } else { 2612 } else {
2600 resolveTypeRequired(nodes.head); 2613 resolveTypeRequired(nodes.head);
2601 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { 2614 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) {
2602 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); 2615 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
2603 resolveTypeRequired(nodes.head); 2616 resolveTypeRequired(nodes.head);
2604 } 2617 }
2605 } 2618 }
2606 } 2619 }
2607 visit(node.elements); 2620 visit(node.elements);
2608 } 2621 }
2609 2622
2610 visitConditional(Conditional node) { 2623 visitConditional(Conditional node) {
2611 node.visitChildren(this); 2624 node.visitChildren(this);
2612 } 2625 }
2613 2626
2614 visitStringInterpolation(StringInterpolation node) { 2627 visitStringInterpolation(StringInterpolation node) {
2615 world.registerInstantiatedClass(compiler.stringClass); 2628 world.registerInstantiatedClass(compiler.stringClass, mapping);
2616 compiler.backend.registerStringInterpolation(); 2629 compiler.backend.registerStringInterpolation(mapping);
2617 node.visitChildren(this); 2630 node.visitChildren(this);
2618 } 2631 }
2619 2632
2620 visitStringInterpolationPart(StringInterpolationPart node) { 2633 visitStringInterpolationPart(StringInterpolationPart node) {
2621 registerImplicitInvocation(const SourceString('toString'), 0); 2634 registerImplicitInvocation(const SourceString('toString'), 0);
2622 node.visitChildren(this); 2635 node.visitChildren(this);
2623 } 2636 }
2624 2637
2625 visitBreakStatement(BreakStatement node) { 2638 visitBreakStatement(BreakStatement node) {
2626 TargetElement target; 2639 TargetElement target;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 } 2764 }
2752 }); 2765 });
2753 if (!targetElement.isTarget && identical(mapping[body], targetElement)) { 2766 if (!targetElement.isTarget && identical(mapping[body], targetElement)) {
2754 // If the body is itself a break or continue for another target, it 2767 // If the body is itself a break or continue for another target, it
2755 // might have updated its mapping to the target it actually does target. 2768 // might have updated its mapping to the target it actually does target.
2756 mapping.remove(body); 2769 mapping.remove(body);
2757 } 2770 }
2758 } 2771 }
2759 2772
2760 visitLiteralMap(LiteralMap node) { 2773 visitLiteralMap(LiteralMap node) {
2761 world.registerInstantiatedClass(compiler.mapClass); 2774 world.registerInstantiatedClass(compiler.mapClass, mapping);
2762 if (node.isConst()) { 2775 if (node.isConst()) {
2763 compiler.backend.registerConstantMap(); 2776 compiler.backend.registerConstantMap(mapping);
2764 } 2777 }
2765 node.visitChildren(this); 2778 node.visitChildren(this);
2766 } 2779 }
2767 2780
2768 visitLiteralMapEntry(LiteralMapEntry node) { 2781 visitLiteralMapEntry(LiteralMapEntry node) {
2769 node.visitChildren(this); 2782 node.visitChildren(this);
2770 } 2783 }
2771 2784
2772 visitNamedArgument(NamedArgument node) { 2785 visitNamedArgument(NamedArgument node) {
2773 visit(node.expression); 2786 visit(node.expression);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 continueLabels.forEach((String key, LabelElement label) { 2847 continueLabels.forEach((String key, LabelElement label) {
2835 if (!label.isContinueTarget) { 2848 if (!label.isContinueTarget) {
2836 TargetElement targetElement = label.target; 2849 TargetElement targetElement = label.target;
2837 SwitchCase switchCase = targetElement.statement; 2850 SwitchCase switchCase = targetElement.statement;
2838 mapping.remove(switchCase); 2851 mapping.remove(switchCase);
2839 mapping.remove(label.label); 2852 mapping.remove(label.label);
2840 } 2853 }
2841 }); 2854 });
2842 // TODO(ngeoffray): We should check here instead of the SSA backend if 2855 // TODO(ngeoffray): We should check here instead of the SSA backend if
2843 // there might be an error. 2856 // there might be an error.
2844 compiler.backend.registerFallThroughError(); 2857 compiler.backend.registerFallThroughError(mapping);
2845 } 2858 }
2846 2859
2847 visitSwitchCase(SwitchCase node) { 2860 visitSwitchCase(SwitchCase node) {
2848 node.labelsAndCases.accept(this); 2861 node.labelsAndCases.accept(this);
2849 visitIn(node.statements, new BlockScope(scope)); 2862 visitIn(node.statements, new BlockScope(scope));
2850 } 2863 }
2851 2864
2852 visitCaseMatch(CaseMatch node) { 2865 visitCaseMatch(CaseMatch node) {
2853 visit(node.expression); 2866 visit(node.expression);
2854 } 2867 }
2855 2868
2856 visitTryStatement(TryStatement node) { 2869 visitTryStatement(TryStatement node) {
2857 visit(node.tryBlock); 2870 visit(node.tryBlock);
2858 if (node.catchBlocks.isEmpty && node.finallyBlock == null) { 2871 if (node.catchBlocks.isEmpty && node.finallyBlock == null) {
2859 // TODO(ngeoffray): The precise location is 2872 // TODO(ngeoffray): The precise location is
2860 // node.getEndtoken.next. Adjust when issue #1581 is fixed. 2873 // node.getEndtoken.next. Adjust when issue #1581 is fixed.
2861 error(node, MessageKind.NO_CATCH_NOR_FINALLY); 2874 error(node, MessageKind.NO_CATCH_NOR_FINALLY);
2862 } 2875 }
2863 visit(node.catchBlocks); 2876 visit(node.catchBlocks);
2864 visit(node.finallyBlock); 2877 visit(node.finallyBlock);
2865 } 2878 }
2866 2879
2867 visitCatchBlock(CatchBlock node) { 2880 visitCatchBlock(CatchBlock node) {
2868 compiler.backend.registerCatchStatement(); 2881 compiler.backend.registerCatchStatement(mapping);
2869 // Check that if catch part is present, then 2882 // Check that if catch part is present, then
2870 // it has one or two formal parameters. 2883 // it has one or two formal parameters.
2871 if (node.formals != null) { 2884 if (node.formals != null) {
2872 if (node.formals.isEmpty) { 2885 if (node.formals.isEmpty) {
2873 error(node, MessageKind.EMPTY_CATCH_DECLARATION); 2886 error(node, MessageKind.EMPTY_CATCH_DECLARATION);
2874 } 2887 }
2875 if (!node.formals.nodes.tail.isEmpty) { 2888 if (!node.formals.nodes.tail.isEmpty) {
2876 if (!node.formals.nodes.tail.tail.isEmpty) { 2889 if (!node.formals.nodes.tail.tail.isEmpty) {
2877 for (Node extra in node.formals.nodes.tail.tail) { 2890 for (Node extra in node.formals.nodes.tail.tail) {
2878 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); 2891 error(extra, MessageKind.EXTRA_CATCH_DECLARATION);
2879 } 2892 }
2880 } 2893 }
2881 compiler.backend.registerStackTraceInCatch(); 2894 compiler.backend.registerStackTraceInCatch(mapping);
2882 } 2895 }
2883 2896
2884 // Check that the formals aren't optional and that they have no 2897 // Check that the formals aren't optional and that they have no
2885 // modifiers or type. 2898 // modifiers or type.
2886 for (Link<Node> link = node.formals.nodes; 2899 for (Link<Node> link = node.formals.nodes;
2887 !link.isEmpty; 2900 !link.isEmpty;
2888 link = link.tail) { 2901 link = link.tail) {
2889 // If the formal parameter is a node list, it means that it is a 2902 // If the formal parameter is a node list, it means that it is a
2890 // sequence of optional parameters. 2903 // sequence of optional parameters.
2891 NodeList nodeList = link.head.asNodeList(); 2904 NodeList nodeList = link.head.asNodeList();
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 } 3429 }
3417 3430
3418 SourceString visitSendSet(SendSet node) { 3431 SourceString visitSendSet(SendSet node) {
3419 assert(node.arguments.tail.isEmpty); // Sanity check 3432 assert(node.arguments.tail.isEmpty); // Sanity check
3420 resolver.visit(node.arguments.head); 3433 resolver.visit(node.arguments.head);
3421 return visit(node.selector); 3434 return visit(node.selector);
3422 } 3435 }
3423 3436
3424 SourceString visitIdentifier(Identifier node) { 3437 SourceString visitIdentifier(Identifier node) {
3425 // The variable is initialized to null. 3438 // The variable is initialized to null.
3426 resolver.world.registerInstantiatedClass(compiler.nullClass); 3439 resolver.world.registerInstantiatedClass(compiler.nullClass,
3440 resolver.mapping);
3427 return node.source; 3441 return node.source;
3428 } 3442 }
3429 3443
3430 visitNodeList(NodeList node) { 3444 visitNodeList(NodeList node) {
3431 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { 3445 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) {
3432 SourceString name = visit(link.head); 3446 SourceString name = visit(link.head);
3433 VariableElement element = 3447 VariableElement element =
3434 new VariableElementX(name, variables, kind, link.head); 3448 new VariableElementX(name, variables, kind, link.head);
3435 resolver.defineElement(link.head, element); 3449 resolver.defineElement(link.head, element);
3436 } 3450 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 ConstructorResolver(Compiler compiler, this.resolver) : super(compiler); 3669 ConstructorResolver(Compiler compiler, this.resolver) : super(compiler);
3656 3670
3657 visitNode(Node node) { 3671 visitNode(Node node) {
3658 throw 'not supported'; 3672 throw 'not supported';
3659 } 3673 }
3660 3674
3661 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode, 3675 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode,
3662 SourceString targetName, MessageKind kind, 3676 SourceString targetName, MessageKind kind,
3663 Map arguments) { 3677 Map arguments) {
3664 if (kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 3678 if (kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
3665 compiler.backend.registerThrowNoSuchMethod(); 3679 compiler.backend.registerThrowNoSuchMethod(mapping);
3666 } else { 3680 } else {
3667 compiler.backend.registerThrowRuntimeError(); 3681 compiler.backend.registerThrowRuntimeError(mapping);
3668 } 3682 }
3669 if (inConstContext) { 3683 if (inConstContext) {
3670 error(diagnosticNode, kind, arguments); 3684 error(diagnosticNode, kind, arguments);
3671 } else { 3685 } else {
3672 ResolutionWarning warning = new ResolutionWarning(kind, arguments); 3686 ResolutionWarning warning = new ResolutionWarning(kind, arguments);
3673 compiler.reportWarning(diagnosticNode, warning); 3687 compiler.reportWarning(diagnosticNode, warning);
3674 return new ErroneousElementX(kind, arguments, targetName, enclosing); 3688 return new ErroneousElementX(kind, arguments, targetName, enclosing);
3675 } 3689 }
3676 } 3690 }
3677 3691
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3807 return e; 3821 return e;
3808 } 3822 }
3809 3823
3810 /// Assumed to be called by [resolveRedirectingFactory]. 3824 /// Assumed to be called by [resolveRedirectingFactory].
3811 Element visitReturn(Return node) { 3825 Element visitReturn(Return node) {
3812 Node expression = node.expression; 3826 Node expression = node.expression;
3813 return finishConstructorReference(visit(expression), 3827 return finishConstructorReference(visit(expression),
3814 expression, expression); 3828 expression, expression);
3815 } 3829 }
3816 } 3830 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698