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 __EXPRESSION_LIST_H__
18 #define __EXPRESSION_LIST_H__
20 #include <compiler/expression/expression.h>
23 ///////////////////////////////////////////////////////////////////////////////
25 DECLARE_BOOST_TYPES(ExpressionList
);
27 class ExpressionList
: public Expression
{
36 ExpressionList(EXPRESSION_CONSTRUCTOR_PARAMETERS
,
37 ListKind kind
= ListKindParam
);
39 // change case to lower so to make it case insensitive
42 DECLARE_EXPRESSION_VIRTUAL_FUNCTIONS
;
43 ExpressionPtr
preOptimize(AnalysisResultConstPtr ar
);
44 ExpressionPtr
postOptimize(AnalysisResultConstPtr ar
);
46 virtual void setContext(Context context
);
47 void setListKind(ListKind kind
) { m_kind
= kind
; }
48 ListKind
getListKind() const { return m_kind
; }
49 virtual void addElement(ExpressionPtr exp
);
50 virtual void insertElement(ExpressionPtr exp
, int index
= 0);
51 virtual bool isScalar() const;
52 virtual int getLocalEffects() const { return NoEffect
; }
53 bool isNoObjectInvolved() const;
54 virtual bool containsDynamicConstant(AnalysisResultPtr ar
) const;
55 void removeElement(int index
);
57 virtual bool getScalarValue(Variant
&value
);
58 virtual bool isRefable(bool checkError
= false) const;
59 virtual bool kidUnused(int i
) const;
60 ExpressionPtr
listValue() const;
61 virtual bool isLiteralString() const;
62 virtual std::string
getLiteralString() const;
64 bool isScalarArrayPairs() const;
66 int getCount() const { return m_exps
.size();}
67 ExpressionPtr
&operator[](int index
);
69 void getStrings(std::vector
<std::string
> &strings
);
70 void getOriginalStrings(std::vector
<std::string
> &strings
);
73 void markParam(int p
, bool noRefWrapper
);
74 void markParams(bool noRefWrapper
);
77 * When a function call has too many arguments, we only want to output
78 * max number of arguments, by limiting output count of subexpressions.
80 void setOutputCount(int count
);
81 int getOutputCount() const;
82 void resetOutputCount();
84 virtual bool canonCompare(ExpressionPtr e
) const;
86 void preOutputStash(CodeGenerator
&cg
, AnalysisResultPtr ar
,
88 bool preOutputCPP(CodeGenerator
&cg
, AnalysisResultPtr ar
,
90 bool outputCPPUnneeded(CodeGenerator
&cg
, AnalysisResultPtr ar
);
91 bool hasNonArrayCreateValue(bool arrayElements
= true,
92 unsigned int start
= 0) const;
93 void outputCPPUniqLitKeyArrayInit(CodeGenerator
&cg
,
97 bool arrayElements
= true,
98 unsigned int start
= 0);
100 * Checks whether the expression list contains only literal strings and
101 * (recursive) arrays of literal strings. Also returns the list of strings
104 bool flattenLiteralStrings(std::vector
<ExpressionPtr
> &literals
) const;
107 void optimize(AnalysisResultConstPtr ar
);
108 unsigned int checkLitstrKeys() const;
109 bool outputCPPArrayCreate(CodeGenerator
&cg
, AnalysisResultPtr ar
,
110 bool isVector
, bool pre
);
111 bool outputCPPInternal(CodeGenerator
&cg
,
112 AnalysisResultPtr ar
, bool needed
, bool pre
);
114 ExpressionPtrVec m_exps
;
116 bool m_arrayElements
;
120 ///////////////////////////////////////////////////////////////////////////////
122 #endif // __EXPRESSION_LIST_H__