runtime-date.cc 1.04 KB
Newer Older
1 2 3 4
// 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.

5
#include "src/runtime/runtime-utils.h"
6 7

#include "src/arguments.h"
8
#include "src/conversions-inl.h"
9
#include "src/date.h"
10
#include "src/factory.h"
11
#include "src/isolate-inl.h"
12
#include "src/messages.h"
13 14 15 16

namespace v8 {
namespace internal {

17
RUNTIME_FUNCTION(Runtime_IsDate) {
18 19 20
  SealHandleScope shs(isolate);
  DCHECK_EQ(1, args.length());
  CONVERT_ARG_CHECKED(Object, obj, 0);
21
  return isolate->heap()->ToBoolean(obj->IsJSDate());
22 23 24
}


25 26
RUNTIME_FUNCTION(Runtime_ThrowNotDateError) {
  HandleScope scope(isolate);
27
  DCHECK_EQ(0, args.length());
28 29
  THROW_NEW_ERROR_RETURN_FAILURE(isolate,
                                 NewTypeError(MessageTemplate::kNotDateObject));
30 31 32 33 34
}


RUNTIME_FUNCTION(Runtime_DateCurrentTime) {
  HandleScope scope(isolate);
35 36
  DCHECK_EQ(0, args.length());
  return *isolate->factory()->NewNumber(JSDate::CurrentTimeValue(isolate));
37 38
}

39 40
}  // namespace internal
}  // namespace v8