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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart

Issue 14646031: Implement invoke, setField, and getField (unminified). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 7 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 | Annotate | Revision Log
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 part of _js_helper; 5 part of _js_helper;
6 6
7 setRuntimeTypeInfo(target, typeInfo) { 7 setRuntimeTypeInfo(target, typeInfo) {
8 assert(typeInfo == null || isJsArray(typeInfo)); 8 assert(typeInfo == null || isJsArray(typeInfo));
9 // We have to check for null because factories may return null. 9 // We have to check for null because factories may return null.
10 if (target != null) JS('var', r'#.$builtinTypeInfo = #', target, typeInfo); 10 if (target != null) JS('var', r'#.$builtinTypeInfo = #', target, typeInfo);
11 } 11 }
12 12
13 getRuntimeTypeInfo(target) { 13 getRuntimeTypeInfo(target) {
14 if (target == null) return null; 14 if (target == null) return null;
15 return JS('var', r'#.$builtinTypeInfo', target); 15 return JS('var', r'#.$builtinTypeInfo', target);
16 } 16 }
17 17
18 getRuntimeTypeArgument(target, substitution, index) { 18 getRuntimeTypeArgument(target, substitution, index) {
19 var arguments = substitute(substitution, getRuntimeTypeInfo(target)); 19 var arguments = substitute(substitution, getRuntimeTypeInfo(target));
20 return (arguments == null) ? null : getField(arguments, index); 20 return (arguments == null) ? null : getField(arguments, index);
21 } 21 }
22 22
23 class TypeImpl implements Type { 23 class TypeImpl implements Type {
24 final String typeName; 24 final String _typeName;
25 TypeImpl(this.typeName); 25
26 toString() => typeName; 26 TypeImpl(this._typeName);
27 int get hashCode => typeName.hashCode; 27
28 toString() => _typeName;
29
30 // TODO(ahe): This is a poor hashCode as it collides with its name.
31 int get hashCode => _typeName.hashCode;
32
28 bool operator ==(other) { 33 bool operator ==(other) {
29 if (other is !TypeImpl) return false; 34 return (other is TypeImpl) && _typeName == other._typeName;
30 return typeName == other.typeName;
31 } 35 }
32 } 36 }
33 37
34 String getClassName(var object) { 38 String getClassName(var object) {
35 return JS('String', r'#.constructor.builtin$cls', getInterceptor(object)); 39 return JS('String', r'#.constructor.builtin$cls', getInterceptor(object));
36 } 40 }
37 41
38 String getRuntimeTypeAsString(List runtimeType) { 42 String getRuntimeTypeAsString(List runtimeType) {
39 String className = getConstructorName(runtimeType[0]); 43 String className = getConstructorName(runtimeType[0]);
40 return '$className${joinArguments(runtimeType, 1)}'; 44 return '$className${joinArguments(runtimeType, 1)}';
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // of [t]. 239 // of [t].
236 if ((!isJsArray(s) && JS('bool', '# == null', substitution)) || 240 if ((!isJsArray(s) && JS('bool', '# == null', substitution)) ||
237 !isJsArray(t)) { 241 !isJsArray(t)) {
238 return true; 242 return true;
239 } 243 }
240 // Recursively check the type arguments. 244 // Recursively check the type arguments.
241 return checkArguments(substitution, getArguments(s), getArguments(t)); 245 return checkArguments(substitution, getArguments(s), getArguments(t));
242 } 246 }
243 247
244 createRuntimeType(String name) => new TypeImpl(name); 248 createRuntimeType(String name) => new TypeImpl(name);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698