00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef STILSigRefExpr_H
00014 #define STILSigRefExpr_H
00015
00016
00017 #include "stilcom.h"
00018 #include "stilcomstr.h"
00019 #include "stilsignal.h"
00020 #include "stilsignallist.h"
00021
00022 #include <list>
00023 #include <stack>
00024
00025 class STILEvalEngine;
00026
00027
00033
00034 class STILSigRefExpr : public STILEntity {
00035
00036
00037 public:
00038
00039 friend struct STILSigRefExpr_Data;
00040
00041
00042 enum Operator {
00043 UndefinedOperator,
00044 Plus,
00045 Minus,
00046 LeftParen,
00047 RightParen
00048 };
00049
00050
00051 STILSigRefExpr();
00052
00053
00054 STILSigRefExpr(const STILSigRefExpr &);
00055
00056
00057 virtual ~STILSigRefExpr();
00058
00059
00060 STILSigRefExpr & operator=(const STILSigRefExpr &);
00061
00062
00063 void init();
00064
00065
00066 virtual void write(FILE * pOutFile, LONG indentation=0) const;
00067
00068
00069
00070 void addOp(Operator op);
00071
00072
00073 void addId(const sstring & id, LONG idx1=-1, LONG idx2=-1);
00074
00075
00076 const sstring & getText() const;
00077
00078
00079 enum NodeType {
00080 UndefinedNodeType,
00081 Id,
00082 Op
00083 };
00084
00086 struct STILSigRefExpr_Data {
00087 NodeType type;
00088 char * identifier;
00089 LONG idx1;
00090 LONG idx2;
00091 Operator op;
00092 };
00093
00094 struct STILSigRefExpr_Node;
00095
00096 struct STILSigRefExpr_Node {
00097 STILSigRefExpr_Data data;
00098 STILSigRefExpr_Node *l_tree;
00099 STILSigRefExpr_Node *r_tree;
00100 };
00101
00102
00103 void printTree(const STILSigRefExpr_Node * p_tree = NULL) const;
00104
00105
00106 void clearTree(STILSigRefExpr_Node * p_tree = NULL);
00107
00108
00109 void copyTree(STILSigRefExpr_Node *&,const STILSigRefExpr_Node *);
00110
00111
00112
00113
00114 STILSignalList eval(const STILEvalEngine*, const STILSigRefExpr_Node *p_tree = NULL);
00115
00116
00117 private:
00118
00119
00120
00121 STILSigRefExpr_Node * m_exprTree;
00122 sstring m_exprText;
00123 std::stack<void *,std::list<void *> > m_parenStack;
00124 bool m_errInEval;
00125
00126 };
00127
00128
00129
00137
00138 inline const sstring & STILSigRefExpr::getText() const { return m_exprText; }
00139
00140
00141 #endif