}
-double StringToDouble(UnicodeCache* unicode_cache,
- String* string,
- int flags,
- double empty_string_val) {
- DisallowHeapAllocation no_gc;
- String::FlatContent flat = string->GetFlatContent();
- // ECMA-262 section 15.1.2.3, empty string is NaN
- if (flat.IsOneByte()) {
- return StringToDouble(
- unicode_cache, flat.ToOneByteVector(), flags, empty_string_val);
- } else {
- return StringToDouble(
- unicode_cache, flat.ToUC16Vector(), flags, empty_string_val);
+double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
+ int flags, double empty_string_val) {
+ Handle<String> flattened = String::Flatten(string);
+ {
+ DisallowHeapAllocation no_gc;
+ String::FlatContent flat = flattened->GetFlatContent();
+ DCHECK(flat.IsFlat());
+ // ECMA-262 section 15.1.2.3, empty string is NaN
+ if (flat.IsOneByte()) {
+ return StringToDouble(unicode_cache, flat.ToOneByteVector(), flags,
+ empty_string_val);
+ } else {
+ return StringToDouble(unicode_cache, flat.ToUC16Vector(), flags,
+ empty_string_val);
+ }
}
}
}
-double StringToDouble(UnicodeCache* unicode_cache,
- String* string,
- int flags,
- double empty_string_val = 0.0);
+double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
+ int flags, double empty_string_val = 0.0);
inline bool TryNumberToSize(Isolate* isolate,
Handle<String> name_string = Handle<String>::cast(name());
if (name_string->length() > 0) {
double d =
- StringToDouble(isolate()->unicode_cache(), *name_string, NO_FLAGS);
+ StringToDouble(isolate()->unicode_cache(), name_string, NO_FLAGS);
if (!std::isnan(d)) {
if (String::Equals(isolate()->factory()->minus_zero_string(),
name_string))
}
return *isolate->factory()->NewNumber(
- StringToDouble(isolate->unicode_cache(), *subject, flags));
+ StringToDouble(isolate->unicode_cache(), subject, flags));
}
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
- subject = String::Flatten(subject);
- double value = StringToDouble(isolate->unicode_cache(), *subject,
+ double value = StringToDouble(isolate->unicode_cache(), subject,
ALLOW_TRAILING_JUNK, base::OS::nan_value());
return *isolate->factory()->NewNumber(value);
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var array = new Int8Array(10);
+array[/\u007d\u00fc\u0043/] = 1.499
+assertEquals(1.499, array[/\u007d\u00fc\u0043/]);