| 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 '../deprecated_problems.dart' show deprecated_internalProblem; | 33 import '../problems.dart' show unhandled, unsupported; |
| 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 deprecated_internalProblem( | 540 unsupported( |
| 541 'Unexpected call to _collectDependencies for DirectMethodInvocation'); | 541 "DirectMethodInvocation._collectDependencies", fileOffset, null); |
| 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 deprecated_internalProblem( | 566 unsupported("DirectPropertyGet._collectDependencies", fileOffset, null); |
| 567 'Unexpected call to _collectDependencies for DirectPropertyGet'); | |
| 568 } | 567 } |
| 569 | 568 |
| 570 @override | 569 @override |
| 571 DartType _inferExpression( | 570 DartType _inferExpression( |
| 572 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 571 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
| 573 return inferrer.inferPropertyGet( | 572 return inferrer.inferPropertyGet( |
| 574 this, receiver, fileOffset, typeContext, typeNeeded, | 573 this, receiver, fileOffset, typeContext, typeNeeded, |
| 575 propertyName: target.name); | 574 propertyName: target.name); |
| 576 } | 575 } |
| 577 } | 576 } |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 var parameter = function.positionalParameters[0]; | 1443 var parameter = function.positionalParameters[0]; |
| 1445 engine.instrumentation?.record(Uri.parse(uri), parameter.fileOffset, | 1444 engine.instrumentation?.record(Uri.parse(uri), parameter.fileOffset, |
| 1446 'topType', new InstrumentationValueForType(inferredType)); | 1445 'topType', new InstrumentationValueForType(inferredType)); |
| 1447 parameter.type = inferredType; | 1446 parameter.type = inferredType; |
| 1448 } | 1447 } |
| 1449 } else if (isGetter) { | 1448 } else if (isGetter) { |
| 1450 engine.instrumentation?.record(Uri.parse(uri), fileOffset, 'topType', | 1449 engine.instrumentation?.record(Uri.parse(uri), fileOffset, 'topType', |
| 1451 new InstrumentationValueForType(inferredType)); | 1450 new InstrumentationValueForType(inferredType)); |
| 1452 function.returnType = inferredType; | 1451 function.returnType = inferredType; |
| 1453 } else { | 1452 } else { |
| 1454 deprecated_internalProblem( | 1453 unhandled("setInferredType", "not accessor", fileOffset, Uri.parse(uri)); |
| 1455 'setInferredType called on a procedure that is not an accessor'); | |
| 1456 } | 1454 } |
| 1457 } | 1455 } |
| 1458 | 1456 |
| 1459 static MethodNode getMethodNode(Procedure procedure) { | 1457 static MethodNode getMethodNode(Procedure procedure) { |
| 1460 if (procedure is KernelProcedure) return procedure._methodNode; | 1458 if (procedure is KernelProcedure) return procedure._methodNode; |
| 1461 return null; | 1459 return null; |
| 1462 } | 1460 } |
| 1463 | 1461 |
| 1464 static bool hasImplicitReturnType(KernelProcedure procedure) { | 1462 static bool hasImplicitReturnType(KernelProcedure procedure) { |
| 1465 return procedure._hasImplicitReturnType; | 1463 return procedure._hasImplicitReturnType; |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2405 ? inferrer.coreTypes.streamClass | 2403 ? inferrer.coreTypes.streamClass |
| 2406 : inferrer.coreTypes.iterableClass); | 2404 : inferrer.coreTypes.iterableClass); |
| 2407 } | 2405 } |
| 2408 var inferredType = inferrer.inferExpression(expression, typeContext, true); | 2406 var inferredType = inferrer.inferExpression(expression, typeContext, true); |
| 2409 closureContext.handleYield(inferrer, isYieldStar, inferredType); | 2407 closureContext.handleYield(inferrer, isYieldStar, inferredType); |
| 2410 inferrer.listener.yieldStatementExit(this); | 2408 inferrer.listener.yieldStatementExit(this); |
| 2411 } | 2409 } |
| 2412 } | 2410 } |
| 2413 | 2411 |
| 2414 class _UnfinishedCascade extends Expression { | 2412 class _UnfinishedCascade extends Expression { |
| 2415 accept(v) { | 2413 accept(v) => unsupported("accept", -1, null); |
| 2416 return deprecated_internalProblem("Internal error: Unsupported operation."); | |
| 2417 } | |
| 2418 | 2414 |
| 2419 accept1(v, arg) { | 2415 accept1(v, arg) => unsupported("accept1", -1, null); |
| 2420 return deprecated_internalProblem("Internal error: Unsupported operation."); | |
| 2421 } | |
| 2422 | 2416 |
| 2423 getStaticType(types) { | 2417 getStaticType(types) => unsupported("getStaticType", -1, null); |
| 2424 return deprecated_internalProblem("Internal error: Unsupported operation."); | |
| 2425 } | |
| 2426 | 2418 |
| 2427 transformChildren(v) { | 2419 transformChildren(v) => unsupported("transformChildren", -1, null); |
| 2428 return deprecated_internalProblem("Internal error: Unsupported operation."); | |
| 2429 } | |
| 2430 | 2420 |
| 2431 visitChildren(v) { | 2421 visitChildren(v) => unsupported("visitChildren", -1, null); |
| 2432 return deprecated_internalProblem("Internal error: Unsupported operation."); | |
| 2433 } | |
| 2434 } | 2422 } |
| OLD | NEW |