Changes in / [971ae89:334ebc23]


Ignore:
Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r971ae89 r334ebc23  
    258258             
    259259                                  case OT_CALL:
    260                                         // there are no intrinsic definitions of the function call operator
     260                                  case OT_CTOR:
     261                                  case OT_DTOR:
     262                                        // there are no intrinsic definitions of the function call operator or constructors or destructors
    261263                                        assert( false );
    262264                                        break;
  • src/CodeGen/OperatorTable.cc

    r971ae89 r334ebc23  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 17:41:14 2015
    13 // Update Count     : 5
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:17:34 2015
     13// Update Count     : 7
    1414//
    1515
     
    2121                const OperatorInfo tableValues[] = {
    2222                        {       "?[?]",         "",             "_operator_index",                              OT_INDEX                        },
     23                        {       "?{}",          "",             "_constructor",                                 OT_CTOR                         },
     24                        {       "-?{}",         "",             "_destructor",                                  OT_DTOR                         }, // -?{}, !?{}, $?{}, ??{}, ?destroy, ?delete
    2325                        {       "?()",          "",             "_operator_call",                               OT_CALL                         },
    2426                        {       "?++",          "++",   "_operator_postincr",                   OT_POSTFIXASSIGN        },
  • src/CodeGen/OperatorTable.h

    r971ae89 r334ebc23  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 16:09:27 2015
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:17:57 2015
     13// Update Count     : 5
    1414//
    1515
     
    2222        enum OperatorType {
    2323                OT_INDEX,
     24                OT_CTOR,
     25                OT_DTOR,
    2426                OT_CALL,
    2527                OT_PREFIX,
  • src/MakeLibCfa.cc

    r971ae89 r334ebc23  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 10:33:33 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 26 16:52:59 2015
    13 // Update Count     : 14
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Jul 03 18:11:37 2015
     13// Update Count     : 18
    1414//
    1515
     
    7777                                break;
    7878                        }
     79                  case CodeGen::OT_CTOR:
     80                  case CodeGen::OT_DTOR:
    7981                  case CodeGen::OT_CONSTANT:
    8082                  case CodeGen::OT_LABELADDRESS:
  • src/Parser/LinkageSpec.cc

    r971ae89 r334ebc23  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:22:09 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 16 13:23:21 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 19 15:53:05 2015
     13// Update Count     : 5
    1414//
    1515
     
    7979}
    8080
     81
     82bool LinkageSpec::isOverridable( Type t ) {
     83        switch ( t ) {
     84          case Intrinsic:
     85          case AutoGen:
     86                return true;
     87          case Cforall:
     88          case C:
     89          case Compiler:
     90                return false;
     91        }
     92        assert( false );
     93        return false;
     94}
     95
    8196bool LinkageSpec::isBuiltin( Type t ) {
    8297        switch ( t ) {
  • src/Parser/LinkageSpec.h

    r971ae89 r334ebc23  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 16 13:26:14 2015
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Aug 18 14:11:55 2015
     13// Update Count     : 5
    1414//
    1515
     
    3434        static bool isGeneratable( Type );
    3535        static bool isOverloadable( Type );
     36        static bool isOverridable( Type );
    3637        static bool isBuiltin( Type );
    3738};
  • src/Parser/ParseNode.h

    r971ae89 r334ebc23  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 13:27:11 2015
    13 // Update Count     : 172
     12// Last Modified On : Wed Aug 19 15:59:27 2015
     13// Update Count     : 174
    1414//
    1515
     
    180180                                Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn,
    181181                                ERAssn, OrAssn, Index, FieldSel, PFieldSel, Range,
    182                                 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress
     182                                UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
     183                                Ctor, Dtor,
    183184        };
    184185
  • src/SymTab/IdTable.cc

    r971ae89 r334ebc23  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 17:04:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 17:07:43 2015
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 19 15:47:58 2015
     13// Update Count     : 38
    1414//
    1515
     
    5252                if ( decl->get_linkage() == LinkageSpec::C ) {
    5353                        manglename = name;
     54                } else if ( LinkageSpec::isOverridable( decl->get_linkage() ) ) {
     55                        // mangle the name without including the appropriate suffix
     56                        // this will make it so that overridable routines are placed
     57                        // into the same "bucket" as their user defined versions.
     58                        manglename = Mangler::mangle( decl, false );
    5459                } else {
    5560                        manglename = Mangler::mangle( decl );
     
    6469                        std::stack< DeclEntry >& entry = it->second;
    6570                        if ( ! entry.empty() && entry.top().second == scopeLevel ) {
     71                                // typesCompatible doesn't really do the right thing here. When checking compatibility of function types,
     72                                // we should ignore outermost pointer qualifiers, except _Atomic?
     73
    6674                                if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) {
    6775                                        FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( decl );
    6876                                        FunctionDecl *old = dynamic_cast< FunctionDecl* >( entry.top().first );
    69                                         if ( newentry && old && newentry->get_statements() && old->get_statements() ) {
    70                                                 throw SemanticError( "duplicate function definition for ", decl );
     77                                        if ( LinkageSpec::isOverridable( old->get_linkage() ) ) {
     78                                                // new definition shadows the autogenerated one, even at the same scope
     79                                                declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
     80                                        } else if ( newentry && old && newentry->get_statements() && old->get_statements() ) {
     81                                                throw SemanticError( "duplicate function definition for 1 ", decl );
    7182                                        } else {
     83                                                // two objects with the same mangled name defined in the same scope.
     84                                                // both objects must be marked extern for this to be okay
    7285                                                ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( decl );
    7386                                                ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( entry.top().first );
    74                                                 if ( newobj && oldobj && newobj->get_init() && oldobj->get_init() ) {
     87                                                if ( newobj && oldobj && newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) {
    7588                                                        throw SemanticError( "duplicate definition for ", decl );
    7689                                                } // if
    7790                                        } // if
    7891                                } else {
    79                                         throw SemanticError( "duplicate definition for ", decl );
     92                                        // C definitions with the same name but incompatible types
     93                                        throw SemanticError( "duplicate definition for 2 ", decl );
    8094                                } // if
    8195                        } else {
     
    8498                } // if
    8599                // ensure the set of routines with C linkage cannot be overloaded
     100                // this ensures that no two declarations with the same unmangled name both have C linkage
    86101                for ( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
    87102                        if ( ! i->second.empty() && i->second.top().first->get_linkage() == LinkageSpec::C && declTable.size() > 1 ) {
  • src/SymTab/Mangler.cc

    r971ae89 r334ebc23  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:40:29 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 15:12:12 2015
    13 // Update Count     : 8
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 19 15:52:24 2015
     13// Update Count     : 19
    1414//
    1515
     
    3030
    3131namespace SymTab {
    32         Mangler::Mangler() : nextVarNum( 0 ), isTopLevel( true ) {
     32        Mangler::Mangler( bool mangleOverridable ) : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ) {
    3333        }
    3434
     
    4141                nextVarNum = rhs.nextVarNum;
    4242                isTopLevel = rhs.isTopLevel;
     43                mangleOverridable = rhs.mangleOverridable;
    4344        }
    4445
     
    5960                mangleName << "__";
    6061                maybeAccept( declaration->get_type(), *this );
     62                if ( mangleOverridable && LinkageSpec::isOverridable( declaration->get_linkage() ) ) {
     63                        // want to be able to override autogenerated and intrinsic routines,
     64                        // so they need a different name mangling
     65                        if ( declaration->get_linkage() == LinkageSpec::AutoGen ) {
     66                                mangleName << "autogen__";
     67                        } else if ( declaration->get_linkage() == LinkageSpec::Intrinsic ) {
     68                                mangleName << "intrinsic__";
     69                        } else {
     70                                // if we add another kind of overridable function, this has to change
     71                                assert( false );
     72                        } // if
     73                }
    6174                isTopLevel = wasTopLevel;
    6275        }
     
    214227                                varNums[ (*i )->get_name() ] = std::pair< int, int >( nextVarNum++, (int )(*i )->get_kind() );
    215228                                for ( std::list< DeclarationWithType* >::iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) {
    216                                         Mangler sub_mangler;
     229                                        Mangler sub_mangler( mangleOverridable );
    217230                                        sub_mangler.nextVarNum = nextVarNum;
    218231                                        sub_mangler.isTopLevel = false;
  • src/SymTab/Mangler.h

    r971ae89 r334ebc23  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:44:03 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 14:47:14 2015
    13 // Update Count     : 5
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 19 15:48:46 2015
     13// Update Count     : 14
    1414//
    1515
     
    2525          public:
    2626                template< typename SynTreeClass >
    27             static std::string mangle( SynTreeClass *decl ); // interface to clients
     27            static std::string mangle( SynTreeClass *decl, bool mangleOverridable = true ); // interface to clients
    2828
    2929///   using Visitor::visit;
     
    5050                int nextVarNum;
    5151                bool isTopLevel;
     52                bool mangleOverridable;
    5253 
    53                 Mangler();
     54                Mangler( bool mangleOverridable );
    5455                Mangler( const Mangler & );
    5556 
     
    6162
    6263        template< typename SynTreeClass >
    63         std::string Mangler::mangle( SynTreeClass *decl ) {
    64                 Mangler mangler;
     64        std::string Mangler::mangle( SynTreeClass *decl, bool mangleOverridable ) {
     65                Mangler mangler( mangleOverridable );
    6566                maybeAccept( decl, mangler );
    6667                return mangler.get_mangleName();
Note: See TracChangeset for help on using the changeset viewer.