Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2746293006: Pulling the element model out of global type inference. (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 typeBuilder = new TypeBuilder(this); 146 typeBuilder = new TypeBuilder(this);
147 graph.element = targetElement; 147 graph.element = targetElement;
148 // TODO(het): Should sourceInformationBuilder be in GraphBuilder? 148 // TODO(het): Should sourceInformationBuilder be in GraphBuilder?
149 this.sourceInformationBuilder = 149 this.sourceInformationBuilder =
150 sourceInformationFactory.createBuilderForContext(resolvedAst); 150 sourceInformationFactory.createBuilderForContext(resolvedAst);
151 graph.sourceInformation = 151 graph.sourceInformation =
152 sourceInformationBuilder.buildVariableDeclaration(); 152 sourceInformationBuilder.buildVariableDeclaration();
153 this.localsHandler = new LocalsHandler(this, targetElement, null, compiler); 153 this.localsHandler = new LocalsHandler(this, targetElement, null, compiler);
154 this.astAdapter = new KernelAstAdapter(kernel, compiler.backend, 154 this.astAdapter = new KernelAstAdapter(kernel, compiler.backend,
155 resolvedAst, kernel.nodeToAst, kernel.nodeToElement); 155 resolvedAst, kernel.nodeToAst, kernel.nodeToElement);
156 Element originTarget = targetElement; 156 target = astAdapter.getInitialKernelNode(targetElement);
157 if (originTarget.isPatch) { 157 if (targetElement is FunctionElement &&
Siggi Cherem (dart-lang) 2017/03/16 00:37:45 I think you can drop this check too (since Constru
Emily Fortuna 2017/03/17 01:03:02 ah, touche!
158 originTarget = originTarget.origin; 158 targetElement is ConstructorBodyElement) {
159 } 159 _targetIsConstructorBody = true;
160 if (originTarget is FunctionElement) {
161 if (originTarget is ConstructorBodyElement) {
162 ConstructorBodyElement body = originTarget;
163 _targetIsConstructorBody = true;
164 originTarget = body.constructor;
165 }
166 target = kernel.functions[originTarget];
167 // Closures require a lookup one level deeper in the closure class mapper.
168 if (target == null) {
169 FunctionElement originTargetFunction = originTarget;
170 ClosureClassMap classMap = compiler.closureToClassMapper
171 .getClosureToClassMapping(originTargetFunction.resolvedAst);
172 if (classMap.closureElement != null) {
173 target = kernel.localFunctions[classMap.closureElement];
174 }
175 }
176 } else if (originTarget is FieldElement) {
177 target = kernel.fields[originTarget];
178 } 160 }
179 } 161 }
180 162
181 HGraph build() { 163 HGraph build() {
182 // TODO(het): no reason to do this here... 164 // TODO(het): no reason to do this here...
183 HInstruction.idCounter = 0; 165 HInstruction.idCounter = 0;
184 if (target is ir.Procedure) { 166 if (target is ir.Procedure) {
185 _targetFunction = (target as ir.Procedure).function; 167 _targetFunction = (target as ir.Procedure).function;
186 buildFunctionNode(_targetFunction); 168 buildFunctionNode(_targetFunction);
187 } else if (target is ir.Field) { 169 } else if (target is ir.Field) {
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 } 841 }
860 842
861 loopHandler.handleLoop(forInStatement, buildInitializer, buildCondition, 843 loopHandler.handleLoop(forInStatement, buildInitializer, buildCondition,
862 buildUpdate, buildBody); 844 buildUpdate, buildBody);
863 } 845 }
864 846
865 _buildForInIterator(ir.ForInStatement forInStatement) { 847 _buildForInIterator(ir.ForInStatement forInStatement) {
866 // Generate a structure equivalent to: 848 // Generate a structure equivalent to:
867 // Iterator<E> $iter = <iterable>.iterator; 849 // Iterator<E> $iter = <iterable>.iterator;
868 // while ($iter.moveNext()) { 850 // while ($iter.moveNext()) {
869 // <declaredIdentifier> = $iter.current; 851 // <variable> = $iter.current;
870 // <body> 852 // <body>
871 // } 853 // }
872 854
873 // The iterator is shared between initializer, condition and body. 855 // The iterator is shared between initializer, condition and body.
874 HInstruction iterator; 856 HInstruction iterator;
875 857
876 void buildInitializer() { 858 void buildInitializer() {
877 TypeMask mask = astAdapter.typeOfIterator(forInStatement); 859 TypeMask mask = astAdapter.typeOfIterator(forInStatement);
878 forInStatement.iterable.accept(this); 860 forInStatement.iterable.accept(this);
879 HInstruction receiver = pop(); 861 HInstruction receiver = pop();
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3253 enterBlock.setBlockFlow( 3235 enterBlock.setBlockFlow(
3254 new HTryBlockInformation( 3236 new HTryBlockInformation(
3255 kernelBuilder.wrapStatementGraph(bodyGraph), 3237 kernelBuilder.wrapStatementGraph(bodyGraph),
3256 exception, 3238 exception,
3257 kernelBuilder.wrapStatementGraph(catchGraph), 3239 kernelBuilder.wrapStatementGraph(catchGraph),
3258 kernelBuilder.wrapStatementGraph(finallyGraph)), 3240 kernelBuilder.wrapStatementGraph(finallyGraph)),
3259 exitBlock); 3241 exitBlock);
3260 kernelBuilder.inTryStatement = previouslyInTryStatement; 3242 kernelBuilder.inTryStatement = previouslyInTryStatement;
3261 } 3243 }
3262 } 3244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698