5848c633c3
This diff suppresses the output of C++ for the "pure" classes defined in system/classes, and it rips out all the uses of MethodCallPackage (except for the i_* and ifa_* helpers, which we can go after separately). Also cleans up a bunch of "if (hhvm)" and "#ifdef HHVM" checks in builtin_functions.cpp, systemlib.cpp, object_data.cpp, and class_info.cpp (and the corresponding .h files). Note that this does not completely remove the generated C++ files. We still generate code for the PHP files in "system/globals" and we still generate the g_class_map (because the VM needs g_class_map at startup when it creates Class's for the extensions). We also still have the dynamic_func_table/dynamic_class_table stuff, MethodCallPackage, and the i_* and ifa_* helpers to support invoke_builtin() (which is still used by the compiler).
142 linhas
6.3 KiB
C++
142 linhas
6.3 KiB
C++
/*
|
|
+----------------------------------------------------------------------+
|
|
| HipHop for PHP |
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| http://www.php.net/license/3_01.txt |
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
|
|
#include <system/lib/systemlib.h>
|
|
#include <runtime/base/hphp_system.h>
|
|
#include <runtime/base/complex_types.h>
|
|
#include <runtime/vm/unit.h>
|
|
#include <runtime/vm/class.h>
|
|
#include <runtime/vm/instance.h>
|
|
|
|
namespace HPHP {
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define ALLOC_OBJECT_STUB_RETURN(name) \
|
|
HPHP::VM::Instance::newInstance(SystemLib::s_##name##Class)
|
|
|
|
#define ALLOC_OBJECT_STUB(name) \
|
|
HPHP::VM::Class* SystemLib::s_##name##Class = nullptr; \
|
|
ObjectData* SystemLib::Alloc##name##Object() { \
|
|
return ALLOC_OBJECT_STUB_RETURN(name); \
|
|
}
|
|
|
|
bool SystemLib::s_inited = false;
|
|
HPHP::Eval::PhpFile* SystemLib::s_phpFile = nullptr;
|
|
HPHP::VM::Unit* SystemLib::s_unit = nullptr;
|
|
HPHP::VM::Unit* SystemLib::s_nativeFuncUnit = nullptr;
|
|
HPHP::VM::Unit* SystemLib::s_nativeClassUnit = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_stdclassClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_ExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_BadMethodCallExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_InvalidArgumentExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_RuntimeExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_OutOfBoundsExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_InvalidOperationExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_pinitSentinelClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_resourceClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_DOMExceptionClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_SplFileObjectClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_SoapFaultClass = nullptr;
|
|
HPHP::VM::Class* SystemLib::s_ContinuationClass = nullptr;
|
|
|
|
ObjectData* SystemLib::AllocStdClassObject() {
|
|
return HPHP::VM::Instance::newInstance(SystemLib::s_stdclassClass);
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocPinitSentinel() {
|
|
return HPHP::VM::Instance::newInstance(SystemLib::s_pinitSentinelClass);
|
|
}
|
|
|
|
#define CREATE_AND_CONSTRUCT(clsname, params) \
|
|
HPHP::VM::Instance* inst = \
|
|
HPHP::VM::Instance::newInstance(SystemLib::s_##clsname##Class); \
|
|
TypedValue ret; \
|
|
{ \
|
|
/* Increment refcount across call to ctor, so the object doesn't */ \
|
|
/* get destroyed when ctor's frame is torn down */ \
|
|
CountableHelper cnt(inst); \
|
|
inst->invokeUserMethod(&ret, \
|
|
SystemLib::s_##clsname##Class->getCtor(), \
|
|
params); \
|
|
} \
|
|
tvRefcountedDecRef(&ret); \
|
|
return inst;
|
|
|
|
ObjectData* SystemLib::AllocExceptionObject(CVarRef message) {
|
|
CREATE_AND_CONSTRUCT(Exception, CREATE_VECTOR1(message));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocBadMethodCallExceptionObject(CVarRef message) {
|
|
CREATE_AND_CONSTRUCT(BadMethodCallException, CREATE_VECTOR1(message));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocInvalidArgumentExceptionObject(CVarRef message) {
|
|
CREATE_AND_CONSTRUCT(InvalidArgumentException, CREATE_VECTOR1(message));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocRuntimeExceptionObject(CVarRef message) {
|
|
CREATE_AND_CONSTRUCT(RuntimeException, CREATE_VECTOR1(message));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocOutOfBoundsExceptionObject(CVarRef message) {
|
|
CREATE_AND_CONSTRUCT(OutOfBoundsException, CREATE_VECTOR1(message));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocInvalidOperationExceptionObject(CVarRef message) {
|
|
CREATE_AND_CONSTRUCT(InvalidOperationException, CREATE_VECTOR1(message));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocDOMExceptionObject(CVarRef message, CVarRef code) {
|
|
CREATE_AND_CONSTRUCT(DOMException, CREATE_VECTOR2(message, code));
|
|
}
|
|
|
|
ObjectData* SystemLib::AllocSplFileObjectObject(CVarRef filename,
|
|
CVarRef open_mode,
|
|
CVarRef use_include_path,
|
|
CVarRef context) {
|
|
CREATE_AND_CONSTRUCT(SplFileObject,
|
|
CREATE_VECTOR4(filename, open_mode, use_include_path, context));
|
|
}
|
|
|
|
ObjectData*
|
|
SystemLib::AllocSoapFaultObject(CVarRef code,
|
|
CVarRef message,
|
|
CVarRef actor /* = null_variant */,
|
|
CVarRef detail /* = null_variant */,
|
|
CVarRef name /* = null_variant */,
|
|
CVarRef header /* = null_variant */) {
|
|
CREATE_AND_CONSTRUCT(SoapFault, CREATE_VECTOR6(code, message, actor,
|
|
detail, name, header));
|
|
}
|
|
|
|
#undef CREATE_AND_CONSTRUCT
|
|
|
|
VM::Func*
|
|
SystemLib::GetNullFunction() {
|
|
VM::Func* f = s_nativeFuncUnit->firstHoistable();
|
|
assert(!strcmp(f->name()->data(), "86null"));
|
|
return f;
|
|
}
|
|
|
|
ALLOC_OBJECT_STUB(Directory);
|
|
ALLOC_OBJECT_STUB(RecursiveDirectoryIterator);
|
|
ALLOC_OBJECT_STUB(SplFileInfo);
|
|
ALLOC_OBJECT_STUB(PDOException);
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
}
|
|
|