Add sub-controls for Hack array compat runtime checks
[hiphop-php.git] / hphp / runtime / base / type-object.cpp
blob0d6a7b320f669515f594762944ddfb0be821d5fb
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/base/type-object.h"
19 #include "hphp/runtime/base/array-iterator.h"
20 #include "hphp/runtime/base/builtin-functions.h"
21 #include "hphp/runtime/base/collections.h"
22 #include "hphp/runtime/base/strings.h"
23 #include "hphp/runtime/base/variable-serializer.h"
25 #include "hphp/runtime/ext/datetime/ext_datetime.h"
27 #include "hphp/system/systemlib.h"
29 namespace HPHP {
31 extern const Object null_object = Object();
33 ///////////////////////////////////////////////////////////////////////////////
35 void Object::compileTimeAssertions() {
36 static_assert(sizeof(Object) == sizeof(req::ptr<ObjectData>), "Fix this.");
39 void ObjNR::compileTimeAssertions() {
40 static_assert(offsetof(ObjNR, m_px) == kExpectedMPxOffset, "");
43 Array Object::toArray() const {
44 return m_obj ? m_obj->toArray() : Array();
47 String Object::toString() const {
48 return m_obj ? m_obj->invokeToString() : String();
51 int64_t Object::toInt64ForCompare() const {
52 check_collection_compare(get());
53 return toInt64();
56 double Object::toDoubleForCompare() const {
57 check_collection_compare(get());
58 return toDouble();
61 const char* Object::classname_cstr() const {
62 return m_obj->getClassName().c_str();
65 ///////////////////////////////////////////////////////////////////////////////