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

Side by Side Diff: pkg/compiler/lib/src/universe/selector.dart

Issue 2865693002: Create closed world for hello world using .dill file (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dart2js.selector; 5 library dart2js.selector;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Names; 8 import '../common/names.dart' show Names;
9 import '../elements/elements.dart' show Element, Elements, FunctionSignature; 9 import '../elements/elements.dart' show Element, Elements, FunctionSignature;
10 import '../elements/entities.dart'; 10 import '../elements/entities.dart';
11 import '../elements/names.dart'; 11 import '../elements/names.dart';
12 import '../elements/operators.dart';
12 import '../util/util.dart' show Hashing; 13 import '../util/util.dart' show Hashing;
13 import 'call_structure.dart' show CallStructure; 14 import 'call_structure.dart' show CallStructure;
14 15
15 class SelectorKind { 16 class SelectorKind {
16 final String name; 17 final String name;
17 final int hashCode; 18 final int hashCode;
18 const SelectorKind(this.name, this.hashCode); 19 const SelectorKind(this.name, this.hashCode);
19 20
20 static const SelectorKind GETTER = const SelectorKind('getter', 0); 21 static const SelectorKind GETTER = const SelectorKind('getter', 0);
21 static const SelectorKind SETTER = const SelectorKind('setter', 1); 22 static const SelectorKind SETTER = const SelectorKind('setter', 1);
(...skipping 23 matching lines...) Expand all
45 46
46 int get argumentCount => callStructure.argumentCount; 47 int get argumentCount => callStructure.argumentCount;
47 int get namedArgumentCount => callStructure.namedArgumentCount; 48 int get namedArgumentCount => callStructure.namedArgumentCount;
48 int get positionalArgumentCount => callStructure.positionalArgumentCount; 49 int get positionalArgumentCount => callStructure.positionalArgumentCount;
49 List<String> get namedArguments => callStructure.namedArguments; 50 List<String> get namedArguments => callStructure.namedArguments;
50 51
51 String get name => memberName.text; 52 String get name => memberName.text;
52 53
53 LibraryEntity get library => memberName.library; 54 LibraryEntity get library => memberName.library;
54 55
56 static bool isOperatorName(String name) {
57 if (name == Names.INDEX_SET_NAME.text) {
58 return true;
59 } else if (name == UnaryOperator.NEGATE.selectorName) {
60 return true;
61 } else if (name == UnaryOperator.COMPLEMENT.selectorName) {
62 return true;
63 } else {
64 return BinaryOperator.parseUserDefinable(name) != null;
65 }
66 }
67
55 Selector.internal( 68 Selector.internal(
56 this.kind, this.memberName, this.callStructure, this.hashCode) { 69 this.kind, this.memberName, this.callStructure, this.hashCode) {
57 assert(invariant( 70 assert(invariant(
58 NO_LOCATION_SPANNABLE, 71 NO_LOCATION_SPANNABLE,
59 kind == SelectorKind.INDEX || 72 kind == SelectorKind.INDEX ||
60 (memberName != Names.INDEX_NAME && 73 (memberName != Names.INDEX_NAME &&
61 memberName != Names.INDEX_SET_NAME), 74 memberName != Names.INDEX_SET_NAME),
62 message: "kind=$kind,memberName=$memberName," 75 message: "kind=$kind,memberName=$memberName,"
63 "callStructure:$callStructure")); 76 "callStructure:$callStructure"));
64 assert(invariant( 77 assert(invariant(
65 NO_LOCATION_SPANNABLE, 78 NO_LOCATION_SPANNABLE,
66 kind == SelectorKind.OPERATOR || 79 kind == SelectorKind.OPERATOR ||
67 kind == SelectorKind.INDEX || 80 kind == SelectorKind.INDEX ||
68 !Elements.isOperatorName(memberName.text) || 81 !isOperatorName(memberName.text) ||
69 memberName.text == '??', 82 memberName.text == '??',
70 message: "kind=$kind,memberName=$memberName," 83 message: "kind=$kind,memberName=$memberName,"
71 "callStructure:$callStructure")); 84 "callStructure:$callStructure"));
72 assert(invariant( 85 assert(invariant(
73 NO_LOCATION_SPANNABLE, 86 NO_LOCATION_SPANNABLE,
74 kind == SelectorKind.CALL || 87 kind == SelectorKind.CALL ||
75 kind == SelectorKind.GETTER || 88 kind == SelectorKind.GETTER ||
76 kind == SelectorKind.SETTER || 89 kind == SelectorKind.SETTER ||
77 Elements.isOperatorName(memberName.text) || 90 isOperatorName(memberName.text) ||
78 memberName.text == '??', 91 memberName.text == '??',
79 message: "kind=$kind,memberName=$memberName," 92 message: "kind=$kind,memberName=$memberName,"
80 "callStructure:$callStructure")); 93 "callStructure:$callStructure"));
81 } 94 }
82 95
83 // TODO(johnniwinther): Extract caching. 96 // TODO(johnniwinther): Extract caching.
84 static Map<int, List<Selector>> canonicalizedValues = 97 static Map<int, List<Selector>> canonicalizedValues =
85 new Map<int, List<Selector>>(); 98 new Map<int, List<Selector>>();
86 99
87 factory Selector(SelectorKind kind, Name name, CallStructure callStructure) { 100 factory Selector(SelectorKind kind, Name name, CallStructure callStructure) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Add bits from the call structure. 267 // Add bits from the call structure.
255 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); 268 return Hashing.mixHashCodeBits(hash, callStructure.hashCode);
256 } 269 }
257 270
258 String toString() { 271 String toString() {
259 return 'Selector($kind, $name, ${callStructure.structureToString()})'; 272 return 'Selector($kind, $name, ${callStructure.structureToString()})';
260 } 273 }
261 274
262 Selector toCallSelector() => new Selector.callClosureFrom(this); 275 Selector toCallSelector() => new Selector.callClosureFrom(this);
263 } 276 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution_strategy.dart ('k') | tests/compiler/dart2js/analyze_test_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698