| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 fieldValues[fieldParameterElement.fieldElement] = argument; | 932 fieldValues[fieldParameterElement.fieldElement] = argument; |
| 933 } | 933 } |
| 934 }); | 934 }); |
| 935 | 935 |
| 936 // Build the initializers in the context of the new constructor. | 936 // Build the initializers in the context of the new constructor. |
| 937 TreeElements oldElements = elements; | 937 TreeElements oldElements = elements; |
| 938 elements = compiler.resolver.resolveMethodElement(constructor); | 938 elements = compiler.resolver.resolveMethodElement(constructor); |
| 939 buildInitializers(constructor, constructors, fieldValues); | 939 buildInitializers(constructor, constructors, fieldValues); |
| 940 elements = oldElements; | 940 elements = oldElements; |
| 941 } | 941 } |
| 942 |
| 942 /** | 943 /** |
| 943 * Run through the initializers and inline all field initializers. Recursively | 944 * Run through the initializers and inline all field initializers. Recursively |
| 944 * inlines super initializers. | 945 * inlines super initializers. |
| 945 * | 946 * |
| 946 * The constructors of the inlined initializers is added to [constructors] | 947 * The constructors of the inlined initializers is added to [constructors] |
| 947 * with sub constructors having a lower index than super constructors. | 948 * with sub constructors having a lower index than super constructors. |
| 948 */ | 949 */ |
| 949 void buildInitializers(FunctionElement constructor, | 950 void buildInitializers(FunctionElement constructor, |
| 950 List<FunctionElement> constructors, | 951 List<FunctionElement> constructors, |
| 951 Map<Element, HInstruction> fieldValues) { | 952 Map<Element, HInstruction> fieldValues) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 params.forEachParameter((Element element) { | 1027 params.forEachParameter((Element element) { |
| 1027 if (element.kind == ElementKind.FIELD_PARAMETER) { | 1028 if (element.kind == ElementKind.FIELD_PARAMETER) { |
| 1028 // If the [element] is a field-parameter (such as [:this.x:] then | 1029 // If the [element] is a field-parameter (such as [:this.x:] then |
| 1029 // initialize the field element with its value. | 1030 // initialize the field element with its value. |
| 1030 FieldParameterElement fieldParameterElement = element; | 1031 FieldParameterElement fieldParameterElement = element; |
| 1031 HInstruction parameterValue = localsHandler.readLocal(element); | 1032 HInstruction parameterValue = localsHandler.readLocal(element); |
| 1032 fieldValues[fieldParameterElement.fieldElement] = parameterValue; | 1033 fieldValues[fieldParameterElement.fieldElement] = parameterValue; |
| 1033 } | 1034 } |
| 1034 }); | 1035 }); |
| 1035 | 1036 |
| 1036 final Map<FunctionElement, TreeElements> constructorElements = | |
| 1037 compiler.resolver.constructorElements; | |
| 1038 List<FunctionElement> constructors = <FunctionElement>[functionElement]; | 1037 List<FunctionElement> constructors = <FunctionElement>[functionElement]; |
| 1039 | 1038 |
| 1040 // Analyze the constructor and all referenced constructors and collect | 1039 // Analyze the constructor and all referenced constructors and collect |
| 1041 // initializers and constructor bodies. | 1040 // initializers and constructor bodies. |
| 1042 buildInitializers(functionElement, constructors, fieldValues); | 1041 buildInitializers(functionElement, constructors, fieldValues); |
| 1043 | 1042 |
| 1044 // Call the JavaScript constructor with the fields as argument. | 1043 // Call the JavaScript constructor with the fields as argument. |
| 1045 List<HInstruction> constructorArguments = <HInstruction>[]; | 1044 List<HInstruction> constructorArguments = <HInstruction>[]; |
| 1046 classElement.forEachInstanceField( | 1045 classElement.forEachInstanceField( |
| 1047 includeBackendMembers: true, | 1046 includeBackendMembers: true, |
| (...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3625 new HSubGraphBlockInformation(elseBranch.graph)); | 3624 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3626 | 3625 |
| 3627 HBasicBlock conditionStartBlock = conditionBranch.block; | 3626 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3628 conditionStartBlock.setBlockFlow(info, joinBlock); | 3627 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3629 SubGraph conditionGraph = conditionBranch.graph; | 3628 SubGraph conditionGraph = conditionBranch.graph; |
| 3630 HIf branch = conditionGraph.end.last; | 3629 HIf branch = conditionGraph.end.last; |
| 3631 assert(branch is HIf); | 3630 assert(branch is HIf); |
| 3632 branch.blockInformation = conditionStartBlock.blockFlow; | 3631 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3633 } | 3632 } |
| 3634 } | 3633 } |
| OLD | NEW |