Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: src/objects.h

Issue 2579023002: [runtime] Improve Object::ToNumber, ToInteger, ToInt32, ToUint32, ToString (Closed)
Patch Set: fix Uint32 conversion Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 8d05411cd1beb6fe96482ebb2e20fcae2b9fa8b3..73881e4c73fe46928f4f51137ffbebc6679c619e 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1299,23 +1299,24 @@ class Object {
Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
// ES6 section 7.1.3 ToNumber
- MUST_USE_RESULT static MaybeHandle<Object> ToNumber(Handle<Object> input);
+ MUST_USE_RESULT static inline MaybeHandle<Object> ToNumber(
+ Handle<Object> input);
// ES6 section 7.1.4 ToInteger
- MUST_USE_RESULT static MaybeHandle<Object> ToInteger(Isolate* isolate,
- Handle<Object> input);
+ MUST_USE_RESULT static inline MaybeHandle<Object> ToInteger(
+ Isolate* isolate, Handle<Object> input);
// ES6 section 7.1.5 ToInt32
- MUST_USE_RESULT static MaybeHandle<Object> ToInt32(Isolate* isolate,
- Handle<Object> input);
+ MUST_USE_RESULT static inline MaybeHandle<Object> ToInt32(
+ Isolate* isolate, Handle<Object> input);
// ES6 section 7.1.6 ToUint32
- MUST_USE_RESULT static MaybeHandle<Object> ToUint32(Isolate* isolate,
- Handle<Object> input);
+ MUST_USE_RESULT inline static MaybeHandle<Object> ToUint32(
+ Isolate* isolate, Handle<Object> input);
// ES6 section 7.1.12 ToString
- MUST_USE_RESULT static MaybeHandle<String> ToString(Isolate* isolate,
- Handle<Object> input);
+ MUST_USE_RESULT static inline MaybeHandle<String> ToString(
+ Isolate* isolate, Handle<Object> input);
static Handle<String> NoSideEffectsToString(Isolate* isolate,
Handle<Object> input);
@@ -1564,7 +1565,16 @@ class Object {
MUST_USE_RESULT static MaybeHandle<Name> ConvertToName(Isolate* isolate,
Handle<Object> input);
-
+ MUST_USE_RESULT static MaybeHandle<String> ConvertToString(
+ Isolate* isolate, Handle<Object> input);
+ MUST_USE_RESULT static MaybeHandle<Object> ConvertToNumber(
+ Isolate* isolate, Handle<Object> input);
+ MUST_USE_RESULT static MaybeHandle<Object> ConvertToInteger(
+ Isolate* isolate, Handle<Object> input);
+ MUST_USE_RESULT static MaybeHandle<Object> ConvertToInt32(
+ Isolate* isolate, Handle<Object> input);
+ MUST_USE_RESULT static MaybeHandle<Object> ConvertToUint32(
+ Isolate* isolate, Handle<Object> input);
DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
};
@@ -1591,6 +1601,10 @@ class Smi: public Object {
public:
// Returns the integer value.
inline int value() const { return Internals::SmiValue(this); }
+ inline Smi* ToUint32Smi() {
+ if (value() <= 0) return Smi::kZero;
+ return Smi::FromInt(static_cast<uint32_t>(value()));
+ }
// Convert a value to a Smi object.
static inline Smi* FromInt(int value) {
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698