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

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

Issue 791263003: Remove Compiler.reportFatalError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: One more crash revealed. Created 6 years 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 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 // TODO(johnniwinther): Register the relation between the annotation 1325 // TODO(johnniwinther): Register the relation between the annotation
1326 // and the annotated element instead. This will allow the backend to 1326 // and the annotated element instead. This will allow the backend to
1327 // retrieve the backend constant and only register metadata on the 1327 // retrieve the backend constant and only register metadata on the
1328 // elements for which it is needed. (Issue 17732). 1328 // elements for which it is needed. (Issue 17732).
1329 registry.registerMetadataConstant(annotation, annotatedElement); 1329 registry.registerMetadataConstant(annotation, annotatedElement);
1330 annotation.resolutionState = STATE_DONE; 1330 annotation.resolutionState = STATE_DONE;
1331 })); 1331 }));
1332 } 1332 }
1333 1333
1334 error(Spannable node, MessageKind kind, [arguments = const {}]) { 1334 error(Spannable node, MessageKind kind, [arguments = const {}]) {
1335 // TODO(ahe): Make non-fatal. 1335 compiler.reportError(node, kind, arguments);
1336 compiler.reportFatalError(node, kind, arguments);
1337 } 1336 }
1338 1337
1339 Link<MetadataAnnotation> resolveMetadata(Element element, 1338 Link<MetadataAnnotation> resolveMetadata(Element element,
1340 VariableDefinitions node) { 1339 VariableDefinitions node) {
1341 LinkBuilder<MetadataAnnotation> metadata = 1340 LinkBuilder<MetadataAnnotation> metadata =
1342 new LinkBuilder<MetadataAnnotation>(); 1341 new LinkBuilder<MetadataAnnotation>();
1343 for (Metadata annotation in node.metadata.nodes) { 1342 for (Metadata annotation in node.metadata.nodes) {
1344 ParameterMetadataAnnotation metadataAnnotation = 1343 ParameterMetadataAnnotation metadataAnnotation =
1345 new ParameterMetadataAnnotation(annotation); 1344 new ParameterMetadataAnnotation(annotation);
1346 metadataAnnotation.annotatedElement = element; 1345 metadataAnnotation.annotatedElement = element;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 final Node selector = init.selector; 1405 final Node selector = init.selector;
1407 final String name = selector.asIdentifier().source; 1406 final String name = selector.asIdentifier().source;
1408 // Lookup target field. 1407 // Lookup target field.
1409 Element target; 1408 Element target;
1410 if (isFieldInitializer(init)) { 1409 if (isFieldInitializer(init)) {
1411 target = constructor.enclosingClass.lookupLocalMember(name); 1410 target = constructor.enclosingClass.lookupLocalMember(name);
1412 if (target == null) { 1411 if (target == null) {
1413 error(selector, MessageKind.CANNOT_RESOLVE, {'name': name}); 1412 error(selector, MessageKind.CANNOT_RESOLVE, {'name': name});
1414 } else if (target.kind != ElementKind.FIELD) { 1413 } else if (target.kind != ElementKind.FIELD) {
1415 error(selector, MessageKind.NOT_A_FIELD, {'fieldName': name}); 1414 error(selector, MessageKind.NOT_A_FIELD, {'fieldName': name});
1415 throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:05 Ditto.
ahe 2015/01/07 12:55:24 Done.
1416 } else if (!target.isInstanceMember) { 1416 } else if (!target.isInstanceMember) {
1417 error(selector, MessageKind.INIT_STATIC_FIELD, {'fieldName': name}); 1417 error(selector, MessageKind.INIT_STATIC_FIELD, {'fieldName': name});
1418 } 1418 }
1419 } else { 1419 } else {
1420 error(init, MessageKind.INVALID_RECEIVER_IN_INITIALIZER); 1420 error(init, MessageKind.INVALID_RECEIVER_IN_INITIALIZER);
1421 } 1421 }
1422 registry.useElement(init, target); 1422 registry.useElement(init, target);
1423 registry.registerStaticUse(target); 1423 registry.registerStaticUse(target);
1424 checkForDuplicateInitializers(target, init); 1424 checkForDuplicateInitializers(target, init);
1425 // Resolve initializing value. 1425 // Resolve initializing value.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 'internal error: Unhandled node: ${node.getObjectDescription()}'); 1632 'internal error: Unhandled node: ${node.getObjectDescription()}');
1633 return null; 1633 return null;
1634 } 1634 }
1635 1635
1636 R visitEmptyStatement(Node node) => null; 1636 R visitEmptyStatement(Node node) => null;
1637 1637
1638 /** Convenience method for visiting nodes that may be null. */ 1638 /** Convenience method for visiting nodes that may be null. */
1639 R visit(Node node) => (node == null) ? null : node.accept(this); 1639 R visit(Node node) => (node == null) ? null : node.accept(this);
1640 1640
1641 void error(Spannable node, MessageKind kind, [Map arguments = const {}]) { 1641 void error(Spannable node, MessageKind kind, [Map arguments = const {}]) {
1642 compiler.reportFatalError(node, kind, arguments); 1642 compiler.reportError(node, kind, arguments);
1643 } 1643 }
1644 1644
1645 void warning(Spannable node, MessageKind kind, [Map arguments = const {}]) { 1645 void warning(Spannable node, MessageKind kind, [Map arguments = const {}]) {
1646 compiler.reportWarning(node, kind, arguments); 1646 compiler.reportWarning(node, kind, arguments);
1647 } 1647 }
1648 1648
1649 void internalError(Spannable node, message) { 1649 void internalError(Spannable node, message) {
1650 compiler.internalError(node, message); 1650 compiler.internalError(node, message);
1651 } 1651 }
1652 1652
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 MessageKind kind, 2230 MessageKind kind,
2231 [Map arguments = const {}]) { 2231 [Map arguments = const {}]) {
2232 compiler.reportWarning(node, kind, arguments); 2232 compiler.reportWarning(node, kind, arguments);
2233 return new ErroneousElementX(kind, arguments, name, enclosingElement); 2233 return new ErroneousElementX(kind, arguments, name, enclosingElement);
2234 } 2234 }
2235 2235
2236 ResolutionResult visitIdentifier(Identifier node) { 2236 ResolutionResult visitIdentifier(Identifier node) {
2237 if (node.isThis()) { 2237 if (node.isThis()) {
2238 if (!inInstanceContext) { 2238 if (!inInstanceContext) {
2239 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node}); 2239 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node});
2240 throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:04 Ditto.
ahe 2015/01/07 12:55:24 Done.
2240 } 2241 }
2241 return null; 2242 return null;
2242 } else if (node.isSuper()) { 2243 } else if (node.isSuper()) {
2243 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC); 2244 if (!inInstanceContext) {
2245 error(node, MessageKind.NO_SUPER_IN_STATIC);
2246 throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:04 Ditto.
ahe 2015/01/07 12:55:24 Done.
2247 }
2244 if ((ElementCategory.SUPER & allowedCategory) == 0) { 2248 if ((ElementCategory.SUPER & allowedCategory) == 0) {
2245 error(node, MessageKind.INVALID_USE_OF_SUPER); 2249 error(node, MessageKind.INVALID_USE_OF_SUPER);
2246 } 2250 }
2247 return null; 2251 return null;
2248 } else { 2252 } else {
2249 String name = node.source; 2253 String name = node.source;
2250 Element element = lookupInScope(compiler, node, scope, name); 2254 Element element = lookupInScope(compiler, node, scope, name);
2251 if (Elements.isUnresolved(element) && name == 'dynamic') { 2255 if (Elements.isUnresolved(element) && name == 'dynamic') {
2252 // TODO(johnniwinther): Remove this hack when we can return more complex 2256 // TODO(johnniwinther): Remove this hack when we can return more complex
2253 // objects than [Element] from this method. 2257 // objects than [Element] from this method.
2254 element = compiler.typeClass; 2258 element = compiler.typeClass;
2255 // Set the type to be `dynamic` to mark that this is a type literal. 2259 // Set the type to be `dynamic` to mark that this is a type literal.
2256 registry.setType(node, const DynamicType()); 2260 registry.setType(node, const DynamicType());
2257 } 2261 }
2258 element = reportLookupErrorIfAny(element, node, node.source); 2262 element = reportLookupErrorIfAny(element, node, node.source);
2259 if (element == null) { 2263 if (element == null) {
2260 if (!inInstanceContext) { 2264 if (!inInstanceContext) {
2261 element = warnAndCreateErroneousElement( 2265 element = warnAndCreateErroneousElement(
2262 node, node.source, MessageKind.CANNOT_RESOLVE, 2266 node, node.source, MessageKind.CANNOT_RESOLVE,
2263 {'name': node}); 2267 {'name': node});
2264 registry.registerThrowNoSuchMethod(); 2268 registry.registerThrowNoSuchMethod();
2265 } 2269 }
2266 } else if (element.isErroneous) { 2270 } else if (element.isErroneous) {
2267 // Use the erroneous element. 2271 // Use the erroneous element.
2268 } else { 2272 } else {
2269 if ((element.kind.category & allowedCategory) == 0) { 2273 if ((element.kind.category & allowedCategory) == 0) {
2270 // TODO(ahe): Improve error message. Need UX input. 2274 // TODO(ahe): Improve error message. Need UX input.
2271 error(node, MessageKind.GENERIC, 2275 error(node, MessageKind.GENERIC,
2272 {'text': "is not an expression $element"}); 2276 {'text': "is not an expression $element"});
2277 throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:05 Ditto.
ahe 2015/01/07 12:55:24 Done.
2273 } 2278 }
2274 } 2279 }
2275 if (!Elements.isUnresolved(element) && element.isClass) { 2280 if (!Elements.isUnresolved(element) && element.isClass) {
2276 ClassElement classElement = element; 2281 ClassElement classElement = element;
2277 classElement.ensureResolved(compiler); 2282 classElement.ensureResolved(compiler);
2278 } 2283 }
2279 return new ElementResult(registry.useElement(node, element)); 2284 return new ElementResult(registry.useElement(node, element));
2280 } 2285 }
2281 } 2286 }
2282 2287
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 allowedCategory |= ElementCategory.PREFIX | ElementCategory.SUPER; 2524 allowedCategory |= ElementCategory.PREFIX | ElementCategory.SUPER;
2520 ResolutionResult resolvedReceiver = visit(node.receiver); 2525 ResolutionResult resolvedReceiver = visit(node.receiver);
2521 allowedCategory = oldCategory; 2526 allowedCategory = oldCategory;
2522 2527
2523 Element target; 2528 Element target;
2524 String name = node.selector.asIdentifier().source; 2529 String name = node.selector.asIdentifier().source;
2525 if (identical(name, 'this')) { 2530 if (identical(name, 'this')) {
2526 // TODO(ahe): Why is this using GENERIC? 2531 // TODO(ahe): Why is this using GENERIC?
2527 error(node.selector, MessageKind.GENERIC, 2532 error(node.selector, MessageKind.GENERIC,
2528 {'text': "expected an identifier"}); 2533 {'text': "expected an identifier"});
2534 return null;
2529 } else if (node.isSuperCall) { 2535 } else if (node.isSuperCall) {
2530 if (node.isOperator) { 2536 if (node.isOperator) {
2531 if (isUserDefinableOperator(name)) { 2537 if (isUserDefinableOperator(name)) {
2532 name = selector.name; 2538 name = selector.name;
2533 } else { 2539 } else {
2534 error(node.selector, MessageKind.ILLEGAL_SUPER_SEND, {'name': name}); 2540 error(node.selector, MessageKind.ILLEGAL_SUPER_SEND, {'name': name});
2541 return null;
2535 } 2542 }
2536 } 2543 }
2537 if (!inInstanceContext) { 2544 if (!inInstanceContext) {
2538 error(node.receiver, MessageKind.NO_INSTANCE_AVAILABLE, {'name': name}); 2545 error(node.receiver, MessageKind.NO_INSTANCE_AVAILABLE, {'name': name});
2539 return null; 2546 return null;
2540 } 2547 }
2541 if (currentClass.supertype == null) { 2548 if (currentClass.supertype == null) {
2542 // This is just to guard against internal errors, so no need 2549 // This is just to guard against internal errors, so no need
2543 // for a real error message. 2550 // for a real error message.
2544 error(node.receiver, MessageKind.GENERIC, 2551 error(node.receiver, MessageKind.GENERIC,
2545 {'text': "Object has no superclass"}); 2552 {'text': "Object has no superclass"});
2553 return null;
2546 } 2554 }
2547 // TODO(johnniwinther): Ensure correct behavior if currentClass is a 2555 // TODO(johnniwinther): Ensure correct behavior if currentClass is a
2548 // patch. 2556 // patch.
2549 target = currentClass.lookupSuperSelector(selector); 2557 target = currentClass.lookupSuperSelector(selector);
2550 // [target] may be null which means invoking noSuchMethod on 2558 // [target] may be null which means invoking noSuchMethod on
2551 // super. 2559 // super.
2552 if (target == null) { 2560 if (target == null) {
2553 target = warnAndCreateErroneousElement( 2561 target = warnAndCreateErroneousElement(
2554 node, name, MessageKind.NO_SUCH_SUPER_MEMBER, 2562 node, name, MessageKind.NO_SUCH_SUPER_MEMBER,
2555 {'className': currentClass, 'memberName': name}); 2563 {'className': currentClass, 'memberName': name});
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, 3342 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS,
3335 {'type': keyType}); 3343 {'type': keyType});
3336 } 3344 }
3337 } 3345 }
3338 } 3346 }
3339 3347
3340 void analyzeConstant(Node node) { 3348 void analyzeConstant(Node node) {
3341 ConstantExpression constant = 3349 ConstantExpression constant =
3342 compiler.resolver.constantCompiler.compileNode( 3350 compiler.resolver.constantCompiler.compileNode(
3343 node, registry.mapping); 3351 node, registry.mapping);
3352 if (constant == null) {
3353 assert(invariant(node, compiler.compilationFailed));
3354 return;
3355 }
3344 3356
3345 ConstantValue value = constant.value; 3357 ConstantValue value = constant.value;
3346 if (value.isMap) { 3358 if (value.isMap) {
3347 checkConstMapKeysDontOverrideEquals(node, value); 3359 checkConstMapKeysDontOverrideEquals(node, value);
3348 } 3360 }
3349 3361
3350 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names 3362 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names
3351 // a class that will be instantiated outside the program by attaching a 3363 // a class that will be instantiated outside the program by attaching a
3352 // native class dispatch record referencing the interceptor. 3364 // native class dispatch record referencing the interceptor.
3353 if (argumentsToJsInterceptorConstant != null && 3365 if (argumentsToJsInterceptorConstant != null &&
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
4903 MessageKind.CANNOT_RESOLVE, 4915 MessageKind.CANNOT_RESOLVE,
4904 {'name': name}); 4916 {'name': name});
4905 } else if (element.isErroneous) { 4917 } else if (element.isErroneous) {
4906 return element; 4918 return element;
4907 } else if (element.isTypedef) { 4919 } else if (element.isTypedef) {
4908 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, 4920 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF,
4909 {'typedefName': name}); 4921 {'typedefName': name});
4910 } else if (element.isTypeVariable) { 4922 } else if (element.isTypeVariable) {
4911 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, 4923 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE,
4912 {'typeVariableName': name}); 4924 {'typeVariableName': name});
4925 throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:04 Ditto.
ahe 2015/01/07 12:55:24 Done.
4913 } else if (!element.isClass && !element.isPrefix) { 4926 } else if (!element.isClass && !element.isPrefix) {
4914 error(node, MessageKind.NOT_A_TYPE, {'node': name}); 4927 error(node, MessageKind.NOT_A_TYPE, {'node': name});
4928 throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:04 Ditto.
ahe 2015/01/07 12:55:24 Done.
4915 } 4929 }
4916 return element; 4930 return element;
4917 } 4931 }
4918 4932
4919 /// Assumed to be called by [resolveRedirectingFactory]. 4933 /// Assumed to be called by [resolveRedirectingFactory].
4920 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) { 4934 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) {
4921 Node constructorReference = node.constructorReference; 4935 Node constructorReference = node.constructorReference;
4922 return finishConstructorReference(visit(constructorReference), 4936 return finishConstructorReference(visit(constructorReference),
4923 constructorReference, node); 4937 constructorReference, node);
4924 } 4938 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 } 5001 }
4988 5002
4989 /// The result for the resolution of the `assert` method. 5003 /// The result for the resolution of the `assert` method.
4990 class AssertResult implements ResolutionResult { 5004 class AssertResult implements ResolutionResult {
4991 const AssertResult(); 5005 const AssertResult();
4992 5006
4993 Element get element => null; 5007 Element get element => null;
4994 5008
4995 String toString() => 'AssertResult()'; 5009 String toString() => 'AssertResult()';
4996 } 5010 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698