Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/MakeLibCfa.cc

    rf1e012b rd3b7937  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // MakeLibCfa.cc --
     7// MakeLibCfa.cc -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 10:33:33 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Jan 19 13:20:26 2016
    13 // Update Count     : 40
    14 //
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jun 26 16:52:59 2015
     13// Update Count     : 14
     14// 
    1515
    1616#include "MakeLibCfa.h"
     
    2222#include "SynTree/Initializer.h"
    2323#include "CodeGen/OperatorTable.h"
    24 #include "UniqueName.h"
     24#include "Common/UniqueName.h"
    2525
    2626namespace LibCfa {
     
    2929                void visit( FunctionDecl* funcDecl );
    3030                void visit( ObjectDecl* objDecl );
    31 
     31 
    3232                std::list< Declaration* > &get_newDecls() { return newDecls; }
    3333          private:
     
    4343        void MakeLibCfa::visit( FunctionDecl* origFuncDecl ) {
    4444                if ( origFuncDecl->get_linkage() != LinkageSpec::Intrinsic ) return;
    45 
     45 
    4646                FunctionDecl *funcDecl = origFuncDecl->clone();
    4747                CodeGen::OperatorInfo opInfo;
     
    5454                assert( param != funcDecl->get_functionType()->get_parameters().end() );
    5555
    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 );
     56                if ( (*param)->get_name() == "" ) {
     57                        (*param)->set_name( paramNamer.newName() );
     58                        (*param)->set_linkage( LinkageSpec::C );
     59                } // if
    6660
    6761                switch ( opInfo.type ) {
     
    7165                  case CodeGen::OT_POSTFIX:
    7266                  case CodeGen::OT_INFIX:
     67                        newExpr->get_args().push_back( new VariableExpr( *param ) );
     68                        break;
    7369                  case CodeGen::OT_PREFIXASSIGN:
    7470                  case CodeGen::OT_POSTFIXASSIGN:
    7571                  case CodeGen::OT_INFIXASSIGN:
    76                                 funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
     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 );
    7777                                break;
    78                   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;
    93                   case CodeGen::OT_DTOR:
    94                         // intrinsic destructors should do nothing
    95                         // delete newExpr;
    96                         break;
     78                        }
    9779                  case CodeGen::OT_CONSTANT:
    9880                  case CodeGen::OT_LABELADDRESS:
     
    10082                        assert( false );
    10183                } // switch
     84
     85                for ( param++; param != funcDecl->get_functionType()->get_parameters().end(); ++param ) {
     86                        if ( (*param)->get_name() == "" ) {
     87                                (*param)->set_name( paramNamer.newName() );
     88                                (*param)->set_linkage( LinkageSpec::C );
     89                        }
     90                        newExpr->get_args().push_back( new VariableExpr( *param ) );
     91                } // for
     92                funcDecl->set_statements( new CompoundStmt( std::list< Label >() ) );
     93                funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( std::list< Label >(), newExpr ) );
     94                newDecls.push_back( funcDecl );
    10295        }
    10396
    10497        void MakeLibCfa::visit( ObjectDecl* origObjDecl ) {
    10598                if ( origObjDecl->get_linkage() != LinkageSpec::Intrinsic ) return;
    106 
     99 
    107100                ObjectDecl *objDecl = origObjDecl->clone();
    108101                assert( ! objDecl->get_init() );
    109102                std::list< Expression* > noDesignators;
    110                 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators, false ) ); // cannot be constructed
     103                objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators ) );
    111104                newDecls.push_back( objDecl );
    112105        }
    113106} // namespace LibCfa
     107
     108// Local Variables: //
     109// tab-width: 4 //
     110// mode: c++ //
     111// compile-command: "make install" //
     112// End: //
Note: See TracChangeset for help on using the changeset viewer.