Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/PtrsCastable.cc

    rb0837e4 rea6332d  
    5050        };
    5151
    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 ) {
     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 ) {
    6660                                                return -1;
    6761                                        } // if
     62                                } //if
     63                        } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
     64                                if ( eqvClass.data.kind == TypeDecl::Ftype ) {
     65                                        return -1;
    6866                                } // if
    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                 }
     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
    7573        }
    7674
     
    9593        }
    9694
    97         void PtrsCastable::visit( VoidType * ) {
     95        void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) {
    9896                result = objectCast( dest, env, indexer );
    9997        }
    10098
    101         void PtrsCastable::visit( BasicType * ) {
     99        void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) {
    102100                result = objectCast( dest, env, indexer );
    103101        }
    104102
    105         void PtrsCastable::visit( PointerType * ) {
     103        void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) {
    106104                result = objectCast( dest, env, indexer );
    107105        }
    108106
    109         void PtrsCastable::visit( ArrayType * ) {
     107        void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) {
    110108                result = objectCast( dest, env, indexer );
    111109        }
    112110
    113         void PtrsCastable::visit( FunctionType * ) {
     111        void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) {
    114112                // result = -1;
    115113                result = functionCast( dest, env, indexer );
    116114        }
    117115
    118         void PtrsCastable::visit( StructInstType * ) {
     116        void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) {
    119117                result = objectCast( dest, env, indexer );
    120118        }
    121119
    122         void PtrsCastable::visit( UnionInstType * ) {
     120        void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) {
    123121                result = objectCast( dest, env, indexer );
    124122        }
    125123
    126         void PtrsCastable::visit( EnumInstType * ) {
     124        void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) {
    127125                if ( dynamic_cast< EnumInstType* >( dest ) ) {
    128126                        result = 1;
     
    138136        }
    139137
    140         void PtrsCastable::visit( TraitInstType * ) {}
     138        void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst ) {}
    141139
    142140        void PtrsCastable::visit(TypeInstType *inst) {
     
    145143        }
    146144
    147         void PtrsCastable::visit( TupleType * ) {
     145        void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) {
    148146                result = objectCast( dest, env, indexer );
    149147        }
    150148
    151         void PtrsCastable::visit( VarArgsType * ) {
     149        void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) {
    152150                result = objectCast( dest, env, indexer );
    153151        }
    154152
    155         void PtrsCastable::visit( ZeroType * ) {
     153        void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) {
    156154                result = objectCast( dest, env, indexer );
    157155        }
    158156
    159         void PtrsCastable::visit( OneType * ) {
     157        void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) {
    160158                result = objectCast( dest, env, indexer );
    161159        }
Note: See TracChangeset for help on using the changeset viewer.