Changeset f1e012b for src/MakeLibCfa.cc


Ignore:
Timestamp:
Jan 19, 2016, 1:28:25 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, 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:
ca1c11f
Parents:
71f4e4f
Message:

added intrinsic ctor/dtors to prelude, modified MakeLibCfa? to build prelude ctor/dtors, added ctor/dtor to polymorphic object type constraints, rudimentary fallback on initializer nodes if chosen ctor is intrinsic, remove intrinsic destructor statements to reduce output pollution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/MakeLibCfa.cc

    r71f4e4f rf1e012b  
    1010// Created On       : Sat May 16 10:33:33 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jan 07 13:34:39 2016
    13 // Update Count     : 20
     12// Last Modified On : Tue Jan 19 13:20:26 2016
     13// Update Count     : 40
    1414//
    1515
     
    5454                assert( param != funcDecl->get_functionType()->get_parameters().end() );
    5555
    56                 if ( (*param)->get_name() == "" ) {
    57                         (*param)->set_name( paramNamer.newName() );
    58                         (*param)->set_linkage( LinkageSpec::C );
    59                 } // if
     56                for ( ; param != funcDecl->get_functionType()->get_parameters().end(); ++param ) {
     57                        if ( (*param)->get_name() == "" ) {
     58                                (*param)->set_name( paramNamer.newName() );
     59                                (*param)->set_linkage( LinkageSpec::C );
     60                        }
     61                        newExpr->get_args().push_back( new VariableExpr( *param ) );
     62                } // for
     63
     64                funcDecl->set_statements( new CompoundStmt( std::list< Label >() ) );
     65                newDecls.push_back( funcDecl );
    6066
    6167                switch ( opInfo.type ) {
     
    6571                  case CodeGen::OT_POSTFIX:
    6672                  case CodeGen::OT_INFIX:
    67                         newExpr->get_args().push_back( new VariableExpr( *param ) );
    68                         break;
    6973                  case CodeGen::OT_PREFIXASSIGN:
    7074                  case CodeGen::OT_POSTFIXASSIGN:
    7175                  case CodeGen::OT_INFIXASSIGN:
    72                         {
    73                                 newExpr->get_args().push_back( new VariableExpr( *param ) );
    74                                 // UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    75                                 // deref->get_args().push_back( new VariableExpr( *param ) );
    76                                 // newExpr->get_args().push_back( deref );
     76                                funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
    7777                                break;
    78                         }
    7978                  case CodeGen::OT_CTOR:
     79                        // ctors don't return a value
     80                        if ( funcDecl->get_functionType()->get_parameters().size() == 1 ) {
     81                                // intrinsic default constructors should do nothing
     82                                // delete newExpr;
     83                                break;
     84                        } else {
     85                                assert( funcDecl->get_functionType()->get_parameters().size() == 2 );
     86                                // anything else is a single parameter constructor that is effectively a C-style assignment
     87                                // delete newExpr->get_function();
     88                                assert(newExpr->get_args().size()==2);
     89                                newExpr->set_function( new NameExpr( "?=?" ) );
     90                                funcDecl->get_statements()->get_kids().push_back( new ExprStmt( std::list< Label >(), newExpr ) );
     91                        }
     92                        break;
    8093                  case CodeGen::OT_DTOR:
     94                        // intrinsic destructors should do nothing
     95                        // delete newExpr;
     96                        break;
    8197                  case CodeGen::OT_CONSTANT:
    8298                  case CodeGen::OT_LABELADDRESS:
     
    84100                        assert( false );
    85101                } // switch
    86 
    87                 for ( param++; param != funcDecl->get_functionType()->get_parameters().end(); ++param ) {
    88                         if ( (*param)->get_name() == "" ) {
    89                                 (*param)->set_name( paramNamer.newName() );
    90                                 (*param)->set_linkage( LinkageSpec::C );
    91                         }
    92                         newExpr->get_args().push_back( new VariableExpr( *param ) );
    93                 } // for
    94                 funcDecl->set_statements( new CompoundStmt( std::list< Label >() ) );
    95                 funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
    96                 newDecls.push_back( funcDecl );
    97102        }
    98103
     
    107112        }
    108113} // namespace LibCfa
    109 
    110 // Local Variables: //
    111 // tab-width: 4 //
    112 // mode: c++ //
    113 // compile-command: "make install" //
    114 // End: //
Note: See TracChangeset for help on using the changeset viewer.