| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 Element get currentNonClosureClass { | 859 Element get currentNonClosureClass { |
| 860 ClassElement cls = sourceElement.enclosingClass; | 860 ClassElement cls = sourceElement.enclosingClass; |
| 861 if (cls != null && cls.isClosure) { | 861 if (cls != null && cls.isClosure) { |
| 862 var closureClass = cls; | 862 var closureClass = cls; |
| 863 return closureClass.methodElement.enclosingClass; | 863 return closureClass.methodElement.enclosingClass; |
| 864 } else { | 864 } else { |
| 865 return cls; | 865 return cls; |
| 866 } | 866 } |
| 867 } | 867 } |
| 868 | 868 |
| 869 /// A stack of [DartType]s the have been seen during inlining of factory | 869 /// A stack of [DartType]s that have been seen during inlining of factory |
| 870 /// constructors. These types are preserved in [HInvokeStatic]s and | 870 /// constructors. These types are preserved in [HInvokeStatic]s and |
| 871 /// [HForeignNew]s inside the inline code and registered during code | 871 /// [HCreate]s inside the inline code and registered during code generation |
| 872 /// generation for these nodes. | 872 /// for these nodes. |
| 873 // TODO(karlklose): consider removing this and keeping the (substituted) | 873 // TODO(karlklose): consider removing this and keeping the (substituted) types |
| 874 // types of the type variables in an environment (like the [LocalsHandler]). | 874 // of the type variables in an environment (like the [LocalsHandler]). |
| 875 final List<DartType> currentInlinedInstantiations = <DartType>[]; | 875 final List<DartType> currentInlinedInstantiations = <DartType>[]; |
| 876 | 876 |
| 877 final List<AstInliningState> inliningStack = <AstInliningState>[]; | 877 final List<AstInliningState> inliningStack = <AstInliningState>[]; |
| 878 | 878 |
| 879 Local returnLocal; | 879 Local returnLocal; |
| 880 DartType returnType; | 880 DartType returnType; |
| 881 | 881 |
| 882 bool inTryStatement = false; | 882 bool inTryStatement = false; |
| 883 | 883 |
| 884 ConstantValue getConstantForNode(ast.Node node) { | 884 ConstantValue getConstantForNode(ast.Node node) { |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 TypeMask ssaType = | 1491 TypeMask ssaType = |
| 1492 new TypeMask.nonNullExact(classElement.declaration, compiler.world); | 1492 new TypeMask.nonNullExact(classElement.declaration, compiler.world); |
| 1493 List<DartType> instantiatedTypes; | 1493 List<DartType> instantiatedTypes; |
| 1494 addInlinedInstantiation(type); | 1494 addInlinedInstantiation(type); |
| 1495 if (!currentInlinedInstantiations.isEmpty) { | 1495 if (!currentInlinedInstantiations.isEmpty) { |
| 1496 instantiatedTypes = new List<DartType>.from(currentInlinedInstantiations); | 1496 instantiatedTypes = new List<DartType>.from(currentInlinedInstantiations); |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 HInstruction newObject; | 1499 HInstruction newObject; |
| 1500 if (!isNativeUpgradeFactory) { | 1500 if (!isNativeUpgradeFactory) { |
| 1501 newObject = new HForeignNew( | 1501 newObject = new HCreate( |
| 1502 classElement, ssaType, constructorArguments, instantiatedTypes); | 1502 classElement, constructorArguments, ssaType, instantiatedTypes); |
| 1503 if (function != null) { | 1503 if (function != null) { |
| 1504 // TODO(johnniwinther): Provide source information for creation | 1504 // TODO(johnniwinther): Provide source information for creation |
| 1505 // through synthetic constructors. | 1505 // through synthetic constructors. |
| 1506 newObject.sourceInformation = | 1506 newObject.sourceInformation = |
| 1507 sourceInformationBuilder.buildCreate(function); | 1507 sourceInformationBuilder.buildCreate(function); |
| 1508 } | 1508 } |
| 1509 add(newObject); | 1509 add(newObject); |
| 1510 } else { | 1510 } else { |
| 1511 // Bulk assign to the initialized fields. | 1511 // Bulk assign to the initialized fields. |
| 1512 newObject = graph.explicitReceiverParameter; | 1512 newObject = graph.explicitReceiverParameter; |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2424 List<HInstruction> capturedVariables = <HInstruction>[]; | 2424 List<HInstruction> capturedVariables = <HInstruction>[]; |
| 2425 closureClassElement.closureFields.forEach((ClosureFieldElement field) { | 2425 closureClassElement.closureFields.forEach((ClosureFieldElement field) { |
| 2426 Local capturedLocal = | 2426 Local capturedLocal = |
| 2427 nestedClosureData.getLocalVariableForClosureField(field); | 2427 nestedClosureData.getLocalVariableForClosureField(field); |
| 2428 assert(capturedLocal != null); | 2428 assert(capturedLocal != null); |
| 2429 capturedVariables.add(localsHandler.readLocal(capturedLocal)); | 2429 capturedVariables.add(localsHandler.readLocal(capturedLocal)); |
| 2430 }); | 2430 }); |
| 2431 | 2431 |
| 2432 TypeMask type = | 2432 TypeMask type = |
| 2433 new TypeMask.nonNullExact(closureClassElement, compiler.world); | 2433 new TypeMask.nonNullExact(closureClassElement, compiler.world); |
| 2434 push(new HForeignNew(closureClassElement, type, capturedVariables) | 2434 push(new HCreate(closureClassElement, capturedVariables, type) |
| 2435 ..sourceInformation = sourceInformationBuilder.buildCreate(node)); | 2435 ..sourceInformation = sourceInformationBuilder.buildCreate(node)); |
| 2436 | 2436 |
| 2437 Element methodElement = nestedClosureData.closureElement; | 2437 Element methodElement = nestedClosureData.closureElement; |
| 2438 registry?.registerInstantiatedClosure(methodElement); | 2438 registry?.registerInstantiatedClosure(methodElement); |
| 2439 } | 2439 } |
| 2440 | 2440 |
| 2441 visitFunctionDeclaration(ast.FunctionDeclaration node) { | 2441 visitFunctionDeclaration(ast.FunctionDeclaration node) { |
| 2442 assert(isReachable); | 2442 assert(isReachable); |
| 2443 visit(node.function); | 2443 visit(node.function); |
| 2444 LocalFunctionElement localFunction = | 2444 LocalFunctionElement localFunction = |
| (...skipping 5108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7553 const _LoopTypeVisitor(); | 7553 const _LoopTypeVisitor(); |
| 7554 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; | 7554 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; |
| 7555 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; | 7555 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; |
| 7556 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; | 7556 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; |
| 7557 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | 7557 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; |
| 7558 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 7558 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 7559 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 7559 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 7560 int visitSwitchStatement(ast.SwitchStatement node) => | 7560 int visitSwitchStatement(ast.SwitchStatement node) => |
| 7561 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 7561 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
| 7562 } | 7562 } |
| OLD | NEW |