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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 2154583002: dart2js: get:hashCode methods to avoid Object.hashCode (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: xxx Created 4 years, 5 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Identifiers; 8 import '../common/names.dart' show Identifiers;
9 import '../common/resolution.dart' show Resolution, ParsingContext; 9 import '../common/resolution.dart' show Resolution, ParsingContext;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 21 matching lines...) Expand all
32 32
33 /// Object that identifies a declaration site. 33 /// Object that identifies a declaration site.
34 /// 34 ///
35 /// For most elements, this is the element itself, but for variable declarations 35 /// For most elements, this is the element itself, but for variable declarations
36 /// where multi-declarations like `var a, b, c` are allowed, the declaration 36 /// where multi-declarations like `var a, b, c` are allowed, the declaration
37 /// site is a separate object. 37 /// site is a separate object.
38 // TODO(johnniwinther): Add [beginToken] and [endToken] getters. 38 // TODO(johnniwinther): Add [beginToken] and [endToken] getters.
39 abstract class DeclarationSite {} 39 abstract class DeclarationSite {}
40 40
41 abstract class ElementX extends Element with ElementCommon { 41 abstract class ElementX extends Element with ElementCommon {
42 static int elementHashCode = 0; 42 static int _elementHashCode = 0;
43 static int newHashCode() =>
44 _elementHashCode = (_elementHashCode + 1).toUnsigned(30);
43 45
44 final String name; 46 final String name;
45 final ElementKind kind; 47 final ElementKind kind;
46 final Element enclosingElement; 48 final Element enclosingElement;
47 final int hashCode = ++elementHashCode; 49 final int hashCode = newHashCode();
48 List<MetadataAnnotation> metadataInternal; 50 List<MetadataAnnotation> metadataInternal;
49 51
50 ElementX(this.name, this.kind, this.enclosingElement) { 52 ElementX(this.name, this.kind, this.enclosingElement) {
51 assert(isError || implementationLibrary != null); 53 assert(isError || implementationLibrary != null);
52 } 54 }
53 55
54 Modifiers get modifiers => Modifiers.EMPTY; 56 Modifiers get modifiers => Modifiers.EMPTY;
55 57
56 Node parseNode(ParsingContext parsing) { 58 Node parseNode(ParsingContext parsing) {
57 parsing.reporter.internalError(this, 'parseNode not implemented on $this.'); 59 parsing.reporter.internalError(this, 'parseNode not implemented on $this.');
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 } 3181 }
3180 3182
3181 class JumpTargetX implements JumpTarget { 3183 class JumpTargetX implements JumpTarget {
3182 final ExecutableElement executableContext; 3184 final ExecutableElement executableContext;
3183 final Node statement; 3185 final Node statement;
3184 final int nestingLevel; 3186 final int nestingLevel;
3185 Link<LabelDefinition> labels = const Link<LabelDefinition>(); 3187 Link<LabelDefinition> labels = const Link<LabelDefinition>();
3186 bool isBreakTarget = false; 3188 bool isBreakTarget = false;
3187 bool isContinueTarget = false; 3189 bool isContinueTarget = false;
3188 3190
3191 final int hashCode = ElementX.newHashCode();
3192
3189 JumpTargetX(this.statement, this.nestingLevel, this.executableContext); 3193 JumpTargetX(this.statement, this.nestingLevel, this.executableContext);
3190 3194
3191 String get name => "target"; 3195 String get name => "target";
3192 3196
3193 bool get isTarget => isBreakTarget || isContinueTarget; 3197 bool get isTarget => isBreakTarget || isContinueTarget;
3194 3198
3195 LabelDefinition addLabel(Label label, String labelName) { 3199 LabelDefinition addLabel(Label label, String labelName) {
3196 LabelDefinition result = new LabelDefinitionX(label, labelName, this); 3200 LabelDefinition result = new LabelDefinitionX(label, labelName, this);
3197 labels = labels.prepend(result); 3201 labels = labels.prepend(result);
3198 return result; 3202 return result;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 Element annotatedElement; 3282 Element annotatedElement;
3279 int resolutionState; 3283 int resolutionState;
3280 3284
3281 /** 3285 /**
3282 * The beginning token of this annotation, or [:null:] if it is synthetic. 3286 * The beginning token of this annotation, or [:null:] if it is synthetic.
3283 */ 3287 */
3284 Token get beginToken; 3288 Token get beginToken;
3285 3289
3286 Token get endToken; 3290 Token get endToken;
3287 3291
3292 final int hashCode = ElementX.newHashCode();
3293
3288 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); 3294 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]);
3289 3295
3290 MetadataAnnotation ensureResolved(Resolution resolution) { 3296 MetadataAnnotation ensureResolved(Resolution resolution) {
3291 if (annotatedElement.isClass || annotatedElement.isTypedef) { 3297 if (annotatedElement.isClass || annotatedElement.isTypedef) {
3292 TypeDeclarationElement typeDeclaration = annotatedElement; 3298 TypeDeclarationElement typeDeclaration = annotatedElement;
3293 typeDeclaration.ensureResolved(resolution); 3299 typeDeclaration.ensureResolved(resolution);
3294 } 3300 }
3295 if (resolutionState == STATE_NOT_STARTED) { 3301 if (resolutionState == STATE_NOT_STARTED) {
3296 resolution.resolveMetadataAnnotation(this); 3302 resolution.resolveMetadataAnnotation(this);
3297 } 3303 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 body = node.asFunctionExpression().body; 3389 body = node.asFunctionExpression().body;
3384 } 3390 }
3385 return new ParsedResolvedAst( 3391 return new ParsedResolvedAst(
3386 declaration, 3392 declaration,
3387 node, 3393 node,
3388 body, 3394 body,
3389 definingElement.treeElements, 3395 definingElement.treeElements,
3390 definingElement.compilationUnit.script.resourceUri); 3396 definingElement.compilationUnit.script.resourceUri);
3391 } 3397 }
3392 } 3398 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_types.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698