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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/inference/enumerator.dart
diff --git a/tests/compiler/dart2js/inference/enumerator.dart b/tests/compiler/dart2js/inference/enumerator.dart
new file mode 100644
index 0000000000000000000000000000000000000000..07328da174c9a572c313877a7f53c8d604089d01
--- /dev/null
+++ b/tests/compiler/dart2js/inference/enumerator.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:compiler/src/resolution/access_semantics.dart';
+import 'package:compiler/src/resolution/send_structure.dart';
+import 'package:compiler/src/resolution/tree_elements.dart';
+import 'package:compiler/src/tree/nodes.dart' as ast;
+
+/// Id for a code point with type inference information.
+// TODO(johnniwinther): Create an [Id]-based equivalence with the kernel IR.
+class Id {
+ final int value;
+
+ const Id(this.value);
+
+ int get hashCode => value.hashCode;
+
+ bool operator ==(other) {
+ if (identical(this, other)) return true;
+ if (other is! Id) return false;
+ return value == other.value;
+ }
+
+ String toString() => value.toString();
+}
+
+abstract class AstEnumeratorMixin {
+ TreeElements get elements;
+
+ Id computeAccessId(ast.Send node, AccessSemantics access) {
+ switch (access.kind) {
+ case AccessKind.DYNAMIC_PROPERTY:
+ return new Id(node.selector.getBeginToken().charOffset);
+ default:
+ return new Id(node.getBeginToken().charOffset);
+ }
+ }
+
+ Id computeId(ast.Send node) {
+ var sendStructure = elements.getSendStructure(node);
+ if (sendStructure == null) return null;
+ switch (sendStructure.kind) {
+ case SendStructureKind.GET:
+ case SendStructureKind.INVOKE:
+ case SendStructureKind.INCOMPATIBLE_INVOKE:
+ return computeAccessId(node, sendStructure.semantics);
+ default:
+ return new Id(node.getBeginToken().charOffset);
+ }
+ }
+}
« 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