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

visitor.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_VISITOR_H
00038 #define CBZ_VISITOR_H
00039 
00040 
00092 class Visitor {
00093 
00094 private:
00095 
00096 public:
00097 
00100   Visitor()
00101   {}
00102 
00109 
00110   virtual void at_node(Node * the_node)
00111      { // Default: do nothing
00112      }
00113 
00114   virtual void at_unit(unitNode * the_unit)
00115      { at_node(the_unit); }
00116 
00117   virtual void at_def(defNode * the_def)
00118      { at_node(the_def); }
00119 
00120   virtual void at_decl(declNode * the_decl)
00121      { at_def(the_decl); }
00122 
00123   virtual void at_subdecl(subdeclNode * the_subdecl)
00124      { at_decl(the_subdecl); }
00125 
00126   virtual void at_proc(procNode * the_proc)
00127      { at_def(the_proc); }
00128 
00129   virtual void at_type(typeNode * the_type)
00130      { at_node(the_type); }
00131 
00132   virtual void at_prim(primNode * the_prim)
00133      { at_type(the_prim); }
00134 
00135   virtual void at_tdef(tdefNode * the_tdef)
00136      { at_type(the_tdef); }
00137 
00138   virtual void at_ptr(ptrNode * the_ptr)
00139      { at_type(the_ptr); }
00140 
00141   virtual void at_array(arrayNode * the_array)
00142      { at_type(the_array); }
00143 
00144   virtual void at_func(funcNode * the_func)
00145      { at_type(the_func); }
00146 
00147   virtual void at_sue(sueNode * the_sue)
00148      { at_type(the_sue); }
00149 
00150   virtual void at_struct(structNode * the_struct)
00151      { at_sue(the_struct); }
00152 
00153   virtual void at_union(unionNode * the_union)
00154      { at_sue(the_union); }
00155 
00156   virtual void at_enum(enumNode * the_enum)
00157      { at_sue(the_enum); }
00158 
00159   virtual void at_suespec(suespecNode * the_suespec)
00160      { at_type(the_suespec); }
00161 
00162   virtual void at_expr(exprNode * the_expr)
00163      { at_node(the_expr); }
00164 
00165   virtual void at_const(constNode * the_const)
00166      { at_expr(the_const); }
00167 
00168   virtual void at_id(idNode * the_id)
00169      { at_expr(the_id); }
00170 
00171   virtual void at_binary(binaryNode * the_binary)
00172      { at_expr(the_binary); }
00173 
00174   virtual void at_unary(unaryNode * the_unary)
00175      { at_expr(the_unary); }
00176 
00177   virtual void at_cast(castNode * the_cast)
00178      { at_expr(the_cast); }
00179 
00180   virtual void at_comma(commaNode * the_comma)
00181      { at_expr(the_comma); }
00182 
00183   virtual void at_ternary(ternaryNode * the_ternary)
00184      { at_expr(the_ternary); }
00185 
00186   virtual void at_call(callNode * the_call)
00187      { at_expr(the_call); }
00188 
00189   virtual void at_initializer(initializerNode * the_initializer)
00190      { at_expr(the_initializer); }
00191 
00192   virtual void at_stmt(stmtNode * the_stmt)
00193      { at_node(the_stmt); }
00194 
00195   virtual void at_block(blockNode * the_block)
00196      { at_stmt(the_block); }
00197 
00198   virtual void at_basicblock(basicblockNode * the_basicblock)
00199      { at_block(the_basicblock); }
00200 
00201   virtual void at_exprstmt(exprstmtNode * the_exprstmt)
00202      { at_stmt(the_exprstmt); }
00203 
00204   virtual void at_target(targetNode * the_target)
00205      { at_stmt(the_target); }
00206 
00207   virtual void at_label(labelNode * the_label)
00208      { at_target(the_label); }
00209 
00210   virtual void at_case(caseNode * the_case)
00211      { at_target(the_case); }
00212 
00213   virtual void at_selection(selectionNode * the_selection)
00214      { at_stmt(the_selection); }
00215 
00216   virtual void at_if(ifNode * the_if)
00217      { at_selection(the_if); }
00218 
00219   virtual void at_switch(switchNode * the_switch)
00220      { at_selection(the_switch); }
00221 
00222   virtual void at_loop(loopNode * the_loop)
00223      { at_stmt(the_loop); }
00224 
00225   virtual void at_while(whileNode * the_while)
00226      { at_loop(the_while); }
00227 
00228   virtual void at_do(doNode * the_do)
00229      { at_loop(the_do); }
00230 
00231   virtual void at_for(forNode * the_for)
00232      { at_loop(the_for); }
00233 
00234   virtual void at_jump(jumpNode * the_jump)
00235      { at_stmt(the_jump); }
00236 
00237   virtual void at_goto(gotoNode * the_goto)
00238      { at_jump(the_goto); }
00239 
00240   virtual void at_continue(continueNode * the_continue)
00241      { at_jump(the_continue); }
00242 
00243   virtual void at_break(breakNode * the_break)
00244      { at_jump(the_break); }
00245 
00246   virtual void at_return(returnNode * the_return)
00247      { at_jump(the_return); }
00248 
00249   virtual void at_attrib(attribNode * the_attrib)
00250      { at_stmt(the_attrib); }
00251 
00252   virtual void at_text(textNode * the_text)
00253      { at_node(the_text); }
00255 
00256 private:
00257 
00258   /* -- Deprecated...
00259 
00260   virtual void at_index(indexNode * the_index)
00261      { at_expr(the_index); }
00262 
00263   virtual void at_implicitcast(implicitcastNode * the_implicitcast)
00264      { at_expr(the_implicitcast); }
00265 
00266   virtual void at_default(defaultNode * the_default)
00267      { at_target(the_default); }
00268 
00269   virtual void at_ifelse(ifelseNode * the_ifelse)
00270      { at_selection(the_ifelse); }
00271   */
00272 
00273 };
00274 
00275 // -- Invoke the visitor on a list...
00276 
00285 template< class T >
00286 void list_visitor(list< T > & l, Visitor * the_visitor)
00287 {
00288   for (list< T >::iterator p = l.begin();
00289        p != l.end();
00290        ++p)
00291     (*p)->visit(the_visitor);
00292 }
00293 
00294 
00295 #endif // CBZ_VISITOR_H

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