Ignore:
Timestamp:
Oct 3, 2017, 2:55:13 PM (5 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7821d6c
Parents:
11a2d9b
Message:

Convert FixFunction? to PassVisitor?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/FixFunction.cc

    r11a2d9b r21b7161  
    2626        FixFunction::FixFunction() : isVoid( false ) {}
    2727
    28         DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
     28
     29        DeclarationWithType * FixFunction::postmutate(FunctionDecl *functionDecl) {
    2930                // can't delete function type because it may contain assertions, so transfer ownership to new object
    30                 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type() ), 0, functionDecl->get_attributes() );
    31                 functionDecl->get_attributes().clear();
     31                ObjectDecl *pointer = new ObjectDecl( functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr, new PointerType( Type::Qualifiers(), functionDecl->type ), nullptr, functionDecl->attributes );
     32                functionDecl->attributes.clear();
    3233                functionDecl->type = nullptr;
    3334                delete functionDecl;
     
    3536        }
    3637
    37         Type * FixFunction::mutate(VoidType *voidType) {
    38                 isVoid = true;
    39                 return voidType;
    40         }
    41 
    42         Type * FixFunction::mutate(BasicType *basicType) {
    43                 return basicType;
    44         }
    45 
    46         Type * FixFunction::mutate(PointerType *pointerType) {
    47                 return pointerType;
    48         }
    49 
    50         Type * FixFunction::mutate(ArrayType *arrayType) {
     38        Type * FixFunction::postmutate(ArrayType *arrayType) {
    5139                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
    52                 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() );
     40                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic );
     41                arrayType->base = nullptr;
     42                arrayType->dimension = nullptr;
    5343                delete arrayType;
    5444                return pointerType;
    5545        }
    5646
    57         Type * FixFunction::mutate(StructInstType *aggregateUseType) {
    58                 return aggregateUseType;
     47        void FixFunction::premutate(VoidType *) {
     48                isVoid = true;
    5949        }
    6050
    61         Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
    62                 return aggregateUseType;
    63         }
    64 
    65         Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
    66                 return aggregateUseType;
    67         }
    68 
    69         Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
    70                 return aggregateUseType;
    71         }
    72 
    73         Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
    74                 return aggregateUseType;
    75         }
    76 
    77         Type * FixFunction::mutate(TupleType *tupleType) {
    78                 return tupleType;
    79         }
    80 
    81         Type * FixFunction::mutate(VarArgsType *varArgsType) {
    82                 return varArgsType;
    83         }
    84 
    85         Type * FixFunction::mutate(ZeroType *zeroType) {
    86                 return zeroType;
    87         }
    88 
    89         Type * FixFunction::mutate(OneType *oneType) {
    90                 return oneType;
    91         }
     51        void FixFunction::premutate(FunctionDecl *) { visit_children = false; }
     52        void FixFunction::premutate(BasicType *) { visit_children = false; }
     53        void FixFunction::premutate(PointerType *) { visit_children = false; }
     54        void FixFunction::premutate(StructInstType *) { visit_children = false; }
     55        void FixFunction::premutate(UnionInstType *) { visit_children = false; }
     56        void FixFunction::premutate(EnumInstType *) { visit_children = false; }
     57        void FixFunction::premutate(TraitInstType *) { visit_children = false; }
     58        void FixFunction::premutate(TypeInstType *) { visit_children = false; }
     59        void FixFunction::premutate(TupleType *) { visit_children = false; }
     60        void FixFunction::premutate(VarArgsType *) { visit_children = false; }
     61        void FixFunction::premutate(ZeroType *) { visit_children = false; }
     62        void FixFunction::premutate(OneType *) { visit_children = false; }
    9263} // namespace SymTab
    9364
Note: See TracChangeset for help on using the changeset viewer.