OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef XFA_SRC_FXFA_FM2JS_XFA_EXPRESSION_H_ | |
8 #define XFA_SRC_FXFA_FM2JS_XFA_EXPRESSION_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "xfa/src/fxfa/fm2js/xfa_simpleexpression.h" | |
13 | |
14 enum XFA_FM_EXPTYPE { | |
15 XFA_FM_EXPTYPE_UNKNOWN, | |
16 XFA_FM_EXPTYPE_FUNC, | |
17 XFA_FM_EXPTYPE_VAR, | |
18 XFA_FM_EXPTYPE_EXP, | |
19 XFA_FM_EXPTYPE_BLOCK, | |
20 XFA_FM_EXPTYPE_IF, | |
21 XFA_FM_EXPTYPE_BREAK, | |
22 XFA_FM_EXPTYPE_CONTINUE, | |
23 }; | |
24 | |
25 class CXFA_FMExpression { | |
26 public: | |
27 explicit CXFA_FMExpression(FX_DWORD line); | |
28 CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type); | |
29 virtual ~CXFA_FMExpression() {} | |
30 virtual void ToJavaScript(CFX_WideTextBuf& javascript); | |
31 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); | |
32 FX_DWORD GetLine() { return m_line; } | |
33 XFA_FM_EXPTYPE GetExpType() const { return m_type; } | |
34 | |
35 protected: | |
36 XFA_FM_EXPTYPE m_type; | |
37 FX_DWORD m_line; | |
38 }; | |
39 | |
40 class CXFA_FMFunctionDefinition : public CXFA_FMExpression { | |
41 public: | |
42 CXFA_FMFunctionDefinition(FX_DWORD line, | |
43 FX_BOOL isGlobal, | |
44 const CFX_WideStringC& wsName, | |
45 CFX_WideStringCArray* pArguments, | |
46 CFX_PtrArray* pExpressions); | |
47 ~CXFA_FMFunctionDefinition() override; | |
48 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
49 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
50 | |
51 private: | |
52 CFX_WideStringC m_wsName; | |
53 CFX_WideStringCArray* m_pArguments; | |
54 CFX_PtrArray* m_pExpressions; | |
55 FX_BOOL m_isGlobal; | |
56 }; | |
57 | |
58 class CXFA_FMVarExpression : public CXFA_FMExpression { | |
59 public: | |
60 CXFA_FMVarExpression(FX_DWORD line, | |
61 const CFX_WideStringC& wsName, | |
62 CXFA_FMExpression* pInit); | |
63 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
64 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
65 | |
66 private: | |
67 CFX_WideStringC m_wsName; | |
68 std::unique_ptr<CXFA_FMExpression> m_pInit; | |
69 }; | |
70 | |
71 class CXFA_FMExpExpression : public CXFA_FMExpression { | |
72 public: | |
73 CXFA_FMExpExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression); | |
74 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
75 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
76 | |
77 private: | |
78 std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; | |
79 }; | |
80 | |
81 class CXFA_FMBlockExpression : public CXFA_FMExpression { | |
82 public: | |
83 CXFA_FMBlockExpression(FX_DWORD line, CFX_PtrArray* pExpressionList); | |
84 ~CXFA_FMBlockExpression() override; | |
85 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
86 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
87 | |
88 private: | |
89 CFX_PtrArray* m_pExpressionList; | |
90 }; | |
91 | |
92 class CXFA_FMDoExpression : public CXFA_FMExpression { | |
93 public: | |
94 CXFA_FMDoExpression(FX_DWORD line, CXFA_FMExpression* pList); | |
95 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
96 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
97 | |
98 private: | |
99 std::unique_ptr<CXFA_FMExpression> m_pList; | |
100 }; | |
101 | |
102 class CXFA_FMIfExpression : public CXFA_FMExpression { | |
103 public: | |
104 CXFA_FMIfExpression(FX_DWORD line, | |
105 CXFA_FMSimpleExpression* pExpression, | |
106 CXFA_FMExpression* pIfExpression, | |
107 CXFA_FMExpression* pElseExpression); | |
108 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
109 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
110 | |
111 private: | |
112 std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; | |
113 std::unique_ptr<CXFA_FMExpression> m_pIfExpression; | |
114 std::unique_ptr<CXFA_FMExpression> m_pElseExpression; | |
115 }; | |
116 | |
117 class CXFA_FMLoopExpression : public CXFA_FMExpression { | |
118 public: | |
119 explicit CXFA_FMLoopExpression(FX_DWORD line) : CXFA_FMExpression(line) {} | |
120 ~CXFA_FMLoopExpression() override; | |
121 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
122 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
123 }; | |
124 | |
125 class CXFA_FMWhileExpression : public CXFA_FMLoopExpression { | |
126 public: | |
127 CXFA_FMWhileExpression(FX_DWORD line, | |
128 CXFA_FMSimpleExpression* pCodition, | |
129 CXFA_FMExpression* pExpression); | |
130 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
131 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
132 | |
133 private: | |
134 std::unique_ptr<CXFA_FMSimpleExpression> m_pCondition; | |
135 std::unique_ptr<CXFA_FMExpression> m_pExpression; | |
136 }; | |
137 | |
138 class CXFA_FMBreakExpression : public CXFA_FMExpression { | |
139 public: | |
140 explicit CXFA_FMBreakExpression(FX_DWORD line); | |
141 ~CXFA_FMBreakExpression() override; | |
142 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
143 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
144 }; | |
145 | |
146 class CXFA_FMContinueExpression : public CXFA_FMExpression { | |
147 public: | |
148 explicit CXFA_FMContinueExpression(FX_DWORD line); | |
149 ~CXFA_FMContinueExpression() override; | |
150 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
151 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
152 }; | |
153 | |
154 class CXFA_FMForExpression : public CXFA_FMLoopExpression { | |
155 public: | |
156 CXFA_FMForExpression(FX_DWORD line, | |
157 const CFX_WideStringC& wsVariant, | |
158 CXFA_FMSimpleExpression* pAssignment, | |
159 CXFA_FMSimpleExpression* pAccessor, | |
160 int32_t iDirection, | |
161 CXFA_FMSimpleExpression* pStep, | |
162 CXFA_FMExpression* pList); | |
163 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
164 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
165 | |
166 private: | |
167 CFX_WideStringC m_wsVariant; | |
168 std::unique_ptr<CXFA_FMSimpleExpression> m_pAssignment; | |
169 std::unique_ptr<CXFA_FMSimpleExpression> m_pAccessor; | |
170 int32_t m_iDirection; | |
171 std::unique_ptr<CXFA_FMSimpleExpression> m_pStep; | |
172 std::unique_ptr<CXFA_FMExpression> m_pList; | |
173 }; | |
174 | |
175 class CXFA_FMForeachExpression : public CXFA_FMLoopExpression { | |
176 public: | |
177 CXFA_FMForeachExpression(FX_DWORD line, | |
178 const CFX_WideStringC& wsIdentifier, | |
179 CFX_PtrArray* pAccessors, | |
180 CXFA_FMExpression* pList); | |
181 ~CXFA_FMForeachExpression() override; | |
182 void ToJavaScript(CFX_WideTextBuf& javascript) override; | |
183 void ToImpliedReturnJS(CFX_WideTextBuf&) override; | |
184 | |
185 private: | |
186 CFX_WideStringC m_wsIdentifier; | |
187 CFX_PtrArray* m_pAccessors; | |
188 std::unique_ptr<CXFA_FMExpression> m_pList; | |
189 }; | |
190 | |
191 #endif // XFA_SRC_FXFA_FM2JS_XFA_EXPRESSION_H_ | |
OLD | NEW |