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 12 matching lines...) Expand all Loading... |
23 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; | 23 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; |
24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'; | 24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'; |
25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; | 25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; |
26 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; | 26 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; |
27 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
; | 27 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
; |
28 import 'package:kernel/ast.dart' | 28 import 'package:kernel/ast.dart' |
29 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 29 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
30 import 'package:kernel/frontend/accessors.dart'; | 30 import 'package:kernel/frontend/accessors.dart'; |
31 import 'package:kernel/type_environment.dart'; | 31 import 'package:kernel/type_environment.dart'; |
32 | 32 |
33 import '../errors.dart' show internalError; | 33 import '../deprecated_problems.dart' show deprecated_internalProblem; |
34 | 34 |
35 /// Computes the return type of a (possibly factory) constructor. | 35 /// Computes the return type of a (possibly factory) constructor. |
36 InterfaceType computeConstructorReturnType(Member constructor) { | 36 InterfaceType computeConstructorReturnType(Member constructor) { |
37 if (constructor is Constructor) { | 37 if (constructor is Constructor) { |
38 return constructor.enclosingClass.thisType; | 38 return constructor.enclosingClass.thisType; |
39 } else { | 39 } else { |
40 return constructor.function.returnType; | 40 return constructor.function.returnType; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 implements KernelExpression { | 530 implements KernelExpression { |
531 KernelDirectMethodInvocation( | 531 KernelDirectMethodInvocation( |
532 Expression receiver, Procedure target, Arguments arguments) | 532 Expression receiver, Procedure target, Arguments arguments) |
533 : super(receiver, target, arguments); | 533 : super(receiver, target, arguments); |
534 | 534 |
535 @override | 535 @override |
536 void _collectDependencies(KernelDependencyCollector collector) { | 536 void _collectDependencies(KernelDependencyCollector collector) { |
537 // DirectMethodInvocation can only occur as a result of a use of `super`, | 537 // DirectMethodInvocation can only occur as a result of a use of `super`, |
538 // and `super` can't appear inside a field initializer. So this code should | 538 // and `super` can't appear inside a field initializer. So this code should |
539 // never be reached. | 539 // never be reached. |
540 internalError( | 540 deprecated_internalProblem( |
541 'Unexpected call to _collectDependencies for DirectMethodInvocation'); | 541 'Unexpected call to _collectDependencies for DirectMethodInvocation'); |
542 } | 542 } |
543 | 543 |
544 @override | 544 @override |
545 DartType _inferExpression( | 545 DartType _inferExpression( |
546 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 546 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
547 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, | 547 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, |
548 'target', new InstrumentationValueForMember(target)); | 548 'target', new InstrumentationValueForMember(target)); |
549 return inferrer.inferMethodInvocation( | 549 return inferrer.inferMethodInvocation( |
550 this, receiver, fileOffset, false, typeContext, typeNeeded, | 550 this, receiver, fileOffset, false, typeContext, typeNeeded, |
551 interfaceMember: target, methodName: target.name, arguments: arguments); | 551 interfaceMember: target, methodName: target.name, arguments: arguments); |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 /// Shadow object for [DirectPropertyGet]. | 555 /// Shadow object for [DirectPropertyGet]. |
556 class KernelDirectPropertyGet extends DirectPropertyGet | 556 class KernelDirectPropertyGet extends DirectPropertyGet |
557 implements KernelExpression { | 557 implements KernelExpression { |
558 KernelDirectPropertyGet(Expression receiver, Member target) | 558 KernelDirectPropertyGet(Expression receiver, Member target) |
559 : super(receiver, target); | 559 : super(receiver, target); |
560 | 560 |
561 @override | 561 @override |
562 void _collectDependencies(KernelDependencyCollector collector) { | 562 void _collectDependencies(KernelDependencyCollector collector) { |
563 // DirectPropertyGet can only occur as a result of a use of `super`, and | 563 // DirectPropertyGet can only occur as a result of a use of `super`, and |
564 // `super` can't appear inside a field initializer. So this code should | 564 // `super` can't appear inside a field initializer. So this code should |
565 // never be reached. | 565 // never be reached. |
566 internalError( | 566 deprecated_internalProblem( |
567 'Unexpected call to _collectDependencies for DirectPropertyGet'); | 567 'Unexpected call to _collectDependencies for DirectPropertyGet'); |
568 } | 568 } |
569 | 569 |
570 @override | 570 @override |
571 DartType _inferExpression( | 571 DartType _inferExpression( |
572 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 572 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
573 return inferrer.inferPropertyGet( | 573 return inferrer.inferPropertyGet( |
574 this, receiver, fileOffset, typeContext, typeNeeded, | 574 this, receiver, fileOffset, typeContext, typeNeeded, |
575 propertyName: target.name); | 575 propertyName: target.name); |
576 } | 576 } |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 var parameter = function.positionalParameters[0]; | 1438 var parameter = function.positionalParameters[0]; |
1439 engine.instrumentation?.record(Uri.parse(uri), parameter.fileOffset, | 1439 engine.instrumentation?.record(Uri.parse(uri), parameter.fileOffset, |
1440 'topType', new InstrumentationValueForType(inferredType)); | 1440 'topType', new InstrumentationValueForType(inferredType)); |
1441 parameter.type = inferredType; | 1441 parameter.type = inferredType; |
1442 } | 1442 } |
1443 } else if (isGetter) { | 1443 } else if (isGetter) { |
1444 engine.instrumentation?.record(Uri.parse(uri), fileOffset, 'topType', | 1444 engine.instrumentation?.record(Uri.parse(uri), fileOffset, 'topType', |
1445 new InstrumentationValueForType(inferredType)); | 1445 new InstrumentationValueForType(inferredType)); |
1446 function.returnType = inferredType; | 1446 function.returnType = inferredType; |
1447 } else { | 1447 } else { |
1448 internalError( | 1448 deprecated_internalProblem( |
1449 'setInferredType called on a procedure that is not an accessor'); | 1449 'setInferredType called on a procedure that is not an accessor'); |
1450 } | 1450 } |
1451 } | 1451 } |
1452 | 1452 |
1453 static MethodNode getMethodNode(Procedure procedure) { | 1453 static MethodNode getMethodNode(Procedure procedure) { |
1454 if (procedure is KernelProcedure) return procedure._methodNode; | 1454 if (procedure is KernelProcedure) return procedure._methodNode; |
1455 return null; | 1455 return null; |
1456 } | 1456 } |
1457 | 1457 |
1458 static bool hasImplicitReturnType(KernelProcedure procedure) { | 1458 static bool hasImplicitReturnType(KernelProcedure procedure) { |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 : inferrer.coreTypes.iterableClass); | 2400 : inferrer.coreTypes.iterableClass); |
2401 } | 2401 } |
2402 var inferredType = inferrer.inferExpression(expression, typeContext, true); | 2402 var inferredType = inferrer.inferExpression(expression, typeContext, true); |
2403 closureContext.handleYield(inferrer, isYieldStar, inferredType); | 2403 closureContext.handleYield(inferrer, isYieldStar, inferredType); |
2404 inferrer.listener.yieldStatementExit(this); | 2404 inferrer.listener.yieldStatementExit(this); |
2405 } | 2405 } |
2406 } | 2406 } |
2407 | 2407 |
2408 class _UnfinishedCascade extends Expression { | 2408 class _UnfinishedCascade extends Expression { |
2409 accept(v) { | 2409 accept(v) { |
2410 return internalError("Internal error: Unsupported operation."); | 2410 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2411 } | 2411 } |
2412 | 2412 |
2413 accept1(v, arg) { | 2413 accept1(v, arg) { |
2414 return internalError("Internal error: Unsupported operation."); | 2414 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2415 } | 2415 } |
2416 | 2416 |
2417 getStaticType(types) { | 2417 getStaticType(types) { |
2418 return internalError("Internal error: Unsupported operation."); | 2418 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2419 } | 2419 } |
2420 | 2420 |
2421 transformChildren(v) { | 2421 transformChildren(v) { |
2422 return internalError("Internal error: Unsupported operation."); | 2422 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2423 } | 2423 } |
2424 | 2424 |
2425 visitChildren(v) { | 2425 visitChildren(v) { |
2426 return internalError("Internal error: Unsupported operation."); | 2426 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2427 } | 2427 } |
2428 } | 2428 } |
OLD | NEW |