diff --git a/hphp/compiler/analysis/file_scope.h b/hphp/compiler/analysis/file_scope.h index 71452d2e5..091fdd58c 100644 --- a/hphp/compiler/analysis/file_scope.h +++ b/hphp/compiler/analysis/file_scope.h @@ -48,8 +48,8 @@ public: ContainsDynamicVariable = 0x001, ContainsLDynamicVariable = 0x002, VariableArgument = 0x004, - ContainsExtract = 0x008, // need special VariableTable - ContainsCompact = 0x010, // need RVariableTable + exists() + ContainsExtract = 0x008, // contains call to extract() + ContainsCompact = 0x010, // contains call to compact() ContainsReference = 0x020, // returns ref or has ref parameters ReferenceVariableArgument = 0x040, // like sscanf or fscanf ContainsUnset = 0x080, // need special handling diff --git a/hphp/hhvm/externals_stubs.cpp b/hphp/hhvm/externals_stubs.cpp index 295420a1a..dbff9ad95 100644 --- a/hphp/hhvm/externals_stubs.cpp +++ b/hphp/hhvm/externals_stubs.cpp @@ -30,23 +30,6 @@ namespace HPHP { ////////////////////////////////////////////////////////////////////// -HphpBinary::Type getHphpBinaryType() { return HphpBinary::hhvm; } - -Variant invoke_file(CStrRef s, - bool once, - LVariableTable* variables, - const char *currentDir) { - assert(!variables); // this LVariableTable is unused in HHVM - { - Variant r; - if (eval_invoke_file_hook(r, s, once, variables, currentDir)) { - return r; - } - } - if (s.empty()) return vm_default_invoke_file(once); - return throw_missing_file(s.c_str()); -} - Object create_object_only(CStrRef s, ObjectData* root /* = NULL*/) { ObjectData *obj = eval_create_object_only_hook(s, root); if (UNLIKELY(!obj)) throw_missing_class(s); diff --git a/hphp/hhvm/global_variables.cpp b/hphp/hhvm/global_variables.cpp index 8f96f2ceb..cc232af02 100644 --- a/hphp/hhvm/global_variables.cpp +++ b/hphp/hhvm/global_variables.cpp @@ -40,7 +40,6 @@ void free_global_variables_after_sweep() { } SystemGlobals* get_system_globals() { return get_global_variables(); } -LVariableTable* get_variable_table() { return nullptr; } VM::GlobalNameValueTableWrapper::GlobalNameValueTableWrapper( NameValueTable* tab) : NameValueTableWrapper(tab) { diff --git a/hphp/runtime/base/builtin_functions.cpp b/hphp/runtime/base/builtin_functions.cpp index 7e44bc633..9e0a52dd9 100644 --- a/hphp/runtime/base/builtin_functions.cpp +++ b/hphp/runtime/base/builtin_functions.cpp @@ -24,8 +24,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -375,21 +375,6 @@ Variant vm_call_user_func(CVarRef function, CArrRef params, return ret; } -Variant vm_default_invoke_file(bool incOnce) { - SystemGlobals* g = (SystemGlobals*)get_global_variables(); - Variant& v_argc = g->GV(argc); - Variant& v_argv = g->GV(argv); - if (more(v_argc, int64_t(1))) { - v_argc--; - v_argv.dequeue(); - String s = toString(v_argv.rvalAt(int64_t(0), AccessFlags::Error)); - Variant r; - if (eval_invoke_file_hook(r, s, incOnce, nullptr, "")) return r; - return throw_missing_file(s.c_str()); - } - return true; -} - Variant f_call_user_func_array(CVarRef function, CArrRef params, bool bound /* = false */) { return vm_call_user_func(function, params, bound); @@ -1172,12 +1157,11 @@ String get_source_filename(litstr path, bool dir_component /* = false */) { } } -Variant include_impl_invoke(CStrRef file, bool once, LVariableTable* variables, - const char *currentDir) { +Variant include_impl_invoke(CStrRef file, bool once, const char *currentDir) { if (file[0] == '/') { if (RuntimeOption::SandboxMode || !RuntimeOption::AlwaysUseRelativePath) { try { - return invoke_file(file, once, variables, currentDir); + return invoke_file(file, once, currentDir); } catch(PhpFileDoesNotExistException &e) {} } @@ -1185,13 +1169,57 @@ Variant include_impl_invoke(CStrRef file, bool once, LVariableTable* variables, string(file.data()))); // Don't try/catch - We want the exception to be passed along - return invoke_file(rel_path, once, variables, currentDir); + return invoke_file(rel_path, once, currentDir); } else { // Don't try/catch - We want the exception to be passed along - return invoke_file(file, once, variables, currentDir); + return invoke_file(file, once, currentDir); } } +Variant invoke_file(CStrRef s, bool once, const char *currentDir) { + Variant r; + if (invoke_file_impl(r, s, once, currentDir)) { + return r; + } + if (!s.empty()) { + return throw_missing_file(s.c_str()); + } + // The gross hack which follows is here so that "hhvm foo.php" works + // the same as "hhvm -f foo.php". + // TODO Task #2171414: Find a less hacky way to accomplish this; we probably + // should be handling this elsewhere at a higher level rather than within + // the bowels of the invoke/include machinery + SystemGlobals* g = (SystemGlobals*)get_global_variables(); + Variant& v_argc = g->GV(argc); + Variant& v_argv = g->GV(argv); + if (!more(v_argc, int64_t(1))) { + return true; + } + v_argc--; + v_argv.dequeue(); + String s2 = toString(v_argv.rvalAt(int64_t(0), AccessFlags::Error)); + if (invoke_file_impl(r, s2, once, "")) { + return r; + } + return throw_missing_file(s2.c_str()); +} + +bool invoke_file_impl(Variant &res, CStrRef path, bool once, + const char *currentDir) { + bool initial; + HPHP::Eval::PhpFile* efile = + g_vmContext->lookupPhpFile(path.get(), currentDir, &initial); + HPHP::VM::Unit* u = nullptr; + if (efile) u = efile->unit(); + if (u == nullptr) { + return false; + } + if (!once || initial) { + g_vmContext->invokeUnit((TypedValue*)(&res), u); + } + return true; +} + /** * Used by include_impl. resolve_include() needs some way of checking the * existence of a file path, which for hphpc means attempting to invoke it. @@ -1200,7 +1228,6 @@ Variant include_impl_invoke(CStrRef file, bool once, LVariableTable* variables, */ struct IncludeImplInvokeContext { bool once; - LVariableTable* variables; const char* currentDir; Variant returnValue; @@ -1211,7 +1238,6 @@ static bool include_impl_invoke_context(CStrRef file, void* ctx) { bool invoked_file = false; try { context->returnValue = include_impl_invoke(file, context->once, - context->variables, context->currentDir); invoked_file = true; } catch (PhpFileDoesNotExistException& e) { @@ -1300,10 +1326,9 @@ String resolve_include(CStrRef file, const char* currentDir, } static Variant include_impl(CStrRef file, bool once, - LVariableTable* variables, const char *currentDir, bool required, bool raiseNotice) { - struct IncludeImplInvokeContext ctx = {once, variables, currentDir}; + struct IncludeImplInvokeContext ctx = {once, currentDir}; String can_path = resolve_include(file, currentDir, include_impl_invoke_context, (void*)&ctx); @@ -1324,17 +1349,15 @@ static Variant include_impl(CStrRef file, bool once, } Variant include(CStrRef file, bool once /* = false */, - LVariableTable* variables /* = NULL */, const char *currentDir /* = NULL */, bool raiseNotice /*= true*/) { - return include_impl(file, once, variables, currentDir, false, raiseNotice); + return include_impl(file, once, currentDir, false, raiseNotice); } Variant require(CStrRef file, bool once /* = false */, - LVariableTable* variables /* = NULL */, const char *currentDir /* = NULL */, bool raiseNotice /*= true*/) { - return include_impl(file, once, variables, currentDir, true, raiseNotice); + return include_impl(file, once, currentDir, true, raiseNotice); } /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/runtime/base/builtin_functions.h b/hphp/runtime/base/builtin_functions.h index 76b9b15c3..b8d4b8e41 100644 --- a/hphp/runtime/base/builtin_functions.h +++ b/hphp/runtime/base/builtin_functions.h @@ -363,8 +363,6 @@ HPHP::VM::ActRec* vm_get_previous_frame(); Variant vm_call_user_func(CVarRef function, CArrRef params, bool forwarding = false); -Variant vm_default_invoke_file(bool incOnce); - /** * Invoking an arbitrary static method. */ @@ -506,20 +504,20 @@ inline Variant f_unserialize(CStrRef str) { return unserialize_from_buffer(str.data(), str.size()); } -class LVariableTable; String resolve_include(CStrRef file, const char* currentDir, bool (*tryFile)(CStrRef file, void* ctx), void* ctx); Variant include(CStrRef file, bool once = false, - LVariableTable* variables = nullptr, const char *currentDir = "", bool raiseNotice = true); Variant require(CStrRef file, bool once = false, - LVariableTable* variables = nullptr, const char *currentDir = "", bool raiseNotice = true); Variant include_impl_invoke(CStrRef file, bool once = false, - LVariableTable* variables = nullptr, const char *currentDir = ""); +Variant invoke_file(CStrRef file, bool once = false, + const char *currentDir = nullptr); +bool invoke_file_impl(Variant &res, CStrRef path, bool once, + const char *currentDir); /** * For wrapping expressions that have no effect, so to make gcc happy. @@ -547,10 +545,6 @@ inline const SmartObject &id(const SmartObject &v) { return v; } */ inline Variant wrap_variant(CVarRef x) { return x; } -inline LVariableTable *lvar_ptr(const LVariableTable &vt) { - return const_cast(&vt); -} - bool function_exists(CStrRef function_name); /** diff --git a/hphp/runtime/base/externals.h b/hphp/runtime/base/externals.h index d45c0d51b..df3c63058 100644 --- a/hphp/runtime/base/externals.h +++ b/hphp/runtime/base/externals.h @@ -66,14 +66,6 @@ extern const char *g_paramrtti_map[]; Object create_object(CStrRef s, const Array ¶ms, bool init = true, ObjectData *root = nullptr); extern Object create_object_only(CStrRef s, ObjectData *root = nullptr); -/** - * Dynamically include a file. - */ -class LVariableTable; -extern Variant invoke_file(CStrRef file, bool once = false, - LVariableTable* variables = nullptr, - const char *currentDir = nullptr); -extern bool hphp_could_invoke_file(CStrRef file, void*); /** * Returns a thread local global variable class pointer. @@ -87,7 +79,6 @@ extern Array get_global_state(); /** * Returns a thread local global variable table pointer. */ -extern LVariableTable *get_variable_table(); typedef VM::GlobalNameValueTableWrapper SystemGlobals; extern SystemGlobals *get_system_globals(); diff --git a/hphp/runtime/base/hphp_ffi.cpp b/hphp/runtime/base/hphp_ffi.cpp index f204959cc..8dac2585f 100644 --- a/hphp/runtime/base/hphp_ffi.cpp +++ b/hphp/runtime/base/hphp_ffi.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include using namespace HPHP; @@ -180,14 +179,11 @@ int hphp_ffi_create_object(void **ret, const char *cls, ArrayData *args) { } int hphp_ffi_get_global(void **ret, const char *name) { - LVariableTable *g = get_variable_table(); - Variant result = g->get(name); - return hphp_ffi_exportVariant(result, ret); + const_assert(false); } void hphp_ffi_set_global(const char *name, Variant *value) { - LVariableTable *g = get_variable_table(); - g->get(name) = *value; + const_assert(false); } int hphp_ffi_get_constant(void **ret, const char *constant) { diff --git a/hphp/runtime/base/hphp_system.h b/hphp/runtime/base/hphp_system.h index 3184bc677..226274e93 100644 --- a/hphp/runtime/base/hphp_system.h +++ b/hphp/runtime/base/hphp_system.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +49,6 @@ namespace HPHP { const char* getHphpCompilerVersion(); const char* getHphpCompilerId(); -HphpBinary::Type getHphpBinaryType(); /////////////////////////////////////////////////////////////////////////////// } // namespace HPHP diff --git a/hphp/runtime/base/program_functions.cpp b/hphp/runtime/base/program_functions.cpp index 6d130c5f4..d3e70a5e3 100644 --- a/hphp/runtime/base/program_functions.cpp +++ b/hphp/runtime/base/program_functions.cpp @@ -460,15 +460,9 @@ void execute_command_line_begin(int argc, char **argv, int xhprof) { process_env_variables(g->GV(_ENV)); g->GV(_ENV).set("HPHP", 1); - switch (getHphpBinaryType()) { - case HphpBinary::hhvm: - g->GV(_ENV).set("HHVM", 1); - if (RuntimeOption::EvalJit) { - g->GV(_ENV).set("HHVM_JIT", 1); - } - break; - case HphpBinary::hphpi: g->GV(_ENV).set("HPHPI", 1); break; - default: break; + g->GV(_ENV).set("HHVM", 1); + if (RuntimeOption::EvalJit) { + g->GV(_ENV).set("HHVM_JIT", 1); } process_cmd_arguments(argc, argv); @@ -856,11 +850,7 @@ static int execute_program_impl(int argc, char **argv) { #define HPHP_VERSION(v) const char *version = #v; #include "../../version" - switch (getHphpBinaryType()) { - case HphpBinary::hhvm: { cout << "HipHop VM"; break; } - case HphpBinary::hphpi: { cout << "HipHop Interpreter"; break; } - default: { cout << "Compiled by HipHop Compiler"; break; } - } + cout << "HipHop VM"; cout << " v" << version << " (" << (debug ? "dbg" : "rel") << ")\n"; cout << "Compiler: " << kCompilerId << "\n"; cout << "Repo schema: " << VM::Repo::kSchemaId << "\n"; @@ -1239,7 +1229,7 @@ static bool hphp_warmup(ExecutionContext *context, ServerStatsHelper ssh("reqinit"); try { if (!reqInitDoc.empty()) { - include_impl_invoke(reqInitDoc, true, get_variable_table()); + include_impl_invoke(reqInitDoc, true); } if (!reqInitFunc.empty()) { invoke(reqInitFunc.c_str(), Array()); @@ -1319,7 +1309,7 @@ bool hphp_invoke(ExecutionContext *context, const std::string &cmd, funcRet->assignVal(invoke(cmd.c_str(), funcParams)); } else { if (isServer) hphp_chdir_file(cmd); - include_impl_invoke(cmd.c_str(), once, get_variable_table()); + include_impl_invoke(cmd.c_str(), once); } } catch (...) { handle_invoke_exception(ret, context, errorMsg, error, richErrorMsg); diff --git a/hphp/runtime/base/server/http_protocol.cpp b/hphp/runtime/base/server/http_protocol.cpp index d0312bb58..7a8ffd4ae 100644 --- a/hphp/runtime/base/server/http_protocol.cpp +++ b/hphp/runtime/base/server/http_protocol.cpp @@ -92,15 +92,9 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport, // $_ENV process_env_variables(g->GV(_ENV)); g->GV(_ENV).set("HPHP", 1); - switch (getHphpBinaryType()) { - case HphpBinary::hhvm: - g->GV(_ENV).set("HHVM", 1); - if (RuntimeOption::EvalJit) { - g->GV(_ENV).set("HHVM_JIT", 1); - } - break; - case HphpBinary::hphpi: g->GV(_ENV).set("HPHPI", 1); break; - default: break; + g->GV(_ENV).set("HHVM", 1); + if (RuntimeOption::EvalJit) { + g->GV(_ENV).set("HHVM_JIT", 1); } bool isServer = RuntimeOption::serverExecutionMode(); diff --git a/hphp/runtime/base/types.h b/hphp/runtime/base/types.h index d66abe4c1..df7ccb74a 100644 --- a/hphp/runtime/base/types.h +++ b/hphp/runtime/base/types.h @@ -584,16 +584,6 @@ public: #define ACCESSPARAMS_DECL AccessFlags::Type flags = AccessFlags::None #define ACCESSPARAMS_IMPL AccessFlags::Type flags -namespace HphpBinary { - enum Type { - hphpc, - hphpi, - hhvm, - program, - test - }; -} - /////////////////////////////////////////////////////////////////////////////// } diff --git a/hphp/runtime/base/variable_table.cpp b/hphp/runtime/base/variable_table.cpp deleted file mode 100644 index b02682999..000000000 --- a/hphp/runtime/base/variable_table.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 -#include - -namespace HPHP { -/////////////////////////////////////////////////////////////////////////////// - -Variant &LVariableTable::getImpl(CStrRef s) { - // LVariableTable may have references to its values leaked, and therefore - // cannot support escalation. - if (!m_px) { - m_px = ArrayInit(1).create(); // 1 since we're about to add an elem. - m_px->incRefCount(); - } - return lvalAt(s, AccessFlags::Key); -} - -Array RVariableTable::getDefinedVars() const { - return m_px ? Array(*this) : Array::Create(); -} - -Array LVariableTable::getDefinedVars() { - return m_px ? *this : Array::Create(); -} - - -/////////////////////////////////////////////////////////////////////////////// -} diff --git a/hphp/runtime/base/variable_table.h b/hphp/runtime/base/variable_table.h deleted file mode 100644 index 8c354361c..000000000 --- a/hphp/runtime/base/variable_table.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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. | - +----------------------------------------------------------------------+ -*/ - -#ifndef __HPHP_VARIABLE_TABLE_H__ -#define __HPHP_VARIABLE_TABLE_H__ - -#include -#include - -namespace HPHP { -/////////////////////////////////////////////////////////////////////////////// - -/** - * R-value variable table that can look up a variable's value by its name. Code - * generator will generate a subclass like this, - * - * class VariableTable : public RVariableTable { - * public: - * virtual Variant getImpl(const char *s) { - * if (strcmp(s, "a") == 0) return v_a; - * // ... - * } - * }; - */ -class RVariableTable : public Array { - public: - virtual ~RVariableTable() {} - Variant get(CVarRef s) { return getImpl(s.toString());} - Variant get(CStrRef s) { return getImpl(s);} - Variant get(litstr s) { return getImpl(s);} - - /** - * Code-generated sub-class may override this function by generating one - * entry per variable. - */ - virtual bool exists(CStrRef s) const { - // Integers are never valid variable names. - return Array::exists(s, true); - } - - /** - * Code-generated sub-class will implement this function by generating one - * entry per variable. - */ - virtual Variant getImpl(CStrRef s) = 0; - - virtual Array getDefinedVars() const; -}; - -/////////////////////////////////////////////////////////////////////////////// - -enum SuperGlobal { - SgServer = 0, - SgGet, - SgPost, - SgFiles, - SgCookie, - SgSession, - SgRequest, - SgEnv, - SgGlobals, - SgHttpResponseHeader, - SgNormal -}; - -/** - * L-value variable table that can get/set a variable's value by its name. The - * reason we have both RVariableTable and LVariableTable, instead of just this - * one, is because LVariableTable requires all variables to be Variant type, - * taking away type inference. If we can tell no dynamic variable was used in - * l-value context, we don't have to use LVariableTable. Of course, ideally - * even RVariableTable is not needed, meaning no dynamic variable is ever used. - */ -class LVariableTable : public Array { - public: - virtual ~LVariableTable() {} - Variant &get(CVarRef s) { return getImpl(s.toString()); } - Variant &get(CStrRef s) { return getImpl(s); } - Variant &get(litstr s) { return getImpl(s);} - virtual Variant &getVar(CStrRef s, SuperGlobal sg) { - assert(sg == SgNormal); - return getImpl(s); - } - - /** - * Code-generated sub-class may override this function by generating one - * entry per variable. - */ - virtual bool exists(CStrRef s) const { - return Array::exists(s, true); - } - - /** - * Code-generated sub-class will implement this function by generating one - * entry per variable. - */ - virtual Variant &getImpl(CStrRef s); - - virtual Array getDefinedVars(); -}; - -/////////////////////////////////////////////////////////////////////////////// -} - -#endif // __HPHP_VARIABLE_TABLE_H__ diff --git a/hphp/runtime/eval/eval.cpp b/hphp/runtime/eval/eval.cpp index 52a7ac947..325f9b00b 100644 --- a/hphp/runtime/eval/eval.cpp +++ b/hphp/runtime/eval/eval.cpp @@ -16,7 +16,6 @@ #include #include -#include namespace HPHP { @@ -29,21 +28,6 @@ ObjectData *eval_create_object_only_hook(CStrRef s, ObjectData *root) { const StringData* className = StringData::GetStaticString(s.get()); return g_vmContext->createObjectOnly((StringData*)className); } -bool eval_invoke_file_hook(Variant &res, CStrRef path, bool once, - LVariableTable* variables, const char *currentDir) { - bool initial; - HPHP::Eval::PhpFile* efile = - g_vmContext->lookupPhpFile(path.get(), currentDir, &initial); - HPHP::VM::Unit* u = nullptr; - if (efile) u = efile->unit(); - if (u == nullptr) { - return false; - } - if (!once || initial) { - g_vmContext->invokeUnit((TypedValue*)(&res), u); - } - return true; -} /////////////////////////////////////////////////////////////////////////////// } diff --git a/hphp/runtime/eval/eval.h b/hphp/runtime/eval/eval.h index 04a44738e..2591d7b7a 100644 --- a/hphp/runtime/eval/eval.h +++ b/hphp/runtime/eval/eval.h @@ -23,8 +23,6 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// ObjectData *eval_create_object_only_hook(CStrRef s, ObjectData *root); -bool eval_invoke_file_hook(Variant &res, CStrRef path, bool once, - LVariableTable* variables, const char *currentDir); /////////////////////////////////////////////////////////////////////////////// } diff --git a/hphp/runtime/ext/ext_array.cpp b/hphp/runtime/ext/ext_array.cpp index 8a9ea2062..5cd7693f1 100644 --- a/hphp/runtime/ext/ext_array.cpp +++ b/hphp/runtime/ext/ext_array.cpp @@ -560,37 +560,6 @@ Array f_compact(int _argc, CVarRef varname, CArrRef _argv /* = null_array */) { return ret; } -template -static void compact(T *variables, Array &ret, CVarRef var) { - if (var.isArray()) { - CArrRef vars = var.toCArrRef(); - for (ArrayIter iter(vars); iter; ++iter) { - compact(variables, ret, iter.second()); - } - } else { - String varname = var.toString(); - if (!varname.empty() && variables->exists(varname)) { - ret.set(varname, variables->get(varname)); - } - } -} - -Array compact(RVariableTable *variables, int _argc, CVarRef varname, - CArrRef _argv /* = null_array */) { - Array ret = Array::Create(); - compact(variables, ret, varname); - compact(variables, ret, _argv); - return ret; -} - -Array compact(LVariableTable *variables, int _argc, CVarRef varname, - CArrRef _argv /* = null_array */) { - Array ret = Array::Create(); - compact(variables, ret, varname); - compact(variables, ret, _argv); - return ret; -} - static int php_count_recursive(CArrRef array) { long cnt = array.size(); for (ArrayIter iter(array); iter; ++iter) { diff --git a/hphp/runtime/ext/ext_array.h b/hphp/runtime/ext/ext_array.h index 434b60da6..598fd5a40 100644 --- a/hphp/runtime/ext/ext_array.h +++ b/hphp/runtime/ext/ext_array.h @@ -111,14 +111,7 @@ bool f_array_walk_recursive(VRefParam input, CVarRef funcname, bool f_array_walk(VRefParam input, CVarRef funcname, CVarRef userdata = null_variant); -/** - * LVariableTable parameter is added by HPHP. - */ Array f_compact(int _argc, CVarRef varname, CArrRef _argv = null_array); -Array compact(RVariableTable *variables, int _argc, CVarRef varname, - CArrRef _argv = null_array); -Array compact(LVariableTable *variables, int _argc, CVarRef varname, - CArrRef _argv = null_array); bool f_shuffle(VRefParam array); int64_t f_count(CVarRef var, bool recursive = false); diff --git a/hphp/runtime/ext/ext_spl.cpp b/hphp/runtime/ext/ext_spl.cpp index cd7313293..e18c9acf8 100644 --- a/hphp/runtime/ext/ext_spl.cpp +++ b/hphp/runtime/ext/ext_spl.cpp @@ -332,7 +332,7 @@ void f_spl_autoload(CStrRef class_name, bool found = false; for (ArrayIter iter(ext); iter; ++iter) { String fileName = lClass + iter.second(); - include(fileName, true, nullptr, "", false); + include(fileName, true, "", false); if (f_class_exists(class_name, false)) { found = true; break; diff --git a/hphp/runtime/ext/ext_variable.cpp b/hphp/runtime/ext/ext_variable.cpp index 456394fdf..95e84de55 100644 --- a/hphp/runtime/ext/ext_variable.cpp +++ b/hphp/runtime/ext/ext_variable.cpp @@ -137,18 +137,10 @@ Array f_get_defined_vars() { } } -Array get_defined_vars(LVariableTable *variables) { - return variables->getDefinedVars(); -} - -Array get_defined_vars(RVariableTable *variables) { - return variables->getDefinedVars(); -} - bool f_import_request_variables(CStrRef types, CStrRef prefix /* = "" */) { throw NotSupportedException(__func__, - "It is bad coding practice to remove scoping " - "of variables just to achieve coding convenience, " + "It is bad coding practice to remove scoping of " + "variables just to achieve coding convenience, " "esp. in a language that encourages global " "variables. This is possible to implement " "though, by declaring those global variables " @@ -157,7 +149,7 @@ bool f_import_request_variables(CStrRef types, CStrRef prefix /* = "" */) { } int64_t f_extract(CArrRef var_array, int extract_type /* = EXTR_OVERWRITE */, - CStrRef prefix /* = "" */) { + CStrRef prefix /* = "" */) { bool reference = extract_type & EXTR_REFS; extract_type &= ~EXTR_REFS; @@ -211,52 +203,5 @@ int64_t f_extract(CArrRef var_array, int extract_type /* = EXTR_OVERWRITE */, return count; } -int extract(LVariableTable *variables, CArrRef var_array, - int extract_type /* = EXTR_OVERWRITE */, - String prefix /* = "" */) { - bool reference = extract_type & EXTR_REFS; - extract_type &= ~EXTR_REFS; - - int count = 0; - for (ArrayIter iter(var_array); iter; ++iter) { - String name = iter.first(); - - switch (extract_type) { - case EXTR_SKIP: - if (variables->exists(name)) continue; - break; - case EXTR_IF_EXISTS: - if (!variables->exists(name)) continue; - break; - case EXTR_PREFIX_SAME: - if (variables->exists(name)) name = prefix + "_" + name; - break; - case EXTR_PREFIX_ALL: - name = prefix + "_" + name; - break; - case EXTR_PREFIX_INVALID: - if (!name.isValidVariableName()) name = prefix + "_" + name; - break; - case EXTR_PREFIX_IF_EXISTS: - if (!variables->exists(name)) continue; - name = prefix + "_" + name; - break; - default: - break; - } - - // skip invalid variable names, as in PHP - if (!name.isValidVariableName()) continue; - - if (reference) { - variables->get(name).assignRef(iter.secondRef()); - } else { - variables->get(name).assignVal(iter.second()); - } - count++; - } - return count; -} - /////////////////////////////////////////////////////////////////////////////// } diff --git a/hphp/runtime/ext/ext_variable.h b/hphp/runtime/ext/ext_variable.h index 448f3e106..025e9c6db 100644 --- a/hphp/runtime/ext/ext_variable.h +++ b/hphp/runtime/ext/ext_variable.h @@ -245,8 +245,6 @@ Variant f_unserialize(CStrRef str); // variable table Array f_get_defined_vars(); -Array get_defined_vars(LVariableTable *variables); -Array get_defined_vars(RVariableTable *variables); bool f_import_request_variables(CStrRef types, CStrRef prefix = ""); @@ -259,13 +257,8 @@ bool f_import_request_variables(CStrRef types, CStrRef prefix = ""); #define EXTR_IF_EXISTS 6 #define EXTR_REFS 0x100 -/** - * LVariableTable parameter is added by HPHP. - */ int64_t f_extract(CArrRef var_array, int extract_type = EXTR_OVERWRITE, - CStrRef prefix = ""); -int extract(LVariableTable *variables, CArrRef var_array, - int extract_type = EXTR_OVERWRITE, String prefix = ""); + CStrRef prefix = ""); /////////////////////////////////////////////////////////////////////////////// }