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

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

Issue 11613003: Implement a native identical function in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: reorder function logic, add NaN handling and tests Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/identical_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "vm/bootstrap_natives.h"
6
7 #include "vm/object.h"
8
9 namespace dart {
10
11 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) {
12 GET_NATIVE_ARGUMENT(
13 Instance, a, arguments->NativeArgAt(0));
srdjan 2012/12/17 23:30:20 Can this fit in one line (80 chars).
14 GET_NATIVE_ARGUMENT(
15 Instance, b, arguments->NativeArgAt(1));
srdjan 2012/12/17 23:30:20 Ditto.
16 if (a.raw() == b.raw()) return Bool::True();
17 if (a.IsInteger() && b.IsInteger()) {
18 return Bool::Get(a.Equals(b));
19 }
20 if (a.IsDouble() && b.IsDouble()) {
21 if (a.Equals(b)) return Bool::True();
22 // Check for NaN
srdjan 2012/12/17 23:30:20 Terminate comment with a period.
23 const Double& a_double = Double::Cast(a);
24 const Double& b_double = Double::Cast(b);
25 if (isnan(a_double.value()) && isnan(b_double.value())) {
26 return Bool::True();
27 }
28 }
29 return Bool::False();
30 }
31
32
33 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/identical_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698