Home | History | Annotate | Download | only in fm2js
      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_SIMPLEEXPRESSION_H
      8 #define _XFA_FM_SIMPLEEXPRESSION_H
      9 enum XFA_FM_SimpleExpressionType {
     10   ASSIGN,
     11   LOGICALOR,
     12   LOGICALAND,
     13   EQUALITY,
     14   NOTEQUALITY,
     15   LESS,
     16   LESSEQUAL,
     17   GREATER,
     18   GREATEREQUAL,
     19   PLUS,
     20   MINUS,
     21   MULTIPLE,
     22   DIVIDE,
     23   POSITIVE,
     24   NEGATIVE,
     25   NOT,
     26   CALL,
     27   DOT,
     28   DOTDOT,
     29   CONCATFMOBJECT,
     30   ISFMOBJECT,
     31   ISFMARRAY,
     32   GETFMVALUE,
     33   GETFMJSOBJ,
     34   VARFILTER
     35 };
     36 CFX_WideStringC XFA_FM_EXPTypeToString(
     37     XFA_FM_SimpleExpressionType simpleExpType);
     38 struct XFA_FMBuildInFunc {
     39   uint32_t m_uHash;
     40   const FX_WCHAR* m_buildinfunc;
     41 };
     42 struct XFA_FMSOMMethod {
     43   uint32_t m_uHash;
     44   const FX_WCHAR* m_wsSomMethodName;
     45   FX_DWORD m_dParameters;
     46 };
     47 enum XFA_FM_AccessorIndex {
     48   ACCESSOR_NO_INDEX,
     49   ACCESSOR_NO_RELATIVEINDEX,
     50   ACCESSOR_POSITIVE_INDEX,
     51   ACCESSOR_NEGATIVE_INDEX
     52 };
     53 class CXFA_FMSimpleExpression {
     54  public:
     55   CXFA_FMSimpleExpression(FX_DWORD line, XFA_FM_TOKEN op);
     56   virtual ~CXFA_FMSimpleExpression(){};
     57   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
     58   virtual void ToImpliedReturnJS(CFX_WideTextBuf& javascript);
     59 
     60   XFA_FM_TOKEN GetOperatorToken() const;
     61 
     62  protected:
     63   FX_DWORD m_line;
     64   XFA_FM_TOKEN m_op;
     65 };
     66 class CXFA_FMNullExpression : public CXFA_FMSimpleExpression {
     67  public:
     68   CXFA_FMNullExpression(FX_DWORD line);
     69   virtual ~CXFA_FMNullExpression(){};
     70   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
     71 };
     72 class CXFA_FMNumberExpression : public CXFA_FMSimpleExpression {
     73  public:
     74   CXFA_FMNumberExpression(FX_DWORD line, CFX_WideStringC wsNumber);
     75   virtual ~CXFA_FMNumberExpression(){};
     76   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
     77 
     78  protected:
     79   CFX_WideStringC m_wsNumber;
     80 };
     81 class CXFA_FMStringExpression : public CXFA_FMSimpleExpression {
     82  public:
     83   CXFA_FMStringExpression(FX_DWORD line, CFX_WideStringC wsString);
     84   virtual ~CXFA_FMStringExpression(){};
     85   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
     86 
     87  protected:
     88   CFX_WideStringC m_wsString;
     89 };
     90 class CXFA_FMIdentifierExpressionn : public CXFA_FMSimpleExpression {
     91  public:
     92   CXFA_FMIdentifierExpressionn(FX_DWORD line, CFX_WideStringC wsIdentifier);
     93   virtual ~CXFA_FMIdentifierExpressionn(){};
     94   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
     95 
     96  protected:
     97   CFX_WideStringC m_wsIdentifier;
     98 };
     99 class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression {
    100  public:
    101   CXFA_FMUnaryExpression(FX_DWORD line,
    102                          XFA_FM_TOKEN op,
    103                          CXFA_FMSimpleExpression* pExp);
    104   virtual ~CXFA_FMUnaryExpression();
    105   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    106 
    107  protected:
    108   CXFA_FMSimpleExpression* m_pExp;
    109 };
    110 class CXFA_FMBinExpression : public CXFA_FMSimpleExpression {
    111  public:
    112   CXFA_FMBinExpression(FX_DWORD line,
    113                        XFA_FM_TOKEN op,
    114                        CXFA_FMSimpleExpression* pExp1,
    115                        CXFA_FMSimpleExpression* pExp2);
    116   virtual ~CXFA_FMBinExpression();
    117   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    118 
    119  protected:
    120   CXFA_FMSimpleExpression* m_pExp1;
    121   CXFA_FMSimpleExpression* m_pExp2;
    122 };
    123 class CXFA_FMAssignExpression : public CXFA_FMBinExpression {
    124  public:
    125   CXFA_FMAssignExpression(FX_DWORD line,
    126                           XFA_FM_TOKEN op,
    127                           CXFA_FMSimpleExpression* pExp1,
    128                           CXFA_FMSimpleExpression* pExp2);
    129   virtual ~CXFA_FMAssignExpression(){};
    130   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    131   virtual void ToImpliedReturnJS(CFX_WideTextBuf& javascript);
    132 };
    133 class CXFA_FMLogicalOrExpression : public CXFA_FMBinExpression {
    134  public:
    135   CXFA_FMLogicalOrExpression(FX_DWORD line,
    136                              XFA_FM_TOKEN op,
    137                              CXFA_FMSimpleExpression* pExp1,
    138                              CXFA_FMSimpleExpression* pExp2);
    139   virtual ~CXFA_FMLogicalOrExpression(){};
    140   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    141 };
    142 class CXFA_FMLogicalAndExpression : public CXFA_FMBinExpression {
    143  public:
    144   CXFA_FMLogicalAndExpression(FX_DWORD line,
    145                               XFA_FM_TOKEN op,
    146                               CXFA_FMSimpleExpression* pExp1,
    147                               CXFA_FMSimpleExpression* pExp2);
    148   virtual ~CXFA_FMLogicalAndExpression(){};
    149   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    150 };
    151 class CXFA_FMEqualityExpression : public CXFA_FMBinExpression {
    152  public:
    153   CXFA_FMEqualityExpression(FX_DWORD line,
    154                             XFA_FM_TOKEN op,
    155                             CXFA_FMSimpleExpression* pExp1,
    156                             CXFA_FMSimpleExpression* pExp2);
    157   virtual ~CXFA_FMEqualityExpression(){};
    158   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    159 };
    160 class CXFA_FMRelationalExpression : public CXFA_FMBinExpression {
    161  public:
    162   CXFA_FMRelationalExpression(FX_DWORD line,
    163                               XFA_FM_TOKEN op,
    164                               CXFA_FMSimpleExpression* pExp1,
    165                               CXFA_FMSimpleExpression* pExp2);
    166   virtual ~CXFA_FMRelationalExpression(){};
    167   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    168 };
    169 class CXFA_FMAdditiveExpression : public CXFA_FMBinExpression {
    170  public:
    171   CXFA_FMAdditiveExpression(FX_DWORD line,
    172                             XFA_FM_TOKEN op,
    173                             CXFA_FMSimpleExpression* pExp1,
    174                             CXFA_FMSimpleExpression* pExp2);
    175   virtual ~CXFA_FMAdditiveExpression(){};
    176   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    177 };
    178 class CXFA_FMMultiplicativeExpression : public CXFA_FMBinExpression {
    179  public:
    180   CXFA_FMMultiplicativeExpression(FX_DWORD line,
    181                                   XFA_FM_TOKEN op,
    182                                   CXFA_FMSimpleExpression* pExp1,
    183                                   CXFA_FMSimpleExpression* pExp2);
    184   virtual ~CXFA_FMMultiplicativeExpression(){};
    185   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    186 };
    187 class CXFA_FMPosExpression : public CXFA_FMUnaryExpression {
    188  public:
    189   CXFA_FMPosExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp);
    190   virtual ~CXFA_FMPosExpression(){};
    191   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    192 };
    193 class CXFA_FMNegExpression : public CXFA_FMUnaryExpression {
    194  public:
    195   CXFA_FMNegExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp);
    196   virtual ~CXFA_FMNegExpression(){};
    197   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    198 };
    199 class CXFA_FMNotExpression : public CXFA_FMUnaryExpression {
    200  public:
    201   CXFA_FMNotExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp);
    202   virtual ~CXFA_FMNotExpression(){};
    203   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    204 };
    205 class CXFA_FMCallExpression : public CXFA_FMUnaryExpression {
    206  public:
    207   CXFA_FMCallExpression(FX_DWORD line,
    208                         CXFA_FMSimpleExpression* pExp,
    209                         CFX_PtrArray* pArguments,
    210                         FX_BOOL bIsSomMethod);
    211   virtual ~CXFA_FMCallExpression();
    212   virtual FX_BOOL IsBuildInFunc(CFX_WideTextBuf& funcName);
    213   virtual FX_DWORD IsSomMethodWithObjPara(const CFX_WideStringC& methodName);
    214   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    215 
    216  private:
    217   FX_BOOL m_bIsSomMethod;
    218   CFX_PtrArray* m_pArguments;
    219 };
    220 class CXFA_FMDotAccessorExpression : public CXFA_FMBinExpression {
    221  public:
    222   CXFA_FMDotAccessorExpression(FX_DWORD line,
    223                                CXFA_FMSimpleExpression* pAccessor,
    224                                XFA_FM_TOKEN op,
    225                                CFX_WideStringC wsIdentifier,
    226                                CXFA_FMSimpleExpression* pIndexExp);
    227   virtual ~CXFA_FMDotAccessorExpression(){};
    228   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    229 
    230  protected:
    231   CFX_WideStringC m_wsIdentifier;
    232 };
    233 class CXFA_FMIndexExpression : public CXFA_FMUnaryExpression {
    234  public:
    235   CXFA_FMIndexExpression(FX_DWORD line,
    236                          XFA_FM_AccessorIndex accessorIndex,
    237                          CXFA_FMSimpleExpression* pIndexExp,
    238                          FX_BOOL bIsStarIndex);
    239   virtual ~CXFA_FMIndexExpression(){};
    240   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    241 
    242  protected:
    243   XFA_FM_AccessorIndex m_accessorIndex;
    244   FX_BOOL m_bIsStarIndex;
    245 };
    246 class CXFA_FMDotDotAccessorExpression : public CXFA_FMBinExpression {
    247  public:
    248   CXFA_FMDotDotAccessorExpression(FX_DWORD line,
    249                                   CXFA_FMSimpleExpression* pAccessor,
    250                                   XFA_FM_TOKEN op,
    251                                   CFX_WideStringC wsIdentifier,
    252                                   CXFA_FMSimpleExpression* pIndexExp);
    253   virtual ~CXFA_FMDotDotAccessorExpression(){};
    254   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    255 
    256  protected:
    257   CFX_WideStringC m_wsIdentifier;
    258 };
    259 class CXFA_FMMethodCallExpression : public CXFA_FMBinExpression {
    260  public:
    261   CXFA_FMMethodCallExpression(FX_DWORD line,
    262                               CXFA_FMSimpleExpression* pAccessorExp1,
    263                               CXFA_FMSimpleExpression* pCallExp);
    264   virtual ~CXFA_FMMethodCallExpression(){};
    265   virtual void ToJavaScript(CFX_WideTextBuf& javascript);
    266 
    267  protected:
    268 };
    269 #endif
    270