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_FM_EXPRESSION_H 8 #define _XFA_FM_EXPRESSION_H 9 enum XFA_FM_EXPTYPE { 10 XFA_FM_EXPTYPE_UNKNOWN, 11 XFA_FM_EXPTYPE_FUNC, 12 XFA_FM_EXPTYPE_VAR, 13 XFA_FM_EXPTYPE_EXP, 14 XFA_FM_EXPTYPE_BLOCK, 15 XFA_FM_EXPTYPE_IF, 16 XFA_FM_EXPTYPE_BREAK, 17 XFA_FM_EXPTYPE_CONTINUE, 18 }; 19 class CXFA_FMExpression { 20 public: 21 CXFA_FMExpression(FX_DWORD line); 22 CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type); ~CXFA_FMExpression()23 virtual ~CXFA_FMExpression(){}; 24 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 25 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); GetLine()26 FX_DWORD GetLine() { return m_line; } GetExpType()27 XFA_FM_EXPTYPE GetExpType() const { return m_type; } 28 29 protected: 30 XFA_FM_EXPTYPE m_type; 31 FX_DWORD m_line; 32 }; 33 class CXFA_FMFunctionDefinition : public CXFA_FMExpression { 34 public: 35 CXFA_FMFunctionDefinition(FX_DWORD line, 36 FX_BOOL isGlobal, 37 const CFX_WideStringC& wsName, 38 CFX_WideStringCArray* pArguments, 39 CFX_PtrArray* pExpressions); 40 virtual ~CXFA_FMFunctionDefinition(); 41 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 42 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 43 44 private: 45 CFX_WideStringC m_wsName; 46 CFX_WideStringCArray* m_pArguments; 47 CFX_PtrArray* m_pExpressions; 48 FX_BOOL m_isGlobal; 49 }; 50 class CXFA_FMVarExpression : public CXFA_FMExpression { 51 public: 52 CXFA_FMVarExpression(FX_DWORD line, 53 const CFX_WideStringC& wsName, 54 CXFA_FMExpression* pInit); 55 virtual ~CXFA_FMVarExpression(); 56 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 57 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 58 59 private: 60 CFX_WideStringC m_wsName; 61 CXFA_FMExpression* m_pInit; 62 }; 63 class CXFA_FMExpExpression : public CXFA_FMExpression { 64 public: 65 CXFA_FMExpExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression); 66 virtual ~CXFA_FMExpExpression(); 67 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 68 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 69 70 private: 71 CXFA_FMSimpleExpression* m_pExpression; 72 }; 73 class CXFA_FMBlockExpression : public CXFA_FMExpression { 74 public: 75 CXFA_FMBlockExpression(FX_DWORD line, CFX_PtrArray* pExpressionList); 76 virtual ~CXFA_FMBlockExpression(); 77 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 78 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 79 80 private: 81 CFX_PtrArray* m_pExpressionList; 82 }; 83 class CXFA_FMDoExpression : public CXFA_FMExpression { 84 public: 85 CXFA_FMDoExpression(FX_DWORD line, CXFA_FMExpression* pList); 86 virtual ~CXFA_FMDoExpression(); 87 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 88 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 89 90 private: 91 CXFA_FMExpression* m_pList; 92 }; 93 class CXFA_FMIfExpression : public CXFA_FMExpression { 94 public: 95 CXFA_FMIfExpression(FX_DWORD line, 96 CXFA_FMSimpleExpression* pExpression, 97 CXFA_FMExpression* pIfExpression, 98 CXFA_FMExpression* pElseExpression); 99 virtual ~CXFA_FMIfExpression(); 100 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 101 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 102 103 private: 104 CXFA_FMSimpleExpression* m_pExpression; 105 CXFA_FMExpression* m_pIfExpression; 106 CXFA_FMExpression* m_pElseExpression; 107 }; 108 class CXFA_FMLoopExpression : public CXFA_FMExpression { 109 public: CXFA_FMLoopExpression(FX_DWORD line)110 CXFA_FMLoopExpression(FX_DWORD line) : CXFA_FMExpression(line) {} 111 virtual ~CXFA_FMLoopExpression(); 112 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 113 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 114 }; 115 class CXFA_FMWhileExpression : public CXFA_FMLoopExpression { 116 public: 117 CXFA_FMWhileExpression(FX_DWORD line, 118 CXFA_FMSimpleExpression* pCodition, 119 CXFA_FMExpression* pExpression); 120 virtual ~CXFA_FMWhileExpression(); 121 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 122 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 123 124 private: 125 CXFA_FMSimpleExpression* m_pCondition; 126 CXFA_FMExpression* m_pExpression; 127 }; 128 class CXFA_FMBreakExpression : public CXFA_FMExpression { 129 public: 130 CXFA_FMBreakExpression(FX_DWORD line); 131 virtual ~CXFA_FMBreakExpression(); 132 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 133 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 134 }; 135 class CXFA_FMContinueExpression : public CXFA_FMExpression { 136 public: 137 CXFA_FMContinueExpression(FX_DWORD line); 138 virtual ~CXFA_FMContinueExpression(); 139 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 140 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 141 }; 142 class CXFA_FMForExpression : public CXFA_FMLoopExpression { 143 public: 144 CXFA_FMForExpression(FX_DWORD line, 145 const CFX_WideStringC& wsVariant, 146 CXFA_FMSimpleExpression* pAssignment, 147 CXFA_FMSimpleExpression* pAccessor, 148 int32_t iDirection, 149 CXFA_FMSimpleExpression* pStep, 150 CXFA_FMExpression* pList); 151 virtual ~CXFA_FMForExpression(); 152 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 153 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 154 155 private: 156 CFX_WideStringC m_wsVariant; 157 CXFA_FMSimpleExpression* m_pAssignment; 158 CXFA_FMSimpleExpression* m_pAccessor; 159 int32_t m_iDirection; 160 CXFA_FMSimpleExpression* m_pStep; 161 CXFA_FMExpression* m_pList; 162 }; 163 class CXFA_FMForeachExpression : public CXFA_FMLoopExpression { 164 public: 165 CXFA_FMForeachExpression(FX_DWORD line, 166 const CFX_WideStringC& wsIdentifier, 167 CFX_PtrArray* pAccessors, 168 CXFA_FMExpression* pList); 169 virtual ~CXFA_FMForeachExpression(); 170 virtual void ToJavaScript(CFX_WideTextBuf& javascript); 171 virtual void ToImpliedReturnJS(CFX_WideTextBuf&); 172 173 private: 174 CFX_WideStringC m_wsIdentifier; 175 CFX_PtrArray* m_pAccessors; 176 CXFA_FMExpression* m_pList; 177 }; 178 #endif 179