| OLD | NEW |
| 1 library java.core; | 1 library java.core; |
| 2 | 2 |
| 3 import "dart:math" as math; | 3 import "dart:math" as math; |
| 4 | 4 |
| 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); | 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); |
| 6 | 6 |
| 7 class JavaSystem { | 7 class JavaSystem { |
| 8 static int currentTimeMillis() { | 8 static int currentTimeMillis() { |
| 9 return (new DateTime.now()).millisecondsSinceEpoch; | 9 return (new DateTime.now()).millisecondsSinceEpoch; |
| 10 } | 10 } |
| 11 | 11 |
| 12 static int nanoTime() { | 12 static int nanoTime() { |
| 13 if (!nanoTimeStopwatch.isRunning) { | 13 if (!nanoTimeStopwatch.isRunning) { |
| 14 nanoTimeStopwatch.start(); | 14 nanoTimeStopwatch.start(); |
| 15 } | 15 } |
| 16 return nanoTimeStopwatch.elapsedMicroseconds * 1000; | 16 return nanoTimeStopwatch.elapsedMicroseconds * 1000; |
| 17 } | 17 } |
| 18 | 18 |
| 19 static void arraycopy(List src, int srcPos, List dest, int destPos, int length
) { | 19 static void arraycopy(List src, int srcPos, List dest, int destPos, int length
) { |
| 20 for (int i = 0; i < length; i++) { | 20 for (int i = 0; i < length; i++) { |
| 21 dest[destPos + i] = src[srcPos + i]; | 21 dest[destPos + i] = src[srcPos + i]; |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 Stopwatch instanceOfTimer = new Stopwatch(); | |
| 27 | |
| 28 /** | |
| 29 * Limited implementation of "o is instanceOfType", see | |
| 30 * http://code.google.com/p/dart/issues/detail?id=8184 | |
| 31 */ | |
| 32 bool isInstanceOf(o, Type t) { | |
| 33 instanceOfTimer.start(); | |
| 34 try { | |
| 35 if (o == null) { | |
| 36 return false; | |
| 37 } | |
| 38 if (o.runtimeType == t) { | |
| 39 return true; | |
| 40 } | |
| 41 String oTypeName = o.runtimeType.toString(); | |
| 42 String tTypeName = t.toString(); | |
| 43 if (oTypeName == tTypeName) { | |
| 44 return true; | |
| 45 } | |
| 46 if (oTypeName.startsWith("List") && tTypeName == "List") { | |
| 47 return true; | |
| 48 } | |
| 49 if (tTypeName == "Map" && o is Map) { | |
| 50 return true; | |
| 51 } | |
| 52 // Dart Analysis Engine specific | |
| 53 if (oTypeName == "${tTypeName}Impl") { | |
| 54 return true; | |
| 55 } | |
| 56 if (tTypeName == "FormalParameter") { | |
| 57 return | |
| 58 oTypeName == "DefaultFormalParameter" || | |
| 59 oTypeName == "FieldNormalParameter" || | |
| 60 oTypeName == "FunctionTypedFormalParameter" || | |
| 61 oTypeName == "SimpleFormalParameter"; | |
| 62 } | |
| 63 if (tTypeName == "MethodElement") { | |
| 64 if (oTypeName == "MethodMember") { | |
| 65 return true; | |
| 66 } | |
| 67 } | |
| 68 if (tTypeName == "ExecutableElement") { | |
| 69 if (oTypeName == "MethodElementImpl" || | |
| 70 oTypeName == "FunctionElementImpl" || | |
| 71 oTypeName == "PropertyAccessorElementImpl") { | |
| 72 return true; | |
| 73 } | |
| 74 } | |
| 75 if (tTypeName == "ParameterElement") { | |
| 76 if (oTypeName == "FieldFormalParameterElementImpl" || | |
| 77 oTypeName == "DefaultFieldFormalParameterElementImpl" || | |
| 78 oTypeName == "DefaultParameterElementImpl") { | |
| 79 return true; | |
| 80 } | |
| 81 } | |
| 82 if (tTypeName == "VariableElement") { | |
| 83 if (oTypeName == "LocalVariableElementImpl" || | |
| 84 oTypeName == "ConstLocalVariableElementImpl" || | |
| 85 oTypeName == "FieldElementImpl" || | |
| 86 oTypeName == "ConstFieldElementImpl" || | |
| 87 oTypeName == "TopLevelVariableElementImpl" || | |
| 88 oTypeName == "ConstTopLevelVariableElementImpl") { | |
| 89 return true; | |
| 90 } | |
| 91 } | |
| 92 // no | |
| 93 return false; | |
| 94 } finally { | |
| 95 instanceOfTimer.stop(); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 class JavaArrays { | 26 class JavaArrays { |
| 100 static bool equals(List a, List b) { | 27 static bool equals(List a, List b) { |
| 101 if (identical(a, b)) { | 28 if (identical(a, b)) { |
| 102 return true; | 29 return true; |
| 103 } | 30 } |
| 104 if (a.length != b.length) { | 31 if (a.length != b.length) { |
| 105 return false; | 32 return false; |
| 106 } | 33 } |
| 107 var len = a.length; | 34 var len = a.length; |
| 108 for (int i = 0; i < len; i++) { | 35 for (int i = 0; i < len; i++) { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 if (!_matches.moveNext()) { | 433 if (!_matches.moveNext()) { |
| 507 return false; | 434 return false; |
| 508 } | 435 } |
| 509 _match = _matches.current; | 436 _match = _matches.current; |
| 510 return true; | 437 return true; |
| 511 } | 438 } |
| 512 String group(int i) => _match[i]; | 439 String group(int i) => _match[i]; |
| 513 int start() => _match.start; | 440 int start() => _match.start; |
| 514 int end() => _match.end; | 441 int end() => _match.end; |
| 515 } | 442 } |
| OLD | NEW |