Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

stilsigrefexpr.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright (c) 2006 International Business Machines Corporation
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the Common Public License v1.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.opensource.org/licenses/cpl1.0.php
00007  *
00008  * Contributors:
00009  *    Douglas Sprague, Joel Wheeler - initial API and implementation
00010  *
00011  *****************************************************************************/
00012 
00013 #ifndef STILSigRefExpr_H
00014 #define STILSigRefExpr_H
00015 
00016 
00017 #include "stilcom.h"           // Common include
00018 #include "stilcomstr.h"
00019 #include "stilsignal.h"        // STIL Signal class
00020 #include "stilsignallist.h"    // STIL SignalList class
00021 
00022 #include <list>                // ANSI STL list class
00023 #include <stack>               // ANSI STL stack class
00024 
00025 class STILEvalEngine;
00026 
00027 //---------------------------------------------------------------------------
00033 //---------------------------------------------------------------------------
00034 class STILSigRefExpr : public STILEntity {
00035 
00036   // - Public members
00037   public:
00038 
00039     friend struct STILSigRefExpr_Data;
00040 
00041     // Allowed operators
00042     enum Operator {
00043       UndefinedOperator, 
00044       Plus,              
00045       Minus,             
00046       LeftParen,         
00047       RightParen         
00048     };
00049 
00050     // - Default Constructor
00051     STILSigRefExpr();
00052 
00053     // - Copy Constructor
00054     STILSigRefExpr(const STILSigRefExpr &);
00055 
00056     // - Destructor
00057     virtual ~STILSigRefExpr();
00058 
00059     // - Assignment Operator
00060     STILSigRefExpr & operator=(const STILSigRefExpr &);
00061 
00062     // - Initialize this STILSigRefExpr object.
00063     void        init();
00064 
00065     // - Write out this object to a given FILE
00066     virtual void write(FILE * pOutFile, LONG indentation=0) const;
00067 
00068 
00069     // - Add an operator to this expression
00070     void           addOp(Operator op);
00071 
00072     // - Add an identifier to this expression (with optional indexing)
00073     void           addId(const sstring & id, LONG idx1=-1, LONG idx2=-1);
00074 
00075     // - Get the text sstring representation of this expression
00076     const sstring & getText() const;
00077 
00078     // enumeration for node type
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     // - Print underlying expression tree recursively (for debug purposes)
00103     void           printTree(const STILSigRefExpr_Node * p_tree = NULL) const;
00104 
00105     // - Clear out all storage associated with this expression
00106     void           clearTree(STILSigRefExpr_Node * p_tree = NULL);
00107 
00108     // - Clear out all storage associated with this expression
00109     void           copyTree(STILSigRefExpr_Node *&,const STILSigRefExpr_Node *);
00110 
00111     // - Evaluate the SigRefExpr
00112 //    STILSignalList eval(const STILSymbolTable*, const STILSigRefExpr_Node *p_tree = NULL);
00113 //    STILSignalList& eval(const STILEvalEngine*, const STILSigRefExpr_Node  *p_tree = NULL);
00114     STILSignalList eval(const STILEvalEngine*, const STILSigRefExpr_Node  *p_tree = NULL);
00115 
00116   // Private members
00117   private:
00118 
00119     //----------------------- private members --------------------------------
00120 
00121     STILSigRefExpr_Node *       m_exprTree;   // Pointer to top of expression tree
00122     sstring                      m_exprText;  // String representation of expression
00123     std::stack<void *,std::list<void *> > m_parenStack;// Stack of subtrees from parens
00124     bool                        m_errInEval;  //If the SigRefExpr references
00125                                               //an undefined Signal
00126 }; // end STILSigRefExpr class
00127 
00128 //----------------------------- inline functions -----------------------------
00129 //--------------------------------------------------------------------------
00137 //--------------------------------------------------------------------------
00138 inline const sstring & STILSigRefExpr::getText() const { return m_exprText; }
00139 
00140 
00141 #endif

This page last updated on 6 Jul 2007

SourceForge.net Logo