OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/regexp/jsregexp-inl.h" | 8 #include "src/regexp/jsregexp-inl.h" |
9 #include "src/string-builder.h" | 9 #include "src/string-builder.h" |
10 #include "src/string-search.h" | 10 #include "src/string-search.h" |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 HandleScope handlescope(isolate); | 1248 HandleScope handlescope(isolate); |
1249 DCHECK_EQ(1, args.length()); | 1249 DCHECK_EQ(1, args.length()); |
1250 if (args[0]->IsNumber()) { | 1250 if (args[0]->IsNumber()) { |
1251 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); | 1251 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); |
1252 code &= 0xffff; | 1252 code &= 0xffff; |
1253 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); | 1253 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); |
1254 } | 1254 } |
1255 return isolate->heap()->empty_string(); | 1255 return isolate->heap()->empty_string(); |
1256 } | 1256 } |
1257 | 1257 |
1258 | |
1259 RUNTIME_FUNCTION(Runtime_StringCharAt) { | |
1260 SealHandleScope shs(isolate); | |
1261 DCHECK(args.length() == 2); | |
1262 if (!args[0]->IsString()) return Smi::FromInt(0); | |
1263 if (!args[1]->IsNumber()) return Smi::FromInt(0); | |
1264 if (std::isinf(args.number_at(1))) return isolate->heap()->empty_string(); | |
1265 Object* code = __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | |
1266 if (code->IsNaN()) return isolate->heap()->empty_string(); | |
1267 return __RT_impl_Runtime_StringCharFromCode(Arguments(1, &code), isolate); | |
1268 } | |
1269 | |
1270 RUNTIME_FUNCTION(Runtime_ExternalStringGetChar) { | 1258 RUNTIME_FUNCTION(Runtime_ExternalStringGetChar) { |
1271 SealHandleScope shs(isolate); | 1259 SealHandleScope shs(isolate); |
1272 DCHECK_EQ(2, args.length()); | 1260 DCHECK_EQ(2, args.length()); |
1273 CONVERT_ARG_CHECKED(ExternalString, string, 0); | 1261 CONVERT_ARG_CHECKED(ExternalString, string, 0); |
1274 CONVERT_INT32_ARG_CHECKED(index, 1); | 1262 CONVERT_INT32_ARG_CHECKED(index, 1); |
1275 return Smi::FromInt(string->Get(index)); | 1263 return Smi::FromInt(string->Get(index)); |
1276 } | 1264 } |
1277 | 1265 |
1278 RUNTIME_FUNCTION(Runtime_OneByteSeqStringGetChar) { | 1266 RUNTIME_FUNCTION(Runtime_OneByteSeqStringGetChar) { |
1279 SealHandleScope shs(isolate); | 1267 SealHandleScope shs(isolate); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 SealHandleScope shs(isolate); | 1307 SealHandleScope shs(isolate); |
1320 DCHECK(args.length() == 2); | 1308 DCHECK(args.length() == 2); |
1321 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1309 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
1322 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1310 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
1323 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1311 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
1324 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1312 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
1325 } | 1313 } |
1326 | 1314 |
1327 } // namespace internal | 1315 } // namespace internal |
1328 } // namespace v8 | 1316 } // namespace v8 |
OLD | NEW |