Changeset 356189a


Ignore:
Timestamp:
Apr 14, 2016, 5:11:26 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
b617e4b
Parents:
70a06f6
git-author:
Rob Schluntz <rschlunt@…> (04/14/16 17:10:08)
git-committer:
Rob Schluntz <rschlunt@…> (04/14/16 17:11:26)
Message:

output intrinsic constructor expressions as void expression or C assignment, don't generate field constructor which takes unnamed bitfield as a parameter

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r70a06f6 r356189a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 15:40:00 2016
     12// Last Modified On : Thu Apr 14 17:10:21 2016
    1313// Update Count     : 255
    1414//
     
    238238                                  case OT_POSTFIXASSIGN:
    239239                                  case OT_INFIXASSIGN:
     240                                  case OT_CTOR:
    240241                                        {
    241242                                                assert( arg != applicationExpr->get_args().end() );
    242243                                                if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
    243 
     244                                                        // remove & from first assignment/ctor argument
    244245                                                        *arg = addrExpr->get_arg();
    245246                                                } else {
     247                                                        // no address-of operator, so must be a pointer - add dereference
    246248                                                        UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    247249                                                        newExpr->get_args().push_back( *arg );
     
    266268
    267269                                  case OT_CALL:
    268                                         // there are no intrinsic definitions of the function call operator or constructors or destructors
     270                                        // there are no intrinsic definitions of the function call operator
    269271                                        assert( false );
    270272                                        break;
    271273
    272274                                  case OT_CTOR:
    273                                   // it's just an optimization to disallow this, so for now let it through
    274                                   // since it makes autogenerating constructors a lot easier
    275                                 varExpr->accept( *this );
    276                                         output << "(";
    277                                         genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
    278                                         output << ")";
    279 
    280                                   // intrinsic constructors should never be called directly - they should be transformed back into Initializer nodes
    281                                   // assert(false);
    282                                   break;
     275                                        if ( applicationExpr->get_args().size() == 1 ) {
     276                                                // the expression fed into a single parameter constructor may contain
     277                                                // side effects - output as a void expression
     278                                                output << "((void)(";
     279                                                (*arg++)->accept( *this );
     280                                                output << ")) /* ?{} */";
     281                                        } else if ( applicationExpr->get_args().size() == 2 ) {
     282                                                // intrinsic constructors are essentially bitwise assignment
     283                                                output << "(";
     284                                                (*arg++)->accept( *this );
     285                                                output << opInfo.symbol;
     286                                                (*arg)->accept( *this );
     287                                                output << ") /* ?{} */";
     288                                        } else {
     289                                                // not constructors with 0 or more than 2 parameters
     290                                                assert( false );
     291                                        }
     292                                        break;
    283293
    284294                                  case OT_DTOR:
  • src/CodeGen/OperatorTable.cc

    r70a06f6 r356189a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Oct 06 15:26:34 2015
     12// Last Modified On : Thu Apr 14 16:48:27 2016
    1313// Update Count     : 9
    1414//
     
    2121                const OperatorInfo tableValues[] = {
    2222                        {       "?[?]",         "",             "_operator_index",                              OT_INDEX                        },
    23                         {       "?{}",          "",             "_constructor",                                 OT_CTOR                         },
     23                        {       "?{}",          "=",            "_constructor",                                 OT_CTOR                         },
    2424                        {       "^?{}",         "",             "_destructor",                                  OT_DTOR                         },
    2525                        {       "?()",          "",             "_operator_call",                               OT_CALL                         },
  • src/SymTab/Autogen.cc

    r70a06f6 r356189a  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 16:00:16 2016
     12// Last Modified On : Thu Apr 14 16:58:35 2016
    1313// Update Count     : 1
    1414//
     
    5959        }
    6060
     61        bool isUnnamedBitfield( ObjectDecl * obj ) {
     62                return obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL;
     63        }
     64
    6165        template< typename OutputIterator >
    6266        void makeScalarFunction( Expression *src, ObjectDecl *dstParam, DeclarationWithType *member, std::string fname, OutputIterator out ) {
    6367                ObjectDecl *obj = dynamic_cast<ObjectDecl *>( member );
    6468                // unnamed bit fields are not copied as they cannot be accessed
    65                 if ( obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL ) return;
     69                if ( isUnnamedBitfield( obj ) ) return;
    6670
    6771                // want to be able to generate assignment, ctor, and dtor generically,
     
    321325                        DeclarationWithType * member = dynamic_cast<DeclarationWithType *>( *i );
    322326                        assert( member );
     327                        if ( isUnnamedBitfield( dynamic_cast< ObjectDecl * > ( member ) ) ) {
     328                                // don't make a function whose parameter is an unnamed bitfield
     329                                continue;
     330                        }
    323331                        memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );
    324332                        FunctionDecl * ctor = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, memCtorType->clone(), new CompoundStmt( noLabels ), true, false );
  • src/libcfa/fstream.c

    r70a06f6 r356189a  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fstream.c -- 
     7// fstream.c --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr  6 17:55:27 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 17:04:24 2016
    1313// Update Count     : 176
    1414//
     
    7575        if ( fclose( (FILE *)(os->file) ) == EOF ) {
    7676                perror( IO_MSG "close output" );
    77         } // if 
     77        } // if
    7878} // close
    7979
     
    139139        if ( fclose( (FILE *)(is->file) ) == EOF ) {
    140140                perror( IO_MSG "close input" );
    141         } // if 
     141        } // if
    142142} // close
    143143
     
    154154        return is;
    155155} // read
    156  
     156
    157157ifstream *ungetc( ifstream * is, char c ) {
    158158        if ( fail( is ) ) {
Note: See TracChangeset for help on using the changeset viewer.