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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 var parameter = function.positionalParameters[0]; | 1444 var parameter = function.positionalParameters[0]; |
1445 engine.instrumentation?.record(Uri.parse(uri), parameter.fileOffset, | 1445 engine.instrumentation?.record(Uri.parse(uri), parameter.fileOffset, |
1446 'topType', new InstrumentationValueForType(inferredType)); | 1446 'topType', new InstrumentationValueForType(inferredType)); |
1447 parameter.type = inferredType; | 1447 parameter.type = inferredType; |
1448 } | 1448 } |
1449 } else if (isGetter) { | 1449 } else if (isGetter) { |
1450 engine.instrumentation?.record(Uri.parse(uri), fileOffset, 'topType', | 1450 engine.instrumentation?.record(Uri.parse(uri), fileOffset, 'topType', |
1451 new InstrumentationValueForType(inferredType)); | 1451 new InstrumentationValueForType(inferredType)); |
1452 function.returnType = inferredType; | 1452 function.returnType = inferredType; |
1453 } else { | 1453 } else { |
1454 internalError( | 1454 deprecated_internalProblem( |
1455 'setInferredType called on a procedure that is not an accessor'); | 1455 'setInferredType called on a procedure that is not an accessor'); |
1456 } | 1456 } |
1457 } | 1457 } |
1458 | 1458 |
1459 static MethodNode getMethodNode(Procedure procedure) { | 1459 static MethodNode getMethodNode(Procedure procedure) { |
1460 if (procedure is KernelProcedure) return procedure._methodNode; | 1460 if (procedure is KernelProcedure) return procedure._methodNode; |
1461 return null; | 1461 return null; |
1462 } | 1462 } |
1463 | 1463 |
1464 static bool hasImplicitReturnType(KernelProcedure procedure) { | 1464 static bool hasImplicitReturnType(KernelProcedure procedure) { |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 : inferrer.coreTypes.iterableClass); | 2406 : inferrer.coreTypes.iterableClass); |
2407 } | 2407 } |
2408 var inferredType = inferrer.inferExpression(expression, typeContext, true); | 2408 var inferredType = inferrer.inferExpression(expression, typeContext, true); |
2409 closureContext.handleYield(inferrer, isYieldStar, inferredType); | 2409 closureContext.handleYield(inferrer, isYieldStar, inferredType); |
2410 inferrer.listener.yieldStatementExit(this); | 2410 inferrer.listener.yieldStatementExit(this); |
2411 } | 2411 } |
2412 } | 2412 } |
2413 | 2413 |
2414 class _UnfinishedCascade extends Expression { | 2414 class _UnfinishedCascade extends Expression { |
2415 accept(v) { | 2415 accept(v) { |
2416 return internalError("Internal error: Unsupported operation."); | 2416 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2417 } | 2417 } |
2418 | 2418 |
2419 accept1(v, arg) { | 2419 accept1(v, arg) { |
2420 return internalError("Internal error: Unsupported operation."); | 2420 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2421 } | 2421 } |
2422 | 2422 |
2423 getStaticType(types) { | 2423 getStaticType(types) { |
2424 return internalError("Internal error: Unsupported operation."); | 2424 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2425 } | 2425 } |
2426 | 2426 |
2427 transformChildren(v) { | 2427 transformChildren(v) { |
2428 return internalError("Internal error: Unsupported operation."); | 2428 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2429 } | 2429 } |
2430 | 2430 |
2431 visitChildren(v) { | 2431 visitChildren(v) { |
2432 return internalError("Internal error: Unsupported operation."); | 2432 return deprecated_internalProblem("Internal error: Unsupported operation."); |
2433 } | 2433 } |
2434 } | 2434 } |
OLD | NEW |