Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r0b73f0c r60aaa51d  
    1616#include "Convert.hpp"
    1717
     18#include <deque>
    1819#include <unordered_map>
    1920
     
    575576
    576577                if ( srcInferred.mode == ast::Expr::InferUnion::Params ) {
    577                         const ast::InferredParams &srcParams = srcInferred.inferParamsConst();
     578                        const ast::InferredParams &srcParams = srcInferred.inferParams();
    578579                        for (auto srcParam : srcParams) {
    579580                                tgtInferParams[srcParam.first] = ParamEntry(
     
    585586                        }
    586587                } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots  ) {
    587                         const ast::ResnSlots &srcSlots = srcInferred.resnSlotsConst();
     588                        const ast::ResnSlots &srcSlots = srcInferred.resnSlots();
    588589                        for (auto srcSlot : srcSlots) {
    589590                                tgtResnSlots.push_back(srcSlot);
     
    735736                expr->var = get<DeclarationWithType>().accept1(node->var);
    736737                Type * type = expr->var->get_type()->clone();
    737                 if(FunctionType * ft = dynamic_cast<FunctionType*>(type)) {
    738                         if(node->result.as<ast::PointerType>()) {
    739                                 type = new PointerType({}, ft);
    740                         }
    741                 }
    742 
    743738                type->set_lvalue( true );
    744                 expr->result = type ;
     739                expr->set_result( type );
    745740                this->node = expr;
    746741                return nullptr;
     
    788783                        assert (!rslt->isType);
    789784                }
    790                 else {
    791                         assert(node->type);
     785                if (node->type) {
    792786                        rslt = new SizeofExpr(
    793787                                get<Type>().accept1(node->type)
     
    810804                        assert (!rslt->isType);
    811805                }
    812                 else {
    813                         assert(node->type);
     806                if (node->type) {
    814807                        rslt = new AlignofExpr(
    815808                                get<Type>().accept1(node->type)
     
    14211414#       define GET_ACCEPT_V(child, type) \
    14221415                getAcceptV< ast::type, decltype( old->child ) >( old->child )
     1416       
     1417        template<typename NewT, typename OldC>
     1418        std::deque< ast::ptr<NewT> > getAcceptD( OldC& old ) {
     1419                std::deque< ast::ptr<NewT> > ret;
     1420                for ( auto a : old ) {
     1421                        a->accept( *this );
     1422                        ret.emplace_back( strict_dynamic_cast< NewT * >(node) );
     1423                        node = nullptr;
     1424                }
     1425                return ret;
     1426        }
     1427
     1428#       define GET_ACCEPT_D(child, type) \
     1429                getAcceptD< ast::type, decltype( old->child ) >( old->child )
    14231430
    14241431        ast::Label make_label(Label* old) {
     
    21572164                );
    21582165
    2159                 visitBaseExpr_SkipResultType( old,
     2166                visitBaseExpr( old,
    21602167                        expr
    21612168                );
     
    21632170                expr->var = GET_ACCEPT_1(var, DeclWithType);
    21642171                expr->result = expr->var->get_type();
    2165                 if(const ast::FunctionType * ft = expr->result.as<ast::FunctionType>()) {
    2166                         if(dynamic_cast<PointerType *>(old->result)) {
    2167                                 expr->result = new ast::PointerType(ft);
    2168                         }
    2169                 }
    21702172                add_qualifiers( expr->result, ast::CV::Lvalue );
    21712173                this->node = expr;
     
    24622464
    24632465        virtual void visit( UntypedInitExpr * old ) override final {
    2464                 std::vector<ast::InitAlternative> initAlts;
     2466                std::deque<ast::InitAlternative> initAlts;
    24652467                for (auto ia : old->initAlts) {
    24662468                        initAlts.push_back(ast::InitAlternative(
     
    27272729                this->node = new ast::Designation(
    27282730                        old->location,
    2729                         GET_ACCEPT_V(designators, Expr)
     2731                        GET_ACCEPT_D(designators, Expr)
    27302732                );
    27312733        }
Note: See TracChangeset for help on using the changeset viewer.