Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    rb230091 r7edd5c1  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan 12 16:54:55 2021
    13 // Update Count     : 23
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu May  5 12:10:00 2022
     13// Update Count     : 24
    1414//
    1515
     
    5353// --- FunctionDecl
    5454
    55 FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name, 
     55FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name,
    5656        std::vector<ptr<TypeDecl>>&& forall,
    5757        std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
     
    7474        }
    7575        this->type = ftype;
     76}
     77
     78FunctionDecl::FunctionDecl( const CodeLocation & location, const std::string & name,
     79        std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions,
     80        std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
     81        CompoundStmt * stmts, Storage::Classes storage, Linkage::Spec linkage,
     82        std::vector<ptr<Attribute>>&& attrs, Function::Specs fs, bool isVarArgs)
     83: DeclWithType( location, name, storage, linkage, std::move(attrs), fs ),
     84                params( std::move(params) ), returns( std::move(returns) ),
     85                type_params( std::move( forall) ), assertions( std::move( assertions ) ),
     86                type( nullptr ), stmts( stmts ) {
     87        FunctionType * type = new FunctionType( (isVarArgs) ? VariableArgs : FixedArgs );
     88        for ( auto & param : this->params ) {
     89                type->params.emplace_back( param->get_type() );
     90        }
     91        for ( auto & ret : this->returns ) {
     92                type->returns.emplace_back( ret->get_type() );
     93        }
     94        for ( auto & param : this->type_params ) {
     95                type->forall.emplace_back( new TypeInstType( param ) );
     96        }
     97        for ( auto & assertion : this->assertions ) {
     98                type->assertions.emplace_back(
     99                        new VariableExpr( assertion->location, assertion ) );
     100        }
     101        this->type = type;
    76102}
    77103
     
    136162
    137163        auto it = enumValues.find( enumerator->name );
     164       
    138165        if ( it != enumValues.end() ) {
    139                 value = it->second;
     166                       
     167                // Handle typed enum by casting the value in (C++) compiler
     168                // if ( base ) { // A typed enum
     169                //      if ( const BasicType * bt = dynamic_cast<const BasicType *>(base) ) {
     170                //              switch( bt->kind ) {
     171                //                      case BasicType::Kind::Bool:     value = (bool) it->second; break;
     172                //                      case BasicType::Kind::Char: value = (char) it->second; break;
     173                //                      case BasicType::Kind::SignedChar: value = (signed char) it->second; break;
     174                //                      case BasicType::Kind::UnsignedChar: value = (unsigned char) it->second; break;
     175                //                      case BasicType::Kind::ShortSignedInt: value = (short signed int) it->second; break;
     176                //                      case BasicType::Kind::SignedInt: value = (signed int) it->second; break;
     177                //                      case BasicType::Kind::UnsignedInt: value = (unsigned int) it->second; break;
     178                //                      case BasicType::Kind::LongSignedInt: value = (long signed int) it->second; break;
     179                //                      case BasicType::Kind::LongUnsignedInt: value = (long unsigned int) it->second; break;
     180                //                      case BasicType::Kind::LongLongSignedInt: value = (long long signed int) it->second; break;
     181                //                      case BasicType::Kind::LongLongUnsignedInt: value = (long long unsigned int) it->second; break;
     182                //                      // TODO: value should be able to handle long long unsigned int
     183
     184                //                      default:
     185                //                      value = it->second;
     186                //              }
     187                //      }
     188                // } else {
     189                        value = it->second;
     190                //}
     191
    140192                return true;
    141193        }
Note: See TracChangeset for help on using the changeset viewer.