OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('dart:_js_helper'); | 5 #library('dart:_js_helper'); |
6 | 6 |
7 #import('dart:coreimpl'); | 7 #import('dart:coreimpl'); |
8 | 8 |
9 #source('constant_map.dart'); | 9 #source('constant_map.dart'); |
10 #source('native_helper.dart'); | 10 #source('native_helper.dart'); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 String S(value) { | 336 String S(value) { |
337 var res = value.toString(); | 337 var res = value.toString(); |
338 if (res is !String) throw new ArgumentError(value); | 338 if (res is !String) throw new ArgumentError(value); |
339 return res; | 339 return res; |
340 } | 340 } |
341 | 341 |
342 class ListIterator<T> implements Iterator<T> { | 342 class ListIterator<T> implements Iterator<T> { |
343 int i; | 343 int i; |
344 List<T> list; | 344 List<T> list; |
345 ListIterator(List<T> this.list) : i = 0; | 345 ListIterator(List<T> this.list) : i = 0; |
346 bool hasNext() => i < JS('int', r'#.length', list); | 346 bool get hasNext => i < JS('int', r'#.length', list); |
347 T next() { | 347 T next() { |
348 if (!hasNext()) throw new NoMoreElementsException(); | 348 if (!hasNext) throw new NoMoreElementsException(); |
349 var value = JS('Object', r'#[#]', list, i); | 349 var value = JS('Object', r'#[#]', list, i); |
350 i += 1; | 350 i += 1; |
351 return value; | 351 return value; |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 class Primitives { | 355 class Primitives { |
356 static int hashCodeSeed = 0; | 356 static int hashCodeSeed = 0; |
357 | 357 |
358 static int objectHashCode(object) { | 358 static int objectHashCode(object) { |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 } | 964 } |
965 | 965 |
966 | 966 |
967 /** | 967 /** |
968 * Called by generated code to build a map literal. [keyValuePairs] is | 968 * Called by generated code to build a map literal. [keyValuePairs] is |
969 * a list of key, value, key, value, ..., etc. | 969 * a list of key, value, key, value, ..., etc. |
970 */ | 970 */ |
971 makeLiteralMap(List keyValuePairs) { | 971 makeLiteralMap(List keyValuePairs) { |
972 Iterator iterator = keyValuePairs.iterator(); | 972 Iterator iterator = keyValuePairs.iterator(); |
973 Map result = new LinkedHashMap(); | 973 Map result = new LinkedHashMap(); |
974 while (iterator.hasNext()) { | 974 while (iterator.hasNext) { |
975 String key = iterator.next(); | 975 String key = iterator.next(); |
976 var value = iterator.next(); | 976 var value = iterator.next(); |
977 result[key] = value; | 977 result[key] = value; |
978 } | 978 } |
979 return result; | 979 return result; |
980 } | 980 } |
981 | 981 |
982 invokeClosure(Function closure, | 982 invokeClosure(Function closure, |
983 var isolate, | 983 var isolate, |
984 int numberOfArguments, | 984 int numberOfArguments, |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 JS('void', r'#.runtimeTypeCache[#] = #', JS_CURRENT_ISOLATE(), key, | 1405 JS('void', r'#.runtimeTypeCache[#] = #', JS_CURRENT_ISOLATE(), key, |
1406 runtimeType); | 1406 runtimeType); |
1407 } | 1407 } |
1408 return runtimeType; | 1408 return runtimeType; |
1409 } | 1409 } |
1410 | 1410 |
1411 String getRuntimeTypeString(var object) { | 1411 String getRuntimeTypeString(var object) { |
1412 var typeInfo = JS('Object', r'#.builtin$typeInfo', object); | 1412 var typeInfo = JS('Object', r'#.builtin$typeInfo', object); |
1413 return JS('String', r'#.runtimeType', typeInfo); | 1413 return JS('String', r'#.runtimeType', typeInfo); |
1414 } | 1414 } |
OLD | NEW |