source: translator/GenPoly/ScrubTyVars.cc @ ad17ba6a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since ad17ba6a was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#include "GenPoly.h"
2#include "ScrubTyVars.h"
3
4#include "SynTree/Mutator.h"
5#include "SynTree/Type.h"
6
7
8namespace GenPoly {
9
10Type* 
11ScrubTyVars::mutate( TypeInstType *typeInst )
12{
13  TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() );
14  if( doAll || tyVar != tyVars.end() ) {
15    switch( tyVar->second ) {
16    case TypeDecl::Any:
17    case TypeDecl::Dtype:
18    {
19      PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
20      delete typeInst;
21      return ret;
22    }
23     
24    case TypeDecl::Ftype:
25      delete typeInst;
26      return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
27    }
28  }
29  return typeInst;
30}
31
32Type* 
33ScrubTyVars::mutate( PointerType *pointer )
34{
35  if( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( pointer->get_base() ) ) {
36    if( doAll || tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
37      Type *ret = mutate( typeInst );
38///       std::cout << "pointer is ";
39///       pointer->print( std::cout );
40///       std::cout << std::endl << "ret is ";
41///       ret->print( std::cout );
42///       std::cout << std::endl;
43      ret->get_qualifiers() += pointer->get_qualifiers();
44      pointer->set_base( 0 );
45      delete pointer;
46      return ret;
47    }
48  }
49  return Mutator::mutate( pointer );
50}
51
52} // namespace GenPoly
Note: See TracBrowser for help on using the repository browser.