Changeset 37273c8


Ignore:
Timestamp:
Nov 28, 2023, 3:01:52 PM (5 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
ab9c1b3
Parents:
4bc4b4c
Message:

Removed the old-ast-compatable FunctionDecl? constructor. However, enough cases pass nothing polymorphic along some of the uses of the constructor now go to a new monomorphic function constructor.

Location:
src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r4bc4b4c r37273c8  
    4141
    4242FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name,
    43         std::vector<ptr<TypeDecl>>&& forall,
    4443        std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
    4544        CompoundStmt * stmts, Storage::Classes storage, Linkage::Spec linkage,
    4645        std::vector<ptr<Attribute>>&& attrs, Function::Specs fs, ArgumentFlag isVarArgs )
    47 : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ),
    48         type_params(std::move(forall)), assertions(),
    49         params(std::move(params)), returns(std::move(returns)), stmts( stmts ) {
    50         FunctionType * ftype = new FunctionType( isVarArgs );
    51         for (auto & param : this->params) {
    52                 ftype->params.emplace_back(param->get_type());
    53         }
    54         for (auto & ret : this->returns) {
    55                 ftype->returns.emplace_back(ret->get_type());
    56         }
    57         for (auto & tp : this->type_params) {
    58                 ftype->forall.emplace_back(new TypeInstType(tp));
    59                 for (auto & ap: tp->assertions) {
    60                         ftype->assertions.emplace_back(new VariableExpr(loc, ap));
    61                 }
    62         }
    63         this->type = ftype;
     46: FunctionDecl( loc, name, {}, {}, std::move(params), std::move(returns),
     47                stmts, storage, linkage, std::move(attrs), fs, isVarArgs ) {
    6448}
    6549
  • src/AST/Decl.hpp

    r4bc4b4c r37273c8  
    135135        std::vector< ptr<Expr> > withExprs;
    136136
    137         // The difference between the two constructors is in how they handle
    138         // assertions. The first constructor uses the assertions from the type
    139         // parameters, in the style of the old ast, and puts them on the type.
    140         // The second takes an explicite list of assertions and builds a list of
    141         // references to them on the type.
    142 
    143         FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall,
     137        /// Monomorphic Function Constructor:
     138        FunctionDecl( const CodeLocation & locaction, const std::string & name,
    144139                std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
    145140                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::Cforall,
    146141                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, ArgumentFlag isVarArgs = FixedArgs );
    147142
     143        /// Polymorphic Function Constructor:
    148144        FunctionDecl( const CodeLocation & location, const std::string & name,
    149145                std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions,
  • src/Concurrency/Actors.cpp

    r4bc4b4c r37273c8  
    265265                decl->location,
    266266                "__CFA_receive_wrap",
    267                 {},                     // forall
    268267                {
    269268                    new ObjectDecl(
     
    288287                    )
    289288                },                      // params
    290                 { 
     289                {
    291290                    new ObjectDecl(
    292291                        decl->location,
     
    400399                                )
    401400                        ));
    402            
     401
    403402            // Generates: return receiver;
    404403            sendBody->push_back( new ReturnStmt( decl->location, new NameExpr( decl->location, "receiver" ) ) );
     
    408407                decl->location,
    409408                "?|?",
    410                 {},                     // forall
    411409                {
    412410                    new ObjectDecl(
     
    421419                    )
    422420                },                      // params
    423                 { 
     421                {
    424422                    new ObjectDecl(
    425423                        decl->location,
     
    434432                { Function::Inline }
    435433            );
    436            
     434
    437435            // forward decls to resolve use before decl problem for '|' routines
    438436            forwardDecls.insertDecl( *actorIter, *messageIter , ast::deepCopy( sendOperatorFunction ) );
  • src/Concurrency/Corun.cpp

    r4bc4b4c r37273c8  
    113113            new FunctionDecl( loc,
    114114                fnName,                                             // name
    115                 {},                                                 // forall
    116115                {
    117116                    new ObjectDecl( loc,
     
    261260            new FunctionDecl( loc,
    262261                fnName,                                             // name
    263                 {},                                                 // forall
    264262                {},                                                 // params
    265263                {},                                                 // return
  • src/Concurrency/KeywordsNew.cpp

    r4bc4b4c r37273c8  
    482482                location,
    483483                getter_name,
    484                 {}, // forall
    485484                { this_decl }, // params
    486485                { ret_decl }, // returns
     
    499498                        location,
    500499                        "main",
    501                         {},
    502500                        { ast::deepCopy( this_decl ) },
    503501                        {},
     
    575573                location,
    576574                "lock",
    577                 { /* forall */ },
    578575                {
    579576                        // Copy the declaration of this.
     
    607604                location,
    608605                "unlock",
    609                 { /* forall */ },
    610606                {
    611607                        // Last use, consume the declaration of this.
  • src/Concurrency/Waituntil.cpp

    r4bc4b4c r37273c8  
    553553    return new FunctionDecl( loc,
    554554        predName,
    555         {},                     // forall
    556555        {
    557556            new ObjectDecl( loc,
     
    560559            )
    561560        },
    562         { 
     561        {
    563562            new ObjectDecl( loc,
    564563                "sat_ret",
  • src/ControlStruct/ExceptTranslateNew.cpp

    r4bc4b4c r37273c8  
    253253                location,
    254254                "try",
    255                 {}, //forall
    256255                {}, //no param
    257256                {}, //no return
     
    267266                location,
    268267                "catch",
    269                 {}, //forall
    270268                { make_index_object( location ), make_exception_object( location ) },
    271269                {}, //return void
     
    281279                location,
    282280                "match",
    283                 {}, //forall
    284281                { make_exception_object( location ) },
    285282                { make_unused_index_object( location ) },
     
    295292                location,
    296293                "handle",
    297                 {}, //forall
    298294                { make_exception_object( location ) },
    299295                { make_bool_object( location ) },
     
    309305                location,
    310306                "finally",
    311                 {}, //forall
    312307                { make_voidptr_object( location ) },
    313308                {}, //return void
  • src/InitTweak/FixGlobalInit.cc

    r4bc4b4c r37273c8  
    8484                if (inLibrary) ctorParams.emplace_back(ast::ConstantExpr::from_int(location, 200));
    8585                auto initFunction = new ast::FunctionDecl(location,
    86                         "__global_init__", {}, {}, {},
     86                        "__global_init__", {}, {}, {}, {},
    8787                        new ast::CompoundStmt(location, std::move(fixer.core.initStmts)),
    8888                        ast::Storage::Static, ast::Linkage::C,
     
    9696                if (inLibrary) dtorParams.emplace_back(ast::ConstantExpr::from_int(location, 200));
    9797                auto destroyFunction = new ast::FunctionDecl( location,
    98                         "__global_destroy__", {}, {}, {},
     98                        "__global_destroy__", {}, {}, {}, {},
    9999                        new ast::CompoundStmt(location, std::move(fixer.core.destroyStmts)),
    100100                        ast::Storage::Static, ast::Linkage::C,
  • src/InitTweak/FixInitNew.cpp

    r4bc4b4c r37273c8  
    7474                fname,
    7575                std::move(typeParams),
     76                {},
    7677                {dstParam},
    7778                {},
     
    899900
    900901                                        // void __objName_dtor_atexitN(...) {...}
    901                                         ast::FunctionDecl * dtorCaller = new ast::FunctionDecl(loc, objDecl->mangleName + dtorCallerNamer.newName(), {}, {}, {}, new ast::CompoundStmt(loc, {dtor}), ast::Storage::Static, ast::Linkage::C );
     902                                        ast::FunctionDecl * dtorCaller = new ast::FunctionDecl(loc, objDecl->mangleName + dtorCallerNamer.newName(), {}, {}, {}, {}, new ast::CompoundStmt(loc, {dtor}), ast::Storage::Static, ast::Linkage::C );
    902903                                        dtorCaller->fixUniqueId();
    903904                                        // dtorCaller->stmts->push_back( dtor );
  • src/InitTweak/InitTweak.cc

    r4bc4b4c r37273c8  
    342342        if (!assign) {
    343343                auto td = new ast::TypeDecl(CodeLocation(), "T", {}, nullptr, ast::TypeDecl::Dtype, true);
    344                 assign = new ast::FunctionDecl(CodeLocation(), "?=?", {td},
     344                assign = new ast::FunctionDecl(CodeLocation(), "?=?", {td}, {},
    345345                { new ast::ObjectDecl(CodeLocation(), "_dst", new ast::ReferenceType(new ast::TypeInstType("T", td))),
    346346                  new ast::ObjectDecl(CodeLocation(), "_src", new ast::TypeInstType("T", td))},
  • src/Virtual/Tables.cc

    r4bc4b4c r37273c8  
    165165                location,
    166166                functionName,
    167                 { /* forall */ },
    168167                { new ast::ObjectDecl(
    169168                        location,
  • src/Virtual/VirtualDtor.cpp

    r4bc4b4c r37273c8  
    248248            decl->location,
    249249            "__CFA_set_dtor",
    250             {},                     // forall
    251250            {
    252251                new ObjectDecl(
     
    320319            decl->location,
    321320            "delete",
    322             {},                     // forall
    323321            {
    324322                new ObjectDecl(
Note: See TracChangeset for help on using the changeset viewer.