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

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
« no previous file with comments | « pkg/compiler/lib/src/options.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ConstructorBodyElement) {
158 originTarget = originTarget.origin; 158 _targetIsConstructorBody = true;
159 }
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 } 159 }
179 } 160 }
180 161
181 HGraph build() { 162 HGraph build() {
182 // TODO(het): no reason to do this here... 163 // TODO(het): no reason to do this here...
183 HInstruction.idCounter = 0; 164 HInstruction.idCounter = 0;
184 if (target is ir.Procedure) { 165 if (target is ir.Procedure) {
185 _targetFunction = (target as ir.Procedure).function; 166 _targetFunction = (target as ir.Procedure).function;
186 buildFunctionNode(_targetFunction); 167 buildFunctionNode(_targetFunction);
187 } else if (target is ir.Field) { 168 } else if (target is ir.Field) {
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 } 840 }
860 841
861 loopHandler.handleLoop(forInStatement, buildInitializer, buildCondition, 842 loopHandler.handleLoop(forInStatement, buildInitializer, buildCondition,
862 buildUpdate, buildBody); 843 buildUpdate, buildBody);
863 } 844 }
864 845
865 _buildForInIterator(ir.ForInStatement forInStatement) { 846 _buildForInIterator(ir.ForInStatement forInStatement) {
866 // Generate a structure equivalent to: 847 // Generate a structure equivalent to:
867 // Iterator<E> $iter = <iterable>.iterator; 848 // Iterator<E> $iter = <iterable>.iterator;
868 // while ($iter.moveNext()) { 849 // while ($iter.moveNext()) {
869 // <declaredIdentifier> = $iter.current; 850 // <variable> = $iter.current;
870 // <body> 851 // <body>
871 // } 852 // }
872 853
873 // The iterator is shared between initializer, condition and body. 854 // The iterator is shared between initializer, condition and body.
874 HInstruction iterator; 855 HInstruction iterator;
875 856
876 void buildInitializer() { 857 void buildInitializer() {
877 TypeMask mask = astAdapter.typeOfIterator(forInStatement); 858 TypeMask mask = astAdapter.typeOfIterator(forInStatement);
878 forInStatement.iterable.accept(this); 859 forInStatement.iterable.accept(this);
879 HInstruction receiver = pop(); 860 HInstruction receiver = pop();
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 enterBlock.setBlockFlow( 3228 enterBlock.setBlockFlow(
3248 new HTryBlockInformation( 3229 new HTryBlockInformation(
3249 kernelBuilder.wrapStatementGraph(bodyGraph), 3230 kernelBuilder.wrapStatementGraph(bodyGraph),
3250 exception, 3231 exception,
3251 kernelBuilder.wrapStatementGraph(catchGraph), 3232 kernelBuilder.wrapStatementGraph(catchGraph),
3252 kernelBuilder.wrapStatementGraph(finallyGraph)), 3233 kernelBuilder.wrapStatementGraph(finallyGraph)),
3253 exitBlock); 3234 exitBlock);
3254 kernelBuilder.inTryStatement = previouslyInTryStatement; 3235 kernelBuilder.inTryStatement = previouslyInTryStatement;
3255 } 3236 }
3256 } 3237 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/options.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698