| 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 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/code_patcher.h" | 7 #include "vm/code_patcher.h" |
| 8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/stack_frame.h" | 10 #include "vm/stack_frame.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 Exceptions::JSWarning(caller_frame, "%s", msg); | 31 Exceptions::JSWarning(caller_frame, "%s", msg); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) { | 36 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) { |
| 37 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0)); | 37 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0)); |
| 38 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1)); | 38 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1)); |
| 39 const bool is_identical = a.IsIdenticalTo(b); | 39 const bool is_identical = a.IsIdenticalTo(b); |
| 40 if (FLAG_warn_on_javascript_compatibility) { | 40 if (FLAG_warn_on_javascript_compatibility) { |
| 41 if (!is_identical && a.IsString() && String::Cast(a).Equals(b)) { | 41 if (!is_identical) { |
| 42 JSWarning("strings that are equal are also identical"); | 42 if (a.IsString()) { |
| 43 if (String::Cast(a).Equals(b)) { |
| 44 JSWarning("strings that are equal are also identical"); |
| 45 } |
| 46 } else if (a.IsInteger()) { |
| 47 if (b.IsDouble()) { |
| 48 const int64_t a_value = Integer::Cast(a).AsInt64Value(); |
| 49 const double b_value = Double::Cast(b).value(); |
| 50 if (a_value == floor(b_value)) { |
| 51 JSWarning("integer value and integral double value that are equal " |
| 52 "are also identical"); |
| 53 } |
| 54 } |
| 55 } else if (a.IsDouble()) { |
| 56 if (b.IsInteger()) { |
| 57 const double a_value = Double::Cast(a).value(); |
| 58 const int64_t b_value = Integer::Cast(b).AsInt64Value(); |
| 59 if (floor(a_value) == b_value) { |
| 60 JSWarning("integral double value and integer value that are equal " |
| 61 "are also identical"); |
| 62 } |
| 63 } |
| 64 } |
| 43 } | 65 } |
| 44 } | 66 } |
| 45 return Bool::Get(is_identical).raw(); | 67 return Bool::Get(is_identical).raw(); |
| 46 } | 68 } |
| 47 | 69 |
| 48 } // namespace dart | 70 } // namespace dart |
| OLD | NEW |