2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- 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/compiler/analysis/function_container.h"
18 #include "hphp/compiler/analysis/analysis_result.h"
19 #include "hphp/compiler/analysis/function_scope.h"
20 #include "hphp/compiler/analysis/class_scope.h"
21 #include "hphp/compiler/analysis/file_scope.h"
22 #include "hphp/compiler/analysis/code_error.h"
23 #include "hphp/compiler/statement/statement_list.h"
24 #include "hphp/compiler/option.h"
25 #include "hphp/util/util.h"
26 #include "hphp/util/hash.h"
30 ///////////////////////////////////////////////////////////////////////////////
32 FunctionContainer::FunctionContainer() {
35 ///////////////////////////////////////////////////////////////////////////////
38 void FunctionContainer::countReturnTypes(
39 std::map
<std::string
, int> &counts
,
40 const StringToFunctionScopePtrVecMap
*redec
) {
41 for (StringToFunctionScopePtrMap::const_iterator iter
=
42 m_functions
.begin(); iter
!= m_functions
.end(); ++iter
) {
43 FunctionScopePtr f
= iter
->second
;
44 if (f
->isLocalRedeclaring()) {
46 BOOST_FOREACH(f
, redec
->find(iter
->first
)->second
) {
47 TypePtr type
= f
->getReturnType();
53 TypePtr type
= f
->getReturnType();
61 ///////////////////////////////////////////////////////////////////////////////
62 // code generation functions
64 void FunctionContainer::getFunctionsFlattened(
65 const StringToFunctionScopePtrVecMap
*redec
,
66 FunctionScopePtrVec
&funcs
,
67 bool excludePseudoMains
/* = false */) const {
68 for (StringToFunctionScopePtrMap::const_iterator it
= m_functions
.begin();
69 it
!= m_functions
.end(); ++it
) {
70 FunctionScopePtr func
= it
->second
;
71 if (!excludePseudoMains
|| !func
->inPseudoMain()) {
72 if (func
->isLocalRedeclaring()) {
73 const FunctionScopePtrVec
&r
= redec
->find(it
->first
)->second
;
74 funcs
.insert(funcs
.end(), r
.begin(), r
.end());
76 funcs
.push_back(func
);