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

Side by Side Diff: lib/math.dart

Issue 9677059: - Now that VM entry points are hardened the checking in the Dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class MathNatives { 5 class MathNatives {
6 static int parseInt(String str) {
7 if (str is !String) {
8 throw "Wrong argument";
9 }
10 return _parseInt(str);
11 }
12 static double parseDouble(String str) {
13 if (str is !String) {
14 throw "Wrong argument";
15 }
16 return _parseDouble(str);
17 }
18 static double sqrt(num value) {
19 return _sqrt(_asDouble(value));
20 }
21 static double sin(num value) {
22 return _sin(_asDouble(value));
23 }
24 static double cos(num value) {
25 return _cos(_asDouble(value));
26 }
27 static double tan(num value) {
28 return _tan(_asDouble(value));
29 }
30 static double acos(num value) {
31 return _acos(_asDouble(value));
32 }
33 static double asin(num value) {
34 return _asin(_asDouble(value));
35 }
36 static double atan(num value) {
37 return _atan(_asDouble(value));
38 }
39 static double atan2(num a, num b) {
40 return _atan2(_asDouble(a), _asDouble(b));
41 }
42 static double exp(num value) {
43 return _exp(_asDouble(value));
44 }
45 static double log(num value) {
46 return _log(_asDouble(value));
47 }
48 static num pow(num value, num exponent) { 6 static num pow(num value, num exponent) {
49 if (exponent is int) { 7 if (exponent is int) {
50 return value.pow(exponent); 8 return value.pow(exponent);
51 } 9 }
52 // Double.pow will call exponent.toDouble(). 10 // Double.pow will call exponent.toDouble().
53 return _asDouble(value).pow(exponent); 11 return value.toDouble().pow(exponent);
54 } 12 }
55 static double random() { 13 static double random() => _random();
56 return _random(); 14 static double sqrt(num value) => _sqrt(value.toDouble());
57 } 15 static double sin(num value) => _sin(value.toDouble());
58 static double _asDouble(num value) { 16 static double cos(num value) => _cos(value.toDouble());
59 double result = value.toDouble(); 17 static double tan(num value) => _tan(value.toDouble());
60 if (result is !double) { 18 static double acos(num value) => _acos(value.toDouble());
61 throw "Wrong argument"; 19 static double asin(num value) => _asin(value.toDouble());
62 } 20 static double atan(num value) => _atan(value.toDouble());
63 return result; 21 static double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble());
64 } 22 static double exp(num value) => _exp(value.toDouble());
23 static double log(num value) => _log(value.toDouble());
24 static int parseInt(String str) => _parseInt(str);
25 static double parseDouble(String str) => _parseDouble(str);
26
65 static double _random() native "MathNatives_random"; 27 static double _random() native "MathNatives_random";
66 static double _sqrt(double value) native "MathNatives_sqrt"; 28 static double _sqrt(double value) native "MathNatives_sqrt";
67 static double _sin(double value) native "MathNatives_sin"; 29 static double _sin(double value) native "MathNatives_sin";
68 static double _cos(double value) native "MathNatives_cos"; 30 static double _cos(double value) native "MathNatives_cos";
69 static double _tan(double value) native "MathNatives_tan"; 31 static double _tan(double value) native "MathNatives_tan";
70 static double _acos(double value) native "MathNatives_acos"; 32 static double _acos(double value) native "MathNatives_acos";
71 static double _asin(double value) native "MathNatives_asin"; 33 static double _asin(double value) native "MathNatives_asin";
72 static double _atan(double value) native "MathNatives_atan"; 34 static double _atan(double value) native "MathNatives_atan";
73 static double _atan2(double a, double b) native "MathNatives_2atan"; 35 static double _atan2(double a, double b) native "MathNatives_2atan";
74 static double _exp(double value) native "MathNatives_exp"; 36 static double _exp(double value) native "MathNatives_exp";
75 static double _log(double value) native "MathNatives_log"; 37 static double _log(double value) native "MathNatives_log";
76 static int _parseInt(String str) native "MathNatives_parseInt"; 38 static int _parseInt(String str) native "MathNatives_parseInt";
77 static double _parseDouble(String str) native "MathNatives_parseDouble"; 39 static double _parseDouble(String str) native "MathNatives_parseDouble";
78 } 40 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698