Changeset 37273c8 for src/AST


Ignore:
Timestamp:
Nov 28, 2023, 3:01:52 PM (23 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/AST
Files:
2 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,
Note: See TracChangeset for help on using the changeset viewer.