Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

meta.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 //  C-Breeze
00004 //  C Compiler Framework
00005 // 
00006 //  Copyright (c) 2000 University of Texas at Austin
00007 // 
00008 //  Samuel Z. Guyer
00009 //  Daniel A. Jimenez
00010 //  Calvin Lin
00011 // 
00012 //  Permission is hereby granted, free of charge, to any person
00013 //  obtaining a copy of this software and associated documentation
00014 //  files (the "Software"), to deal in the Software without
00015 //  restriction, including without limitation the rights to use, copy,
00016 //  modify, merge, publish, distribute, sublicense, and/or sell copies
00017 //  of the Software, and to permit persons to whom the Software is
00018 //  furnished to do so, subject to the following conditions:
00019 //  
00020 //  The above copyright notice and this permission notice shall be
00021 //  included in all copies or substantial portions of the Software.
00022 //  
00023 //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00024 //  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00025 //  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00026 //  NONINFRINGEMENT.  IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT
00027 //  AUSTIN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
00028 //  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
00029 //  OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00030 //  THE SOFTWARE.
00031 //
00032 //  We acknowledge the C-to-C Translator from MIT Laboratory for
00033 //  Computer Science for inspiring parts of the C-Breeze design.
00034 //
00035 // ----------------------------------------------------------------------
00036 
00037 #ifndef CBZ_META_H
00038 #define CBZ_META_H
00039 
00040 #include "ast.h"
00041 #include "c_breeze.h"
00042 
00043 class metaVariable
00044 {
00045 private:
00046 
00047   string _name;
00048 
00049 public:
00050 
00051   metaVariable(string & name)
00052     : _name(name)
00053     {}
00054 
00055   inline string & name() { return _name; }
00056 };
00057 
00058 
00059 class metaexprNode : public exprNode,
00060                      public metaVariable
00061 {
00062 public:
00063 
00064   // --- Call this to identify meta variables of type expr (in the
00065   // lexer).
00066 
00067   static bool is_meta_expr(char * name);
00068 
00069   // --- Call this method when you recognize a macro formal argument
00070   // of type $expr (in the parser).
00071 
00072   static void add_meta_expr(char * name);
00073 
00074   // --- Call this method to clear the list of recognized macro
00075   // variables (e.g., at the end of a macro definition.
00076 
00077   static void clear();
00078 
00079 private:
00080 
00081   static list< string > meta_expr_variables;
00082 
00083 public:
00084 
00085   metaexprNode(idNode * id)
00086     : exprNode(Meta, 0, id->coord()),
00087       metaVariable(id->name())
00088     {
00089       delete id;
00090     }
00091 
00092   // -- Virtual Functions from exprNode
00093 
00094   virtual void eval() {}
00095 
00096   // -- Walk and change
00097 
00098   virtual void visit(Visitor * the_visitor);
00099   virtual void walk(Walker & the_walker);
00100   virtual Node * change(Changer & the_changer, bool redispatch);
00101 
00102   // -- Dataflow
00103 
00104   virtual void dataflow(FlowVal * v, FlowProblem & fp);
00105 
00106   // -- Clone
00107 
00108   virtual Node * clone() const { return new metaexprNode ( *this ); }
00109 
00110   // -- Output
00111 
00112   virtual void output_expr(output_context & ct, Node * par, int prec, Assoc assoc);
00113 
00114 };
00115 
00116 
00117 
00118 class metastmtNode : public stmtNode,
00119                      public metaVariable
00120 {
00121 public:
00122 
00123   // --- Call this to identify meta variables of type stmt (in the
00124   // lexer).
00125 
00126   static bool is_meta_stmt(char * name);
00127 
00128   // --- Call this method when you recognize a macro formal argument
00129   // of type $stmt (in the parser).
00130 
00131   static void add_meta_stmt(char * name);
00132 
00133   // --- Call this method to clear the list of recognized macro
00134   // variables (e.g., at the end of a macro definition.
00135 
00136   static void clear();
00137 
00138 private:
00139 
00140   static list< string > meta_stmt_variables;
00141 
00142 public:
00143 
00144   metastmtNode(idNode * id)
00145     : stmtNode(Meta, id->coord()),
00146     metaVariable(id->name())
00147     {
00148       delete id;
00149     }
00150 
00151   // -- Walk and change
00152   
00153   virtual void visit(Visitor * the_visitor);
00154   virtual void walk(Walker & the_walker);
00155   virtual Node * change(Changer & the_changer, bool redispatch = false);
00156   
00157   // -- Dataflow
00158   
00159   virtual void dataflow(FlowVal * v, FlowProblem & fp);
00160   
00161   // -- Clone
00162   
00163   virtual Node * clone() const { return new metastmtNode ( *this ); }
00164   
00165   // -- Output 
00166   virtual void output_stmt(output_context & ct, Node * par);
00167   
00168 };
00169 
00170 
00171 #endif // 

Generated on Thu Jan 10 12:06:20 2002 for C-Breeze by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001