Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index be75faba65c0d58183868a185d7c4e6e3ff523da..19f2a1d7238e525058b59bea1d44ee17192d6c2c 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -64,6 +64,7 @@ |
// - JSBuiltinsObject |
// - JSGlobalProxy |
// - JSValue |
+// - JSDate |
// - JSMessageObject |
// - JSProxy |
// - JSFunctionProxy |
@@ -300,6 +301,7 @@ const int kVariableSizeSentinel = 0; |
V(JS_MESSAGE_OBJECT_TYPE) \ |
\ |
V(JS_VALUE_TYPE) \ |
+ V(JS_DATE_TYPE) \ |
V(JS_OBJECT_TYPE) \ |
V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ |
V(JS_GLOBAL_OBJECT_TYPE) \ |
@@ -619,6 +621,7 @@ enum InstanceType { |
JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE |
JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE |
+ JS_DATE_TYPE, |
JS_OBJECT_TYPE, |
JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
JS_GLOBAL_OBJECT_TYPE, |
@@ -813,6 +816,7 @@ class MaybeObject BASE_EMBEDDED { |
V(Oddball) \ |
V(SharedFunctionInfo) \ |
V(JSValue) \ |
+ V(JSDate) \ |
V(JSMessageObject) \ |
V(StringWrapper) \ |
V(Foreign) \ |
@@ -887,6 +891,7 @@ class Object : public MaybeObject { |
// Extract the number. |
inline double Number(); |
+ inline bool IsNaN(); |
// Returns true if the object is of the correct type to be used as a |
// implementation of a JSObject's elements. |
@@ -5972,7 +5977,7 @@ class JSBuiltinsObject: public GlobalObject { |
}; |
-// Representation for JS Wrapper objects, String, Number, Boolean, Date, etc. |
+// Representation for JS Wrapper objects, String, Number, Boolean, etc. |
class JSValue: public JSObject { |
public: |
// [value]: the object being wrapped. |
@@ -6001,6 +6006,63 @@ class JSValue: public JSObject { |
}; |
+// Representation for JS date objects. |
+class JSDate: public JSObject { |
+ public: |
+ // If one component is NaN, all of them are, indicating a NaN time value. |
+ // [value]: the time value. |
+ DECL_ACCESSORS(value, Object) |
+ // [local]: the offset for the local time value. |
+ DECL_ACCESSORS(local, Object) |
+ // [year]: caches year. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(year, Object) |
+ // [month]: caches month. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(month, Object) |
+ // [day]: caches day. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(day, Object) |
+ // [hour]: caches hours. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(hour, Object) |
+ // [min]: caches minutes. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(min, Object) |
+ // [sec]: caches seconds. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(sec, Object) |
+ // [weekday]: caches day of week. Either undefined, smi, or NaN. |
+ DECL_ACCESSORS(weekday, Object) |
+ |
+ // Casting. |
+ static inline JSDate* cast(Object* obj); |
+ |
+ // Dispatched behavior. |
+#ifdef OBJECT_PRINT |
+ inline void JSDatePrint() { |
+ JSDatePrint(stdout); |
+ } |
+ void JSDatePrint(FILE* out); |
+#endif |
+#ifdef DEBUG |
+ void JSDateVerify(); |
+#endif |
+ |
+ // Layout description. |
+ static const int kValueOffset = JSObject::kHeaderSize; |
+ static const int kLocalOffset = kValueOffset + kPointerSize; |
+ static const int kYearOffset = kLocalOffset + kPointerSize; |
+ static const int kMonthOffset = kYearOffset + kPointerSize; |
+ static const int kDayOffset = kMonthOffset + kPointerSize; |
+ static const int kHourOffset = kDayOffset + kPointerSize; |
+ static const int kMinOffset = kHourOffset + kPointerSize; |
+ static const int kSecOffset = kMinOffset + kPointerSize; |
+ static const int kWeekdayOffset = kSecOffset + kPointerSize; |
+ static const int kSize = kWeekdayOffset + kPointerSize; |
+ |
+ // Index of first field not requiring a write barrier. |
+ static const int kFirstBarrierFree = 2; // year |
+ |
+ private: |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JSDate); |
+}; |
+ |
+ |
// Representation of message objects used for error reporting through |
// the API. The messages are formatted in JavaScript so this object is |
// a real JavaScript object. The information used for formatting the |