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

Side by Side Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2013883003: Migrate UnlinkedVariable.constExpr to UnlinkedExecutable.bodyExpr. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix a comment Created 4 years, 7 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/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.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 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 */ 1623 */
1624 final VariableElementForLink variableElement; 1624 final VariableElementForLink variableElement;
1625 1625
1626 ConstVariableNode(this.variableElement); 1626 ConstVariableNode(this.variableElement);
1627 1627
1628 @override 1628 @override
1629 List<ConstNode> computeDependencies() { 1629 List<ConstNode> computeDependencies() {
1630 List<ConstNode> dependencies = <ConstNode>[]; 1630 List<ConstNode> dependencies = <ConstNode>[];
1631 collectDependencies( 1631 collectDependencies(
1632 dependencies, 1632 dependencies,
1633 variableElement.unlinkedVariable.constExpr, 1633 variableElement.unlinkedVariable.initializer?.bodyExpr,
1634 variableElement.compilationUnit); 1634 variableElement.compilationUnit);
1635 return dependencies; 1635 return dependencies;
1636 } 1636 }
1637 } 1637 }
1638 1638
1639 /** 1639 /**
1640 * Stub implementation of [AnalysisContext] which provides just those methods 1640 * Stub implementation of [AnalysisContext] which provides just those methods
1641 * needed during linking. 1641 * needed during linking.
1642 */ 1642 */
1643 class ContextForLink implements AnalysisContext { 1643 class ContextForLink implements AnalysisContext {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 int strPtr = 0; 1986 int strPtr = 0;
1987 int assignmentOperatorPtr = 0; 1987 int assignmentOperatorPtr = 0;
1988 1988
1989 ExprTypeComputer(VariableElementForLink variableElement) { 1989 ExprTypeComputer(VariableElementForLink variableElement) {
1990 this.variable = variableElement; 1990 this.variable = variableElement;
1991 initializer = variableElement.initializer; 1991 initializer = variableElement.initializer;
1992 unit = variableElement.compilationUnit; 1992 unit = variableElement.compilationUnit;
1993 library = unit.enclosingElement; 1993 library = unit.enclosingElement;
1994 linker = library._linker; 1994 linker = library._linker;
1995 typeProvider = linker.typeProvider; 1995 typeProvider = linker.typeProvider;
1996 unlinkedConst = variableElement.unlinkedVariable.constExpr; 1996 unlinkedConst = variableElement.unlinkedVariable.initializer?.bodyExpr;
1997 } 1997 }
1998 1998
1999 DartType compute() { 1999 DartType compute() {
2000 // Perform RPN evaluation of the constant, using a stack of inferred types. 2000 // Perform RPN evaluation of the constant, using a stack of inferred types.
2001 for (UnlinkedConstOperation operation in unlinkedConst.operations) { 2001 for (UnlinkedConstOperation operation in unlinkedConst.operations) {
2002 switch (operation) { 2002 switch (operation) {
2003 case UnlinkedConstOperation.pushInt: 2003 case UnlinkedConstOperation.pushInt:
2004 intPtr++; 2004 intPtr++;
2005 stack.add(typeProvider.intType); 2005 stack.add(typeProvider.intType);
2006 break; 2006 break;
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4381 } 4381 }
4382 } 4382 }
4383 assert(refPtr == unlinkedConst.references.length); 4383 assert(refPtr == unlinkedConst.references.length);
4384 } 4384 }
4385 4385
4386 @override 4386 @override
4387 List<TypeInferenceNode> computeDependencies() { 4387 List<TypeInferenceNode> computeDependencies() {
4388 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[]; 4388 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[];
4389 collectDependencies( 4389 collectDependencies(
4390 dependencies, 4390 dependencies,
4391 variableElement.unlinkedVariable.constExpr, 4391 variableElement.unlinkedVariable.initializer?.bodyExpr,
4392 variableElement.compilationUnit); 4392 variableElement.compilationUnit);
4393 return dependencies; 4393 return dependencies;
4394 } 4394 }
4395 4395
4396 void evaluate(bool inCycle) { 4396 void evaluate(bool inCycle) {
4397 if (inCycle) { 4397 if (inCycle) {
4398 variableElement._inferredType = DynamicTypeImpl.instance; 4398 variableElement._inferredType = DynamicTypeImpl.instance;
4399 } else { 4399 } else {
4400 variableElement._inferredType = 4400 variableElement._inferredType =
4401 new ExprTypeComputer(variableElement).compute(); 4401 new ExprTypeComputer(variableElement).compute();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
4595 DartType _declaredType; 4595 DartType _declaredType;
4596 PropertyAccessorElementForLink_Variable _getter; 4596 PropertyAccessorElementForLink_Variable _getter;
4597 PropertyAccessorElementForLink_Variable _setter; 4597 PropertyAccessorElementForLink_Variable _setter;
4598 4598
4599 /** 4599 /**
4600 * The compilation unit in which this variable appears. 4600 * The compilation unit in which this variable appears.
4601 */ 4601 */
4602 final CompilationUnitElementForLink compilationUnit; 4602 final CompilationUnitElementForLink compilationUnit;
4603 4603
4604 VariableElementForLink(this.unlinkedVariable, this.compilationUnit) { 4604 VariableElementForLink(this.unlinkedVariable, this.compilationUnit) {
4605 if (compilationUnit.isInBuildUnit && unlinkedVariable.constExpr != null) { 4605 if (compilationUnit.isInBuildUnit &&
4606 unlinkedVariable.initializer?.bodyExpr != null) {
4606 _constNode = new ConstVariableNode(this); 4607 _constNode = new ConstVariableNode(this);
4607 if (unlinkedVariable.type == null) { 4608 if (unlinkedVariable.type == null) {
4608 _typeInferenceNode = new TypeInferenceNode(this); 4609 _typeInferenceNode = new TypeInferenceNode(this);
4609 } 4610 }
4610 } 4611 }
4611 } 4612 }
4612 4613
4613 /** 4614 /**
4614 * If the variable has an explicitly declared return type, return it. 4615 * If the variable has an explicitly declared return type, return it.
4615 * Otherwise return `null`. 4616 * Otherwise return `null`.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4711 * there are no type parameters in scope. 4712 * there are no type parameters in scope.
4712 */ 4713 */
4713 TypeParameterizedElementMixin get _typeParameterContext; 4714 TypeParameterizedElementMixin get _typeParameterContext;
4714 4715
4715 @override 4716 @override
4716 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4717 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4717 4718
4718 @override 4719 @override
4719 String toString() => '$enclosingElement.$name'; 4720 String toString() => '$enclosingElement.$name';
4720 } 4721 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698