Changes in src/MakeLibCfa.cc [845cedc:2794fff]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/MakeLibCfa.cc
r845cedc r2794fff 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // MakeLibCfa.cc -- 7 // MakeLibCfa.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 10:33:33 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 22 13:54:15 201613 // Update Count : 4014 // 12 // Last Modified On : Fri Jul 03 18:11:37 2015 13 // Update Count : 18 14 // 15 15 16 16 #include "MakeLibCfa.h" … … 22 22 #include "SynTree/Initializer.h" 23 23 #include "CodeGen/OperatorTable.h" 24 #include " Common/UniqueName.h"24 #include "UniqueName.h" 25 25 26 26 namespace LibCfa { … … 29 29 void visit( FunctionDecl* funcDecl ); 30 30 void visit( ObjectDecl* objDecl ); 31 31 32 32 std::list< Declaration* > &get_newDecls() { return newDecls; } 33 33 private: … … 43 43 void MakeLibCfa::visit( FunctionDecl* origFuncDecl ) { 44 44 if ( origFuncDecl->get_linkage() != LinkageSpec::Intrinsic ) return; 45 if ( origFuncDecl->get_statements() ) return; 46 45 47 46 FunctionDecl *funcDecl = origFuncDecl->clone(); 48 47 CodeGen::OperatorInfo opInfo; … … 55 54 assert( param != funcDecl->get_functionType()->get_parameters().end() ); 56 55 57 for ( ; param != funcDecl->get_functionType()->get_parameters().end(); ++param ) { 58 if ( (*param)->get_name() == "" ) { 59 (*param)->set_name( paramNamer.newName() ); 60 (*param)->set_linkage( LinkageSpec::C ); 61 } 62 newExpr->get_args().push_back( new VariableExpr( *param ) ); 63 } // for 64 65 funcDecl->set_statements( new CompoundStmt( std::list< Label >() ) ); 66 newDecls.push_back( funcDecl ); 56 if ( (*param)->get_name() == "" ) { 57 (*param)->set_name( paramNamer.newName() ); 58 (*param)->set_linkage( LinkageSpec::C ); 59 } // if 67 60 68 61 switch ( opInfo.type ) { … … 72 65 case CodeGen::OT_POSTFIX: 73 66 case CodeGen::OT_INFIX: 67 newExpr->get_args().push_back( new VariableExpr( *param ) ); 68 break; 74 69 case CodeGen::OT_PREFIXASSIGN: 75 70 case CodeGen::OT_POSTFIXASSIGN: 76 71 case CodeGen::OT_INFIXASSIGN: 77 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 ); 78 77 break; 78 } 79 79 case CodeGen::OT_CTOR: 80 // ctors don't return a value81 if ( funcDecl->get_functionType()->get_parameters().size() == 1 ) {82 // intrinsic default constructors should do nothing83 // delete newExpr;84 break;85 } else {86 assert( funcDecl->get_functionType()->get_parameters().size() == 2 );87 // anything else is a single parameter constructor that is effectively a C-style assignment88 // delete newExpr->get_function();89 assert(newExpr->get_args().size()==2);90 newExpr->set_function( new NameExpr( "?=?" ) );91 funcDecl->get_statements()->get_kids().push_back( new ExprStmt( std::list< Label >(), newExpr ) );92 }93 break;94 80 case CodeGen::OT_DTOR: 95 // intrinsic destructors should do nothing96 // delete newExpr;97 break;98 81 case CodeGen::OT_CONSTANT: 99 82 case CodeGen::OT_LABELADDRESS: … … 101 84 assert( false ); 102 85 } // 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 ); 103 97 } 104 98 105 99 void MakeLibCfa::visit( ObjectDecl* origObjDecl ) { 106 100 if ( origObjDecl->get_linkage() != LinkageSpec::Intrinsic ) return; 107 101 108 102 ObjectDecl *objDecl = origObjDecl->clone(); 109 103 assert( ! objDecl->get_init() ); 110 104 std::list< Expression* > noDesignators; 111 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators , false ) ); // cannot be constructed105 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators ) ); 112 106 newDecls.push_back( objDecl ); 113 107 } 114 108 } // 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.