Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: runtime/lib/identical.cc

Issue 1683363002: Remove support for Javascript warnings in the VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comment Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/lib/errors_patch.dart ('k') | runtime/lib/integers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/object.h" 7 #include "vm/object.h"
8 #include "vm/report.h" 8 #include "vm/report.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
13
14 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) { 12 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) {
15 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0)); 13 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0));
16 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1)); 14 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1));
17 const bool is_identical = a.IsIdenticalTo(b); 15 const bool is_identical = a.IsIdenticalTo(b);
18 if (FLAG_warn_on_javascript_compatibility) {
19 if (!is_identical) {
20 if (a.IsString()) {
21 if (String::Cast(a).Equals(b)) {
22 Report::JSWarningFromNative(
23 true, // Identical_comparison is static.
24 "strings that are equal are also identical");
25 }
26 } else if (a.IsInteger()) {
27 if (b.IsDouble()) {
28 const int64_t a_value = Integer::Cast(a).AsInt64Value();
29 const double b_value = Double::Cast(b).value();
30 if (a_value == floor(b_value)) {
31 Report::JSWarningFromNative(
32 true, // Identical_comparison is static.
33 "integer value and integral double value that are equal "
34 "are also identical");
35 }
36 }
37 } else if (a.IsDouble()) {
38 if (b.IsInteger()) {
39 const double a_value = Double::Cast(a).value();
40 const int64_t b_value = Integer::Cast(b).AsInt64Value();
41 if (floor(a_value) == b_value) {
42 Report::JSWarningFromNative(
43 true, // Identical_comparison is static.
44 "integral double value and integer value that are equal "
45 "are also identical");
46 }
47 }
48 }
49 }
50 }
51 return Bool::Get(is_identical).raw(); 16 return Bool::Get(is_identical).raw();
52 } 17 }
53 18
54 } // namespace dart 19 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/errors_patch.dart ('k') | runtime/lib/integers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698