| OLD | NEW |
| 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); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 TypeImpl(this.typeName); | 25 TypeImpl(this.typeName); |
| 26 toString() => typeName; | 26 toString() => typeName; |
| 27 int get hashCode => typeName.hashCode; | 27 int get hashCode => typeName.hashCode; |
| 28 bool operator ==(other) { | 28 bool operator ==(other) { |
| 29 if (other is !TypeImpl) return false; | 29 if (other is !TypeImpl) return false; |
| 30 return typeName == other.typeName; | 30 return typeName == other.typeName; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 String getClassName(var object) { | 34 String getClassName(var object) { |
| 35 return JS('String', r'#.constructor.builtin$cls', getInterceptor(object)); | 35 return JS('String', r'#.constructor.builtin$cls', object); |
| 36 } | 36 } |
| 37 | 37 |
| 38 String getRuntimeTypeAsString(List runtimeType) { | 38 String getRuntimeTypeAsString(List runtimeType) { |
| 39 String className = getConstructorName(runtimeType[0]); | 39 String className = getConstructorName(runtimeType[0]); |
| 40 return '$className${joinArguments(runtimeType, 1)}'; | 40 return '$className${joinArguments(runtimeType, 1)}'; |
| 41 } | 41 } |
| 42 | 42 |
| 43 String getConstructorName(type) => JS('String', r'#.builtin$cls', type); | 43 String getConstructorName(type) => JS('String', r'#.builtin$cls', type); |
| 44 | 44 |
| 45 String runtimeTypeToString(type) { | 45 String runtimeTypeToString(type) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 73 } | 73 } |
| 74 return allDynamic ? '' : '<$buffer>'; | 74 return allDynamic ? '' : '<$buffer>'; |
| 75 } | 75 } |
| 76 | 76 |
| 77 String getRuntimeTypeString(var object) { | 77 String getRuntimeTypeString(var object) { |
| 78 String className = isJsArray(object) ? 'List' : getClassName(object); | 78 String className = isJsArray(object) ? 'List' : getClassName(object); |
| 79 var typeInfo = JS('var', r'#.$builtinTypeInfo', object); | 79 var typeInfo = JS('var', r'#.$builtinTypeInfo', object); |
| 80 return "$className${joinArguments(typeInfo, 0)}"; | 80 return "$className${joinArguments(typeInfo, 0)}"; |
| 81 } | 81 } |
| 82 | 82 |
| 83 Type getRuntimeType(var object) { | |
| 84 String type = getRuntimeTypeString(object); | |
| 85 return new TypeImpl(type); | |
| 86 } | |
| 87 | |
| 88 bool isJsFunction(var o) => JS('bool', r'typeof # == "function"', o); | 83 bool isJsFunction(var o) => JS('bool', r'typeof # == "function"', o); |
| 89 | 84 |
| 90 Object invoke(function, arguments) { | 85 Object invoke(function, arguments) { |
| 91 return JS('var', r'#.apply(null, #)', function, arguments); | 86 return JS('var', r'#.apply(null, #)', function, arguments); |
| 92 } | 87 } |
| 93 | 88 |
| 94 Object call(target, name) => JS('var', r'#[#]()', target, name); | 89 Object call(target, name) => JS('var', r'#[#]()', target, name); |
| 95 | 90 |
| 96 substitute(var substitution, var arguments) { | 91 substitute(var substitution, var arguments) { |
| 97 if (isJsArray(substitution)) { | 92 if (isJsArray(substitution)) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // of [t]. | 230 // of [t]. |
| 236 if ((!isJsArray(s) && JS('bool', '# == null', substitution)) || | 231 if ((!isJsArray(s) && JS('bool', '# == null', substitution)) || |
| 237 !isJsArray(t)) { | 232 !isJsArray(t)) { |
| 238 return true; | 233 return true; |
| 239 } | 234 } |
| 240 // Recursively check the type arguments. | 235 // Recursively check the type arguments. |
| 241 return checkArguments(substitution, getArguments(s), getArguments(t)); | 236 return checkArguments(substitution, getArguments(s), getArguments(t)); |
| 242 } | 237 } |
| 243 | 238 |
| 244 createRuntimeType(String name) => new TypeImpl(name); | 239 createRuntimeType(String name) => new TypeImpl(name); |
| OLD | NEW |