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

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.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/ssa/builder_kernel.dart ('k') | no next file » | 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:js_runtime/shared/embedded_names.dart'; 5 import 'package:js_runtime/shared/embedded_names.dart';
6 import 'package:kernel/ast.dart' as ir; 6 import 'package:kernel/ast.dart' as ir;
7 7
8 import '../closure.dart';
8 import '../common.dart'; 9 import '../common.dart';
9 import '../compiler.dart'; 10 import '../compiler.dart';
10 import '../constants/expressions.dart'; 11 import '../constants/expressions.dart';
11 import '../constants/values.dart'; 12 import '../constants/values.dart';
12 import '../common_elements.dart'; 13 import '../common_elements.dart';
13 import '../elements/resolution_types.dart'; 14 import '../elements/resolution_types.dart';
14 import '../elements/elements.dart'; 15 import '../elements/elements.dart';
15 import '../elements/entities.dart'; 16 import '../elements/entities.dart';
16 import '../elements/modelx.dart'; 17 import '../elements/modelx.dart';
17 import '../elements/types.dart'; 18 import '../elements/types.dart';
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 80 }
80 for (LocalFunctionElement localFunction in kernel.localFunctions.keys) { 81 for (LocalFunctionElement localFunction in kernel.localFunctions.keys) {
81 _nodeToElement[kernel.localFunctions[localFunction]] = localFunction; 82 _nodeToElement[kernel.localFunctions[localFunction]] = localFunction;
82 } 83 }
83 for (TypeVariableElement typeVariable in kernel.typeParameters.keys) { 84 for (TypeVariableElement typeVariable in kernel.typeParameters.keys) {
84 _nodeToElement[kernel.typeParameters[typeVariable]] = typeVariable; 85 _nodeToElement[kernel.typeParameters[typeVariable]] = typeVariable;
85 } 86 }
86 _typeConverter = new DartTypeConverter(this); 87 _typeConverter = new DartTypeConverter(this);
87 } 88 }
88 89
90 /// Called to find the corresponding Kernel element for a particular Element
91 /// before traversing over it with a Kernel visitor.
92 ir.Node getInitialKernelNode(Element originTarget) {
93 ir.Node target;
94 if (originTarget.isPatch) {
95 originTarget = originTarget.origin;
96 }
97 if (originTarget is FunctionElement) {
98 if (originTarget is ConstructorBodyElement) {
99 ConstructorBodyElement body = originTarget;
100 originTarget = body.constructor;
101 }
102 target = kernel.functions[originTarget];
103 // Closures require a lookup one level deeper in the closure class mapper.
104 if (target == null) {
105 FunctionElement originTargetFunction = originTarget;
106 ClosureClassMap classMap = _compiler.closureToClassMapper
107 .getClosureToClassMapping(originTargetFunction.resolvedAst);
108 if (classMap.closureElement != null) {
109 target = kernel.localFunctions[classMap.closureElement];
110 }
111 }
112 } else if (originTarget is FieldElement) {
113 target = kernel.fields[originTarget];
114 }
115 assert(target != null);
116 return target;
117 }
118
89 @override 119 @override
90 CommonElements get commonElements => _compiler.commonElements; 120 CommonElements get commonElements => _compiler.commonElements;
91 121
92 @override 122 @override
93 ElementEnvironment get elementEnvironment => _compiler.elementEnvironment; 123 ElementEnvironment get elementEnvironment => _compiler.elementEnvironment;
94 124
95 /// Push the existing resolved AST on the stack and shift the current resolved 125 /// Push the existing resolved AST on the stack and shift the current resolved
96 /// AST to the AST that this kernel node points to. 126 /// AST to the AST that this kernel node points to.
97 void pushResolvedAst(ir.Node node) { 127 void pushResolvedAst(ir.Node node) {
98 _resolvedAstStack.add(_resolvedAst); 128 _resolvedAstStack.add(_resolvedAst);
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 JumpTarget continueTarget = 824 JumpTarget continueTarget =
795 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); 825 astAdapter.getJumpTarget(switchCase, isContinueTarget: true);
796 assert(continueTarget is KernelJumpTarget); 826 assert(continueTarget is KernelJumpTarget);
797 targetIndexMap[continueTarget] = switchIndex; 827 targetIndexMap[continueTarget] = switchIndex;
798 assert(builder.jumpTargets[continueTarget] == null); 828 assert(builder.jumpTargets[continueTarget] == null);
799 builder.jumpTargets[continueTarget] = this; 829 builder.jumpTargets[continueTarget] = this;
800 switchIndex++; 830 switchIndex++;
801 } 831 }
802 } 832 }
803 } 833 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698