OLD | NEW |
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 import 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import 'package:js_runtime/shared/embedded_names.dart'; | 7 import 'package:js_runtime/shared/embedded_names.dart'; |
8 | 8 |
9 import '../closure.dart'; | 9 import '../closure.dart'; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 final CodeEmitterTask emitter; | 116 final CodeEmitterTask emitter; |
117 final SourceInformationStrategy sourceInformationFactory; | 117 final SourceInformationStrategy sourceInformationFactory; |
118 | 118 |
119 SsaAstBuilder(CompilerTask task, JavaScriptBackend backend, | 119 SsaAstBuilder(CompilerTask task, JavaScriptBackend backend, |
120 this.sourceInformationFactory) | 120 this.sourceInformationFactory) |
121 : emitter = backend.emitter, | 121 : emitter = backend.emitter, |
122 super(task, backend); | 122 super(task, backend); |
123 | 123 |
124 DiagnosticReporter get reporter => backend.reporter; | 124 DiagnosticReporter get reporter => backend.reporter; |
125 | 125 |
126 HGraph build(ElementCodegenWorkItem work, ClosedWorld closedWorld) { | 126 HGraph build(covariant ElementCodegenWorkItem work, ClosedWorld closedWorld) { |
127 return task.measure(() { | 127 return task.measure(() { |
128 if (handleConstantField(work, closedWorld)) { | 128 if (handleConstantField(work, closedWorld)) { |
129 // No code is generated for `work.element`. | 129 // No code is generated for `work.element`. |
130 return null; | 130 return null; |
131 } | 131 } |
132 MemberElement element = work.element.implementation; | 132 MemberElement element = work.element.implementation; |
133 return reporter.withCurrentElement(element, () { | 133 return reporter.withCurrentElement(element, () { |
134 SsaAstGraphBuilder builder = new SsaAstGraphBuilder( | 134 SsaAstGraphBuilder builder = new SsaAstGraphBuilder( |
135 work.element.implementation, | 135 work.element.implementation, |
136 work.resolvedAst, | 136 work.resolvedAst, |
(...skipping 3178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3315 void handleInvalidSuperInvoke(ast.Send node, ast.NodeList arguments) { | 3315 void handleInvalidSuperInvoke(ast.Send node, ast.NodeList arguments) { |
3316 Selector selector = elements.getSelector(node); | 3316 Selector selector = elements.getSelector(node); |
3317 List<HInstruction> inputs = <HInstruction>[]; | 3317 List<HInstruction> inputs = <HInstruction>[]; |
3318 addGenericSendArgumentsToList(arguments.nodes, inputs); | 3318 addGenericSendArgumentsToList(arguments.nodes, inputs); |
3319 generateSuperNoSuchMethodSend(node, selector, inputs); | 3319 generateSuperNoSuchMethodSend(node, selector, inputs); |
3320 } | 3320 } |
3321 | 3321 |
3322 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { | 3322 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
3323 if (closedWorld.isUsedAsMixin(cls)) return true; | 3323 if (closedWorld.isUsedAsMixin(cls)) return true; |
3324 | 3324 |
3325 return closedWorld.anyStrictSubclassOf(cls, (ClassElement subclass) { | 3325 return closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) { |
3326 return !rtiSubstitutions.isTrivialSubstitution(subclass, cls); | 3326 return !rtiSubstitutions.isTrivialSubstitution(subclass, cls); |
3327 }); | 3327 }); |
3328 } | 3328 } |
3329 | 3329 |
3330 HInstruction handleListConstructor(ResolutionInterfaceType type, | 3330 HInstruction handleListConstructor(ResolutionInterfaceType type, |
3331 ast.Node currentNode, HInstruction newObject) { | 3331 ast.Node currentNode, HInstruction newObject) { |
3332 if (!rtiNeed.classNeedsRti(type.element) || type.treatAsRaw) { | 3332 if (!rtiNeed.classNeedsRti(type.element) || type.treatAsRaw) { |
3333 return newObject; | 3333 return newObject; |
3334 } | 3334 } |
3335 List<HInstruction> inputs = <HInstruction>[]; | 3335 List<HInstruction> inputs = <HInstruction>[]; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3441 ConstructorElement target = constructorDeclaration; | 3441 ConstructorElement target = constructorDeclaration; |
3442 while (target.isRedirectingFactory) { | 3442 while (target.isRedirectingFactory) { |
3443 if (constructorDeclaration.redirectionDeferredPrefix != null) { | 3443 if (constructorDeclaration.redirectionDeferredPrefix != null) { |
3444 generateIsDeferredLoadedCheckIfNeeded( | 3444 generateIsDeferredLoadedCheckIfNeeded( |
3445 target.redirectionDeferredPrefix, node); | 3445 target.redirectionDeferredPrefix, node); |
3446 } | 3446 } |
3447 target = target.immediateRedirectionTarget; | 3447 target = target.immediateRedirectionTarget; |
3448 } | 3448 } |
3449 } | 3449 } |
3450 ResolutionInterfaceType type = elements.getType(node); | 3450 ResolutionInterfaceType type = elements.getType(node); |
3451 ResolutionInterfaceType expectedType = | 3451 ResolutionDartType expectedType = |
3452 constructorDeclaration.computeEffectiveTargetType(type); | 3452 constructorDeclaration.computeEffectiveTargetType(type); |
3453 expectedType = localsHandler.substInContext(expectedType); | 3453 expectedType = localsHandler.substInContext(expectedType); |
3454 | 3454 |
3455 if (compiler.elementHasCompileTimeError(constructor) || | 3455 if (compiler.elementHasCompileTimeError(constructor) || |
3456 compiler.elementHasCompileTimeError(constructor.enclosingClass)) { | 3456 compiler.elementHasCompileTimeError(constructor.enclosingClass)) { |
3457 // TODO(ahe): Do something like [generateWrongArgumentCountError]. | 3457 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
3458 stack.add(graph.addConstantNull(closedWorld)); | 3458 stack.add(graph.addConstantNull(closedWorld)); |
3459 return; | 3459 return; |
3460 } | 3460 } |
3461 | 3461 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3599 /// returns [:true:] if an error can be statically determined. | 3599 /// returns [:true:] if an error can be statically determined. |
3600 bool checkTypeVariableBounds( | 3600 bool checkTypeVariableBounds( |
3601 ast.NewExpression node, ResolutionInterfaceType type) { | 3601 ast.NewExpression node, ResolutionInterfaceType type) { |
3602 if (!options.enableTypeAssertions) return false; | 3602 if (!options.enableTypeAssertions) return false; |
3603 | 3603 |
3604 Map<ResolutionDartType, Set<ResolutionDartType>> seenChecksMap = | 3604 Map<ResolutionDartType, Set<ResolutionDartType>> seenChecksMap = |
3605 new Map<ResolutionDartType, Set<ResolutionDartType>>(); | 3605 new Map<ResolutionDartType, Set<ResolutionDartType>>(); |
3606 bool definitelyFails = false; | 3606 bool definitelyFails = false; |
3607 | 3607 |
3608 void addTypeVariableBoundCheck( | 3608 void addTypeVariableBoundCheck( |
3609 ResolutionInterfaceType instance, | 3609 InterfaceType _instance, |
3610 ResolutionDartType typeArgument, | 3610 DartType _typeArgument, |
3611 ResolutionTypeVariableType typeVariable, | 3611 TypeVariableType _typeVariable, |
3612 ResolutionDartType bound) { | 3612 DartType _bound) { |
3613 if (definitelyFails) return; | 3613 if (definitelyFails) return; |
| 3614 ResolutionInterfaceType instance = _instance; |
| 3615 ResolutionDartType typeArgument = _typeArgument; |
| 3616 ResolutionTypeVariableType typeVariable = _typeVariable; |
| 3617 ResolutionDartType bound = _bound; |
3614 | 3618 |
3615 int subtypeRelation = types.computeSubtypeRelation(typeArgument, bound); | 3619 int subtypeRelation = types.computeSubtypeRelation(typeArgument, bound); |
3616 if (subtypeRelation == DartTypes.IS_SUBTYPE) return; | 3620 if (subtypeRelation == DartTypes.IS_SUBTYPE) return; |
3617 | 3621 |
3618 String message = "Can't create an instance of malbounded type '$type': " | 3622 String message = "Can't create an instance of malbounded type '$type': " |
3619 "'${typeArgument}' is not a subtype of bound '${bound}' for " | 3623 "'${typeArgument}' is not a subtype of bound '${bound}' for " |
3620 "type variable '${typeVariable}' of type " | 3624 "type variable '${typeVariable}' of type " |
3621 "${type == instance | 3625 "${type == instance |
3622 ? "'${type.element.thisType}'" | 3626 ? "'${type.element.thisType}'" |
3623 : "'${instance.element.thisType}' on the supertype " | 3627 : "'${instance.element.thisType}' on the supertype " |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4380 } | 4384 } |
4381 | 4385 |
4382 @override | 4386 @override |
4383 void visitSuperIndexSet(ast.SendSet node, FunctionElement function, | 4387 void visitSuperIndexSet(ast.SendSet node, FunctionElement function, |
4384 ast.Node index, ast.Node rhs, _) { | 4388 ast.Node index, ast.Node rhs, _) { |
4385 handleSuperSendSet(node); | 4389 handleSuperSendSet(node); |
4386 } | 4390 } |
4387 | 4391 |
4388 @override | 4392 @override |
4389 void visitSuperMethodSet( | 4393 void visitSuperMethodSet( |
4390 ast.Send node, MethodElement method, ast.Node rhs, _) { | 4394 ast.SendSet node, MethodElement method, ast.Node rhs, _) { |
4391 handleSuperSendSet(node); | 4395 handleSuperSendSet(node); |
4392 } | 4396 } |
4393 | 4397 |
4394 @override | 4398 @override |
4395 void visitSuperSetterSet( | 4399 void visitSuperSetterSet( |
4396 ast.SendSet node, FunctionElement setter, ast.Node rhs, _) { | 4400 ast.SendSet node, FunctionElement setter, ast.Node rhs, _) { |
4397 handleSuperSendSet(node); | 4401 handleSuperSendSet(node); |
4398 } | 4402 } |
4399 | 4403 |
4400 @override | 4404 @override |
4401 void visitUnresolvedSuperIndexSet( | 4405 void visitUnresolvedSuperIndexSet(ast.SendSet node, ErroneousElement element, |
4402 ast.Send node, Element element, ast.Node index, ast.Node rhs, _) { | 4406 ast.Node index, ast.Node rhs, _) { |
4403 handleSuperSendSet(node); | 4407 handleSuperSendSet(node); |
4404 } | 4408 } |
4405 | 4409 |
4406 @override | 4410 @override |
4407 void visitSuperIndexPrefix( | 4411 void visitSuperIndexPrefix( |
4408 ast.Send node, | 4412 ast.Send node, |
4409 MethodElement indexFunction, | 4413 MethodElement indexFunction, |
4410 MethodElement indexSetFunction, | 4414 MethodElement indexSetFunction, |
4411 ast.Node index, | 4415 ast.Node index, |
4412 IncDecOperator operator, | 4416 IncDecOperator operator, |
4413 _) { | 4417 _) { |
4414 handleSuperSendSet(node); | 4418 handleSuperSendSet(node); |
4415 } | 4419 } |
4416 | 4420 |
4417 @override | 4421 @override |
4418 void visitSuperIndexPostfix( | 4422 void visitSuperIndexPostfix( |
4419 ast.Send node, | 4423 ast.Send node, |
4420 MethodElement indexFunction, | 4424 MethodElement indexFunction, |
4421 MethodElement indexSetFunction, | 4425 MethodElement indexSetFunction, |
4422 ast.Node index, | 4426 ast.Node index, |
4423 IncDecOperator operator, | 4427 IncDecOperator operator, |
4424 _) { | 4428 _) { |
4425 handleSuperSendSet(node); | 4429 handleSuperSendSet(node); |
4426 } | 4430 } |
4427 | 4431 |
4428 @override | 4432 @override |
4429 void visitUnresolvedSuperGetterIndexPrefix(ast.Send node, Element element, | 4433 void visitUnresolvedSuperGetterIndexPrefix(ast.SendSet node, Element element, |
4430 MethodElement setter, ast.Node index, IncDecOperator operator, _) { | 4434 MethodElement setter, ast.Node index, IncDecOperator operator, _) { |
4431 handleSuperSendSet(node); | 4435 handleSuperSendSet(node); |
4432 } | 4436 } |
4433 | 4437 |
4434 @override | 4438 @override |
4435 void visitUnresolvedSuperGetterIndexPostfix(ast.Send node, Element element, | 4439 void visitUnresolvedSuperGetterIndexPostfix(ast.SendSet node, Element element, |
4436 MethodElement setter, ast.Node index, IncDecOperator operator, _) { | 4440 MethodElement setter, ast.Node index, IncDecOperator operator, _) { |
4437 handleSuperSendSet(node); | 4441 handleSuperSendSet(node); |
4438 } | 4442 } |
4439 | 4443 |
4440 @override | 4444 @override |
4441 void visitUnresolvedSuperSetterIndexPrefix( | 4445 void visitUnresolvedSuperSetterIndexPrefix( |
4442 ast.Send node, | 4446 ast.SendSet node, |
4443 MethodElement indexFunction, | 4447 MethodElement indexFunction, |
4444 Element element, | 4448 Element element, |
4445 ast.Node index, | 4449 ast.Node index, |
4446 IncDecOperator operator, | 4450 IncDecOperator operator, |
4447 _) { | 4451 _) { |
4448 handleSuperSendSet(node); | 4452 handleSuperSendSet(node); |
4449 } | 4453 } |
4450 | 4454 |
4451 @override | 4455 @override |
4452 void visitUnresolvedSuperSetterIndexPostfix( | 4456 void visitUnresolvedSuperSetterIndexPostfix( |
4453 ast.Send node, | 4457 ast.SendSet node, |
4454 MethodElement indexFunction, | 4458 MethodElement indexFunction, |
4455 Element element, | 4459 Element element, |
4456 ast.Node index, | 4460 ast.Node index, |
4457 IncDecOperator operator, | 4461 IncDecOperator operator, |
4458 _) { | 4462 _) { |
4459 handleSuperSendSet(node); | 4463 handleSuperSendSet(node); |
4460 } | 4464 } |
4461 | 4465 |
4462 @override | 4466 @override |
4463 void visitUnresolvedSuperIndexPrefix(ast.Send node, Element element, | 4467 void visitUnresolvedSuperIndexPrefix(ast.Send node, Element element, |
(...skipping 14 matching lines...) Expand all Loading... |
4478 MethodElement setter, | 4482 MethodElement setter, |
4479 ast.Node index, | 4483 ast.Node index, |
4480 AssignmentOperator operator, | 4484 AssignmentOperator operator, |
4481 ast.Node rhs, | 4485 ast.Node rhs, |
4482 _) { | 4486 _) { |
4483 handleSuperSendSet(node); | 4487 handleSuperSendSet(node); |
4484 } | 4488 } |
4485 | 4489 |
4486 @override | 4490 @override |
4487 void visitUnresolvedSuperGetterCompoundIndexSet( | 4491 void visitUnresolvedSuperGetterCompoundIndexSet( |
4488 ast.Send node, | 4492 ast.SendSet node, |
4489 Element element, | 4493 Element element, |
4490 MethodElement setter, | 4494 MethodElement setter, |
4491 ast.Node index, | 4495 ast.Node index, |
4492 AssignmentOperator operator, | 4496 AssignmentOperator operator, |
4493 ast.Node rhs, | 4497 ast.Node rhs, |
4494 _) { | 4498 _) { |
4495 handleSuperSendSet(node); | 4499 handleSuperSendSet(node); |
4496 } | 4500 } |
4497 | 4501 |
4498 @override | 4502 @override |
4499 void visitUnresolvedSuperSetterCompoundIndexSet( | 4503 void visitUnresolvedSuperSetterCompoundIndexSet( |
4500 ast.Send node, | 4504 ast.SendSet node, |
4501 MethodElement getter, | 4505 MethodElement getter, |
4502 Element element, | 4506 Element element, |
4503 ast.Node index, | 4507 ast.Node index, |
4504 AssignmentOperator operator, | 4508 AssignmentOperator operator, |
4505 ast.Node rhs, | 4509 ast.Node rhs, |
4506 _) { | 4510 _) { |
4507 handleSuperSendSet(node); | 4511 handleSuperSendSet(node); |
4508 } | 4512 } |
4509 | 4513 |
4510 @override | 4514 @override |
4511 void visitUnresolvedSuperCompoundIndexSet(ast.Send node, Element element, | 4515 void visitUnresolvedSuperCompoundIndexSet(ast.SendSet node, Element element, |
4512 ast.Node index, AssignmentOperator operator, ast.Node rhs, _) { | 4516 ast.Node index, AssignmentOperator operator, ast.Node rhs, _) { |
4513 handleSuperSendSet(node); | 4517 handleSuperSendSet(node); |
4514 } | 4518 } |
4515 | 4519 |
4516 @override | 4520 @override |
4517 void visitSuperFieldCompound(ast.Send node, FieldElement field, | 4521 void visitSuperFieldCompound(ast.Send node, FieldElement field, |
4518 AssignmentOperator operator, ast.Node rhs, _) { | 4522 AssignmentOperator operator, ast.Node rhs, _) { |
4519 handleSuperSendSet(node); | 4523 handleSuperSendSet(node); |
4520 } | 4524 } |
4521 | 4525 |
4522 @override | 4526 @override |
4523 void visitFinalSuperFieldCompound(ast.Send node, FieldElement field, | 4527 void visitFinalSuperFieldCompound(ast.Send node, FieldElement field, |
4524 AssignmentOperator operator, ast.Node rhs, _) { | 4528 AssignmentOperator operator, ast.Node rhs, _) { |
4525 handleSuperSendSet(node); | 4529 handleSuperSendSet(node); |
4526 } | 4530 } |
4527 | 4531 |
4528 @override | 4532 @override |
4529 void visitFinalSuperFieldPrefix( | 4533 void visitFinalSuperFieldPrefix( |
4530 ast.Send node, FieldElement field, IncDecOperator operator, _) { | 4534 ast.Send node, FieldElement field, IncDecOperator operator, _) { |
4531 handleSuperSendSet(node); | 4535 handleSuperSendSet(node); |
4532 } | 4536 } |
4533 | 4537 |
4534 @override | 4538 @override |
4535 void visitUnresolvedSuperPrefix( | 4539 void visitUnresolvedSuperPrefix( |
4536 ast.Send node, Element element, IncDecOperator operator, _) { | 4540 ast.SendSet node, Element element, IncDecOperator operator, _) { |
4537 handleSuperSendSet(node); | 4541 handleSuperSendSet(node); |
4538 } | 4542 } |
4539 | 4543 |
4540 @override | 4544 @override |
4541 void visitUnresolvedSuperPostfix( | 4545 void visitUnresolvedSuperPostfix( |
4542 ast.Send node, Element element, IncDecOperator operator, _) { | 4546 ast.SendSet node, Element element, IncDecOperator operator, _) { |
4543 handleSuperSendSet(node); | 4547 handleSuperSendSet(node); |
4544 } | 4548 } |
4545 | 4549 |
4546 @override | 4550 @override |
4547 void visitUnresolvedSuperCompound(ast.Send node, Element element, | 4551 void visitUnresolvedSuperCompound(ast.Send node, Element element, |
4548 AssignmentOperator operator, ast.Node rhs, _) { | 4552 AssignmentOperator operator, ast.Node rhs, _) { |
4549 handleSuperSendSet(node); | 4553 handleSuperSendSet(node); |
4550 } | 4554 } |
4551 | 4555 |
4552 @override | 4556 @override |
(...skipping 14 matching lines...) Expand all Loading... |
4567 handleSuperSendSet(node); | 4571 handleSuperSendSet(node); |
4568 } | 4572 } |
4569 | 4573 |
4570 @override | 4574 @override |
4571 void visitSuperMethodSetterCompound(ast.Send node, FunctionElement method, | 4575 void visitSuperMethodSetterCompound(ast.Send node, FunctionElement method, |
4572 FunctionElement setter, AssignmentOperator operator, ast.Node rhs, _) { | 4576 FunctionElement setter, AssignmentOperator operator, ast.Node rhs, _) { |
4573 handleSuperSendSet(node); | 4577 handleSuperSendSet(node); |
4574 } | 4578 } |
4575 | 4579 |
4576 @override | 4580 @override |
4577 void visitSuperMethodCompound(ast.Send node, FunctionElement method, | 4581 void visitSuperMethodCompound(ast.Send node, MethodElement method, |
4578 AssignmentOperator operator, ast.Node rhs, _) { | 4582 AssignmentOperator operator, ast.Node rhs, _) { |
4579 handleSuperSendSet(node); | 4583 handleSuperSendSet(node); |
4580 } | 4584 } |
4581 | 4585 |
4582 @override | 4586 @override |
4583 void visitUnresolvedSuperGetterCompound(ast.Send node, Element element, | 4587 void visitUnresolvedSuperGetterCompound(ast.SendSet node, Element element, |
4584 MethodElement setter, AssignmentOperator operator, ast.Node rhs, _) { | 4588 SetterElement setter, AssignmentOperator operator, ast.Node rhs, _) { |
4585 handleSuperSendSet(node); | 4589 handleSuperSendSet(node); |
4586 } | 4590 } |
4587 | 4591 |
4588 @override | 4592 @override |
4589 void visitUnresolvedSuperSetterCompound(ast.Send node, MethodElement getter, | 4593 void visitUnresolvedSuperSetterCompound(ast.Send node, GetterElement getter, |
4590 Element element, AssignmentOperator operator, ast.Node rhs, _) { | 4594 Element element, AssignmentOperator operator, ast.Node rhs, _) { |
4591 handleSuperSendSet(node); | 4595 handleSuperSendSet(node); |
4592 } | 4596 } |
4593 | 4597 |
4594 @override | 4598 @override |
4595 void visitSuperFieldSetterCompound(ast.Send node, FieldElement field, | 4599 void visitSuperFieldSetterCompound(ast.Send node, FieldElement field, |
4596 FunctionElement setter, AssignmentOperator operator, ast.Node rhs, _) { | 4600 FunctionElement setter, AssignmentOperator operator, ast.Node rhs, _) { |
4597 handleSuperSendSet(node); | 4601 handleSuperSendSet(node); |
4598 } | 4602 } |
4599 | 4603 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5173 } else { | 5177 } else { |
5174 for (ParameterElement parameter in targetOptionals) { | 5178 for (ParameterElement parameter in targetOptionals) { |
5175 loadPosition(position++, parameter); | 5179 loadPosition(position++, parameter); |
5176 } | 5180 } |
5177 } | 5181 } |
5178 } | 5182 } |
5179 | 5183 |
5180 ClassElement targetClass = targetConstructor.enclosingClass; | 5184 ClassElement targetClass = targetConstructor.enclosingClass; |
5181 if (rtiNeed.classNeedsRti(targetClass)) { | 5185 if (rtiNeed.classNeedsRti(targetClass)) { |
5182 ClassElement cls = redirectingConstructor.enclosingClass; | 5186 ClassElement cls = redirectingConstructor.enclosingClass; |
5183 ResolutionInterfaceType targetType = | 5187 ResolutionDartType targetType = |
5184 redirectingConstructor.computeEffectiveTargetType(cls.thisType); | 5188 redirectingConstructor.computeEffectiveTargetType(cls.thisType); |
5185 targetType = localsHandler.substInContext(targetType); | 5189 targetType = localsHandler.substInContext(targetType); |
5186 targetType.typeArguments.forEach((ResolutionDartType argument) { | 5190 if (targetType is ResolutionInterfaceType) { |
5187 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 5191 targetType.typeArguments.forEach((ResolutionDartType argument) { |
5188 }); | 5192 inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 5193 }); |
| 5194 } |
5189 } | 5195 } |
5190 pushInvokeStatic(node, targetConstructor.declaration, inputs); | 5196 pushInvokeStatic(node, targetConstructor.declaration, inputs); |
5191 HInstruction value = pop(); | 5197 HInstruction value = pop(); |
5192 emitReturn(value, node); | 5198 emitReturn(value, node); |
5193 } | 5199 } |
5194 | 5200 |
5195 /// Returns true if the [type] is a valid return type for an asynchronous | 5201 /// Returns true if the [type] is a valid return type for an asynchronous |
5196 /// function. | 5202 /// function. |
5197 /// | 5203 /// |
5198 /// Asynchronous functions return a `Future`, and a valid return is thus | 5204 /// Asynchronous functions return a `Future`, and a valid return is thus |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5743 add(keyValuePairs); | 5749 add(keyValuePairs); |
5744 inputs.add(keyValuePairs); | 5750 inputs.add(keyValuePairs); |
5745 } | 5751 } |
5746 | 5752 |
5747 assert(listConstructor.isFactoryConstructor); | 5753 assert(listConstructor.isFactoryConstructor); |
5748 | 5754 |
5749 ConstructorElement constructorElement = listConstructor; | 5755 ConstructorElement constructorElement = listConstructor; |
5750 listConstructor = constructorElement.effectiveTarget; | 5756 listConstructor = constructorElement.effectiveTarget; |
5751 | 5757 |
5752 ResolutionInterfaceType type = elements.getType(node); | 5758 ResolutionInterfaceType type = elements.getType(node); |
5753 ResolutionInterfaceType expectedType = | 5759 ResolutionDartType expectedType = |
5754 constructorElement.computeEffectiveTargetType(type); | 5760 constructorElement.computeEffectiveTargetType(type); |
5755 expectedType = localsHandler.substInContext(expectedType); | 5761 expectedType = localsHandler.substInContext(expectedType); |
5756 | 5762 |
5757 ClassElement cls = listConstructor.enclosingClass; | 5763 ClassElement cls = listConstructor.enclosingClass; |
5758 | 5764 |
5759 MethodElement createFunction = listConstructor; | 5765 MethodElement createFunction = listConstructor; |
5760 if (rtiNeed.classNeedsRti(cls)) { | 5766 if (expectedType is ResolutionInterfaceType && rtiNeed.classNeedsRti(cls)) { |
5761 List<HInstruction> typeInputs = <HInstruction>[]; | 5767 List<HInstruction> typeInputs = <HInstruction>[]; |
5762 expectedType.typeArguments.forEach((ResolutionDartType argument) { | 5768 expectedType.typeArguments.forEach((ResolutionDartType argument) { |
5763 typeInputs | 5769 typeInputs |
5764 .add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 5770 .add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
5765 }); | 5771 }); |
5766 | 5772 |
5767 // We lift this common call pattern into a helper function to save space | 5773 // We lift this common call pattern into a helper function to save space |
5768 // in the output. | 5774 // in the output. |
5769 if (typeInputs.every((HInstruction input) => input.isNull())) { | 5775 if (typeInputs.every((HInstruction input) => input.isNull())) { |
5770 if (listInputs.isEmpty) { | 5776 if (listInputs.isEmpty) { |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6874 this.oldReturnLocal, | 6880 this.oldReturnLocal, |
6875 this.oldReturnType, | 6881 this.oldReturnType, |
6876 this.oldResolvedAst, | 6882 this.oldResolvedAst, |
6877 this.oldStack, | 6883 this.oldStack, |
6878 this.oldLocalsHandler, | 6884 this.oldLocalsHandler, |
6879 this.inTryStatement, | 6885 this.inTryStatement, |
6880 this.allFunctionsCalledOnce, | 6886 this.allFunctionsCalledOnce, |
6881 this.oldElementInferenceResults) | 6887 this.oldElementInferenceResults) |
6882 : super(function); | 6888 : super(function); |
6883 } | 6889 } |
OLD | NEW |