| 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 class JavaSystem { | 5 class JavaSystem { |
| 6 static int currentTimeMillis() { | 6 static int currentTimeMillis() { |
| 7 return (new DateTime.now()).millisecondsSinceEpoch; | 7 return (new DateTime.now()).millisecondsSinceEpoch; |
| 8 } | 8 } |
| 9 | 9 |
| 10 static void arraycopy(List src, int srcPos, List dest, int destPos, int length
) { | 10 static void arraycopy(List src, int srcPos, List dest, int destPos, int length
) { |
| 11 for (int i = 0; i < length; i++) { | 11 for (int i = 0; i < length; i++) { |
| 12 dest[destPos + i] = src[srcPos + i]; | 12 dest[destPos + i] = src[srcPos + i]; |
| 13 } | 13 } |
| 14 } | 14 } |
| 15 } | 15 } |
| 16 | 16 |
| 17 Stopwatch instanceOfTimer = new Stopwatch(); |
| 18 |
| 17 /** | 19 /** |
| 18 * Limited implementation of "o is instanceOfType", see | 20 * Limited implementation of "o is instanceOfType", see |
| 19 * http://code.google.com/p/dart/issues/detail?id=8184 | 21 * http://code.google.com/p/dart/issues/detail?id=8184 |
| 20 */ | 22 */ |
| 21 bool isInstanceOf(o, Type t) { | 23 bool isInstanceOf(o, Type t) { |
| 22 if (o == null) { | 24 instanceOfTimer.start(); |
| 23 return false; | 25 try { |
| 24 } | 26 if (o == null) { |
| 25 if (o.runtimeType == t) { | 27 return false; |
| 26 return true; | 28 } |
| 27 } | 29 if (o.runtimeType == t) { |
| 28 String oTypeName = o.runtimeType.toString(); | |
| 29 String tTypeName = t.toString(); | |
| 30 if (oTypeName == tTypeName) { | |
| 31 return true; | |
| 32 } | |
| 33 if (oTypeName.startsWith("List") && tTypeName == "List") { | |
| 34 return true; | |
| 35 } | |
| 36 if (tTypeName == "Map" && o is Map) { | |
| 37 return true; | |
| 38 } | |
| 39 // Dart Analysis Engine specific | |
| 40 if (oTypeName == "${tTypeName}Impl") { | |
| 41 return true; | |
| 42 } | |
| 43 if (tTypeName == "FormalParameter") { | |
| 44 return | |
| 45 oTypeName == "DefaultFormalParameter" || | |
| 46 oTypeName == "FieldNormalParameter" || | |
| 47 oTypeName == "FunctionTypedFormalParameter" || | |
| 48 oTypeName == "SimpleFormalParameter"; | |
| 49 } | |
| 50 if (tTypeName == "MethodElement") { | |
| 51 if (oTypeName == "MethodMember") { | |
| 52 return true; | 30 return true; |
| 53 } | 31 } |
| 54 } | 32 String oTypeName = o.runtimeType.toString(); |
| 55 if (tTypeName == "ExecutableElement") { | 33 String tTypeName = t.toString(); |
| 56 if (oTypeName == "MethodElementImpl" || | 34 if (oTypeName == tTypeName) { |
| 57 oTypeName == "FunctionElementImpl" || | |
| 58 oTypeName == "PropertyAccessorElementImpl") { | |
| 59 return true; | 35 return true; |
| 60 } | 36 } |
| 61 } | 37 if (oTypeName.startsWith("List") && tTypeName == "List") { |
| 62 if (tTypeName == "ParameterElement") { | |
| 63 if (oTypeName == "FieldFormalParameterElementImpl" || | |
| 64 oTypeName == "DefaultFieldFormalParameterElementImpl" || | |
| 65 oTypeName == "DefaultParameterElementImpl") { | |
| 66 return true; | 38 return true; |
| 67 } | 39 } |
| 68 } | 40 if (tTypeName == "Map" && o is Map) { |
| 69 if (tTypeName == "VariableElement") { | |
| 70 if (oTypeName == "LocalVariableElementImpl" || | |
| 71 oTypeName == "ConstLocalVariableElementImpl" || | |
| 72 oTypeName == "FieldElementImpl" || | |
| 73 oTypeName == "ConstFieldElementImpl" || | |
| 74 oTypeName == "TopLevelVariableElementImpl" || | |
| 75 oTypeName == "ConstTopLevelVariableElementImpl") { | |
| 76 return true; | 41 return true; |
| 77 } | 42 } |
| 43 // Dart Analysis Engine specific |
| 44 if (oTypeName == "${tTypeName}Impl") { |
| 45 return true; |
| 46 } |
| 47 if (tTypeName == "FormalParameter") { |
| 48 return |
| 49 oTypeName == "DefaultFormalParameter" || |
| 50 oTypeName == "FieldNormalParameter" || |
| 51 oTypeName == "FunctionTypedFormalParameter" || |
| 52 oTypeName == "SimpleFormalParameter"; |
| 53 } |
| 54 if (tTypeName == "MethodElement") { |
| 55 if (oTypeName == "MethodMember") { |
| 56 return true; |
| 57 } |
| 58 } |
| 59 if (tTypeName == "ExecutableElement") { |
| 60 if (oTypeName == "MethodElementImpl" || |
| 61 oTypeName == "FunctionElementImpl" || |
| 62 oTypeName == "PropertyAccessorElementImpl") { |
| 63 return true; |
| 64 } |
| 65 } |
| 66 if (tTypeName == "ParameterElement") { |
| 67 if (oTypeName == "FieldFormalParameterElementImpl" || |
| 68 oTypeName == "DefaultFieldFormalParameterElementImpl" || |
| 69 oTypeName == "DefaultParameterElementImpl") { |
| 70 return true; |
| 71 } |
| 72 } |
| 73 if (tTypeName == "VariableElement") { |
| 74 if (oTypeName == "LocalVariableElementImpl" || |
| 75 oTypeName == "ConstLocalVariableElementImpl" || |
| 76 oTypeName == "FieldElementImpl" || |
| 77 oTypeName == "ConstFieldElementImpl" || |
| 78 oTypeName == "TopLevelVariableElementImpl" || |
| 79 oTypeName == "ConstTopLevelVariableElementImpl") { |
| 80 return true; |
| 81 } |
| 82 } |
| 83 // no |
| 84 return false; |
| 85 } finally { |
| 86 instanceOfTimer.stop(); |
| 78 } | 87 } |
| 79 // no | |
| 80 return false; | |
| 81 } | 88 } |
| 82 | 89 |
| 83 class JavaArrays { | 90 class JavaArrays { |
| 84 static bool equals(List a, List b) { | 91 static bool equals(List a, List b) { |
| 85 if (identical(a, b)) { | 92 if (identical(a, b)) { |
| 86 return true; | 93 return true; |
| 87 } | 94 } |
| 88 if (a.length != b.length) { | 95 if (a.length != b.length) { |
| 89 return false; | 96 return false; |
| 90 } | 97 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 if (!_matches.moveNext()) { | 494 if (!_matches.moveNext()) { |
| 488 return false; | 495 return false; |
| 489 } | 496 } |
| 490 _match = _matches.current; | 497 _match = _matches.current; |
| 491 return true; | 498 return true; |
| 492 } | 499 } |
| 493 String group(int i) => _match[i]; | 500 String group(int i) => _match[i]; |
| 494 int start() => _match.start; | 501 int start() => _match.start; |
| 495 int end() => _match.end; | 502 int end() => _match.end; |
| 496 } | 503 } |
| OLD | NEW |