#include <limits.h>
#include <cmath>
+#include "v8.h"
+
+#include "assert-scope.h"
+#include "conversions.h"
#include "conversions-inl.h"
#include "dtoa.h"
+#include "factory.h"
#include "list-inl.h"
#include "strtod.h"
#include "utils.h"
namespace internal {
+namespace {
+
+// C++-style iterator adaptor for StringCharacterStream
+// (unlike C++ iterators the end-marker has different type).
+class StringCharacterStreamIterator {
+ public:
+ class EndMarker {};
+
+ explicit StringCharacterStreamIterator(StringCharacterStream* stream);
+
+ uint16_t operator*() const;
+ void operator++();
+ bool operator==(EndMarker const&) const { return end_; }
+ bool operator!=(EndMarker const& m) const { return !end_; }
+
+ private:
+ StringCharacterStream* const stream_;
+ uint16_t current_;
+ bool end_;
+};
+
+
+StringCharacterStreamIterator::StringCharacterStreamIterator(
+ StringCharacterStream* stream) : stream_(stream) {
+ ++(*this);
+}
+
+uint16_t StringCharacterStreamIterator::operator*() const {
+ return current_;
+}
+
+
+void StringCharacterStreamIterator::operator++() {
+ end_ = !stream_->HasMore();
+ if (!end_) {
+ current_ = stream_->GetNext();
+ }
+}
+} // End anonymous namespace.
+
+
double StringToDouble(UnicodeCache* unicode_cache,
const char* str, int flags, double empty_string_val) {
// We cast to const uint8_t* here to avoid instantiating the
}
-
char* DoubleToExponentialCString(double value, int f) {
const int kMaxDigitsAfterPoint = 20;
// f might be -1 to signal that f was undefined in JavaScript.
return builder.Finalize();
}
+
+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.IsAscii()) {
+ return StringToDouble(
+ unicode_cache, flat.ToOneByteVector(), flags, empty_string_val);
+ } else {
+ return StringToDouble(
+ unicode_cache, flat.ToUC16Vector(), flags, empty_string_val);
+ }
+}
+
+
} } // namespace v8::internal
#ifndef V8_CONVERSIONS_H_
#define V8_CONVERSIONS_H_
+#include <limits>
+
+#include "checks.h"
+#include "handles.h"
+#include "objects.h"
#include "utils.h"
namespace v8 {
char* DoubleToPrecisionCString(double value, int f);
char* DoubleToRadixCString(double value, int radix);
+
+static inline bool IsMinusZero(double value) {
+ static const DoubleRepresentation minus_zero(-0.0);
+ return DoubleRepresentation(value) == minus_zero;
+}
+
+
+// Integer32 is an integer that can be represented as a signed 32-bit
+// integer. It has to be in the range [-2^31, 2^31 - 1].
+// We also have to check for negative 0 as it is not an Integer32.
+static inline bool IsInt32Double(double value) {
+ return !IsMinusZero(value) &&
+ value >= kMinInt &&
+ value <= kMaxInt &&
+ value == FastI2D(FastD2I(value));
+}
+
+
+// Convert from Number object to C integer.
+inline int32_t NumberToInt32(Object* number) {
+ if (number->IsSmi()) return Smi::cast(number)->value();
+ return DoubleToInt32(number->Number());
+}
+
+
+inline uint32_t NumberToUint32(Object* number) {
+ if (number->IsSmi()) return Smi::cast(number)->value();
+ return DoubleToUint32(number->Number());
+}
+
+
+double StringToDouble(UnicodeCache* unicode_cache,
+ String* string,
+ int flags,
+ double empty_string_val = 0.0);
+
+
+inline bool TryNumberToSize(Isolate* isolate,
+ Object* number, size_t* result) {
+ SealHandleScope shs(isolate);
+ if (number->IsSmi()) {
+ int value = Smi::cast(number)->value();
+ ASSERT(static_cast<unsigned>(Smi::kMaxValue)
+ <= std::numeric_limits<size_t>::max());
+ if (value >= 0) {
+ *result = static_cast<size_t>(value);
+ return true;
+ }
+ return false;
+ } else {
+ ASSERT(number->IsHeapNumber());
+ double value = HeapNumber::cast(number)->value();
+ if (value >= 0 &&
+ value <= std::numeric_limits<size_t>::max()) {
+ *result = static_cast<size_t>(value);
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
+// Converts a number into size_t.
+inline size_t NumberToSize(Isolate* isolate,
+ Object* number) {
+ size_t result = 0;
+ bool is_valid = TryNumberToSize(isolate, number, &result);
+ CHECK(is_valid);
+ return result;
+}
+
} } // namespace v8::internal
#endif // V8_CONVERSIONS_H_
#include "v8.h"
#include "arguments.h"
-#include "objects.h"
+#include "conversions.h"
#include "elements.h"
+#include "objects.h"
#include "utils.h"
-#include "v8conversions.h"
// Each concrete ElementsAccessor can handle exactly one ElementsKind,
// several abstract ElementsAccessor classes are used to allow sharing
#include "factory.h"
-#include "macro-assembler.h"
+#include "conversions.h"
#include "isolate-inl.h"
-#include "v8conversions.h"
+#include "macro-assembler.h"
namespace v8 {
namespace internal {
#include "allocation-tracker.h"
#include "code-stubs.h"
-#include "heap-profiler.h"
+#include "conversions.h"
#include "debug.h"
+#include "heap-profiler.h"
#include "types.h"
-#include "v8conversions.h"
namespace v8 {
namespace internal {
#include "bootstrapper.h"
#include "codegen.h"
#include "compilation-cache.h"
+#include "conversions.h"
#include "cpu-profiler.h"
#include "debug.h"
#include "deoptimizer.h"
#include "store-buffer.h"
#include "utils/random-number-generator.h"
#include "utils.h"
-#include "v8conversions.h"
#include "v8threads.h"
#include "vm-state-inl.h"
#if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
#include "allocation.h"
#include "code-stubs.h"
+#include "conversions.h"
#include "data-flow.h"
#include "deoptimizer.h"
#include "small-pointer-list.h"
#include "string-stream.h"
#include "unique.h"
#include "utils.h"
-#include "v8conversions.h"
#include "zone.h"
namespace v8 {
#include "api.h"
#include "arguments.h"
#include "codegen.h"
+#include "conversions.h"
#include "execution.h"
#include "ic-inl.h"
#include "runtime.h"
#include "stub-cache.h"
-#include "v8conversions.h"
namespace v8 {
namespace internal {
#include "code-stubs.h"
#include "compilation-cache.h"
+#include "conversions.h"
#include "objects-visiting.h"
#include "objects-visiting-inl.h"
-#include "v8conversions.h"
namespace v8 {
namespace internal {
#include "v8.h"
#include "char-predicates-inl.h"
-#include "v8conversions.h"
+#include "conversions.h"
#include "messages.h"
#include "spaces-inl.h"
#include "token.h"
#define V8_JSON_STRINGIFIER_H_
#include "v8.h"
+#include "conversions.h"
#include "utils.h"
-#include "v8conversions.h"
namespace v8 {
namespace internal {
#ifndef V8_PROPERTY_DETAILS_INL_H_
#define V8_PROPERTY_DETAILS_INL_H_
+#include "conversions.h"
#include "objects.h"
#include "property-details.h"
-#include "v8conversions.h"
namespace v8 {
namespace internal {
#include "codegen.h"
#include "compilation-cache.h"
#include "compiler.h"
+#include "conversions.h"
#include "cpu.h"
#include "cpu-profiler.h"
#include "dateparser-inl.h"
#include "string-search.h"
#include "stub-cache.h"
#include "uri.h"
-#include "v8conversions.h"
#include "v8threads.h"
#include "vm-state-inl.h"
#include "v8.h"
+#include "conversions.h"
#include "string-search.h"
#include "utils.h"
-#include "v8conversions.h"
namespace v8 {
namespace internal {
+++ /dev/null
-// Copyright 2011 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <stdarg.h>
-#include <limits.h>
-
-#include "v8.h"
-
-#include "assert-scope.h"
-#include "conversions-inl.h"
-#include "v8conversions.h"
-#include "dtoa.h"
-#include "factory.h"
-#include "strtod.h"
-
-namespace v8 {
-namespace internal {
-
-namespace {
-
-// C++-style iterator adaptor for StringCharacterStream
-// (unlike C++ iterators the end-marker has different type).
-class StringCharacterStreamIterator {
- public:
- class EndMarker {};
-
- explicit StringCharacterStreamIterator(StringCharacterStream* stream);
-
- uint16_t operator*() const;
- void operator++();
- bool operator==(EndMarker const&) const { return end_; }
- bool operator!=(EndMarker const& m) const { return !end_; }
-
- private:
- StringCharacterStream* const stream_;
- uint16_t current_;
- bool end_;
-};
-
-
-StringCharacterStreamIterator::StringCharacterStreamIterator(
- StringCharacterStream* stream) : stream_(stream) {
- ++(*this);
-}
-
-uint16_t StringCharacterStreamIterator::operator*() const {
- return current_;
-}
-
-
-void StringCharacterStreamIterator::operator++() {
- end_ = !stream_->HasMore();
- if (!end_) {
- current_ = stream_->GetNext();
- }
-}
-} // End anonymous namespace.
-
-
-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.IsAscii()) {
- return StringToDouble(
- unicode_cache, flat.ToOneByteVector(), flags, empty_string_val);
- } else {
- return StringToDouble(
- unicode_cache, flat.ToUC16Vector(), flags, empty_string_val);
- }
-}
-
-} } // namespace v8::internal
+++ /dev/null
-// Copyright 2011 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef V8_V8CONVERSIONS_H_
-#define V8_V8CONVERSIONS_H_
-
-#include "conversions.h"
-
-namespace v8 {
-namespace internal {
-
-
-static inline bool IsMinusZero(double value) {
- static const DoubleRepresentation minus_zero(-0.0);
- return DoubleRepresentation(value) == minus_zero;
-}
-
-
-// Integer32 is an integer that can be represented as a signed 32-bit
-// integer. It has to be in the range [-2^31, 2^31 - 1].
-// We also have to check for negative 0 as it is not an Integer32.
-static inline bool IsInt32Double(double value) {
- return !IsMinusZero(value) &&
- value >= kMinInt &&
- value <= kMaxInt &&
- value == FastI2D(FastD2I(value));
-}
-
-
-// Convert from Number object to C integer.
-inline int32_t NumberToInt32(Object* number) {
- if (number->IsSmi()) return Smi::cast(number)->value();
- return DoubleToInt32(number->Number());
-}
-
-
-inline uint32_t NumberToUint32(Object* number) {
- if (number->IsSmi()) return Smi::cast(number)->value();
- return DoubleToUint32(number->Number());
-}
-
-
-double StringToDouble(UnicodeCache* unicode_cache,
- String* string,
- int flags,
- double empty_string_val = 0.0);
-
-
-inline bool TryNumberToSize(Isolate* isolate,
- Object* number, size_t* result) {
- SealHandleScope shs(isolate);
- if (number->IsSmi()) {
- int value = Smi::cast(number)->value();
- ASSERT(static_cast<unsigned>(Smi::kMaxValue)
- <= std::numeric_limits<size_t>::max());
- if (value >= 0) {
- *result = static_cast<size_t>(value);
- return true;
- }
- return false;
- } else {
- ASSERT(number->IsHeapNumber());
- double value = HeapNumber::cast(number)->value();
- if (value >= 0 &&
- value <= std::numeric_limits<size_t>::max()) {
- *result = static_cast<size_t>(value);
- return true;
- } else {
- return false;
- }
- }
-}
-
-// Converts a number into size_t.
-inline size_t NumberToSize(Isolate* isolate,
- Object* number) {
- size_t result = 0;
- bool is_valid = TryNumberToSize(isolate, number, &result);
- CHECK(is_valid);
- return result;
-}
-
-} } // namespace v8::internal
-
-#endif // V8_V8CONVERSIONS_H_
'../../src/v8.cc',
'../../src/v8.h',
'../../src/v8checks.h',
- '../../src/v8conversions.cc',
- '../../src/v8conversions.h',
'../../src/v8globals.h',
'../../src/v8memory.h',
'../../src/v8threads.cc',