Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/FixFunction.cc

    rb0845f9 r0bd3faf  
    2626
    2727namespace {
     28        struct FixFunction final : public ast::WithShortCircuiting {
     29                bool isVoid = false;
    2830
    29 struct FixFunction final : public ast::WithShortCircuiting {
    30         bool isVoid = false;
     31                void previsit( const ast::FunctionDecl * ) { visit_children = false; }
    3132
    32         void previsit( const ast::FunctionDecl * ) { visit_children = false; }
     33                const ast::DeclWithType * postvisit( const ast::FunctionDecl * func ) {
     34                        // Cannot handle cases with asserions.
     35                        assert( func->assertions.empty() );
     36                        return new ast::ObjectDecl{
     37                                func->location, func->name, new ast::PointerType( func->type ), nullptr,
     38                                func->storage, func->linkage, nullptr, copy( func->attributes ) };
     39                }
    3340
    34         const ast::DeclWithType * postvisit( const ast::FunctionDecl * func ) {
    35                 // Cannot handle cases with asserions.
    36                 assert( func->assertions.empty() );
    37                 return new ast::ObjectDecl{
    38                         func->location, func->name, new ast::PointerType( func->type ), nullptr,
    39                         func->storage, func->linkage, nullptr, copy( func->attributes ) };
    40         }
     41                void previsit( const ast::ArrayType * ) { visit_children = false; }
    4142
    42         void previsit( const ast::ArrayType * ) { visit_children = false; }
     43                const ast::Type * postvisit( const ast::ArrayType * array ) {
     44                        return new ast::PointerType{
     45                                array->base, array->dimension, array->isVarLen, array->isStatic,
     46                                array->qualifiers };
     47                }
    4348
    44         const ast::Type * postvisit( const ast::ArrayType * array ) {
    45                 return new ast::PointerType{
    46                         array->base, array->dimension, array->isVarLen, array->isStatic,
    47                         array->qualifiers };
    48         }
     49                void previsit( const ast::FunctionType * ) { visit_children = false; }
    4950
    50         void previsit( const ast::FunctionType * ) { visit_children = false; }
     51                const ast::Type * postvisit( const ast::FunctionType * type ) {
     52                        return new ast::PointerType( type );
     53                }
    5154
    52         const ast::Type * postvisit( const ast::FunctionType * type ) {
    53                 return new ast::PointerType( type );
    54         }
     55                void previsit( const ast::VoidType * ) { isVoid = true; }
    5556
    56         void previsit( const ast::VoidType * ) { isVoid = true; }
    57 
    58         void previsit( const ast::BasicType * ) { visit_children = false; }
    59         void previsit( const ast::PointerType * ) { visit_children = false; }
    60         void previsit( const ast::StructInstType * ) { visit_children = false; }
    61         void previsit( const ast::UnionInstType * ) { visit_children = false; }
    62         void previsit( const ast::EnumInstType * ) { visit_children = false; }
    63         void previsit( const ast::TraitInstType * ) { visit_children = false; }
    64         void previsit( const ast::TypeInstType * ) { visit_children = false; }
    65         void previsit( const ast::TupleType * ) { visit_children = false; }
    66         void previsit( const ast::VarArgsType * ) { visit_children = false; }
    67         void previsit( const ast::ZeroType * ) { visit_children = false; }
    68         void previsit( const ast::OneType * ) { visit_children = false; }
    69 };
    70 
     57                void previsit( const ast::BasicType * ) { visit_children = false; }
     58                void previsit( const ast::PointerType * ) { visit_children = false; }
     59                void previsit( const ast::StructInstType * ) { visit_children = false; }
     60                void previsit( const ast::UnionInstType * ) { visit_children = false; }
     61                void previsit( const ast::EnumInstType * ) { visit_children = false; }
     62                void previsit( const ast::TraitInstType * ) { visit_children = false; }
     63                void previsit( const ast::TypeInstType * ) { visit_children = false; }
     64                void previsit( const ast::TupleType * ) { visit_children = false; }
     65                void previsit( const ast::VarArgsType * ) { visit_children = false; }
     66                void previsit( const ast::ZeroType * ) { visit_children = false; }
     67                void previsit( const ast::OneType * ) { visit_children = false; }
     68        };
    7169} // anonymous namespace
    7270
Note: See TracChangeset for help on using the changeset viewer.