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

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

Issue 2508343002: Rename UnlinkedConst -> UnlinkedExpr (Closed)
Patch Set: Created 4 years, 1 month 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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 ConstructorElementForLink constructor = constructorElement 1442 ConstructorElementForLink constructor = constructorElement
1443 .enclosingClass 1443 .enclosingClass
1444 .getContainedName(constructorInitializer.name) 1444 .getContainedName(constructorInitializer.name)
1445 .asConstructor; 1445 .asConstructor;
1446 safeAddDependency(constructor?._constNode); 1446 safeAddDependency(constructor?._constNode);
1447 } 1447 }
1448 CompilationUnitElementForLink compilationUnit = 1448 CompilationUnitElementForLink compilationUnit =
1449 constructorElement.enclosingElement.enclosingElement; 1449 constructorElement.enclosingElement.enclosingElement;
1450 collectDependencies( 1450 collectDependencies(
1451 dependencies, constructorInitializer.expression, compilationUnit); 1451 dependencies, constructorInitializer.expression, compilationUnit);
1452 for (UnlinkedConst unlinkedConst in constructorInitializer.arguments) { 1452 for (UnlinkedExpr unlinkedConst in constructorInitializer.arguments) {
1453 collectDependencies(dependencies, unlinkedConst, compilationUnit); 1453 collectDependencies(dependencies, unlinkedConst, compilationUnit);
1454 } 1454 }
1455 } 1455 }
1456 1456
1457 if (defaultSuperInvocationNeeded) { 1457 if (defaultSuperInvocationNeeded) {
1458 // No explicit superconstructor invocation found, so we need to 1458 // No explicit superconstructor invocation found, so we need to
1459 // manually insert a reference to the implicit superconstructor. 1459 // manually insert a reference to the implicit superconstructor.
1460 if (superClass != null && !superClass.isObject) { 1460 if (superClass != null && !superClass.isObject) {
1461 ConstructorElementForLink unnamedConstructor = 1461 ConstructorElementForLink unnamedConstructor =
1462 superClass.unnamedConstructor; 1462 superClass.unnamedConstructor;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 @override 1527 @override
1528 bool isEvaluated = false; 1528 bool isEvaluated = false;
1529 1529
1530 /** 1530 /**
1531 * Collect the dependencies in [unlinkedConst] (which should be 1531 * Collect the dependencies in [unlinkedConst] (which should be
1532 * interpreted relative to [compilationUnit]) and store them in 1532 * interpreted relative to [compilationUnit]) and store them in
1533 * [dependencies]. 1533 * [dependencies].
1534 */ 1534 */
1535 void collectDependencies( 1535 void collectDependencies(
1536 List<ConstNode> dependencies, 1536 List<ConstNode> dependencies,
1537 UnlinkedConst unlinkedConst, 1537 UnlinkedExpr unlinkedConst,
1538 CompilationUnitElementForLink compilationUnit) { 1538 CompilationUnitElementForLink compilationUnit) {
1539 if (unlinkedConst == null) { 1539 if (unlinkedConst == null) {
1540 return; 1540 return;
1541 } 1541 }
1542 int refPtr = 0; 1542 int refPtr = 0;
1543 int intPtr = 0; 1543 int intPtr = 0;
1544 for (UnlinkedConstOperation operation in unlinkedConst.operations) { 1544 for (UnlinkedExprOperation operation in unlinkedConst.operations) {
1545 switch (operation) { 1545 switch (operation) {
1546 case UnlinkedConstOperation.pushInt: 1546 case UnlinkedExprOperation.pushInt:
1547 intPtr++; 1547 intPtr++;
1548 break; 1548 break;
1549 case UnlinkedConstOperation.pushLongInt: 1549 case UnlinkedExprOperation.pushLongInt:
1550 int numInts = unlinkedConst.ints[intPtr++]; 1550 int numInts = unlinkedConst.ints[intPtr++];
1551 intPtr += numInts; 1551 intPtr += numInts;
1552 break; 1552 break;
1553 case UnlinkedConstOperation.concatenate: 1553 case UnlinkedExprOperation.concatenate:
1554 intPtr++; 1554 intPtr++;
1555 break; 1555 break;
1556 case UnlinkedConstOperation.pushReference: 1556 case UnlinkedExprOperation.pushReference:
1557 EntityRef ref = unlinkedConst.references[refPtr++]; 1557 EntityRef ref = unlinkedConst.references[refPtr++];
1558 ConstVariableNode variable = 1558 ConstVariableNode variable =
1559 compilationUnit.resolveRef(ref.reference).asConstVariable; 1559 compilationUnit.resolveRef(ref.reference).asConstVariable;
1560 if (variable != null) { 1560 if (variable != null) {
1561 dependencies.add(variable); 1561 dependencies.add(variable);
1562 } 1562 }
1563 break; 1563 break;
1564 case UnlinkedConstOperation.makeUntypedList: 1564 case UnlinkedExprOperation.makeUntypedList:
1565 case UnlinkedConstOperation.makeUntypedMap: 1565 case UnlinkedExprOperation.makeUntypedMap:
1566 intPtr++; 1566 intPtr++;
1567 break; 1567 break;
1568 case UnlinkedConstOperation.assignToRef: 1568 case UnlinkedExprOperation.assignToRef:
1569 refPtr++; 1569 refPtr++;
1570 break; 1570 break;
1571 case UnlinkedConstOperation.invokeMethodRef: 1571 case UnlinkedExprOperation.invokeMethodRef:
1572 EntityRef ref = unlinkedConst.references[refPtr++]; 1572 EntityRef ref = unlinkedConst.references[refPtr++];
1573 ConstVariableNode variable = 1573 ConstVariableNode variable =
1574 compilationUnit.resolveRef(ref.reference).asConstVariable; 1574 compilationUnit.resolveRef(ref.reference).asConstVariable;
1575 if (variable != null) { 1575 if (variable != null) {
1576 dependencies.add(variable); 1576 dependencies.add(variable);
1577 } 1577 }
1578 intPtr += 2; 1578 intPtr += 2;
1579 int numTypeArguments = unlinkedConst.ints[intPtr++]; 1579 int numTypeArguments = unlinkedConst.ints[intPtr++];
1580 refPtr += numTypeArguments; 1580 refPtr += numTypeArguments;
1581 break; 1581 break;
1582 case UnlinkedConstOperation.invokeMethod: 1582 case UnlinkedExprOperation.invokeMethod:
1583 intPtr += 2; 1583 intPtr += 2;
1584 int numTypeArguments = unlinkedConst.ints[intPtr++]; 1584 int numTypeArguments = unlinkedConst.ints[intPtr++];
1585 refPtr += numTypeArguments; 1585 refPtr += numTypeArguments;
1586 break; 1586 break;
1587 case UnlinkedConstOperation.makeTypedList: 1587 case UnlinkedExprOperation.makeTypedList:
1588 refPtr++; 1588 refPtr++;
1589 intPtr++; 1589 intPtr++;
1590 break; 1590 break;
1591 case UnlinkedConstOperation.makeTypedMap: 1591 case UnlinkedExprOperation.makeTypedMap:
1592 refPtr += 2; 1592 refPtr += 2;
1593 intPtr++; 1593 intPtr++;
1594 break; 1594 break;
1595 case UnlinkedConstOperation.invokeConstructor: 1595 case UnlinkedExprOperation.invokeConstructor:
1596 EntityRef ref = unlinkedConst.references[refPtr++]; 1596 EntityRef ref = unlinkedConst.references[refPtr++];
1597 ConstructorElementForLink element = 1597 ConstructorElementForLink element =
1598 compilationUnit.resolveRef(ref.reference).asConstructor; 1598 compilationUnit.resolveRef(ref.reference).asConstructor;
1599 if (element?._constNode != null) { 1599 if (element?._constNode != null) {
1600 dependencies.add(element._constNode); 1600 dependencies.add(element._constNode);
1601 } 1601 }
1602 intPtr += 2; 1602 intPtr += 2;
1603 break; 1603 break;
1604 case UnlinkedConstOperation.typeCast: 1604 case UnlinkedExprOperation.typeCast:
1605 case UnlinkedConstOperation.typeCheck: 1605 case UnlinkedExprOperation.typeCheck:
1606 refPtr++; 1606 refPtr++;
1607 break; 1607 break;
1608 case UnlinkedConstOperation.pushLocalFunctionReference: 1608 case UnlinkedExprOperation.pushLocalFunctionReference:
1609 intPtr += 2; 1609 intPtr += 2;
1610 break; 1610 break;
1611 default: 1611 default:
1612 break; 1612 break;
1613 } 1613 }
1614 } 1614 }
1615 assert(refPtr == unlinkedConst.references.length); 1615 assert(refPtr == unlinkedConst.references.length);
1616 assert(intPtr == unlinkedConst.ints.length); 1616 assert(intPtr == unlinkedConst.ints.length);
1617 } 1617 }
1618 } 1618 }
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 } 2065 }
2066 } 2066 }
2067 } 2067 }
2068 2068
2069 class ExprTypeComputer { 2069 class ExprTypeComputer {
2070 final FunctionElementForLink_Local function; 2070 final FunctionElementForLink_Local function;
2071 final CompilationUnitElementForLink unit; 2071 final CompilationUnitElementForLink unit;
2072 final LibraryElementForLink library; 2072 final LibraryElementForLink library;
2073 final Linker linker; 2073 final Linker linker;
2074 final TypeProvider typeProvider; 2074 final TypeProvider typeProvider;
2075 final UnlinkedConst unlinkedConst; 2075 final UnlinkedExpr unlinkedConst;
2076 2076
2077 final List<DartType> stack = <DartType>[]; 2077 final List<DartType> stack = <DartType>[];
2078 int intPtr = 0; 2078 int intPtr = 0;
2079 int refPtr = 0; 2079 int refPtr = 0;
2080 int strPtr = 0; 2080 int strPtr = 0;
2081 int assignmentOperatorPtr = 0; 2081 int assignmentOperatorPtr = 0;
2082 2082
2083 factory ExprTypeComputer(FunctionElementForLink_Local functionElement) { 2083 factory ExprTypeComputer(FunctionElementForLink_Local functionElement) {
2084 CompilationUnitElementForLink unit = functionElement.compilationUnit; 2084 CompilationUnitElementForLink unit = functionElement.compilationUnit;
2085 LibraryElementForLink library = unit.enclosingElement; 2085 LibraryElementForLink library = unit.enclosingElement;
2086 Linker linker = library._linker; 2086 Linker linker = library._linker;
2087 TypeProvider typeProvider = linker.typeProvider; 2087 TypeProvider typeProvider = linker.typeProvider;
2088 UnlinkedConst unlinkedConst = functionElement._unlinkedExecutable.bodyExpr; 2088 UnlinkedExpr unlinkedConst = functionElement._unlinkedExecutable.bodyExpr;
2089 return new ExprTypeComputer._( 2089 return new ExprTypeComputer._(
2090 functionElement, unit, library, linker, typeProvider, unlinkedConst); 2090 functionElement, unit, library, linker, typeProvider, unlinkedConst);
2091 } 2091 }
2092 2092
2093 ExprTypeComputer._(this.function, this.unit, this.library, this.linker, 2093 ExprTypeComputer._(this.function, this.unit, this.library, this.linker,
2094 this.typeProvider, this.unlinkedConst); 2094 this.typeProvider, this.unlinkedConst);
2095 2095
2096 DartType compute() { 2096 DartType compute() {
2097 if (unlinkedConst == null) { 2097 if (unlinkedConst == null) {
2098 // No function body was stored for this function, so we can't infer its 2098 // No function body was stored for this function, so we can't infer its
2099 // return type. Assume `dynamic`. 2099 // return type. Assume `dynamic`.
2100 return DynamicTypeImpl.instance; 2100 return DynamicTypeImpl.instance;
2101 } 2101 }
2102 // Perform RPN evaluation of the constant, using a stack of inferred types. 2102 // Perform RPN evaluation of the constant, using a stack of inferred types.
2103 for (UnlinkedConstOperation operation in unlinkedConst.operations) { 2103 for (UnlinkedExprOperation operation in unlinkedConst.operations) {
2104 switch (operation) { 2104 switch (operation) {
2105 case UnlinkedConstOperation.pushInt: 2105 case UnlinkedExprOperation.pushInt:
2106 intPtr++; 2106 intPtr++;
2107 stack.add(typeProvider.intType); 2107 stack.add(typeProvider.intType);
2108 break; 2108 break;
2109 case UnlinkedConstOperation.pushLongInt: 2109 case UnlinkedExprOperation.pushLongInt:
2110 int numInts = _getNextInt(); 2110 int numInts = _getNextInt();
2111 intPtr += numInts; 2111 intPtr += numInts;
2112 stack.add(typeProvider.intType); 2112 stack.add(typeProvider.intType);
2113 break; 2113 break;
2114 case UnlinkedConstOperation.pushDouble: 2114 case UnlinkedExprOperation.pushDouble:
2115 stack.add(typeProvider.doubleType); 2115 stack.add(typeProvider.doubleType);
2116 break; 2116 break;
2117 case UnlinkedConstOperation.pushTrue: 2117 case UnlinkedExprOperation.pushTrue:
2118 case UnlinkedConstOperation.pushFalse: 2118 case UnlinkedExprOperation.pushFalse:
2119 stack.add(typeProvider.boolType); 2119 stack.add(typeProvider.boolType);
2120 break; 2120 break;
2121 case UnlinkedConstOperation.pushString: 2121 case UnlinkedExprOperation.pushString:
2122 strPtr++; 2122 strPtr++;
2123 stack.add(typeProvider.stringType); 2123 stack.add(typeProvider.stringType);
2124 break; 2124 break;
2125 case UnlinkedConstOperation.concatenate: 2125 case UnlinkedExprOperation.concatenate:
2126 stack.length -= _getNextInt(); 2126 stack.length -= _getNextInt();
2127 stack.add(typeProvider.stringType); 2127 stack.add(typeProvider.stringType);
2128 break; 2128 break;
2129 case UnlinkedConstOperation.makeSymbol: 2129 case UnlinkedExprOperation.makeSymbol:
2130 strPtr++; 2130 strPtr++;
2131 stack.add(typeProvider.symbolType); 2131 stack.add(typeProvider.symbolType);
2132 break; 2132 break;
2133 case UnlinkedConstOperation.pushNull: 2133 case UnlinkedExprOperation.pushNull:
2134 stack.add(BottomTypeImpl.instance); 2134 stack.add(BottomTypeImpl.instance);
2135 break; 2135 break;
2136 case UnlinkedConstOperation.pushReference: 2136 case UnlinkedExprOperation.pushReference:
2137 _doPushReference(); 2137 _doPushReference();
2138 break; 2138 break;
2139 case UnlinkedConstOperation.extractProperty: 2139 case UnlinkedExprOperation.extractProperty:
2140 _doExtractProperty(); 2140 _doExtractProperty();
2141 break; 2141 break;
2142 case UnlinkedConstOperation.invokeConstructor: 2142 case UnlinkedExprOperation.invokeConstructor:
2143 _doInvokeConstructor(); 2143 _doInvokeConstructor();
2144 break; 2144 break;
2145 case UnlinkedConstOperation.makeUntypedList: 2145 case UnlinkedExprOperation.makeUntypedList:
2146 _doMakeUntypedList(); 2146 _doMakeUntypedList();
2147 break; 2147 break;
2148 case UnlinkedConstOperation.makeUntypedMap: 2148 case UnlinkedExprOperation.makeUntypedMap:
2149 _doMakeUntypedMap(); 2149 _doMakeUntypedMap();
2150 break; 2150 break;
2151 case UnlinkedConstOperation.makeTypedList: 2151 case UnlinkedExprOperation.makeTypedList:
2152 _doMakeTypedList(); 2152 _doMakeTypedList();
2153 break; 2153 break;
2154 case UnlinkedConstOperation.makeTypedMap: 2154 case UnlinkedExprOperation.makeTypedMap:
2155 _doMakeTypeMap(); 2155 _doMakeTypeMap();
2156 break; 2156 break;
2157 case UnlinkedConstOperation.not: 2157 case UnlinkedExprOperation.not:
2158 stack.length -= 1; 2158 stack.length -= 1;
2159 stack.add(typeProvider.boolType); 2159 stack.add(typeProvider.boolType);
2160 break; 2160 break;
2161 case UnlinkedConstOperation.complement: 2161 case UnlinkedExprOperation.complement:
2162 _computePrefixExpressionType('~'); 2162 _computePrefixExpressionType('~');
2163 break; 2163 break;
2164 case UnlinkedConstOperation.negate: 2164 case UnlinkedExprOperation.negate:
2165 _computePrefixExpressionType('unary-'); 2165 _computePrefixExpressionType('unary-');
2166 break; 2166 break;
2167 case UnlinkedConstOperation.and: 2167 case UnlinkedExprOperation.and:
2168 case UnlinkedConstOperation.or: 2168 case UnlinkedExprOperation.or:
2169 case UnlinkedConstOperation.equal: 2169 case UnlinkedExprOperation.equal:
2170 case UnlinkedConstOperation.notEqual: 2170 case UnlinkedExprOperation.notEqual:
2171 stack.length -= 2; 2171 stack.length -= 2;
2172 stack.add(typeProvider.boolType); 2172 stack.add(typeProvider.boolType);
2173 break; 2173 break;
2174 case UnlinkedConstOperation.bitXor: 2174 case UnlinkedExprOperation.bitXor:
2175 _computeBinaryExpressionType(TokenType.CARET); 2175 _computeBinaryExpressionType(TokenType.CARET);
2176 break; 2176 break;
2177 case UnlinkedConstOperation.bitAnd: 2177 case UnlinkedExprOperation.bitAnd:
2178 _computeBinaryExpressionType(TokenType.AMPERSAND); 2178 _computeBinaryExpressionType(TokenType.AMPERSAND);
2179 break; 2179 break;
2180 case UnlinkedConstOperation.bitOr: 2180 case UnlinkedExprOperation.bitOr:
2181 _computeBinaryExpressionType(TokenType.BAR); 2181 _computeBinaryExpressionType(TokenType.BAR);
2182 break; 2182 break;
2183 case UnlinkedConstOperation.bitShiftRight: 2183 case UnlinkedExprOperation.bitShiftRight:
2184 _computeBinaryExpressionType(TokenType.GT_GT); 2184 _computeBinaryExpressionType(TokenType.GT_GT);
2185 break; 2185 break;
2186 case UnlinkedConstOperation.bitShiftLeft: 2186 case UnlinkedExprOperation.bitShiftLeft:
2187 _computeBinaryExpressionType(TokenType.LT_LT); 2187 _computeBinaryExpressionType(TokenType.LT_LT);
2188 break; 2188 break;
2189 case UnlinkedConstOperation.add: 2189 case UnlinkedExprOperation.add:
2190 _computeBinaryExpressionType(TokenType.PLUS); 2190 _computeBinaryExpressionType(TokenType.PLUS);
2191 break; 2191 break;
2192 case UnlinkedConstOperation.subtract: 2192 case UnlinkedExprOperation.subtract:
2193 _computeBinaryExpressionType(TokenType.MINUS); 2193 _computeBinaryExpressionType(TokenType.MINUS);
2194 break; 2194 break;
2195 case UnlinkedConstOperation.multiply: 2195 case UnlinkedExprOperation.multiply:
2196 _computeBinaryExpressionType(TokenType.STAR); 2196 _computeBinaryExpressionType(TokenType.STAR);
2197 break; 2197 break;
2198 case UnlinkedConstOperation.divide: 2198 case UnlinkedExprOperation.divide:
2199 _computeBinaryExpressionType(TokenType.SLASH); 2199 _computeBinaryExpressionType(TokenType.SLASH);
2200 break; 2200 break;
2201 case UnlinkedConstOperation.floorDivide: 2201 case UnlinkedExprOperation.floorDivide:
2202 _computeBinaryExpressionType(TokenType.TILDE_SLASH); 2202 _computeBinaryExpressionType(TokenType.TILDE_SLASH);
2203 break; 2203 break;
2204 case UnlinkedConstOperation.greater: 2204 case UnlinkedExprOperation.greater:
2205 _computeBinaryExpressionType(TokenType.GT); 2205 _computeBinaryExpressionType(TokenType.GT);
2206 break; 2206 break;
2207 case UnlinkedConstOperation.less: 2207 case UnlinkedExprOperation.less:
2208 _computeBinaryExpressionType(TokenType.LT); 2208 _computeBinaryExpressionType(TokenType.LT);
2209 break; 2209 break;
2210 case UnlinkedConstOperation.greaterEqual: 2210 case UnlinkedExprOperation.greaterEqual:
2211 _computeBinaryExpressionType(TokenType.GT_EQ); 2211 _computeBinaryExpressionType(TokenType.GT_EQ);
2212 break; 2212 break;
2213 case UnlinkedConstOperation.lessEqual: 2213 case UnlinkedExprOperation.lessEqual:
2214 _computeBinaryExpressionType(TokenType.LT_EQ); 2214 _computeBinaryExpressionType(TokenType.LT_EQ);
2215 break; 2215 break;
2216 case UnlinkedConstOperation.modulo: 2216 case UnlinkedExprOperation.modulo:
2217 _computeBinaryExpressionType(TokenType.PERCENT); 2217 _computeBinaryExpressionType(TokenType.PERCENT);
2218 break; 2218 break;
2219 case UnlinkedConstOperation.conditional: 2219 case UnlinkedExprOperation.conditional:
2220 _doConditional(); 2220 _doConditional();
2221 break; 2221 break;
2222 case UnlinkedConstOperation.assignToRef: 2222 case UnlinkedExprOperation.assignToRef:
2223 _doAssignToRef(); 2223 _doAssignToRef();
2224 break; 2224 break;
2225 case UnlinkedConstOperation.assignToProperty: 2225 case UnlinkedExprOperation.assignToProperty:
2226 _doAssignToProperty(); 2226 _doAssignToProperty();
2227 break; 2227 break;
2228 case UnlinkedConstOperation.assignToIndex: 2228 case UnlinkedExprOperation.assignToIndex:
2229 _doAssignToIndex(); 2229 _doAssignToIndex();
2230 break; 2230 break;
2231 case UnlinkedConstOperation.extractIndex: 2231 case UnlinkedExprOperation.extractIndex:
2232 _doExtractIndex(); 2232 _doExtractIndex();
2233 break; 2233 break;
2234 case UnlinkedConstOperation.invokeMethodRef: 2234 case UnlinkedExprOperation.invokeMethodRef:
2235 _doInvokeMethodRef(); 2235 _doInvokeMethodRef();
2236 break; 2236 break;
2237 case UnlinkedConstOperation.invokeMethod: 2237 case UnlinkedExprOperation.invokeMethod:
2238 _doInvokeMethod(); 2238 _doInvokeMethod();
2239 break; 2239 break;
2240 case UnlinkedConstOperation.cascadeSectionBegin: 2240 case UnlinkedExprOperation.cascadeSectionBegin:
2241 stack.add(stack.last); 2241 stack.add(stack.last);
2242 break; 2242 break;
2243 case UnlinkedConstOperation.cascadeSectionEnd: 2243 case UnlinkedExprOperation.cascadeSectionEnd:
2244 stack.removeLast(); 2244 stack.removeLast();
2245 break; 2245 break;
2246 case UnlinkedConstOperation.typeCast: 2246 case UnlinkedExprOperation.typeCast:
2247 stack.removeLast(); 2247 stack.removeLast();
2248 DartType type = _getNextTypeRef(); 2248 DartType type = _getNextTypeRef();
2249 stack.add(type); 2249 stack.add(type);
2250 break; 2250 break;
2251 case UnlinkedConstOperation.typeCheck: 2251 case UnlinkedExprOperation.typeCheck:
2252 stack.removeLast(); 2252 stack.removeLast();
2253 refPtr++; 2253 refPtr++;
2254 stack.add(typeProvider.boolType); 2254 stack.add(typeProvider.boolType);
2255 break; 2255 break;
2256 case UnlinkedConstOperation.throwException: 2256 case UnlinkedExprOperation.throwException:
2257 stack.removeLast(); 2257 stack.removeLast();
2258 stack.add(BottomTypeImpl.instance); 2258 stack.add(BottomTypeImpl.instance);
2259 break; 2259 break;
2260 case UnlinkedConstOperation.pushLocalFunctionReference: 2260 case UnlinkedExprOperation.pushLocalFunctionReference:
2261 int popCount = _getNextInt(); 2261 int popCount = _getNextInt();
2262 assert(popCount == 0); // TODO(paulberry): handle the nonzero case. 2262 assert(popCount == 0); // TODO(paulberry): handle the nonzero case.
2263 stack.add(function.functions[_getNextInt()].type); 2263 stack.add(function.functions[_getNextInt()].type);
2264 break; 2264 break;
2265 case UnlinkedConstOperation.pushParameter: 2265 case UnlinkedExprOperation.pushParameter:
2266 stack.add(_findParameterType(_getNextString())); 2266 stack.add(_findParameterType(_getNextString()));
2267 break; 2267 break;
2268 default: 2268 default:
2269 // TODO(paulberry): implement. 2269 // TODO(paulberry): implement.
2270 throw new UnimplementedError('$operation'); 2270 throw new UnimplementedError('$operation');
2271 } 2271 }
2272 } 2272 }
2273 assert(intPtr == unlinkedConst.ints.length); 2273 assert(intPtr == unlinkedConst.ints.length);
2274 assert(refPtr == unlinkedConst.references.length); 2274 assert(refPtr == unlinkedConst.references.length);
2275 assert(strPtr == unlinkedConst.strings.length); 2275 assert(strPtr == unlinkedConst.strings.length);
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
3996 @override 3996 @override
3997 void set inheritsCovariant(bool value) { 3997 void set inheritsCovariant(bool value) {
3998 _inheritsCovariant = value; 3998 _inheritsCovariant = value;
3999 } 3999 }
4000 4000
4001 @override 4001 @override
4002 bool get isCovariant { 4002 bool get isCovariant {
4003 if (inheritsCovariant) { 4003 if (inheritsCovariant) {
4004 return true; 4004 return true;
4005 } 4005 }
4006 for (UnlinkedConst annotation in _unlinkedParam.annotations) { 4006 for (UnlinkedExpr annotation in _unlinkedParam.annotations) {
4007 if (annotation.operations.length == 1 && 4007 if (annotation.operations.length == 1 &&
4008 annotation.operations[0] == UnlinkedConstOperation.pushReference) { 4008 annotation.operations[0] == UnlinkedExprOperation.pushReference) {
4009 ReferenceableElementForLink element = 4009 ReferenceableElementForLink element =
4010 this.compilationUnit.resolveRef(annotation.references[0].reference); 4010 this.compilationUnit.resolveRef(annotation.references[0].reference);
4011 if (element is PropertyAccessorElementForLink && 4011 if (element is PropertyAccessorElementForLink &&
4012 element.name == 'checked' && 4012 element.name == 'checked' &&
4013 element.library.name == 'meta') { 4013 element.library.name == 'meta') {
4014 return true; 4014 return true;
4015 } 4015 }
4016 } 4016 }
4017 } 4017 }
4018 return false; 4018 return false;
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4671 4671
4672 /** 4672 /**
4673 * Collect the type inference dependencies in [unlinkedExecutable] (which 4673 * Collect the type inference dependencies in [unlinkedExecutable] (which
4674 * should be interpreted relative to [compilationUnit]) and store them in 4674 * should be interpreted relative to [compilationUnit]) and store them in
4675 * [dependencies]. 4675 * [dependencies].
4676 */ 4676 */
4677 void collectDependencies( 4677 void collectDependencies(
4678 List<TypeInferenceNode> dependencies, 4678 List<TypeInferenceNode> dependencies,
4679 UnlinkedExecutable unlinkedExecutable, 4679 UnlinkedExecutable unlinkedExecutable,
4680 CompilationUnitElementForLink compilationUnit) { 4680 CompilationUnitElementForLink compilationUnit) {
4681 UnlinkedConst unlinkedConst = unlinkedExecutable?.bodyExpr; 4681 UnlinkedExpr unlinkedConst = unlinkedExecutable?.bodyExpr;
4682 if (unlinkedConst == null) { 4682 if (unlinkedConst == null) {
4683 return; 4683 return;
4684 } 4684 }
4685 int refPtr = 0; 4685 int refPtr = 0;
4686 int intPtr = 0; 4686 int intPtr = 0;
4687 4687
4688 for (UnlinkedConstOperation operation in unlinkedConst.operations) { 4688 for (UnlinkedExprOperation operation in unlinkedConst.operations) {
4689 switch (operation) { 4689 switch (operation) {
4690 case UnlinkedConstOperation.pushInt: 4690 case UnlinkedExprOperation.pushInt:
4691 intPtr++; 4691 intPtr++;
4692 break; 4692 break;
4693 case UnlinkedConstOperation.pushLongInt: 4693 case UnlinkedExprOperation.pushLongInt:
4694 int numInts = unlinkedConst.ints[intPtr++]; 4694 int numInts = unlinkedConst.ints[intPtr++];
4695 intPtr += numInts; 4695 intPtr += numInts;
4696 break; 4696 break;
4697 case UnlinkedConstOperation.concatenate: 4697 case UnlinkedExprOperation.concatenate:
4698 intPtr++; 4698 intPtr++;
4699 break; 4699 break;
4700 case UnlinkedConstOperation.pushReference: 4700 case UnlinkedExprOperation.pushReference:
4701 EntityRef ref = unlinkedConst.references[refPtr++]; 4701 EntityRef ref = unlinkedConst.references[refPtr++];
4702 // TODO(paulberry): cache these resolved references for 4702 // TODO(paulberry): cache these resolved references for
4703 // later use by evaluate(). 4703 // later use by evaluate().
4704 TypeInferenceNode dependency = 4704 TypeInferenceNode dependency =
4705 compilationUnit.resolveRef(ref.reference).asTypeInferenceNode; 4705 compilationUnit.resolveRef(ref.reference).asTypeInferenceNode;
4706 if (dependency != null) { 4706 if (dependency != null) {
4707 dependencies.add(dependency); 4707 dependencies.add(dependency);
4708 } 4708 }
4709 break; 4709 break;
4710 case UnlinkedConstOperation.invokeConstructor: 4710 case UnlinkedExprOperation.invokeConstructor:
4711 refPtr++; 4711 refPtr++;
4712 intPtr += 2; 4712 intPtr += 2;
4713 break; 4713 break;
4714 case UnlinkedConstOperation.makeUntypedList: 4714 case UnlinkedExprOperation.makeUntypedList:
4715 case UnlinkedConstOperation.makeUntypedMap: 4715 case UnlinkedExprOperation.makeUntypedMap:
4716 intPtr++; 4716 intPtr++;
4717 break; 4717 break;
4718 case UnlinkedConstOperation.makeTypedList: 4718 case UnlinkedExprOperation.makeTypedList:
4719 refPtr++; 4719 refPtr++;
4720 intPtr++; 4720 intPtr++;
4721 break; 4721 break;
4722 case UnlinkedConstOperation.makeTypedMap: 4722 case UnlinkedExprOperation.makeTypedMap:
4723 refPtr += 2; 4723 refPtr += 2;
4724 intPtr++; 4724 intPtr++;
4725 break; 4725 break;
4726 case UnlinkedConstOperation.assignToRef: 4726 case UnlinkedExprOperation.assignToRef:
4727 // TODO(paulberry): if this reference refers to a variable, should it 4727 // TODO(paulberry): if this reference refers to a variable, should it
4728 // be considered a type inference dependency? 4728 // be considered a type inference dependency?
4729 refPtr++; 4729 refPtr++;
4730 break; 4730 break;
4731 case UnlinkedConstOperation.invokeMethodRef: 4731 case UnlinkedExprOperation.invokeMethodRef:
4732 // TODO(paulberry): if this reference refers to a variable, should it 4732 // TODO(paulberry): if this reference refers to a variable, should it
4733 // be considered a type inference dependency? 4733 // be considered a type inference dependency?
4734 refPtr++; 4734 refPtr++;
4735 intPtr += 2; 4735 intPtr += 2;
4736 int numTypeArguments = unlinkedConst.ints[intPtr++]; 4736 int numTypeArguments = unlinkedConst.ints[intPtr++];
4737 refPtr += numTypeArguments; 4737 refPtr += numTypeArguments;
4738 break; 4738 break;
4739 case UnlinkedConstOperation.invokeMethod: 4739 case UnlinkedExprOperation.invokeMethod:
4740 intPtr += 2; 4740 intPtr += 2;
4741 int numTypeArguments = unlinkedConst.ints[intPtr++]; 4741 int numTypeArguments = unlinkedConst.ints[intPtr++];
4742 refPtr += numTypeArguments; 4742 refPtr += numTypeArguments;
4743 break; 4743 break;
4744 case UnlinkedConstOperation.typeCast: 4744 case UnlinkedExprOperation.typeCast:
4745 case UnlinkedConstOperation.typeCheck: 4745 case UnlinkedExprOperation.typeCheck:
4746 refPtr++; 4746 refPtr++;
4747 break; 4747 break;
4748 case UnlinkedConstOperation.pushLocalFunctionReference: 4748 case UnlinkedExprOperation.pushLocalFunctionReference:
4749 int popCount = unlinkedConst.ints[intPtr++]; 4749 int popCount = unlinkedConst.ints[intPtr++];
4750 assert(popCount == 0); // TODO(paulberry): handle the nonzero case. 4750 assert(popCount == 0); // TODO(paulberry): handle the nonzero case.
4751 dependencies.add(functionElement 4751 dependencies.add(functionElement
4752 .getLocalFunction(unlinkedConst.ints[intPtr++]) 4752 .getLocalFunction(unlinkedConst.ints[intPtr++])
4753 .asTypeInferenceNode); 4753 .asTypeInferenceNode);
4754 break; 4754 break;
4755 default: 4755 default:
4756 break; 4756 break;
4757 } 4757 }
4758 } 4758 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
5079 * there are no type parameters in scope. 5079 * there are no type parameters in scope.
5080 */ 5080 */
5081 TypeParameterizedElementMixin get _typeParameterContext; 5081 TypeParameterizedElementMixin get _typeParameterContext;
5082 5082
5083 @override 5083 @override
5084 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 5084 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
5085 5085
5086 @override 5086 @override
5087 String toString() => '$enclosingElement.$name'; 5087 String toString() => '$enclosingElement.$name';
5088 } 5088 }
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