Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r16ba4a6f r07de76b  
    2121
    2222#include "AST/Decl.hpp"
    23 #include "AST/Eval.hpp"
    2423#include "AST/Expr.hpp"
    2524#include "AST/Init.hpp"
     
    5554        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
    5655        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true );
    57 
    58         ast::FunctionDecl * genDefaultFunc(const CodeLocation loc, const std::string fname, const ast::Type * paramType, bool maybePolymorphic = true);
    5956
    6057        /// generate the type of a copy constructor for paramType.
     
    167164                fExpr->args.emplace_back( dstParam );
    168165
    169                 ast::ptr<ast::Stmt> listInit = srcParam.buildListInit( fExpr );
     166                const ast::Stmt * listInit = srcParam.buildListInit( fExpr );
    170167
    171168                // fetch next set of arguments
     
    268265                }
    269266
    270                 ast::ptr< ast::Expr > begin, end;
    271                 std::string cmp, update;
     267                ast::ptr< ast::Expr > begin, end, cmp, update;
    272268
    273269                if ( forward ) {
     
    275271                        begin = ast::ConstantExpr::from_int( loc, 0 );
    276272                        end = array->dimension;
    277                         cmp = "?<?";
    278                         update = "++?";
     273                        cmp = new ast::NameExpr{ loc, "?<?" };
     274                        update = new ast::NameExpr{ loc, "++?" };
    279275                } else {
    280276                        // generate: for ( int i = N-1; i >= 0; --i )
    281                         begin = ast::call(
    282                                 loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ) );
     277                        begin = new ast::UntypedExpr{
     278                                loc, new ast::NameExpr{ loc, "?-?" },
     279                                { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } };
    283280                        end = ast::ConstantExpr::from_int( loc, 0 );
    284                         cmp = "?>=?";
    285                         update = "--?";
     281                        cmp = new ast::NameExpr{ loc, "?>=?" };
     282                        update = new ast::NameExpr{ loc, "--?" };
    286283                }
    287284
     
    289286                        loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt },
    290287                        new ast::SingleInit{ loc, begin } };
    291                 ast::ptr< ast::Expr > indexVar = new ast::VariableExpr{ loc, index };
    292                
    293                 ast::ptr< ast::Expr > cond = ast::call( loc, cmp, indexVar, end );
    294                
    295                 ast::ptr< ast::Expr > inc = ast::call( loc, update, indexVar );
    296                
    297                 ast::ptr< ast::Expr > dstIndex = ast::call( loc, "?[?]", dstParam, indexVar );
     288               
     289                ast::ptr< ast::Expr > cond = new ast::UntypedExpr{
     290                        loc, cmp, { new ast::VariableExpr{ loc, index }, end } };
     291               
     292                ast::ptr< ast::Expr > inc = new ast::UntypedExpr{
     293                        loc, update, { new ast::VariableExpr{ loc, index } } };
     294               
     295                ast::ptr< ast::Expr > dstIndex = new ast::UntypedExpr{
     296                        loc, new ast::NameExpr{ loc, "?[?]" },
     297                        { dstParam, new ast::VariableExpr{ loc, index } } };
    298298               
    299299                // srcParam must keep track of the array indices to build the source parameter and/or
    300300                // array list initializer
    301                 srcParam.addArrayIndex( indexVar, array->dimension );
     301                srcParam.addArrayIndex( new ast::VariableExpr{ loc, index }, array->dimension );
    302302
    303303                // for stmt's body, eventually containing call
     
    385385                if ( isUnnamedBitfield( obj ) ) return {};
    386386
    387                 ast::ptr< ast::Type > addCast;
     387                ast::ptr< ast::Type > addCast = nullptr;
    388388                if ( (fname == "?{}" || fname == "^?{}") && ( ! obj || ( obj && ! obj->bitfieldWidth ) ) ) {
    389389                        assert( dstParam->result );
Note: See TracChangeset for help on using the changeset viewer.