OLD | NEW |
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 #include <ctype.h> // isspace. | 5 #include <ctype.h> // isspace. |
6 | 6 |
7 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
8 | 8 |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
11 #include "vm/native_entry.h" | 11 #include "vm/native_entry.h" |
12 #include "vm/object.h" | 12 #include "vm/object.h" |
13 #include "vm/random.h" | |
14 #include "vm/scanner.h" | 13 #include "vm/scanner.h" |
15 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
16 | 15 |
17 namespace dart { | 16 namespace dart { |
18 | 17 |
19 DEFINE_NATIVE_ENTRY(Math_sqrt, 1) { | 18 DEFINE_NATIVE_ENTRY(Math_sqrt, 1) { |
20 GET_NATIVE_ARGUMENT(Double, operand, arguments->NativeArgAt(0)); | 19 GET_NATIVE_ARGUMENT(Double, operand, arguments->NativeArgAt(0)); |
21 return Double::New(sqrt(operand.value())); | 20 return Double::New(sqrt(operand.value())); |
22 } | 21 } |
23 | 22 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 DEFINE_NATIVE_ENTRY(Math_exp, 1) { | 59 DEFINE_NATIVE_ENTRY(Math_exp, 1) { |
61 GET_NATIVE_ARGUMENT(Double, operand, arguments->NativeArgAt(0)); | 60 GET_NATIVE_ARGUMENT(Double, operand, arguments->NativeArgAt(0)); |
62 return Double::New(exp(operand.value())); | 61 return Double::New(exp(operand.value())); |
63 } | 62 } |
64 | 63 |
65 DEFINE_NATIVE_ENTRY(Math_log, 1) { | 64 DEFINE_NATIVE_ENTRY(Math_log, 1) { |
66 GET_NATIVE_ARGUMENT(Double, operand, arguments->NativeArgAt(0)); | 65 GET_NATIVE_ARGUMENT(Double, operand, arguments->NativeArgAt(0)); |
67 return Double::New(log(operand.value())); | 66 return Double::New(log(operand.value())); |
68 } | 67 } |
69 | 68 |
70 DEFINE_NATIVE_ENTRY(Math_random, 0) { | |
71 return Double::New(static_cast<double>(Random::RandomInt32()-1)/0x80000000); | |
72 } | |
73 | |
74 } // namespace dart | 69 } // namespace dart |
OLD | NEW |