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" | 13 #include "vm/random.h" |
14 #include "vm/scanner.h" | 14 #include "vm/scanner.h" |
| 15 #include "vm/symbols.h" |
15 | 16 |
16 namespace dart { | 17 namespace dart { |
17 | 18 |
18 DEFINE_NATIVE_ENTRY(MathNatives_sqrt, 1) { | 19 DEFINE_NATIVE_ENTRY(MathNatives_sqrt, 1) { |
19 GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0)); | 20 GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0)); |
20 arguments->SetReturn(Double::Handle(Double::New(sqrt(operand.value())))); | 21 arguments->SetReturn(Double::Handle(Double::New(sqrt(operand.value())))); |
21 } | 22 } |
22 | 23 |
23 DEFINE_NATIVE_ENTRY(MathNatives_sin, 1) { | 24 DEFINE_NATIVE_ENTRY(MathNatives_sin, 1) { |
24 GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0)); | 25 GET_NATIVE_ARGUMENT(Double, operand, arguments->At(0)); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Scanner scanner(value, String::Handle()); | 111 Scanner scanner(value, String::Handle()); |
111 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); | 112 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); |
112 String* int_string; | 113 String* int_string; |
113 bool is_positive; | 114 bool is_positive; |
114 if (IsValidLiteral(tokens, Token::kINTEGER, &is_positive, &int_string)) { | 115 if (IsValidLiteral(tokens, Token::kINTEGER, &is_positive, &int_string)) { |
115 Integer& result = Integer::Handle(); | 116 Integer& result = Integer::Handle(); |
116 if (is_positive) { | 117 if (is_positive) { |
117 result = Integer::New(*int_string); | 118 result = Integer::New(*int_string); |
118 } else { | 119 } else { |
119 String& temp = String::Handle(); | 120 String& temp = String::Handle(); |
120 temp = String::Concat(String::Handle(String::NewSymbol("-")), | 121 temp = String::Concat(String::Handle(Symbols::New("-")), |
121 *int_string); | 122 *int_string); |
122 result = Integer::New(temp); | 123 result = Integer::New(temp); |
123 } | 124 } |
124 arguments->SetReturn(result); | 125 arguments->SetReturn(result); |
125 } else { | 126 } else { |
126 GrowableArray<const Object*> args; | 127 GrowableArray<const Object*> args; |
127 args.Add(&value); | 128 args.Add(&value); |
128 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args); | 129 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args); |
129 } | 130 } |
130 } | 131 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return; | 175 return; |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 GrowableArray<const Object*> args; | 179 GrowableArray<const Object*> args; |
179 args.Add(&value); | 180 args.Add(&value); |
180 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args); | 181 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args); |
181 } | 182 } |
182 | 183 |
183 } // namespace dart | 184 } // namespace dart |
OLD | NEW |