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

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

Issue 1633863002: Support for constructor references in constant serializer and prelinker. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
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 library serialization.summarize_ast; 5 library serialization.summarize_ast;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/src/generated/scanner.dart'; 9 import 'package:analyzer/src/generated/scanner.dart';
10 import 'package:analyzer/src/generated/utilities_dart.dart'; 10 import 'package:analyzer/src/generated/utilities_dart.dart';
(...skipping 10 matching lines...) Expand all
21 21
22 /** 22 /**
23 * Instances of this class keep track of intermediate state during 23 * Instances of this class keep track of intermediate state during
24 * serialization of a single constant [Expression]. 24 * serialization of a single constant [Expression].
25 */ 25 */
26 class _ConstExprSerializer extends AbstractConstExprSerializer { 26 class _ConstExprSerializer extends AbstractConstExprSerializer {
27 final _SummarizeAstVisitor visitor; 27 final _SummarizeAstVisitor visitor;
28 28
29 _ConstExprSerializer(this.visitor); 29 _ConstExprSerializer(this.visitor);
30 30
31 @override
32 EntityRefBuilder serializeConstructorName(ConstructorName constructor) {
33 TypeName type = constructor.type;
34 Identifier typeName = type.name;
35 EntityRefBuilder typeBuilder = serializeType(type);
36 if (typeName is SimpleIdentifier) {
37 int nameRef = visitor.serializeReference(typeBuilder.reference, '');
38 return new EntityRefBuilder(reference: nameRef);
Paul Berry 2016/01/26 00:47:21 I don't understand why there are three separate re
scheglov 2016/01/26 04:34:49 Fixed. Now we record only explicit names and let t
39 } else if (typeName is PrefixedIdentifier) {
40 if (constructor.name == null) {
41 return typeBuilder;
42 } else {
43 String name = constructor.name.name;
44 int nameRef = visitor.serializeReference(typeBuilder.reference, name);
45 return new EntityRefBuilder(reference: nameRef);
46 }
47 } else {
48 throw new StateError(
49 'Unexpected identifier type: ${typeName.runtimeType}');
50 }
51 }
52
31 EntityRefBuilder serializeIdentifier(Identifier identifier) { 53 EntityRefBuilder serializeIdentifier(Identifier identifier) {
32 EntityRefBuilder b = new EntityRefBuilder(); 54 EntityRefBuilder b = new EntityRefBuilder();
33 if (identifier is SimpleIdentifier) { 55 if (identifier is SimpleIdentifier) {
34 b.reference = visitor.serializeReference(null, identifier.name); 56 b.reference = visitor.serializeReference(null, identifier.name);
35 } else if (identifier is PrefixedIdentifier) { 57 } else if (identifier is PrefixedIdentifier) {
36 int prefix = visitor.serializeReference(null, identifier.prefix.name); 58 int prefix = visitor.serializeReference(null, identifier.prefix.name);
37 b.reference = 59 b.reference =
38 visitor.serializeReference(prefix, identifier.identifier.name); 60 visitor.serializeReference(prefix, identifier.identifier.name);
39 } else { 61 } else {
40 throw new StateError( 62 throw new StateError(
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 /** 871 /**
850 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 872 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
851 */ 873 */
852 class _TypeParameterScope extends _Scope { 874 class _TypeParameterScope extends _Scope {
853 /** 875 /**
854 * Get the number of [_ScopedTypeParameter]s defined in this 876 * Get the number of [_ScopedTypeParameter]s defined in this
855 * [_TypeParameterScope]. 877 * [_TypeParameterScope].
856 */ 878 */
857 int get length => _definedNames.length; 879 int get length => _definedNames.length;
858 } 880 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698