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

Side by Side Diff: tests/compiler/dart2js/inference/enumerator.dart

Issue 2656583003: Add inference test functionality based on code point id. (Closed)
Patch Set: Updated cf. comments Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'package:compiler/src/resolution/access_semantics.dart';
6 import 'package:compiler/src/resolution/send_structure.dart';
7 import 'package:compiler/src/resolution/tree_elements.dart';
8 import 'package:compiler/src/tree/nodes.dart' as ast;
9
10 /// Id for a code point with type inference information.
11 // TODO(johnniwinther): Create an [Id]-based equivalence with the kernel IR.
12 class Id {
13 final int value;
14
15 const Id(this.value);
16
17 int get hashCode => value.hashCode;
18
19 bool operator ==(other) {
20 if (identical(this, other)) return true;
21 if (other is! Id) return false;
22 return value == other.value;
23 }
24
25 String toString() => value.toString();
26 }
27
28 abstract class AstEnumeratorMixin {
29 TreeElements get elements;
30
31 Id computeAccessId(ast.Send node, AccessSemantics access) {
32 switch (access.kind) {
33 case AccessKind.DYNAMIC_PROPERTY:
34 return new Id(node.selector.getBeginToken().charOffset);
35 default:
36 return new Id(node.getBeginToken().charOffset);
37 }
38 }
39
40 Id computeId(ast.Send node) {
41 var sendStructure = elements.getSendStructure(node);
42 if (sendStructure == null) return null;
43 switch (sendStructure.kind) {
44 case SendStructureKind.GET:
45 case SendStructureKind.INVOKE:
46 case SendStructureKind.INCOMPATIBLE_INVOKE:
47 return computeAccessId(node, sendStructure.semantics);
48 default:
49 return new Id(node.getBeginToken().charOffset);
50 }
51 }
52 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/annotated_code_helper.dart ('k') | tests/compiler/dart2js/inference/inference_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698