Changes in / [68c9165:b0ec971]


Ignore:
Location:
src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Attribute.cpp

    r68c9165 rb0ec971  
    2828        auto end = name.find_last_not_of('_');
    2929        if ( begin == std::string::npos || end == std::string::npos ) return "";
    30 
     30       
    3131        // convert to lowercase
    3232        std::string ret;
  • src/AST/Convert.cpp

    r68c9165 rb0ec971  
    11301130        const ast::Type * visit( const ast::FunctionType * node ) override final {
    11311131                auto ty = new FunctionType {
    1132                         cv( node ),
     1132                        cv( node ), 
    11331133                        (bool)node->isVarArgs
    11341134                };
     
    13381338                // TypeSubstitution is not a node in the old model, so the conversion result wouldn't fit in this->node.
    13391339                assert( 0 );
    1340                 (void)node;
    13411340                return nullptr;
    13421341        }
     
    14101409#       define GET_LABELS_V(labels) \
    14111410                to<std::vector>::from( make_labels( std::move( labels ) ) )
    1412 
     1411       
    14131412        static ast::CV::Qualifiers cv( Type * ty ) { return { ty->get_qualifiers().val }; }
    14141413
     
    15501549
    15511550        virtual void visit( TypeDecl * old ) override final {
    1552                 if ( inCache( old ) ) return;
     1551                if ( inCache( old ) ) return;   
    15531552                auto decl = new ast::TypeDecl{
    15541553                        old->location,
     
    15881587        virtual void visit( AsmDecl * old ) override final {
    15891588                auto decl = new ast::AsmDecl{
    1590                         old->location,
     1589                        old->location, 
    15911590                        GET_ACCEPT_1(stmt, AsmStmt)
    15921591                };
     
    21432142                        rslt = new ast::ConstantExpr(
    21442143                                old->location,
    2145                                 GET_ACCEPT_1(result, Type),
    2146                                 old->constant.get_value(),
     2144                                GET_ACCEPT_1(result, Type), 
     2145                                old->constant.get_value(), 
    21472146                                (double) old->constant.get_dval()
    21482147                        );
     
    21642163                        assert(!old->isType);
    21652164                        rslt = new ast::SizeofExpr(
    2166                                 old->location,
     2165                                old->location, 
    21672166                                GET_ACCEPT_1(expr, Expr)
    21682167                        );
     
    21712170                        assert(old->isType);
    21722171                        rslt = new ast::SizeofExpr(
    2173                                 old->location,
     2172                                old->location, 
    21742173                                GET_ACCEPT_1(type, Type)
    21752174                        );
     
    21852184                        assert(!old->isType);
    21862185                        rslt = new ast::AlignofExpr(
    2187                                 old->location,
     2186                                old->location, 
    21882187                                GET_ACCEPT_1(expr, Expr)
    21892188                        );
     
    21922191                        assert(old->isType);
    21932192                        rslt = new ast::AlignofExpr(
    2194                                 old->location,
     2193                                old->location, 
    21952194                                GET_ACCEPT_1(type, Type)
    21962195                        );
     
    22362235                                GET_ACCEPT_1(arg1, Expr),
    22372236                                GET_ACCEPT_1(arg2, Expr),
    2238                                 old->get_isAnd() ?
     2237                                old->get_isAnd() ? 
    22392238                                        ast::LogicalFlag::AndExpr :
    22402239                                        ast::LogicalFlag::OrExpr
  • src/AST/Expr.cpp

    r68c9165 rb0ec971  
    159159        assert( aggregate->result );
    160160
    161         // take ownership of member type
    162         result = mem->get_type();
    163         // substitute aggregate generic parameters into member type
    164         genericSubsitution( aggregate->result ).apply( result );
    165         // ensure lvalue and appropriate restrictions from aggregate type
    166         result.get_and_mutate()->qualifiers |= aggregate->result->qualifiers | CV::Lvalue;
     161        #warning Needs GenericSubsitution.cpp building to work correctly
     162        result.set_and_mutate( mem->get_type() )->qualifiers |= aggregate->result->qualifiers | CV::Lvalue;  // FIXME temporary patch
     163
     164        // // take ownership of member type
     165        // result = mem->get_type();
     166        // // substitute aggregate generic parameters into member type
     167        // genericSubsitution( aggregate->result ).apply( result );
     168        // // ensure lvalue and appropriate restrictions from aggregate type
     169        // result.get_and_mutate()->qualifiers |= aggregate->result->qualifiers | CV::Lvalue;
    167170}
    168171
     
    342345}
    343346
    344 TupleAssignExpr::TupleAssignExpr(
     347TupleAssignExpr::TupleAssignExpr( 
    345348        const CodeLocation & loc, const Type * result, const StmtExpr * s )
    346349: Expr( loc, result ), stmtExpr() {
  • src/AST/GenericSubstitution.cpp

    r68c9165 rb0ec971  
    2323#include "Pass.hpp"
    2424#include "Type.hpp"
    25 #include "TypeSubstitution.hpp"
     25#include "TypeSubstitution.cpp"
    2626
    2727namespace ast {
     
    3232
    3333                void previsit( const Type * ty ) {
    34                         assertf( false, "Attempted generic substitution for non-aggregate type: %s",
     34                        assertf( false, "Attempted generic substitution for non-aggregate type: %s", 
    3535                                toString( ty ).c_str() );
    3636                }
    3737
    38                 void previsit( const ReferenceType * ) {
     38                void previsit( const ReferenceType * ty ) {
    3939                        // do nothing; allows substitution from base type
    4040                }
  • src/AST/Pass.hpp

    r68c9165 rb0ec971  
    178178        const ast::TypeSubstitution * visit( const ast::TypeSubstitution     * ) override final;
    179179
    180         template<typename pass_type>
    181         friend void acceptAll( std::list< ptr<Decl> > & decls, Pass<pass_type>& visitor );
     180        friend void acceptAll( std::list< ptr<Decl> > & decls, Pass<pass_t>& visitor );
    182181private:
    183182
  • src/AST/Pass.proto.hpp

    r68c9165 rb0ec971  
    115115                static constexpr bool value = std::is_void< ret_t >::value ||
    116116                        std::is_base_of<const node_t, typename std::remove_pointer<ret_t>::type >::value;
    117         };
    118 
    119         template<bool is_void>
    120         struct __assign;
    121 
    122         template<>
    123         struct __assign<true> {
    124                 template<typename pass_t, typename node_t>
    125                 static inline void result( pass_t & pass, const node_t * & node ) {
    126                         pass.previsit( node );
    127                 }
    128         };
    129 
    130         template<>
    131         struct __assign<false> {
    132                 template<typename pass_t, typename node_t>
    133                 static inline void result( pass_t & pass, const node_t * & node ) {
    134                         node = pass.previsit( node );
    135                         assertf(node, "Previsit must not return NULL");
    136                 }
    137117        };
    138118
     
    158138                        "Previsit may not change the type of the node. It must return its paremeter or void."
    159139                );
    160 
    161                 __assign<
    162                         std::is_void<
    163                                 decltype( pass.previsit( node ) )
    164                         >::value
    165                 >::result( pass, node );
     140                if(std::is_void< decltype( pass.previsit(node) ) >::value) {
     141                        pass.previsit( node );
     142                } else {
     143                        node = pass.previsit( node );
     144                        assert(node);
     145                }
    166146        }
    167147
  • src/AST/Print.cpp

    r68c9165 rb0ec971  
    2222#include "TypeSubstitution.hpp"
    2323
    24 #include "Common/utility.h" // for group_iterate
    25 
    26 using namespace std;
     24#include "Common/utility.h"      // for group_iterate
    2725
    2826namespace ast {
     
    3028template <typename C, typename... T>
    3129constexpr auto make_array(T&&... values) ->
    32         array<C,sizeof...(T)>
     30        std::array<C,sizeof...(T)>
    3331{
    34         return array<C,sizeof...(T)>{
    35                 forward<T>(values)...
     32        return std::array<C,sizeof...(T)>{
     33                std::forward<T>(values)...
    3634        };
    3735}
     
    3937class Printer : public Visitor {
    4038public:
    41         ostream & os;
     39        std::ostream & os;
    4240        Indenter indent;
    43         bool short_mode;
    44 
    45         Printer(ostream & os, Indenter indent, bool short_mode) : os( os ), indent( indent ), short_mode(short_mode) {}
     41
     42        Printer(std::ostream & os, Indenter indent) : os( os ), indent( indent ) {}
    4643
    4744private:
     
    5451                                // need an endl after each element because it's not
    5552                                // easy to know when each individual item should end
    56                                 os << endl;
     53                                os << std::endl;
    5754                        } // if
    5855                } // for
     
    7774
    7875        template<typename storage_t, size_t N>
    79         void print(const storage_t & storage, const array<const char *, N> & Names ) {
     76        void print(const storage_t & storage, const std::array<const char *, N> & Names ) {
    8077                if ( storage.any() ) {
    8178                        for ( size_t i = 0; i < Names.size(); i += 1 ) {
     
    138135                print( node->qualifiers );
    139136        }
    140        
    141         void print( const ast::AggregateDecl * node ) {
    142                 os << node->typeString() << " " << node->name << ":";
    143                 if ( node->linkage != Linkage::Cforall ) {
    144                         os << " " << Linkage::name( node->linkage );
    145                 } // if
    146                 os << " with body : " << (node->body ? "yes " : "no ");
    147 
    148                 if ( ! node->params.empty() ) {
    149                         os << endl << indent << "... with parameters" << endl;
    150                         ++indent;
    151                         printAll( node->params );
    152                         --indent;
    153                 } // if
    154                 if ( ! node->members.empty() ) {
    155                         os << endl << indent << "... with members" << endl;
    156                         ++indent;
    157                         printAll( node->members );
    158                         --indent;
    159                 } // if
    160                 if ( ! node->attributes.empty() ) {
    161                         os << endl << indent << "... with attributes" << endl;
    162                         ++indent;
    163                         printAll( node->attributes );
    164                         --indent;
    165                 } // if
    166                 os << endl;
    167         }
    168 
    169         void print( const ast::NamedTypeDecl * node ) {
    170                 if ( !node->name.empty() ) os << node->name << ": ";
    171 
    172                 if ( node->linkage != Linkage::Cforall ) {
    173                         os << Linkage::name( node->linkage ) << " ";
    174                 } // if
    175                 print( node->storage );
    176                 os << node->typeString();
    177                 if ( node->base ) {
    178                         os << " for ";
    179                         ++indent;
    180                         node->base->accept( *this );
    181                         --indent;
    182                 } // if
    183                 if ( ! node->params.empty() ) {
    184                         os << endl << indent << "... with parameters" << endl;
    185                         ++indent;
    186                         printAll( node->params );
    187                         --indent;
    188                 } // if
    189                 if ( ! node->assertions.empty() ) {
    190                         os << endl << indent << "... with assertions" << endl;
    191                         ++indent;
    192                         printAll( node->assertions );
    193                         --indent;
    194                 } // if
    195         }
    196137
    197138public:
    198         virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) {
    199                 if ( !node->name.empty() ) os << node->name << ": ";
     139        virtual const ast::DeclWithType *     visit( const ast::ObjectDecl          * node ) {
     140                if ( node->name != "" ) os << node->name << ": ";
    200141
    201142                if ( node->linkage != Linkage::Cforall ) {
     
    216157                                        ? "maybe constructed"
    217158                                        : "not constructed"
    218                                 ) << ")" << endl << indent+1;
     159                                ) << ")" << std::endl << indent+1;
    219160
    220161                        ++indent;
    221162                        node->init->accept( *this );
    222163                        --indent;
    223                         os << endl;
     164                        os << std::endl;
    224165                } // if
    225166
    226167                if ( ! node->attributes.empty() ) {
    227                         os << endl << indent << "... with attributes:" << endl;
     168                        os << std::endl << indent << "... with attributes:" << std::endl;
    228169                        ++indent;
    229170                        printAll( node->attributes );
     
    238179        }
    239180
    240         virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) {
    241                 if ( !node->name.empty() ) {
    242                         os << node->name << ": ";
    243                 } // if
    244                 if ( node->linkage != Linkage::Cforall ) {
    245                         os << Linkage::name( node->linkage ) << " ";
    246                 } // if
    247 
    248                 printAll( node->attributes );
    249 
    250                 print( node->storage );
    251                 print( node->funcSpec );
    252 
    253                 if ( node->type ) {
    254                         node->type->accept( *this );
    255                 } else {
    256                         os << "untyped entity ";
    257                 } // if
    258 
    259                 if ( node->stmts ) {
    260                         os << indent << "... with body" << endl << indent+1;
    261                         ++indent;
    262                         node->stmts->accept( *this );
    263                         --indent;
    264                 } // if
    265                 return node;
    266         }
    267 
    268         virtual const ast::Decl * visit( const ast::StructDecl * node ) {
    269                 print(node);
    270                 return node;
    271         }
    272 
    273         virtual const ast::Decl * visit( const ast::UnionDecl * node ) {
    274                 print(node);
    275                 return node;
    276         }
    277 
    278         virtual const ast::Decl * visit( const ast::EnumDecl * node ) {
    279                 print(node);
    280                 return node;
    281         }
    282 
    283         virtual const ast::Decl * visit( const ast::TraitDecl * node ) {
    284                 print(node);
    285                 return node;
    286         }
    287 
    288         virtual const ast::Decl * visit( const ast::TypeDecl * node ) {
    289                 print( node );
    290                 if ( node->init ) {
    291                         os << endl << indent << "with type initializer: ";
    292                         ++indent;
    293                         node->init->accept( *this );
    294                         --indent;
    295                 }
    296                 return node;
    297         }
    298 
    299         virtual const ast::Decl * visit( const ast::TypedefDecl * node ) {
    300                 print( node );
    301                 return node;
    302         }
    303 
    304         virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) {
    305                 node->stmt->accept( *this );
    306                 return node;
    307         }
    308 
    309         virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) {
    310                 os << "Static Assert with condition: ";
    311                 ++indent;
    312                 node->cond->accept( *this );
    313                 --indent;
    314                 os << endl << indent << "and message: ";
    315                 ++indent;
    316                 node->msg->accept( *this );
    317                 --indent;
    318                 os << endl;
    319                 return node;
    320         }
    321 
    322         virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) {
    323                 os << "CompoundStmt" << endl;
    324                 ++indent;
    325                 printAll( node->kids );
    326                 --indent;
    327                 return node;
    328         }
    329 
    330         virtual const ast::Stmt * visit( const ast::ExprStmt * node ) {
    331                 ++indent;
    332                 os << "Expression Statement:" << endl << indent;
    333                 node->expr->accept( *this );
    334                 --indent;
    335                 return node;
    336         }
    337 
    338         virtual const ast::Stmt * visit( const ast::AsmStmt * node ) {
    339                 os << "Assembler Statement:" << endl;
    340                 ++indent;
    341                 os << indent << "instruction: " << endl << indent;
    342                 node->instruction->accept( *this );
    343                 if ( ! node->output.empty() ) {
    344                         os << endl << indent+1 << "output: " << endl;
    345                         printAll( node->output );
    346                 } // if
    347                 if ( ! node->input.empty() ) {
    348                         os << indent+1 << "input: " << endl;
    349                         printAll( node->input );
    350                 } // if
    351                 if ( ! node->clobber.empty() ) {
    352                         os << indent+1 << "clobber: " << endl;
    353                         printAll( node->clobber );
    354                 } // if
    355                 --indent;
    356                 return node;
    357         }
    358 
    359         virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) {
    360                 os << "GCC Directive:" << node->directive << endl;
    361                 return node;
    362         }
    363 
    364         virtual const ast::Stmt * visit( const ast::IfStmt * node ) {
    365                 os << "If on condition: " << endl;
    366                 os << indent+1;
    367                 ++indent;
    368                 node->cond->accept( *this );
    369                 --indent;
    370 
    371                 if ( !node->inits.empty() ) {
    372                         os << indent << "... with initialization: \n";
    373                         ++indent;
    374                         for ( const Stmt * stmt : node->inits ) {
    375                                 os << indent;
    376                                 stmt->accept( *this );
    377                         }
    378                         --indent;
    379                         os << endl;
    380                 }
    381 
    382                 os << indent << "... then: " << endl;
    383 
    384                 ++indent;
    385                 os << indent;
    386                 node->thenPart->accept( *this );
    387                 --indent;
    388 
    389                 if ( node->elsePart != 0 ) {
    390                         os << indent << "... else: " << endl;
    391                         ++indent;
    392                         os << indent;
    393                         node->elsePart->accept( *this );
    394                         --indent;
    395                 } // if
    396                 return node;
    397         }
    398 
    399         virtual const ast::Stmt * visit( const ast::WhileStmt * node ) {
    400                 return node;
    401         }
    402 
    403         virtual const ast::Stmt * visit( const ast::ForStmt * node ) {
    404                 return node;
    405         }
    406 
    407         virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) {
    408                 return node;
    409         }
    410 
    411         virtual const ast::Stmt * visit( const ast::CaseStmt * node ) {
    412                 return node;
    413         }
    414 
    415         virtual const ast::Stmt * visit( const ast::BranchStmt * node ) {
    416                 return node;
    417         }
    418 
    419         virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) {
    420                 return node;
    421         }
    422 
    423         virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) {
    424                 return node;
    425         }
    426 
    427         virtual const ast::Stmt * visit( const ast::TryStmt * node ) {
    428                 return node;
    429         }
    430 
    431         virtual const ast::Stmt * visit( const ast::CatchStmt * node ) {
    432                 return node;
    433         }
    434 
    435         virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) {
    436                 return node;
    437         }
    438 
    439         virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) {
    440                 return node;
    441         }
    442 
    443         virtual const ast::Stmt * visit( const ast::WithStmt * node ) {
    444                 return node;
    445         }
    446 
    447         virtual const ast::NullStmt * visit( const ast::NullStmt * node ) {
    448                 return node;
    449         }
    450 
    451         virtual const ast::Stmt * visit( const ast::DeclStmt * node ) {
    452                 return node;
    453         }
    454 
    455         virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) {
    456                 return node;
    457         }
    458 
    459         virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) {
    460                 return node;
    461         }
    462 
    463         virtual const ast::Expr * visit( const ast::UntypedExpr * node ) {
    464                 return node;
    465         }
    466 
    467         virtual const ast::Expr * visit( const ast::NameExpr * node ) {
    468                 return node;
    469         }
    470 
    471         virtual const ast::Expr * visit( const ast::AddressExpr * node ) {
    472                 return node;
    473         }
    474 
    475         virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) {
    476                 return node;
    477         }
    478 
    479         virtual const ast::Expr * visit( const ast::CastExpr * node ) {
    480                 return node;
    481         }
    482 
    483         virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) {
    484                 return node;
    485         }
    486 
    487         virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) {
    488                 return node;
    489         }
    490 
    491         virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) {
    492                 return node;
    493         }
    494 
    495         virtual const ast::Expr * visit( const ast::MemberExpr * node ) {
    496                 return node;
    497         }
    498 
    499         virtual const ast::Expr * visit( const ast::VariableExpr * node ) {
    500                 return node;
    501         }
    502 
    503         virtual const ast::Expr * visit( const ast::ConstantExpr * node ) {
    504                 return node;
    505         }
    506 
    507         virtual const ast::Expr * visit( const ast::SizeofExpr * node ) {
    508                 return node;
    509         }
    510 
    511         virtual const ast::Expr * visit( const ast::AlignofExpr * node ) {
    512                 return node;
    513         }
    514 
    515         virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) {
    516                 return node;
    517         }
    518 
    519         virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) {
    520                 return node;
    521         }
    522 
    523         virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) {
    524                 return node;
    525         }
    526 
    527         virtual const ast::Expr * visit( const ast::LogicalExpr * node ) {
    528                 return node;
    529         }
    530 
    531         virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) {
    532                 return node;
    533         }
    534 
    535         virtual const ast::Expr * visit( const ast::CommaExpr * node ) {
    536                 return node;
    537         }
    538 
    539         virtual const ast::Expr * visit( const ast::TypeExpr * node ) {
    540                 return node;
    541         }
    542 
    543         virtual const ast::Expr * visit( const ast::AsmExpr * node ) {
    544                 return node;
    545         }
    546 
    547         virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) {
    548                 return node;
    549         }
    550 
    551         virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) {
    552                 return node;
    553         }
    554 
    555         virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) {
    556                 return node;
    557         }
    558 
    559         virtual const ast::Expr * visit( const ast::RangeExpr * node ) {
    560                 return node;
    561         }
    562 
    563         virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) {
    564                 return node;
    565         }
    566 
    567         virtual const ast::Expr * visit( const ast::TupleExpr * node ) {
    568                 return node;
    569         }
    570 
    571         virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) {
    572                 return node;
    573         }
    574 
    575         virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) {
    576                 return node;
    577         }
    578 
    579         virtual const ast::Expr * visit( const ast::StmtExpr * node ) {
    580                 return node;
    581         }
    582 
    583         virtual const ast::Expr * visit( const ast::UniqueExpr * node ) {
    584                 return node;
    585         }
    586 
    587         virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) {
    588                 return node;
    589         }
    590 
    591         virtual const ast::Expr * visit( const ast::InitExpr * node ) {
    592                 return node;
    593         }
    594 
    595         virtual const ast::Expr * visit( const ast::DeletedExpr * node ) {
    596                 return node;
    597         }
    598 
    599         virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) {
    600                 return node;
    601         }
    602 
    603         virtual const ast::Expr * visit( const ast::GenericExpr * node ) {
    604                 return node;
    605         }
    606 
    607         virtual const ast::Type * visit( const ast::VoidType * node ) {
     181        virtual const ast::DeclWithType *     visit( const ast::FunctionDecl         * node ) {
     182                return node;
     183        }
     184
     185        virtual const ast::Decl *             visit( const ast::StructDecl           * node ) {
     186                return node;
     187        }
     188
     189        virtual const ast::Decl *             visit( const ast::UnionDecl            * node ) {
     190                return node;
     191        }
     192
     193        virtual const ast::Decl *             visit( const ast::EnumDecl             * node ) {
     194                return node;
     195        }
     196
     197        virtual const ast::Decl *             visit( const ast::TraitDecl            * node ) {
     198                return node;
     199        }
     200
     201        virtual const ast::Decl *             visit( const ast::TypeDecl             * node ) {
     202                return node;
     203        }
     204
     205        virtual const ast::Decl *             visit( const ast::TypedefDecl          * node ) {
     206                return node;
     207        }
     208
     209        virtual const ast::AsmDecl *          visit( const ast::AsmDecl              * node ) {
     210                return node;
     211        }
     212
     213        virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl     * node ) {
     214                return node;
     215        }
     216
     217        virtual const ast::CompoundStmt *     visit( const ast::CompoundStmt         * node ) {
     218                return node;
     219        }
     220
     221        virtual const ast::Stmt *             visit( const ast::ExprStmt             * node ) {
     222                return node;
     223        }
     224
     225        virtual const ast::Stmt *             visit( const ast::AsmStmt              * node ) {
     226                return node;
     227        }
     228
     229        virtual const ast::Stmt *             visit( const ast::DirectiveStmt        * node ) {
     230                return node;
     231        }
     232
     233        virtual const ast::Stmt *             visit( const ast::IfStmt               * node ) {
     234                return node;
     235        }
     236
     237        virtual const ast::Stmt *             visit( const ast::WhileStmt            * node ) {
     238                return node;
     239        }
     240
     241        virtual const ast::Stmt *             visit( const ast::ForStmt              * node ) {
     242                return node;
     243        }
     244
     245        virtual const ast::Stmt *             visit( const ast::SwitchStmt           * node ) {
     246                return node;
     247        }
     248
     249        virtual const ast::Stmt *             visit( const ast::CaseStmt             * node ) {
     250                return node;
     251        }
     252
     253        virtual const ast::Stmt *             visit( const ast::BranchStmt           * node ) {
     254                return node;
     255        }
     256
     257        virtual const ast::Stmt *             visit( const ast::ReturnStmt           * node ) {
     258                return node;
     259        }
     260
     261        virtual const ast::Stmt *             visit( const ast::ThrowStmt            * node ) {
     262                return node;
     263        }
     264
     265        virtual const ast::Stmt *             visit( const ast::TryStmt              * node ) {
     266                return node;
     267        }
     268
     269        virtual const ast::Stmt *             visit( const ast::CatchStmt            * node ) {
     270                return node;
     271        }
     272
     273        virtual const ast::Stmt *             visit( const ast::FinallyStmt          * node ) {
     274                return node;
     275        }
     276
     277        virtual const ast::Stmt *             visit( const ast::WaitForStmt          * node ) {
     278                return node;
     279        }
     280
     281        virtual const ast::Stmt *             visit( const ast::WithStmt             * node ) {
     282                return node;
     283        }
     284
     285        virtual const ast::NullStmt *         visit( const ast::NullStmt             * node ) {
     286                return node;
     287        }
     288
     289        virtual const ast::Stmt *             visit( const ast::DeclStmt             * node ) {
     290                return node;
     291        }
     292
     293        virtual const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * node ) {
     294                return node;
     295        }
     296
     297        virtual const ast::Expr *             visit( const ast::ApplicationExpr      * node ) {
     298                return node;
     299        }
     300
     301        virtual const ast::Expr *             visit( const ast::UntypedExpr          * node ) {
     302                return node;
     303        }
     304
     305        virtual const ast::Expr *             visit( const ast::NameExpr             * node ) {
     306                return node;
     307        }
     308
     309        virtual const ast::Expr *             visit( const ast::AddressExpr          * node ) {
     310                return node;
     311        }
     312
     313        virtual const ast::Expr *             visit( const ast::LabelAddressExpr     * node ) {
     314                return node;
     315        }
     316
     317        virtual const ast::Expr *             visit( const ast::CastExpr             * node ) {
     318                return node;
     319        }
     320
     321        virtual const ast::Expr *             visit( const ast::KeywordCastExpr      * node ) {
     322                return node;
     323        }
     324
     325        virtual const ast::Expr *             visit( const ast::VirtualCastExpr      * node ) {
     326                return node;
     327        }
     328
     329        virtual const ast::Expr *             visit( const ast::UntypedMemberExpr    * node ) {
     330                return node;
     331        }
     332
     333        virtual const ast::Expr *             visit( const ast::MemberExpr           * node ) {
     334                return node;
     335        }
     336
     337        virtual const ast::Expr *             visit( const ast::VariableExpr         * node ) {
     338                return node;
     339        }
     340
     341        virtual const ast::Expr *             visit( const ast::ConstantExpr         * node ) {
     342                return node;
     343        }
     344
     345        virtual const ast::Expr *             visit( const ast::SizeofExpr           * node ) {
     346                return node;
     347        }
     348
     349        virtual const ast::Expr *             visit( const ast::AlignofExpr          * node ) {
     350                return node;
     351        }
     352
     353        virtual const ast::Expr *             visit( const ast::UntypedOffsetofExpr  * node ) {
     354                return node;
     355        }
     356
     357        virtual const ast::Expr *             visit( const ast::OffsetofExpr         * node ) {
     358                return node;
     359        }
     360
     361        virtual const ast::Expr *             visit( const ast::OffsetPackExpr       * node ) {
     362                return node;
     363        }
     364
     365        virtual const ast::Expr *             visit( const ast::LogicalExpr          * node ) {
     366                return node;
     367        }
     368
     369        virtual const ast::Expr *             visit( const ast::ConditionalExpr      * node ) {
     370                return node;
     371        }
     372
     373        virtual const ast::Expr *             visit( const ast::CommaExpr            * node ) {
     374                return node;
     375        }
     376
     377        virtual const ast::Expr *             visit( const ast::TypeExpr             * node ) {
     378                return node;
     379        }
     380
     381        virtual const ast::Expr *             visit( const ast::AsmExpr              * node ) {
     382                return node;
     383        }
     384
     385        virtual const ast::Expr *             visit( const ast::ImplicitCopyCtorExpr * node ) {
     386                return node;
     387        }
     388
     389        virtual const ast::Expr *             visit( const ast::ConstructorExpr      * node ) {
     390                return node;
     391        }
     392
     393        virtual const ast::Expr *             visit( const ast::CompoundLiteralExpr  * node ) {
     394                return node;
     395        }
     396
     397        virtual const ast::Expr *             visit( const ast::RangeExpr            * node ) {
     398                return node;
     399        }
     400
     401        virtual const ast::Expr *             visit( const ast::UntypedTupleExpr     * node ) {
     402                return node;
     403        }
     404
     405        virtual const ast::Expr *             visit( const ast::TupleExpr            * node ) {
     406                return node;
     407        }
     408
     409        virtual const ast::Expr *             visit( const ast::TupleIndexExpr       * node ) {
     410                return node;
     411        }
     412
     413        virtual const ast::Expr *             visit( const ast::TupleAssignExpr      * node ) {
     414                return node;
     415        }
     416
     417        virtual const ast::Expr *             visit( const ast::StmtExpr             * node ) {
     418                return node;
     419        }
     420
     421        virtual const ast::Expr *             visit( const ast::UniqueExpr           * node ) {
     422                return node;
     423        }
     424
     425        virtual const ast::Expr *             visit( const ast::UntypedInitExpr      * node ) {
     426                return node;
     427        }
     428
     429        virtual const ast::Expr *             visit( const ast::InitExpr             * node ) {
     430                return node;
     431        }
     432
     433        virtual const ast::Expr *             visit( const ast::DeletedExpr          * node ) {
     434                return node;
     435        }
     436
     437        virtual const ast::Expr *             visit( const ast::DefaultArgExpr       * node ) {
     438                return node;
     439        }
     440
     441        virtual const ast::Expr *             visit( const ast::GenericExpr          * node ) {
     442                return node;
     443        }
     444
     445        virtual const ast::Type *             visit( const ast::VoidType             * node ) {
    608446                preprint( node );
    609447                os << "void";
     
    611449        }
    612450
    613         virtual const ast::Type * visit( const ast::BasicType * node ) {
     451        virtual const ast::Type *             visit( const ast::BasicType            * node ) {
    614452                preprint( node );
    615453                os << ast::BasicType::typeNames[ node->kind ];
     
    617455        }
    618456
    619         virtual const ast::Type * visit( const ast::PointerType * node ) {
     457        virtual const ast::Type *             visit( const ast::PointerType          * node ) {
    620458                preprint( node );
    621459                if ( ! node->isArray() ) {
     
    644482        }
    645483
    646         virtual const ast::Type * visit( const ast::ArrayType * node ) {
     484        virtual const ast::Type *             visit( const ast::ArrayType            * node ) {
    647485                preprint( node );
    648486                if ( node->isStatic ) {
     
    672510        }
    673511
    674         virtual const ast::Type * visit( const ast::ReferenceType * node ) {
     512        virtual const ast::Type *             visit( const ast::ReferenceType        * node ) {
    675513                preprint( node );
    676514
     
    685523        }
    686524
    687         virtual const ast::Type * visit( const ast::QualifiedType * node ) {
     525        virtual const ast::Type *             visit( const ast::QualifiedType        * node ) {
    688526                preprint( node );
    689527
     
    699537        }
    700538
    701         virtual const ast::Type * visit( const ast::FunctionType * node ) {
     539        virtual const ast::Type *             visit( const ast::FunctionType        * node ) {
    702540                preprint( node );
    703541
     
    728566        }
    729567
    730         virtual const ast::Type * visit( const ast::StructInstType * node ) {
     568        virtual const ast::Type *             visit( const ast::StructInstType      * node ) {
    731569                preprint( node );
    732570
     
    740578        }
    741579
    742         virtual const ast::Type * visit( const ast::UnionInstType * node ) {
     580        virtual const ast::Type *             visit( const ast::UnionInstType        * node ) {
    743581                preprint( node );
    744582
     
    752590        }
    753591
    754         virtual const ast::Type * visit( const ast::EnumInstType * node ) {
     592        virtual const ast::Type *             visit( const ast::EnumInstType        * node ) {
    755593                preprint( node );
    756594
     
    764602        }
    765603
    766         virtual const ast::Type * visit( const ast::TraitInstType * node ) {
     604        virtual const ast::Type *             visit( const ast::TraitInstType        * node ) {
    767605                preprint( node );
    768606
     
    773611        }
    774612
    775         virtual const ast::Type * visit( const ast::TypeInstType * node ) {
     613        virtual const ast::Type *             visit( const ast::TypeInstType        * node ) {
    776614                preprint( node );
    777615
     
    783621        }
    784622
    785         virtual const ast::Type * visit( const ast::TupleType * node ) {
     623        virtual const ast::Type *             visit( const ast::TupleType            * node ) {
    786624                preprint( node );
    787625
     
    794632        }
    795633
    796         virtual const ast::Type * visit( const ast::TypeofType * node ) {
     634        virtual const ast::Type *             visit( const ast::TypeofType          * node ) {
    797635                preprint( node );
    798636
     
    808646        }
    809647
    810         virtual const ast::Type * visit( const ast::VarArgsType * node ) {
     648        virtual const ast::Type *             visit( const ast::VarArgsType          * node ) {
    811649                preprint( node );
    812650                os << "builtin var args pack";
     
    814652        }
    815653
    816         virtual const ast::Type * visit( const ast::ZeroType * node ) {
     654        virtual const ast::Type *             visit( const ast::ZeroType            * node ) {
    817655                preprint( node );
    818656                os << "zero_t";
     
    820658        }
    821659
    822         virtual const ast::Type * visit( const ast::OneType * node ) {
     660        virtual const ast::Type *             visit( const ast::OneType              * node ) {
    823661                preprint( node );
    824662                os << "one_t";
     
    826664        }
    827665
    828         virtual const ast::Type * visit( const ast::GlobalScopeType * node ) {
     666        virtual const ast::Type *             visit( const ast::GlobalScopeType      * node ) {
    829667                preprint( node );
    830668                os << "Global Scope Type";
     
    832670        }
    833671
    834         virtual const ast::Designation * visit( const ast::Designation * node ) {
     672        virtual const ast::Designation *      visit( const ast::Designation          * node ) {
    835673                if ( node->designators.empty() ) return node;
    836674                os << "... designated by: " << std::endl;
     
    845683        }
    846684
    847         virtual const ast::Init * visit( const ast::SingleInit * node ) {
     685        virtual const ast::Init *             visit( const ast::SingleInit          * node ) {
    848686                os << "Simple Initializer: ";
    849687                node->value->accept( *this );
     
    851689        }
    852690
    853         virtual const ast::Init * visit( const ast::ListInit * node ) {
     691        virtual const ast::Init *             visit( const ast::ListInit            * node ) {
    854692                os << "Compound initializer: " << std::endl;
    855693                ++indent;
     
    869707        }
    870708
    871         virtual const ast::Init * visit( const ast::ConstructorInit * node ) {
     709        virtual const ast::Init *             visit( const ast::ConstructorInit      * node ) {
    872710                os << "Constructor initializer: " << std::endl;
    873711                if ( node->ctor ) {
     
    894732        }
    895733
    896         virtual const ast::Attribute * visit( const ast::Attribute * node ) {
     734        virtual const ast::Attribute *        visit( const ast::Attribute            * node ) {
    897735                if ( node->empty() ) return node;
    898736                os << "Attribute with name: " << node->name;
     
    905743        }
    906744
    907         virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) {
     745        virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution     * node ) {
    908746                os << indent << "Types:" << std::endl;
    909747                for ( const auto& i : *node ) {
     
    927765};
    928766
    929 void print( ostream & os, const ast::Node * node, Indenter indent ) {
    930         Printer printer { os, indent, false };
    931         node->accept(printer);
    932 }
    933 
    934 void printShort( ostream & os, const ast::Node * node, Indenter indent ) {
    935         Printer printer { os, indent, true };
     767void print( std::ostream & os, const ast::Node * node, Indenter indent ) {
     768        Printer printer { os, indent };
    936769        node->accept(printer);
    937770}
     
    940773// The size here needs to be explicit but at least the compiler will produce an error
    941774// if the wrong size is specified
    942 constexpr array<const char*, 3> Printer::Names::FuncSpecifiers;
    943 constexpr array<const char*, 5> Printer::Names::StorageClasses;
    944 constexpr array<const char*, 6> Printer::Names::Qualifiers;
     775constexpr std::array<const char*, 3> Printer::Names::FuncSpecifiers;
     776constexpr std::array<const char*, 5> Printer::Names::StorageClasses;
     777constexpr std::array<const char*, 6> Printer::Names::Qualifiers;
    945778}
  • src/AST/TypeSubstitution.hpp

    r68c9165 rb0ec971  
    2525#include "Fwd.hpp"        // for UniqueId
    2626#include "ParseNode.hpp"
    27 #include "Type.hpp"
     27#include "Type.hpp"       
    2828#include "Common/SemanticError.h"  // for SemanticError
    2929#include "Visitor.hpp"
  • src/AST/module.mk

    r68c9165 rb0ec971  
    2121        AST/DeclReplacer.cpp \
    2222        AST/Expr.cpp \
    23         AST/GenericSubstitution.cpp \
    2423        AST/Init.cpp \
    2524        AST/LinkageSpec.cpp \
  • src/Makefile.in

    r68c9165 rb0ec971  
    167167am__objects_1 = AST/Attribute.$(OBJEXT) AST/Convert.$(OBJEXT) \
    168168        AST/Decl.$(OBJEXT) AST/DeclReplacer.$(OBJEXT) \
    169         AST/Expr.$(OBJEXT) AST/GenericSubstitution.$(OBJEXT) \
    170         AST/Init.$(OBJEXT) AST/LinkageSpec.$(OBJEXT) \
    171         AST/Node.$(OBJEXT) AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) \
    172         AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \
    173         AST/TypeSubstitution.$(OBJEXT)
     169        AST/Expr.$(OBJEXT) AST/Init.$(OBJEXT) \
     170        AST/LinkageSpec.$(OBJEXT) AST/Node.$(OBJEXT) \
     171        AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) \
     172        AST/Type.$(OBJEXT) AST/TypeSubstitution.$(OBJEXT)
    174173am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \
    175174        CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \
     
    575574        AST/DeclReplacer.cpp \
    576575        AST/Expr.cpp \
    577         AST/GenericSubstitution.cpp \
    578576        AST/Init.cpp \
    579577        AST/LinkageSpec.cpp \
     
    741739        AST/$(DEPDIR)/$(am__dirstamp)
    742740AST/Expr.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
    743 AST/GenericSubstitution.$(OBJEXT): AST/$(am__dirstamp) \
    744         AST/$(DEPDIR)/$(am__dirstamp)
    745741AST/Init.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
    746742AST/LinkageSpec.$(OBJEXT): AST/$(am__dirstamp) \
     
    11771173@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/DeclReplacer.Po@am__quote@
    11781174@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Expr.Po@am__quote@
    1179 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/GenericSubstitution.Po@am__quote@
    11801175@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Init.Po@am__quote@
    11811176@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@
  • src/ResolvExpr/Unify.cc

    r68c9165 rb0ec971  
    179179                                result = false;
    180180                        } else {
    181                                 result = env.bindVarToVar(
    182                                         var1, var2, TypeDecl::Data{ entry1->second, entry2->second }, needAssertions,
     181                                result = env.bindVarToVar( 
     182                                        var1, var2, TypeDecl::Data{ entry1->second, entry2->second }, needAssertions, 
    183183                                        haveAssertions, openVars, widenMode, indexer );
    184184                        }
     
    648648
    649649        ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ) {
    650                 if ( func->returns.empty() ) return new ast::VoidType{};
    651                 if ( func->returns.size() == 1 ) return func->returns[0]->get_type();
    652 
    653                 std::vector<ast::ptr<ast::Type>> tys;
    654                 for ( const ast::DeclWithType * decl : func->returns ) {
    655                         tys.emplace_back( decl->get_type() );
    656                 }
    657                 return new ast::TupleType{ std::move(tys) };
     650                assert(!"restore after AST added to build");
     651                // if ( func->returns.empty() ) return new ast::VoidType{};
     652                // if ( func->returns.size() == 1 ) return func->returns[0]->get_type();
     653
     654                // std::vector<ast::ptr<ast::Type>> tys;
     655                // for ( const ast::DeclWithType * decl : func->returns ) {
     656                //      tys.emplace_back( decl->get_type() );
     657                // }
     658                // return new ast::TupleType{ std::move(tys) };
    658659        }
    659660} // namespace ResolvExpr
  • src/Tuples/TupleExpansion.cc

    r68c9165 rb0ec971  
    320320        }
    321321        const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) {
    322                 // produce the TupleType which aggregates the types of the exprs
    323                 std::vector<ast::ptr<ast::Type>> types;
    324                 ast::CV::Qualifiers quals{
    325                         ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |
    326                         ast::CV::Atomic | ast::CV::Mutex };
    327 
    328                 for ( const ast::Expr * expr : exprs ) {
    329                         assert( expr->result );
    330                         // if the type of any expr is void, the type of the entire tuple is void
    331                         if ( expr->result->isVoid() ) return new ast::VoidType{};
    332 
    333                         // qualifiers on the tuple type are the qualifiers that exist on all components
    334                         quals &= expr->result->qualifiers;
    335 
    336                         types.emplace_back( expr->result );
    337                 }
    338 
    339                 if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; }
    340                 return new ast::TupleType{ std::move(types), quals };
     322                (void) exprs;
     323                #warning Not implemented; needs Type.cpp in build
     324                assertf(false, "Not implemented; needs Type.cpp in build");
     325                // // produce the TupleType which aggregates the types of the exprs
     326                // std::vector<ast::ptr<ast::Type>> types;
     327                // ast::CV::Qualifiers quals{
     328                //      ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |
     329                //      ast::CV::Atomic | ast::CV::Mutex };
     330
     331                // for ( const ast::Expr * expr : exprs ) {
     332                //      assert( expr->result );
     333                //      // if the type of any expr is void, the type of the entire tuple is void
     334                //      if ( expr->result->isVoid() ) return new ast::VoidType{};
     335
     336                //      // qualifiers on the tuple type are the qualifiers that exist on all components
     337                //      quals &= expr->result->qualifiers;
     338
     339                //      types.emplace_back( expr->result );
     340                // }
     341
     342                // if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; }
     343                // return new ast::TupleType{ std::move(types), quals };
    341344        }
    342345
     
    351354
    352355        const ast::TypeInstType * isTtype( const ast::Type * type ) {
    353                 if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
    354                         if ( inst->base && inst->base->kind == ast::TypeVar::Ttype ) {
    355                                 return inst;
    356                         }
    357                 }
     356                #warning unimplemented
    358357                return nullptr;
    359358        }
Note: See TracChangeset for help on using the changeset viewer.