Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > ffa1e6f5ad04360808fe8840fe3ba036 > files > 52

vrq-devel-1.0.88-1.fc14.i686.rpm

/*-----------------------------------------------------------------------------
 * 	Copyright (c) 1997-2009 Mark Hummel DBA Raquette Software.
 *		All rights reserved
 *
 *    This file contains source code written by Raquette Software, 
 *    68 Stewart Street, Franklin MA 02038. It may not be used without 
 *    express written permission. The expression of the information 
 *    contained herein is protected under federal copyright laws and 
 *    all copying without permission is prohibited and may be subject 
 *    to criminal penalties. The Author assumes no responsibility for 
 *    errors, omissions, or damages caused by the use of these programs 
 *    or from use of the information contained herein.
 *
 *-----------------------------------------------------------------------------
 */
/******************************************************************************
 *
 *
 *	   example2.cc
 *	   - methods for example plugin
 *
 ******************************************************************************
 */
						

#include "example2.h"

/************************************************
 	CreateToolInstance
	- entry point for dll. Vrq will 
	  call this entry point (must be C code)
	  to create and initialize the tool.
	  If tool creation fails, return NULL and
	  vrq will ignore DLL.
 ************************************************/
extern "C" {
    CBackend* CreateToolInstance()
    {
	/*
 	 * Only initialize the tool if it was built for
 	 * the running version of vrq.
 	 */
        if( strcmp( VRQ_VERSION, VrqVersionString() ) ) {
    	    return NULL;
        }
	/*
 	 * Create tool and return it.
 	 */
        return new CExample2();
    }
}

/************************************************
 	Constructor
	- Initialize tool
 ************************************************/
CExample2::CExample2( ) 
{
}

/************************************************
	AcceptAllPlusArgs
 	- return TRUE if tool accepts arbitrary
	  plusargs.
 ************************************************/
int CExample2::AcceptAllPlusArgs( void ) 
{ 
    /*
     * Tool does not support arbitary plusargs
     */
    return FALSE; 
}

/************************************************
	HideTool
	- return TRUE if tool should be hidden
	  from help system. This allows a tool
	  to be functional and hidden.
 ***********************************************/
int CExample2::HideTool() 
{ 
    return FALSE;
}

/************************************************
	IgnoreVrqComments
	- return TRUE if tool requires lexer to
	  treat vrq translate_on/off pragmas
	  as pure comments.
 ***********************************************/
int CExample2::IgnoreVrqComments() 
{ 
    return FALSE; 
}

/************************************************
	ResolveModules
	- return TRUE if tool requires all
	  module references to be resolved.
	  This is done by search specified
	  library search paths.
 ***********************************************/
int CExample2::ResolveModules() 
{ 
    return FALSE;
}

/************************************************
	ResolveInstance
	- return TRUE if tool requires the
	  given module reference to be resolved.
	  This is allows a tool to implement a
	  fine grain filter on what must be resolved.
	  Note this only called if ResolvedModules
	  returns TRUE.
 ***********************************************/
int CExample2::ResolveInstance( CModule*, CInstance* ) 
{
    return FALSE;
}

/************************************************
	Activate
	- This routine is called before a tool
	  is invoked. It is only called once
	  and will only be called if the tool
	  will be used in a pipeline.
 ***********************************************/
void CExample2::Activate() 
{
}


/************************************************
	GetToolName
 	- return name of tool
 ************************************************/
char* CExample2::GetToolName( void )
{
    static char	toolName[] = "example2";

    return toolName;
}

/************************************************
	GetToolDescription
 	- return description of tool. This
	  text is used in vrq help text, man pages, etc.
 ************************************************/
char* CExample2::GetToolDescription( void )
{
    static char	toolDescription[] = "Example plugin that converts if statements"
				    " to case statements";

    return toolDescription;
}

/************************************************
	ProcessIfStatements
	- callback routine used to convert if
	  statements to case statements. 
 ***********************************************/
CNode* ProcessIfStatements( CNode* n, void* arg )
{
    switch( n->GetOp() ) {
    }

    return n;
}


/************************************************
	Process
	- process a compilation unit 
 ************************************************/
void CExample2::Process( list<CElement>& inputList,
		       list<CElement>& outputList )
{
    /*
     * process each compilation unit, pass on modified trees to next filter.
     */
    list<CElement>::iterator ptr;
    for( ptr = inputList.begin(); ptr != inputList.end(); ++ptr ) {
	/*
 	 * Transverse the entire code tree for the given compilation
 	 * unit. For each node ProcessIfStatements will be called to 
 	 * convert if to case
 	 */
        CNode* code = ptr->Code(); 
	code = code->PostSubVisit1( ProcessIfStatements, NULL );
        outputList.push_back( CElement( ptr->Filename(), !ptr->Filename(), code ) );
    }

}