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 a32b204 was
a32b204,
checked in by Peter A. Buhr <pabuhr@…>, 9 years ago
|
licencing: second groups of files
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[51b7345] | 1 | #include "GenPoly.h" |
---|
| 2 | #include "ScrubTyVars.h" |
---|
| 3 | |
---|
| 4 | #include "SynTree/Mutator.h" |
---|
| 5 | #include "SynTree/Type.h" |
---|
[bdd516a] | 6 | #include "SynTree/Expression.h" |
---|
[51b7345] | 7 | |
---|
| 8 | |
---|
| 9 | namespace GenPoly { |
---|
[bdd516a] | 10 | Type * ScrubTyVars::mutate( TypeInstType *typeInst ) { |
---|
| 11 | TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() ); |
---|
| 12 | if ( doAll || tyVar != tyVars.end() ) { |
---|
[a32b204] | 13 | switch ( tyVar->second ) { |
---|
[bdd516a] | 14 | case TypeDecl::Any: |
---|
| 15 | case TypeDecl::Dtype: |
---|
| 16 | { |
---|
| 17 | PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) ); |
---|
| 18 | delete typeInst; |
---|
| 19 | return ret; |
---|
| 20 | } |
---|
| 21 | case TypeDecl::Ftype: |
---|
| 22 | delete typeInst; |
---|
| 23 | return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); |
---|
| 24 | } |
---|
| 25 | } |
---|
| 26 | return typeInst; |
---|
[51b7345] | 27 | } |
---|
| 28 | |
---|
[bdd516a] | 29 | Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) { |
---|
| 30 | // sizeof( T ) => T parameter, which is the size of T |
---|
| 31 | if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( szeof->get_type() ) ) { |
---|
| 32 | Expression *expr = new NameExpr( typeInst->get_name() ); |
---|
| 33 | return expr; |
---|
| 34 | } else { |
---|
| 35 | return Mutator::mutate( szeof ); |
---|
| 36 | } |
---|
[51b7345] | 37 | } |
---|
| 38 | |
---|
[bdd516a] | 39 | Type * ScrubTyVars::mutate( PointerType *pointer ) { |
---|
| 40 | if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( pointer->get_base() ) ) { |
---|
| 41 | if ( doAll || tyVars.find( typeInst->get_name() ) != tyVars.end() ) { |
---|
| 42 | Type *ret = mutate( typeInst ); |
---|
| 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 | } |
---|
[51b7345] | 51 | } // namespace GenPoly |
---|
Note: See
TracBrowser
for help on using the repository browser.