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 #ifndef __FUNCTION_CALL_H__
18 #define __FUNCTION_CALL_H__
20 #include <compiler/expression/static_class_name.h>
23 ///////////////////////////////////////////////////////////////////////////////
25 DECLARE_BOOST_TYPES(ExpressionList
);
26 DECLARE_BOOST_TYPES(FunctionScope
);
27 DECLARE_BOOST_TYPES(FunctionCall
);
29 class FunctionCall
: public Expression
, public StaticClassName
{
31 FunctionCall(EXPRESSION_CONSTRUCTOR_PARAMETERS
, ExpressionPtr nameExp
,
32 const std::string
&name
, ExpressionListPtr params
,
33 ExpressionPtr classExp
);
35 // overriding Expression::outputCPP to implement void wrapper
36 virtual void outputCPP(CodeGenerator
&cg
, AnalysisResultPtr ar
);
37 virtual bool isRefable(bool checkError
= false) const { return true;}
38 virtual bool isTemporary() const;
40 virtual ConstructPtr
getNthKid(int n
) const;
41 virtual void setNthKid(int n
, ConstructPtr cp
);
42 virtual int getKidCount() const;
44 virtual ExpressionPtr
preOptimize(AnalysisResultPtr ar
);
45 virtual ExpressionPtr
postOptimize(AnalysisResultPtr ar
);
47 void setAllowVoidReturn() { m_allowVoidReturn
= true;}
48 void setFunctionAndClassScope(FunctionScopePtr fsp
, ClassScopePtr csp
);
49 bool preOutputCPP(CodeGenerator
&cg
, AnalysisResultPtr ar
,
51 void deepCopy(FunctionCallPtr exp
);
53 FunctionScopePtr
getFuncScope() const { return m_funcScope
; }
55 ExpressionPtr m_nameExp
;
57 std::string m_origName
;
60 ExpressionListPtr m_params
;
62 // Pointers to the corresponding function scope and class scope for this
63 // function call, set during the AnalyzeAll phase. These pointers may be
64 // null if the function scope or class scope could not be resolved.
65 FunctionScopePtr m_funcScope
;
66 ClassScopePtr m_classScope
;
71 bool m_variableArgument
;
72 bool m_voidReturn
; // no return type
73 bool m_voidWrapper
; // void wrapper is needed
74 bool m_allowVoidReturn
;
76 bool m_redeclaredClass
;
77 bool m_derivedFromRedeclaring
;
80 // Extra arguments form an array, to which the scalar array optimization
85 void optimizeArgArray(AnalysisResultPtr ar
);
87 void markRefParams(FunctionScopePtr func
, const std::string
&name
,
88 bool canInvokeFewArgs
);
91 * Each program needs to reset this object's members to revalidate
96 TypePtr
checkParamsAndReturn(AnalysisResultPtr ar
, TypePtr type
,
97 bool coerce
, FunctionScopePtr func
,
101 ///////////////////////////////////////////////////////////////////////////////
103 #endif // __FUNCTION_CALL_H__