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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1651653002: Verify AST instead of constant values. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/lib/src/summary/summarize_const_expr.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index 69acbd7d2f2cb7cfb3e0f5008e8cef84f179e14e..f05f3a8d788f51c72aaef90292bfafc164cd693b 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -11,7 +11,6 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
-import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/element_handle.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/resolver.dart';
@@ -21,7 +20,6 @@ import 'package:analyzer/src/generated/testing/ast_factory.dart';
import 'package:analyzer/src/generated/testing/token_factory.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/summary/format.dart';
-import 'package:analyzer/src/task/dart.dart' show ConstantEvaluationTarget;
/**
* Implementation of [ElementResynthesizer] used when resynthesizing an element
@@ -317,6 +315,9 @@ class _ConstExprBuilder {
case UnlinkedConstOperation.equal:
_pushBinary(TokenType.EQ_EQ);
break;
+ case UnlinkedConstOperation.notEqual:
+ _pushBinary(TokenType.BANG_EQ);
+ break;
case UnlinkedConstOperation.and:
_pushBinary(TokenType.AMPERSAND_AMPERSAND);
break;
@@ -393,6 +394,7 @@ class _ConstExprBuilder {
_push(AstFactory.methodInvocation(
null, 'identical', <Expression>[first, second]));
break;
+ // containers
case UnlinkedConstOperation.makeUntypedList:
_pushList(null);
break;
@@ -418,25 +420,18 @@ class _ConstExprBuilder {
return stack.single;
}
- void _pushMap(TypeArgumentList typeArguments) {
- int count = uc.ints[intPtr++];
- List<MapLiteralEntry> entries = <MapLiteralEntry>[];
- for (int i = 0; i < count; i++) {
- Expression value = _pop();
- Expression key = _pop();
- entries.insert(0, AstFactory.mapLiteralEntry2(key, value));
- }
- _push(AstFactory.mapLiteral(Keyword.CONST, typeArguments, entries));
- }
-
TypeName _buildTypeAst(DartType type) {
if (type is DynamicTypeImpl) {
- return AstFactory.typeName4('dynamic')..type = type;
+ TypeName node = AstFactory.typeName4('dynamic');
+ node.type = type;
+ (node.name as SimpleIdentifier).staticElement = type.element;
+ return node;
} else if (type is InterfaceType) {
List<TypeName> argumentNodes =
type.typeArguments.map(_buildTypeAst).toList();
TypeName node = AstFactory.typeName4(type.name, argumentNodes);
node.type = type;
+ (node.name as SimpleIdentifier).staticElement = type.element;
return node;
}
throw new StateError('Unsupported type $type');
@@ -484,6 +479,17 @@ class _ConstExprBuilder {
_push(AstFactory.listLiteral2(Keyword.CONST, typeArguments, elements));
}
+ void _pushMap(TypeArgumentList typeArguments) {
+ int count = uc.ints[intPtr++];
+ List<MapLiteralEntry> entries = <MapLiteralEntry>[];
+ for (int i = 0; i < count; i++) {
+ Expression value = _pop();
+ Expression key = _pop();
+ entries.insert(0, AstFactory.mapLiteralEntry2(key, value));
+ }
+ _push(AstFactory.mapLiteral(Keyword.CONST, typeArguments, entries));
+ }
+
void _pushPrefix(TokenType operator) {
Expression operand = _pop();
_push(AstFactory.prefixExpression(operator, operand));
@@ -491,17 +497,6 @@ class _ConstExprBuilder {
}
/**
- * A single constant variable for which the constant value should be computed.
- *
- * TODO(scheglov) we will probably need to add dependency list
- */
-class _ConstVariable {
- final ConstVariableElement element;
-
- _ConstVariable(this.element);
-}
-
-/**
* An instance of [_LibraryResynthesizer] is responsible for resynthesizing the
* elements in a single library from that library's summary.
*/
@@ -587,11 +582,6 @@ class _LibraryResynthesizer {
Map<String, FieldElementImpl> fields;
/**
- * List of constant variables to compute values for.
- */
- List<_ConstVariable> constVariables = <_ConstVariable>[];
-
- /**
* List of [_ReferenceInfo] objects describing the references in the current
* compilation unit.
*/
@@ -1169,17 +1159,6 @@ class _LibraryResynthesizer {
if (library.name != 'dart.core' && library.name != 'dart.async') {
library.createLoadLibraryFunction(summaryResynthesizer.typeProvider);
}
- // Compute constants.
- for (_ConstVariable constVariable in constVariables) {
- AnalysisContext context = summaryResynthesizer.context;
- ConstantEvaluationEngine constantEvaluationEngine =
- new ConstantEvaluationEngine(
- summaryResynthesizer.typeProvider, context.declaredVariables,
- typeSystem: context.typeSystem);
- ConstantEvaluationTarget constTarget =
- constVariable.element as ConstantEvaluationTarget;
- constantEvaluationEngine.computeConstantValue(constTarget);
- }
// Done.
return library;
}
@@ -1366,7 +1345,6 @@ class _LibraryResynthesizer {
_ConstExprBuilder builder =
new _ConstExprBuilder(this, serializedVariable.constExpr);
constElement.constantInitializer = builder.build();
- constVariables.add(new _ConstVariable(constElement));
} else {
element = new TopLevelVariableElementImpl(
serializedVariable.name, serializedVariable.nameOffset);
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/lib/src/summary/summarize_const_expr.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698