Ignore:
Timestamp:
Nov 3, 2017, 3:01:31 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4ee36bf0
Parents:
4ee1efb (diff), 760ba67 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/PtrsCastable.cc

    r4ee1efb r136ccd7  
    5050        };
    5151
    52         int objectCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
    53                 if ( dynamic_cast< FunctionType* >( src ) ) {
    54                         return -1;
    55                 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) {
    56                         EqvClass eqvClass;
    57                         if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    58                                 if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
    59                                         if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
     52        namespace {
     53                int objectCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     54                        if ( dynamic_cast< FunctionType* >( src ) ) {
     55                                return -1;
     56                        } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) {
     57                                EqvClass eqvClass;
     58                                if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
     59                                        if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
     60                                                if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
     61                                                        return -1;
     62                                                } // if
     63                                        } //if
     64                                } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
     65                                        if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    6066                                                return -1;
    6167                                        } // if
    62                                 } //if
    63                         } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    64                                 if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    65                                         return -1;
    6668                                } // if
    67                         } // if
    68                 } //if
    69                 return 1;
    70         }
    71         int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
    72                 return -1 * objectCast( src, env, indexer );  // reverse the sense of objectCast
     69                        } //if
     70                        return 1;
     71                }
     72                int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     73                        return -1 * objectCast( src, env, indexer );  // reverse the sense of objectCast
     74                }
    7375        }
    7476
     
    9395        }
    9496
    95         void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) {
     97        void PtrsCastable::visit( VoidType * ) {
    9698                result = objectCast( dest, env, indexer );
    9799        }
    98100
    99         void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) {
     101        void PtrsCastable::visit( BasicType * ) {
    100102                result = objectCast( dest, env, indexer );
    101103        }
    102104
    103         void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) {
     105        void PtrsCastable::visit( PointerType * ) {
    104106                result = objectCast( dest, env, indexer );
    105107        }
    106108
    107         void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) {
     109        void PtrsCastable::visit( ArrayType * ) {
    108110                result = objectCast( dest, env, indexer );
    109111        }
    110112
    111         void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) {
     113        void PtrsCastable::visit( FunctionType * ) {
    112114                // result = -1;
    113115                result = functionCast( dest, env, indexer );
    114116        }
    115117
    116         void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) {
     118        void PtrsCastable::visit( StructInstType * ) {
    117119                result = objectCast( dest, env, indexer );
    118120        }
    119121
    120         void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) {
     122        void PtrsCastable::visit( UnionInstType * ) {
    121123                result = objectCast( dest, env, indexer );
    122124        }
    123125
    124         void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) {
     126        void PtrsCastable::visit( EnumInstType * ) {
    125127                if ( dynamic_cast< EnumInstType* >( dest ) ) {
    126128                        result = 1;
     
    136138        }
    137139
    138         void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst ) {}
     140        void PtrsCastable::visit( TraitInstType * ) {}
    139141
    140142        void PtrsCastable::visit(TypeInstType *inst) {
     
    143145        }
    144146
    145         void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) {
     147        void PtrsCastable::visit( TupleType * ) {
    146148                result = objectCast( dest, env, indexer );
    147149        }
    148150
    149         void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) {
     151        void PtrsCastable::visit( VarArgsType * ) {
    150152                result = objectCast( dest, env, indexer );
    151153        }
    152154
    153         void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) {
     155        void PtrsCastable::visit( ZeroType * ) {
    154156                result = objectCast( dest, env, indexer );
    155157        }
    156158
    157         void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) {
     159        void PtrsCastable::visit( OneType * ) {
    158160                result = objectCast( dest, env, indexer );
    159161        }
Note: See TracChangeset for help on using the changeset viewer.