Changes in / [803deb1:771b3c3]
- Location:
- src
- Files:
-
- 2 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r803deb1 r771b3c3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 20 12:5 4:50201613 // Update Count : 2 4112 // Last Modified On : Wed Jan 20 12:59:17 2016 13 // Update Count : 254 14 14 // 15 15 … … 258 258 259 259 case OT_CALL: 260 // there are no intrinsic definitions of the function call operator 260 // there are no intrinsic definitions of the function call operator or constructors or destructors 261 261 assert( false ); 262 262 break; 263 264 case OT_CTOR: 265 // intrinsic constructors should never be called directly - they should be transformed back into Initializer nodes 266 assert(false); 267 break; 268 269 case OT_DTOR: 270 // intrinsic destructors do nothing - don't generate any code 271 output << " // " << dynamic_cast<VariableExpr*>(applicationExpr->get_function())->get_var()->get_name() << endl; 272 break; 263 273 264 274 case OT_PREFIX: … … 277 287 output << opInfo.symbol; 278 288 break; 289 279 290 280 291 case OT_INFIX: … … 323 334 case OT_CALL: 324 335 assert( false ); 336 337 case OT_CTOR: 338 case OT_DTOR: 339 // intrinsic constructors should never be called 340 // intrinsic destructors do nothing 325 341 break; 326 342 -
src/CodeGen/OperatorTable.cc
r803deb1 r771b3c3 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Jun 23 17:41:14 201513 // Update Count : 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Oct 06 15:26:34 2015 13 // Update Count : 9 14 14 // 15 15 … … 21 21 const OperatorInfo tableValues[] = { 22 22 { "?[?]", "", "_operator_index", OT_INDEX }, 23 { "?{}", "", "_constructor", OT_CTOR }, 24 { "^?{}", "", "_destructor", OT_DTOR }, // ~?{}, -?{}, !?{}, $?{}, ??{}, ^?{}, ?destroy, ?delete 23 25 { "?()", "", "_operator_call", OT_CALL }, 24 26 { "?++", "++", "_operator_postincr", OT_POSTFIXASSIGN }, -
src/CodeGen/OperatorTable.h
r803deb1 r771b3c3 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Jun 23 16:09:27 201513 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jun 24 16:17:57 2015 13 // Update Count : 5 14 14 // 15 15 … … 22 22 enum OperatorType { 23 23 OT_INDEX, 24 OT_CTOR, 25 OT_DTOR, 24 26 OT_CALL, 25 27 OT_PREFIX, -
src/GenPoly/Box.cc
r803deb1 r771b3c3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 18 14:53:08 201513 // Update Count : 21 712 // Last Modified On : Thu Jan 07 13:40:05 2016 13 // Update Count : 219 14 14 // 15 15 … … 1139 1139 1140 1140 std::list<Expression*> designators; 1141 objectDecl->set_init( new SingleInit( alloc, designators ) );1141 objectDecl->set_init( new SingleInit( alloc, designators, false ) ); // not constructed 1142 1142 } 1143 1143 } -
src/GenPoly/Specialize.cc
r803deb1 r771b3c3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 20 1 2:40:33201613 // Update Count : 1812 // Last Modified On : Wed Jan 20 13:00:00 2016 13 // Update Count : 24 14 14 // 15 15 … … 142 142 143 143 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 144 assert( ! actual->get_results().empty() ); 144 assert( ! actual->get_results().empty() ); // using front, should have this assert 145 145 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) { 146 146 FunctionType *funType; -
src/InitTweak/InitModel.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InitModel.cc -- 7 // InitModel.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue May 19 16:37:08 201513 // Update Count : 111 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 07 13:38:46 2016 13 // Update Count : 5 14 14 // 15 15 … … 198 198 assert(init == 0 && single != 0); 199 199 std::list< Expression * > empty; 200 init = new SingleInit( single->get_expr(), empty );200 init = new SingleInit( single->get_expr(), empty, false ); // cannot be constructed 201 201 return; 202 202 } … … 214 214 } // if 215 215 216 init = new ListInit( contents ); 216 std::list< Expression * > desig; 217 init = new ListInit( contents, desig, false ); // cannot be constructed 217 218 return; 218 219 } -
src/InitTweak/RemoveInit.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // RemoveInit.cc -- 7 // RemoveInit.cc -- 8 8 // 9 9 // Author : Rob Schluntz 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 15 15:37:26 2015 13 // Update Count : 15 14 // 15 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jan 19 11:12:49 2016 13 // Update Count : 165 14 // 15 16 #include <stack> 17 #include <list> 16 18 #include "RemoveInit.h" 17 19 #include "SynTree/Declaration.h" … … 21 23 #include "SynTree/Initializer.h" 22 24 #include "SynTree/Mutator.h" 25 #include "GenPoly/PolyMutator.h" 23 26 24 27 namespace InitTweak { … … 26 29 const std::list<Label> noLabels; 27 30 } 28 29 class RemoveInit : public Mutator {31 32 class RemoveInit : public GenPoly::PolyMutator { 30 33 public: 34 /// removes and replaces initialization for polymorphic value objects 35 /// with assignment (TODO: constructor) statements. 36 /// also consistently allocates a temporary variable for the return value 37 /// of a function so that anything which the resolver decides can be assigned 38 /// into the return type of a function can be returned. 39 static void removeInitializers( std::list< Declaration * > &translationUnit ); 40 31 41 RemoveInit(); 32 virtual ObjectDecl * mutate( ObjectDecl *objDecl);42 virtual ObjectDecl * mutate( ObjectDecl *objDecl ); 33 43 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 34 44 35 45 virtual Statement * mutate( ReturnStmt * returnStmt ); 36 37 virtual CompoundStmt * mutate(CompoundStmt * compoundStmt); 38 46 39 47 protected: 40 std::list< Statement* > stmtsToAddBefore;41 std::list< Statement* > stmtsToAddAfter;42 void mutateStatementList( std::list< Statement* > &statements );43 44 48 std::list<DeclarationWithType*> returnVals; 45 49 UniqueName tempNamer; … … 47 51 }; 48 52 49 void tweak( std::list< Declaration * > translationUnit ) { 53 class CtorDtor : public GenPoly::PolyMutator { 54 public: 55 /// create constructor and destructor statements for object declarations. 56 /// Destructors are inserted directly into the code, whereas constructors 57 /// will be added in after the resolver has run so that the initializer expression 58 /// is only removed if a constructor is found 59 static void generateCtorDtor( std::list< Declaration * > &translationUnit ); 60 61 CtorDtor() : inFunction( false ) {} 62 63 virtual ObjectDecl * mutate( ObjectDecl * ); 64 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 65 virtual Declaration* mutate( StructDecl *aggregateDecl ); 66 virtual Declaration* mutate( UnionDecl *aggregateDecl ); 67 virtual Declaration* mutate( EnumDecl *aggregateDecl ); 68 virtual Declaration* mutate( ContextDecl *aggregateDecl ); 69 virtual TypeDecl* mutate( TypeDecl *typeDecl ); 70 virtual Declaration* mutate( TypedefDecl *typeDecl ); 71 72 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ); 73 74 protected: 75 bool inFunction; 76 77 // to be added before block ends - use push_front so order is correct 78 std::list< Statement * > destructorStmts; 79 }; 80 81 void tweak( std::list< Declaration * > & translationUnit ) { 82 RemoveInit::removeInitializers( translationUnit ); 83 CtorDtor::generateCtorDtor( translationUnit ); 84 } 85 86 void RemoveInit::removeInitializers( std::list< Declaration * > & translationUnit ) { 50 87 RemoveInit remover; 51 88 mutateAll( translationUnit, remover ); … … 53 90 54 91 RemoveInit::RemoveInit() : tempNamer( "_retVal" ) {} 55 56 void RemoveInit::mutateStatementList( std::list< Statement* > &statements ) {57 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {58 if ( ! stmtsToAddAfter.empty() ) {59 statements.splice( i, stmtsToAddAfter );60 } // if61 *i = (*i)->acceptMutator( *this );62 if ( ! stmtsToAddBefore.empty() ) {63 statements.splice( i, stmtsToAddBefore );64 } // if65 } // for66 if ( ! stmtsToAddAfter.empty() ) {67 statements.splice( statements.end(), stmtsToAddAfter );68 } // if69 }70 71 CompoundStmt *RemoveInit::mutate(CompoundStmt *compoundStmt) {72 mutateStatementList( compoundStmt->get_kids() );73 return compoundStmt;74 }75 92 76 93 // in the case where an object has an initializer and a polymorphic type, insert an assignment immediately after the … … 79 96 if (objDecl->get_init() && dynamic_cast<TypeInstType*>(objDecl->get_type())) { 80 97 if (SingleInit * single = dynamic_cast<SingleInit*>(objDecl->get_init())) { 81 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) ); 98 // xxx this can be more complicated - consider ListInit 99 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?{}" ) ); 82 100 assign->get_args().push_back( new AddressExpr (new NameExpr( objDecl->get_name() ) ) ); 83 101 assign->get_args().push_back( single->get_value()->clone() ); … … 93 111 // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address 94 112 // is being returned 113 // xxx - this should construct rather than assign 95 114 if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_isLvalue() ) { 96 115 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, returnVals.front()->get_type()->clone(), 0 ); 97 stmtsToAdd Before.push_back( new DeclStmt( noLabels, newObj ) );98 116 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 117 99 118 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) ); 100 119 assign->get_args().push_back( new AddressExpr (new NameExpr( newObj->get_name() ) ) ); 101 120 assign->get_args().push_back( returnStmt->get_expr() ); 102 stmtsToAdd Before.push_back(new ExprStmt(noLabels, assign));121 stmtsToAdd.push_back(new ExprStmt(noLabels, assign)); 103 122 104 123 returnStmt->set_expr( new VariableExpr( newObj ) ); … … 110 129 std::list<DeclarationWithType*> oldReturnVals = returnVals; 111 130 std::string oldFuncName = funcName; 112 131 113 132 FunctionType * type = functionDecl->get_functionType(); 114 133 returnVals = type->get_returnVals(); … … 119 138 return decl; 120 139 } 140 141 142 void CtorDtor::generateCtorDtor( std::list< Declaration * > & translationUnit ) { 143 CtorDtor ctordtor; 144 mutateAll( translationUnit, ctordtor ); 145 } 146 147 namespace { 148 bool tryConstruct( ObjectDecl * objDecl ) { 149 // xxx - handle designations 150 return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) && 151 (objDecl->get_init() == NULL || 152 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )); 153 } 154 155 Expression * makeCtorDtorExpr( std::string name, ObjectDecl * objDecl, std::list< Expression * > args ) { 156 UntypedExpr * expr = new UntypedExpr( new NameExpr( name ) ); 157 expr->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) ); 158 expr->get_args().splice( expr->get_args().end(), args ); 159 return expr; 160 } 161 162 class InitExpander : public Visitor { 163 public: 164 InitExpander() {} 165 // ~InitExpander() {} 166 virtual void visit( SingleInit * singleInit ); 167 virtual void visit( ListInit * listInit ); 168 std::list< Expression * > argList; 169 }; 170 171 void InitExpander::visit( SingleInit * singleInit ) { 172 argList.push_back( singleInit->get_value()->clone() ); 173 } 174 175 void InitExpander::visit( ListInit * listInit ) { 176 // xxx - for now, assume no nested list inits 177 std::list<Initializer*>::iterator it = listInit->begin_initializers(); 178 for ( ; it != listInit->end_initializers(); ++it ) { 179 (*it)->accept( *this ); 180 } 181 } 182 183 std::list< Expression * > makeInitList( Initializer * init ) { 184 InitExpander expander; 185 maybeAccept( init, expander ); 186 return expander.argList; 187 } 188 } 189 190 ObjectDecl * CtorDtor::mutate( ObjectDecl * objDecl ) { 191 // hands off if designated or if @= 192 if ( tryConstruct( objDecl ) ) { 193 if ( inFunction ) { 194 Expression * ctor = makeCtorDtorExpr( "?{}", objDecl, makeInitList( objDecl->get_init() ) ); 195 Expression * dtor = makeCtorDtorExpr( "^?{}", objDecl, std::list< Expression * >() ); 196 197 // need to remember init expression, in case no ctors exist 198 // if ctor does exist, want to use ctor expression instead of init 199 // push this decision to the resolver 200 objDecl->set_init( new ConstructorInit( ctor, objDecl->get_init() ) ); 201 destructorStmts.push_front( new ExprStmt( noLabels, dtor ) ); 202 } else { 203 // xxx - find a way to construct/destruct globals 204 // hack: implicit "static" initialization routine for each struct type? or something similar? 205 // --ties into module system 206 } 207 } 208 return objDecl; 209 } 210 211 DeclarationWithType * CtorDtor::mutate( FunctionDecl *functionDecl ) { 212 // parameters should not be constructed and destructed, so don't mutate FunctionType 213 bool oldInFunc = inFunction; 214 mutateAll( functionDecl->get_oldDecls(), *this ); 215 inFunction = true; 216 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) ); 217 inFunction = oldInFunc; 218 return functionDecl; 219 } 220 221 CompoundStmt * CtorDtor::mutate( CompoundStmt * compoundStmt ) { 222 CompoundStmt * ret = PolyMutator::mutate( compoundStmt ); 223 std::list< Statement * > &statements = ret->get_kids(); 224 if ( ! destructorStmts.empty() ) { 225 statements.splice( statements.end(), destructorStmts ); 226 } // if 227 return ret; 228 } 229 230 // should not traverse into any of these declarations to find objects 231 // that need to be constructed or destructed 232 Declaration* CtorDtor::mutate( StructDecl *aggregateDecl ) { return aggregateDecl; } 233 Declaration* CtorDtor::mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; } 234 Declaration* CtorDtor::mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; } 235 Declaration* CtorDtor::mutate( ContextDecl *aggregateDecl ) { return aggregateDecl; } 236 TypeDecl* CtorDtor::mutate( TypeDecl *typeDecl ) { return typeDecl; } 237 Declaration* CtorDtor::mutate( TypedefDecl *typeDecl ) { return typeDecl; } 238 121 239 } // namespace InitTweak 122 240 -
src/InitTweak/RemoveInit.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // RemoveInit.h -- 7 // RemoveInit.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Nov 27 17:00:47 201513 // Update Count : 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Jan 11 16:02:44 2016 13 // Update Count : 3 14 14 // 15 15 … … 26 26 namespace InitTweak { 27 27 /// Adds assignment statements for polymorphic type initializers 28 void tweak( std::list< Declaration * > translationUnit );29 } // namespace 28 void tweak( std::list< Declaration * > & translationUnit ); 29 } // namespace 30 30 31 31 #endif // GENPOLY_POLYMUTATOR_H -
src/InitTweak/module.mk
r803deb1 r771b3c3 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Rob Schluntz 13 ## Last Modified On : Mon Jan 11 14:40:16201614 ## Update Count : 213 ## Last Modified On : Wed Jan 13 16:29:03 2016 14 ## Update Count : 3 15 15 ############################################################################### 16 16 17 SRC += InitTweak/RemoveInit.cc 18 17 SRC += InitTweak/RemoveInit.cc \ 18 InitTweak/FixInit.cc -
src/MakeLibCfa.cc
r803deb1 r771b3c3 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 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jun 26 16:52:59 201513 // Update Count : 1414 // 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jan 19 13:20:26 2016 13 // Update Count : 40 14 // 15 15 16 16 #include "MakeLibCfa.h" … … 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 45 46 46 FunctionDecl *funcDecl = origFuncDecl->clone(); 47 47 CodeGen::OperatorInfo opInfo; … … 54 54 assert( param != funcDecl->get_functionType()->get_parameters().end() ); 55 55 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 ); 60 66 61 67 switch ( opInfo.type ) { … … 65 71 case CodeGen::OT_POSTFIX: 66 72 case CodeGen::OT_INFIX: 67 newExpr->get_args().push_back( new VariableExpr( *param ) );68 break;69 73 case CodeGen::OT_PREFIXASSIGN: 70 74 case CodeGen::OT_POSTFIXASSIGN: 71 75 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 ) ); 77 77 break; 78 } 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; 79 97 case CodeGen::OT_CONSTANT: 80 98 case CodeGen::OT_LABELADDRESS: … … 82 100 assert( false ); 83 101 } // 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 } // for92 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 );95 102 } 96 103 97 104 void MakeLibCfa::visit( ObjectDecl* origObjDecl ) { 98 105 if ( origObjDecl->get_linkage() != LinkageSpec::Intrinsic ) return; 99 106 100 107 ObjectDecl *objDecl = origObjDecl->clone(); 101 108 assert( ! objDecl->get_init() ); 102 109 std::list< Expression* > noDesignators; 103 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators ) );110 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators, false ) ); // cannot be constructed 104 111 newDecls.push_back( objDecl ); 105 112 } 106 113 } // namespace LibCfa 107 108 // Local Variables: //109 // tab-width: 4 //110 // mode: c++ //111 // compile-command: "make install" //112 // End: // -
src/Makefile.in
r803deb1 r771b3c3 124 124 GenPoly/cfa_cpp-DeclMutator.$(OBJEXT) \ 125 125 InitTweak/cfa_cpp-RemoveInit.$(OBJEXT) \ 126 InitTweak/cfa_cpp-FixInit.$(OBJEXT) \ 126 127 Parser/cfa_cpp-parser.$(OBJEXT) Parser/cfa_cpp-lex.$(OBJEXT) \ 127 128 Parser/cfa_cpp-TypedefTable.$(OBJEXT) \ … … 346 347 GenPoly/CopyParams.cc GenPoly/FindFunction.cc \ 347 348 GenPoly/InstantiateGeneric.cc GenPoly/DeclMutator.cc \ 348 InitTweak/RemoveInit.cc Parser/parser.yy Parser/lex.ll\349 Parser/ TypedefTable.cc Parser/ParseNode.cc \349 InitTweak/RemoveInit.cc InitTweak/FixInit.cc Parser/parser.yy \ 350 Parser/lex.ll Parser/TypedefTable.cc Parser/ParseNode.cc \ 350 351 Parser/DeclarationNode.cc Parser/ExpressionNode.cc \ 351 352 Parser/StatementNode.cc Parser/InitializerNode.cc \ … … 562 563 @: > InitTweak/$(DEPDIR)/$(am__dirstamp) 563 564 InitTweak/cfa_cpp-RemoveInit.$(OBJEXT): InitTweak/$(am__dirstamp) \ 565 InitTweak/$(DEPDIR)/$(am__dirstamp) 566 InitTweak/cfa_cpp-FixInit.$(OBJEXT): InitTweak/$(am__dirstamp) \ 564 567 InitTweak/$(DEPDIR)/$(am__dirstamp) 565 568 Parser/parser.h: Parser/parser.cc … … 783 786 -rm -f GenPoly/cfa_cpp-ScrubTyVars.$(OBJEXT) 784 787 -rm -f GenPoly/cfa_cpp-Specialize.$(OBJEXT) 788 -rm -f InitTweak/cfa_cpp-FixInit.$(OBJEXT) 785 789 -rm -f InitTweak/cfa_cpp-RemoveInit.$(OBJEXT) 786 790 -rm -f Parser/cfa_cpp-DeclarationNode.$(OBJEXT) … … 890 894 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-ScrubTyVars.Po@am__quote@ 891 895 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/cfa_cpp-Specialize.Po@am__quote@ 896 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Po@am__quote@ 892 897 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/cfa_cpp-RemoveInit.Po@am__quote@ 893 898 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/cfa_cpp-DeclarationNode.Po@am__quote@ … … 1388 1393 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi` 1389 1394 1395 InitTweak/cfa_cpp-FixInit.o: InitTweak/FixInit.cc 1396 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/cfa_cpp-FixInit.o -MD -MP -MF InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Tpo -c -o InitTweak/cfa_cpp-FixInit.o `test -f 'InitTweak/FixInit.cc' || echo '$(srcdir)/'`InitTweak/FixInit.cc 1397 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Tpo InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Po 1398 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixInit.cc' object='InitTweak/cfa_cpp-FixInit.o' libtool=no @AMDEPBACKSLASH@ 1399 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1400 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/cfa_cpp-FixInit.o `test -f 'InitTweak/FixInit.cc' || echo '$(srcdir)/'`InitTweak/FixInit.cc 1401 1402 InitTweak/cfa_cpp-FixInit.obj: InitTweak/FixInit.cc 1403 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/cfa_cpp-FixInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Tpo -c -o InitTweak/cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi` 1404 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Tpo InitTweak/$(DEPDIR)/cfa_cpp-FixInit.Po 1405 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixInit.cc' object='InitTweak/cfa_cpp-FixInit.obj' libtool=no @AMDEPBACKSLASH@ 1406 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1407 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi` 1408 1390 1409 Parser/cfa_cpp-parser.o: Parser/parser.cc 1391 1410 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/cfa_cpp-parser.Tpo -c -o Parser/cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc -
src/Parser/DeclarationNode.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // DeclarationNode.cc -- 7 // DeclarationNode.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 12:34:05 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Jul 14 14:46:32 201513 // Update Count : 1 2611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 07 13:18:02 2016 13 // Update Count : 130 14 14 // 15 15 … … 96 96 os << endl << string( indent + 2, ' ' ) << "with initializer "; 97 97 initializer->printOneLine( os ); 98 os << " maybe constructed? " << initializer->get_maybeConstructed(); 99 98 100 } // if 99 101 … … 357 359 } // if 358 360 } 359 361 360 362 DeclarationNode *DeclarationNode::addQualifiers( DeclarationNode *q ) { 361 363 if ( q ) { … … 508 510 assert( false ); 509 511 } // switch 510 512 511 513 return this; 512 514 } … … 619 621 assert( a->type->kind == TypeData::Array ); 620 622 TypeData *lastArray = findLast( a->type ); 621 if ( type ) { 623 if ( type ) { 622 624 switch ( type->kind ) { 623 625 case TypeData::Aggregate: … … 663 665 } // if 664 666 } 665 667 666 668 DeclarationNode *DeclarationNode::addIdList( DeclarationNode *ids ) { 667 669 type = addIdListToType( type, ids ); … … 868 870 Type *DeclarationNode::buildType() const { 869 871 assert( type ); 870 872 871 873 switch ( type->kind ) { 872 874 case TypeData::Enum: -
src/Parser/InitializerNode.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InitializerNode.cc -- 8 // 7 // InitializerNode.cc -- 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:20:24 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Oct 8 17:18:55 201513 // Update Count : 414 // 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 07 13:32:57 2016 13 // Update Count : 13 14 // 15 15 16 16 #include <cassert> … … 23 23 24 24 InitializerNode::InitializerNode( ExpressionNode *_expr, bool aggrp, ExpressionNode *des ) 25 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ) {25 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) { 26 26 if ( aggrp ) 27 27 kids = dynamic_cast< InitializerNode *>( get_link() ); … … 32 32 33 33 InitializerNode::InitializerNode( InitializerNode *init, bool aggrp, ExpressionNode *des ) 34 : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ) {34 : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) { 35 35 if ( init != 0 ) 36 36 set_link(init); … … 91 91 } // if 92 92 93 return new ListInit( initlist, designlist );93 return new ListInit( initlist, designlist, maybeConstructed ); 94 94 } else { 95 95 std::list< Expression *> designators; … … 99 99 100 100 if ( get_expression() != 0) 101 return new SingleInit( get_expression()->build(), designators );101 return new SingleInit( get_expression()->build(), designators, maybeConstructed ); 102 102 } // if 103 103 -
src/Parser/ParseNode.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ParseNode.h -- 7 // ParseNode.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 12 13:27:11 201513 // Update Count : 17 212 // Last Modified On : Thu Jan 07 13:17:46 2016 13 // Update Count : 177 14 14 // 15 15 … … 175 175 public: 176 176 enum Type { TupleC, Comma, TupleFieldSel, 177 Cond, NCond, 178 SizeOf, AlignOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And, 179 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq, 180 Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, 177 Cond, NCond, 178 SizeOf, AlignOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And, 179 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq, 180 Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, 181 181 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, 183 184 }; 184 185 … … 306 307 ValofExprNode( const ValofExprNode &other ); 307 308 ~ValofExprNode(); 308 309 309 310 virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); } 310 311 … … 329 330 enum TypeClass { Type, Dtype, Ftype }; 330 331 331 static const char *storageName[]; 332 static const char *storageName[]; 332 333 static const char *qualifierName[]; 333 334 static const char *basicTypeName[]; … … 419 420 class StatementNode : public ParseNode { 420 421 public: 421 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru, 422 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru, 422 423 While, Do, For, 423 424 Goto, Continue, Break, Return, Throw, … … 517 518 ExpressionNode *get_designators() const { return designator; } 518 519 520 InitializerNode *set_maybeConstructed( bool value ) { maybeConstructed = value; return this; } 521 bool get_maybeConstructed() const { return maybeConstructed; } 522 519 523 InitializerNode *next_init() const { return kids; } 520 524 … … 528 532 ExpressionNode *designator; // may be list 529 533 InitializerNode *kids; 534 bool maybeConstructed; 530 535 }; 531 536 -
src/Parser/TypeData.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeData.cc -- 7 // TypeData.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Jul 14 14:57:23 201513 // Update Count : 3 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 14 10:43:42 2016 13 // Update Count : 36 14 14 // 15 15 … … 436 436 for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 437 437 if ( (*i)->get_kind() == TypeDecl::Any ) { 438 // add assertion parameters to `type' tyvars 439 // add: T * ?=?(T *, T) 438 440 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 439 441 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); … … 441 443 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) ); 442 444 (*i)->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, 0, false, false ) ); 445 446 // add: void ?{}(T *) 447 FunctionType *ctorType = new FunctionType( Type::Qualifiers(), false ); 448 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); 449 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) ); 450 451 // add: void ^?{}(T *) 452 FunctionType *dtorType = new FunctionType( Type::Qualifiers(), false ); 453 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); 454 (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) ); 443 455 } // if 444 456 } // for -
src/Parser/parser.cc
r803deb1 r771b3c3 7291 7291 /* Line 1806 of yacc.c */ 7292 7292 #line 1684 "parser.yy" 7293 { (yyval.in) = (yyvsp[(2) - (2)].in) ; }7293 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); } 7294 7294 break; 7295 7295 -
src/Parser/parser.yy
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // cfa.y -- 8 // 7 // cfa.y -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 … … 12 12 // Last Modified On : Thu Oct 8 17:17:54 2015 13 13 // Update Count : 1473 14 // 14 // 15 15 16 16 // This grammar is based on the ANSI99/11 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on the C … … 1682 1682 { $$ = $2; } 1683 1683 | ATassign initializer 1684 { $$ = $2 ; }1684 { $$ = $2->set_maybeConstructed( false ); } 1685 1685 ; 1686 1686 -
src/ResolvExpr/Resolver.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Resolver.cc -- 7 // Resolver.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:17:01 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 24 17:33:54 201513 // Update Count : 17811 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 14 16:45:32 2016 13 // Update Count : 203 14 14 // 15 15 … … 33 33 public: 34 34 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 35 35 36 36 virtual void visit( FunctionDecl *functionDecl ); 37 37 virtual void visit( ObjectDecl *functionDecl ); … … 54 54 virtual void visit( SingleInit *singleInit ); 55 55 virtual void visit( ListInit *listInit ); 56 virtual void visit( ConstructorInit *ctorInit ); 56 57 private: 57 58 typedef std::list< Initializer * >::iterator InitIterator; … … 59 60 void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & ); 60 61 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 62 void fallbackInit( ConstructorInit * ctorInit ); 61 63 62 64 std::list< Type * > functionReturn; … … 95 97 return newExpr; 96 98 } 97 99 98 100 Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 99 101 TypeEnvironment env; … … 126 128 } // if 127 129 } 128 130 129 131 Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 130 132 TypeEnvironment env; … … 159 161 return newExpr; 160 162 } 161 162 } 163 163 164 } 165 164 166 void Resolver::visit( ObjectDecl *objectDecl ) { 165 167 Type *new_type = resolveTypeof( objectDecl->get_type(), *this ); … … 251 253 forStmt->set_condition( newExpr ); 252 254 } // if 253 255 254 256 if ( forStmt->get_increment() ) { 255 257 Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this ); … … 265 267 delete switchStmt->get_condition(); 266 268 switchStmt->set_condition( newExpr ); 267 269 268 270 visitor.Visitor::visit( switchStmt ); 269 271 } … … 307 309 bool isCharType( T t ) { 308 310 if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) { 309 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 311 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 310 312 bt->get_kind() == BasicType::UnsignedChar; 311 313 } … … 319 321 string n = ne->get_name(); 320 322 if (n == "0") { 321 initContext = new BasicType(Type::Qualifiers(), 323 initContext = new BasicType(Type::Qualifiers(), 322 324 BasicType::SignedInt); 323 325 } else { … … 325 327 initContext = decl->get_type(); 326 328 } 327 } else if (ConstantExpr * e = 329 } else if (ConstantExpr * e = 328 330 dynamic_cast<ConstantExpr*>(singleInit->get_value())) { 329 331 Constant *c = e->get_constant(); … … 349 351 singleInit->set_value( ce->get_arg() ); 350 352 ce->set_arg( NULL ); 351 delete ce; 353 delete ce; 352 354 } 353 355 } … … 465 467 #endif 466 468 } 469 470 // ConstructorInit - fall back on C-style initializer 471 void Resolver::fallbackInit( ConstructorInit * ctorInit ) { 472 // could not find valid constructor, or found an intrinsic constructor 473 // fall back on C-style initializer 474 delete ctorInit->get_ctor(); 475 ctorInit->set_ctor( NULL ); 476 maybeAccept( ctorInit->get_init(), *this ); 477 } 478 479 void Resolver::visit( ConstructorInit *ctorInit ) { 480 TypeEnvironment env; 481 AlternativeFinder finder( *this, env ); 482 finder.find( ctorInit->get_ctor() ); 483 484 if ( finder.get_alternatives().size() == 0 ) { 485 fallbackInit( ctorInit ); 486 } else if ( finder.get_alternatives().size() == 1 ) { 487 Alternative &choice = finder.get_alternatives().front(); 488 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( choice.expr ) ) { 489 if ( VariableExpr * function = dynamic_cast< VariableExpr * > ( appExpr->get_function() ) ) { 490 if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) { 491 // if the constructor that was found is intrinsic, reset to C-style 492 // initializer so that code generation is easy to handle 493 fallbackInit( ctorInit ); 494 return; 495 } 496 } 497 } 498 // found a constructor - can get rid of C-style initializer 499 Expression *newExpr = choice.expr->clone(); 500 finishExpr( newExpr, choice.env ); 501 ctorInit->set_ctor( newExpr ); 502 delete ctorInit->get_init(); 503 ctorInit->set_init( NULL ); 504 } else { 505 // too many constructors found 506 assert(false); 507 } 508 } 467 509 } // namespace ResolvExpr 468 510 -
src/SymTab/Validate.cc
r803deb1 r771b3c3 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 18 15:34:05 201513 // Update Count : 2 1812 // Last Modified On : Thu Jan 07 11:27:49 2016 13 // Update Count : 269 14 14 // 15 15 … … 202 202 }; 203 203 204 class VerifyCtorDtor : public Visitor { 205 public: 206 /// ensure that constructors and destructors have at least one 207 /// parameter, the first of which must be a pointer, and no 208 /// return values. 209 static void verify( std::list< Declaration * > &translationUnit ); 210 211 // VerifyCtorDtor() {} 212 213 virtual void visit( FunctionDecl *funcDecl ); 214 private: 215 }; 216 204 217 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 205 218 Pass1 pass1; … … 213 226 AutogenerateRoutines::autogenerateRoutines( translationUnit ); 214 227 acceptAll( translationUnit, pass3 ); 228 VerifyCtorDtor::verify( translationUnit ); 215 229 } 216 230 … … 1029 1043 } 1030 1044 1045 void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) { 1046 VerifyCtorDtor verifier; 1047 acceptAll( translationUnit, verifier ); 1048 } 1049 1050 void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) { 1051 FunctionType * funcType = funcDecl->get_functionType(); 1052 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals(); 1053 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 1054 1055 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) { 1056 if ( params.size() == 0 ) { 1057 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl ); 1058 } 1059 if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) { 1060 throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl ); 1061 } 1062 if ( returnVals.size() != 0 ) { 1063 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 1064 } 1065 } 1066 1067 Visitor::visit( funcDecl ); 1068 // original idea: modify signature of ctor/dtors and insert appropriate return statements 1069 // to cause desired behaviour 1070 // new idea: add comma exprs to every ctor call to produce first parameter. 1071 // this requires some memoization of the first parameter, because it can be a 1072 // complicated expression with side effects (see: malloc). idea: add temporary variable 1073 // that is assigned address of constructed object in ctor argument position and 1074 // return the temporary. It should also be done after all implicit ctors are 1075 // added, so not in this pass! 1076 } 1031 1077 } // namespace SymTab 1032 1078 -
src/SynTree/Declaration.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Declaration.h -- 7 // Declaration.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:08:22 201513 // Update Count : 3 212 // Last Modified On : Wed Jan 13 16:11:49 2016 13 // Update Count : 36 14 14 // 15 15 -
src/SynTree/Initializer.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Initializer.cc -- 7 // Initializer.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 12 14:05:25 201513 // Update Count : 1412 // Last Modified On : Wed Jan 13 15:31:45 2016 13 // Update Count : 28 14 14 // 15 15 … … 18 18 #include "utility.h" 19 19 20 Initializer::Initializer( ) {}20 Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {} 21 21 22 22 Initializer::~Initializer() {} … … 31 31 void Initializer::print( std::ostream &os, int indent ) {} 32 32 33 SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators ) : value ( v ), designators( _designators ) {33 SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) { 34 34 } 35 35 36 SingleInit::SingleInit( const SingleInit &other ) : value ( other.value ) {36 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( other.value ) { 37 37 cloneAll(other.designators, designators ); 38 38 } … … 54 54 } 55 55 56 ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )57 : initializers( _initializers ), designators( _designators ) {56 ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators, bool maybeConstructed ) 57 : Initializer( maybeConstructed), initializers( _initializers ), designators( _designators ) { 58 58 } 59 59 … … 65 65 66 66 void ListInit::print( std::ostream &os, int indent ) { 67 os << std::endl << std::string(indent, ' ') << "Compound initializer: "; 67 os << std::endl << std::string(indent, ' ') << "Compound initializer: "; 68 68 if ( ! designators.empty() ) { 69 69 os << std::string(indent + 2, ' ' ) << "designated by: ["; 70 70 for ( std::list < Expression * >::iterator i = designators.begin(); 71 71 i != designators.end(); i++ ) { 72 ( *i )->print(os, indent + 4 ); 72 ( *i )->print(os, indent + 4 ); 73 73 } // for 74 74 75 75 os << std::string(indent + 2, ' ' ) << "]"; 76 76 } // if 77 77 78 for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ ) 78 for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ ) 79 79 (*i)->print( os, indent + 2 ); 80 80 } 81 82 83 ConstructorInit::ConstructorInit( Expression * ctor, Initializer * init ) : Initializer( true ), ctor( ctor ), init( init ) {} 84 ConstructorInit::~ConstructorInit() { 85 delete ctor; 86 delete init; 87 } 88 89 ConstructorInit *ConstructorInit::clone() const { 90 return new ConstructorInit( *this ); 91 } 92 93 void ConstructorInit::print( std::ostream &os, int indent ) { 94 os << std::endl << std::string(indent, ' ') << "Constructor initializer: "; 95 if ( ctor ) { 96 os << " initially constructed with "; 97 ctor->print( os, indent+2 ); 98 } // if 99 100 if ( init ) { 101 os << " with fallback C-style initializer: "; 102 init->print( os, indent+2 ); 103 } 104 } 105 106 81 107 // Local Variables: // 82 108 // tab-width: 4 // -
src/SynTree/Initializer.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Initializer.h -- 7 // Initializer.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon May 18 09:03:48 201513 // Update Count : 1 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:29:53 2016 13 // Update Count : 17 14 14 // 15 15 … … 27 27 public: 28 28 // Initializer( std::string _name = std::string(""), int _pos = 0 ); 29 Initializer( );29 Initializer( bool maybeConstructed ); 30 30 virtual ~Initializer(); 31 31 … … 43 43 } 44 44 45 bool get_maybeConstructed() { return maybeConstructed; } 46 45 47 virtual Initializer *clone() const = 0; 46 48 virtual void accept( Visitor &v ) = 0; … … 50 52 // std::string name; 51 53 // int pos; 54 bool maybeConstructed; 52 55 }; 53 56 … … 55 58 class SingleInit : public Initializer { 56 59 public: 57 SingleInit( Expression *value, std::list< Expression *> &designators );60 SingleInit( Expression *value, std::list< Expression *> &designators, bool maybeConstructed ); 58 61 SingleInit( const SingleInit &other ); 59 62 virtual ~SingleInit(); 60 63 61 64 Expression *get_value() { return value; } 62 65 void set_value( Expression *newValue ) { value = newValue; } … … 79 82 class ListInit : public Initializer { 80 83 public: 81 ListInit( std::list<Initializer*> &, 82 std::list<Expression *> &designators = *(new std::list<Expression *>()));84 ListInit( std::list<Initializer*> &, 85 std::list<Expression *> &designators, bool maybeConstructed ); 83 86 virtual ~ListInit(); 84 87 … … 100 103 }; 101 104 105 // ConstructorInit represents an initializer that is either a constructor expression or 106 // a C-style initializer. 107 class ConstructorInit : public Initializer { 108 public: 109 ConstructorInit( Expression * ctor, Initializer * init ); 110 virtual ~ConstructorInit(); 111 112 void set_ctor( Expression * newValue ) { ctor = newValue; } 113 Expression * get_ctor() const { return ctor; } 114 void set_init( Initializer * newValue ) { init = newValue; } 115 Initializer * get_init() const { return init; } 116 117 virtual ConstructorInit *clone() const; 118 virtual void accept( Visitor &v ) { v.visit( this ); } 119 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 120 virtual void print( std::ostream &os, int indent = 0 ); 121 122 private: 123 Expression * ctor; 124 // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback 125 // if an appropriate constructor definition is not found by the resolver 126 Initializer * init; 127 }; 128 102 129 #endif // INITIALIZER_H 103 130 -
src/SynTree/Mutator.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Mutator.cc -- 7 // Mutator.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 25 19:21:33 201513 // Update Count : 1 111 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:32:29 2016 13 // Update Count : 15 14 14 // 15 15 … … 419 419 } 420 420 421 Initializer *Mutator::mutate( ConstructorInit *ctorInit ) { 422 ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) ); 423 ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) ); 424 return ctorInit; 425 } 426 421 427 Subrange *Mutator::mutate( Subrange *subrange ) { 422 428 return subrange; -
src/SynTree/Mutator.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Mutator.h -- 7 // Mutator.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Nov 19 22:26:16 201513 // Update Count : 811 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:24:26 2016 13 // Update Count : 9 14 14 // 15 15 #include <cassert> … … 62 62 virtual Expression* mutate( MemberExpr *memberExpr ); 63 63 virtual Expression* mutate( VariableExpr *variableExpr ); 64 virtual Expression* mutate( ConstantExpr *constantExpr ); 64 virtual Expression* mutate( ConstantExpr *constantExpr ); 65 65 virtual Expression* mutate( SizeofExpr *sizeofExpr ); 66 66 virtual Expression* mutate( AlignofExpr *alignofExpr ); … … 91 91 virtual Initializer* mutate( SingleInit *singleInit ); 92 92 virtual Initializer* mutate( ListInit *listInit ); 93 virtual Initializer* mutate( ConstructorInit *ctorInit ); 93 94 94 95 virtual Subrange *mutate( Subrange *subrange ); -
src/SynTree/ObjectDecl.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ObjectDecl.cc -- 7 // ObjectDecl.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Sep 29 14:13:01 201513 // Update Count : 1812 // Last Modified On : Wed Jan 13 16:11:19 2016 13 // Update Count : 29 14 14 // 15 15 … … 19 19 #include "Expression.h" 20 20 #include "utility.h" 21 #include "Statement.h" 21 22 22 23 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn ) … … 58 59 os << " with initializer "; 59 60 init->print( os, indent ); 61 os << std::string(indent, ' ') << "maybeConstructed? " << init->get_maybeConstructed(); 60 62 } // if 61 63 … … 69 71 #if 0 70 72 if ( get_mangleName() != "") { 71 os << get_mangleName() << ": "; 72 } else 73 os << get_mangleName() << ": "; 74 } else 73 75 #endif 74 76 if ( get_name() != "" ) { -
src/SynTree/SynTree.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SynTree.h -- 7 // SynTree.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Jul 23 23:25:04 201513 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:28:41 2016 13 // Update Count : 4 14 14 // 15 15 … … 99 99 class SingleInit; 100 100 class ListInit; 101 class ConstructorInit; 101 102 102 103 class Subrange; -
src/SynTree/Visitor.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Visitor.cc -- 7 // Visitor.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 24 16:11:05 201513 // Update Count : 1 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:27:23 2016 13 // Update Count : 18 14 14 // 15 15 … … 353 353 } 354 354 355 void Visitor::visit( ConstructorInit *ctorInit ) { 356 maybeAccept( ctorInit->get_ctor(), *this ); 357 maybeAccept( ctorInit->get_init(), *this ); 358 } 359 355 360 void Visitor::visit( Subrange *subrange ) {} 356 361 -
src/SynTree/Visitor.h
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Visitor.h -- 7 // Visitor.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Jul 23 23:22:23 201513 // Update Count : 411 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:24:05 2016 13 // Update Count : 5 14 14 // 15 15 … … 62 62 virtual void visit( MemberExpr *memberExpr ); 63 63 virtual void visit( VariableExpr *variableExpr ); 64 virtual void visit( ConstantExpr *constantExpr ); 64 virtual void visit( ConstantExpr *constantExpr ); 65 65 virtual void visit( SizeofExpr *sizeofExpr ); 66 66 virtual void visit( AlignofExpr *alignofExpr ); … … 91 91 virtual void visit( SingleInit *singleInit ); 92 92 virtual void visit( ListInit *listInit ); 93 virtual void visit( ConstructorInit *ctorInit ); 93 94 94 95 virtual void visit( Subrange *subrange ); -
src/initialization.txt
r803deb1 r771b3c3 34 34 sure that resolved initializers for all declarations are being 35 35 generated. 36 37 38 ------ 39 40 More recent email: (I am quoted; Richard is the responder) 41 > As far as I'm aware, the only way that I could currently get the correct 42 > results from the unification engine is by feeding it an expression that 43 > looks like "?=?( ((struct Y)x.y).a, 10 )", then picking out the pieces that 44 > I need (namely the correct choice for a). Does this seem like a reasonable 45 > approach to solve this problem? 46 47 No, unfortunately. Initialization isn't being rewritten as assignment, 48 so you shouldn't allow the particular selection of assignment 49 operators that happen to be in scope (and which may include 50 user-defined operators) to guide the type resolution. 51 52 I don't think there is any way to rewrite an initializer as a single 53 expression and have the resolver just do the right thing. I see the 54 algorithm as: 55 56 For each alternative interpretation of the designator: 57 Construct an expression that casts the initializer to the type of 58 the designator 59 Construct an AlternativeFinder and use it to find the lowest cost 60 interpretation of the expression 61 Add this interpretation to a list of possibilities 62 Go through the list of possibilities and pick the lowest cost 63 64 As with many things in the resolver, it's conceptually simple but the 65 implementation may be a bit of a pain. It fits in with functions like 66 findSingleExpression, findIntegralExpression in Resolver.cc, although 67 it will be significantly more complicated than any of the existing 68 ones. 69 70 71 -
src/libcfa/prelude.cf
r803deb1 r771b3c3 1 // -*- Mode: C -*- 2 // 1 // -*- Mode: C -*- 2 // 3 3 // Copyright (C) Glen Ditchfield 1994, 1999 4 // 4 // 5 5 // prelude.cf -- Standard Cforall Preample for C99 6 // 6 // 7 7 // Author : Glen Ditchfield 8 8 // Created On : Sat Nov 29 07:23:41 2014 … … 116 116 forall( ftype FT ) lvalue FT *?( FT * ); 117 117 118 _Bool +?( _Bool ), -?( _Bool ), ~?( _Bool ); 119 signed int +?( signed int ), -?( signed int ), ~?( signed int ); 120 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int ); 121 signed long int +?( signed long int ), -?( signed long int ), ~?( signed long int ); 122 unsigned long int +?( unsigned long int ), -?( unsigned long int ), ~?( unsigned long int ); 123 signed long long int +?( signed long long int ), -?( signed long long int ), ~?( signed long long int ); 124 unsigned long long int +?( unsigned long long int ), -?( unsigned long long int ), ~?( unsigned long long int ); 118 _Bool +?( _Bool ), -?( _Bool ), ~?( _Bool ); 119 signed int +?( signed int ), -?( signed int ), ~?( signed int ); 120 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int ); 121 signed long int +?( signed long int ), -?( signed long int ), ~?( signed long int ); 122 unsigned long int +?( unsigned long int ), -?( unsigned long int ), ~?( unsigned long int ); 123 signed long long int +?( signed long long int ), -?( signed long long int ), ~?( signed long long int ); 124 unsigned long long int +?( unsigned long long int ), -?( unsigned long long int ), ~?( unsigned long long int ); 125 125 float +?( float ), -?( float ); 126 126 double +?( double ), -?( double ); … … 626 626 ?+=?( long double _Complex *, long double _Complex ), ?+=?( volatile long double _Complex *, long double _Complex ), 627 627 ?-=?( long double _Complex *, long double _Complex ), ?-=?( volatile long double _Complex *, long double _Complex ); 628 629 630 631 632 633 // ------------------------------------------------------------ 634 // 635 // Section ??? Constructors and Destructors 636 // 637 // ------------------------------------------------------------ 638 639 // default ctor 640 void ?{}( _Bool * ), ?{}( volatile _Bool * ); 641 void ?{}( unsigned char * ), ?{}( volatile unsigned char * ); 642 void ?{}( signed int * ), ?{}( volatile signed int * ); 643 void ?{}( unsigned int * ), ?{}( volatile unsigned int * ); 644 void ?{}( signed long int * ), ?{}( volatile signed long int * ); 645 void ?{}( unsigned long int * ), ?{}( volatile unsigned long int * ); 646 void ?{}( signed long long int * ), ?{}( volatile signed long long int * ); 647 void ?{}( unsigned long long int * ), ?{}( volatile unsigned long long int * ); 648 void ?{}( float * ), ?{}( volatile float * ); 649 void ?{}( double * ), ?{}( volatile double * ); 650 void ?{}( long double * ), ?{}( volatile long double * ); 651 void ?{}( float _Complex * ), ?{}( volatile float _Complex * ); 652 void ?{}( double _Complex * ), ?{}( volatile double _Complex * ); 653 void ?{}( long double _Complex * ), ?{}( volatile long double _Complex * ); 654 655 // copy ctor 656 void ?{}( _Bool *, _Bool ), ?{}( volatile _Bool *, _Bool ); 657 void ?{}( unsigned char *, unsigned char ), ?{}( volatile unsigned char *, unsigned char ); 658 void ?{}( signed int *, signed int), ?{}( volatile signed int *, signed int ); 659 void ?{}( unsigned int *, unsigned int), ?{}( volatile unsigned int *, unsigned int ); 660 void ?{}( signed long int *, signed long int), ?{}( volatile signed long int *, signed long int ); 661 void ?{}( unsigned long int *, unsigned long int), ?{}( volatile unsigned long int *, unsigned long int ); 662 void ?{}( signed long long int *, signed long long int), ?{}( volatile signed long long int *, signed long long int ); 663 void ?{}( unsigned long long int *, unsigned long long int), ?{}( volatile unsigned long long int *, unsigned long long int ); 664 void ?{}( float *, float), ?{}( volatile float *, float ); 665 void ?{}( double *, double), ?{}( volatile double *, double ); 666 void ?{}( long double *, long double), ?{}( volatile long double *, long double ); 667 void ?{}( float _Complex *, float _Complex), ?{}( volatile float _Complex *, float _Complex ); 668 void ?{}( double _Complex *, double _Complex), ?{}( volatile double _Complex *, double _Complex ); 669 void ?{}( long double _Complex *, long double _Complex), ?{}( volatile long double _Complex *, long double _Complex ); 670 671 // dtor 672 void ^?{}( _Bool * ), ^?{}( volatile _Bool * ); 673 void ^?{}( signed int * ), ^?{}( volatile signed int * ); 674 void ^?{}( unsigned int * ), ^?{}( volatile unsigned int * ); 675 void ^?{}( signed long int * ), ^?{}( volatile signed long int * ); 676 void ^?{}( unsigned long int * ), ^?{}( volatile unsigned long int * ); 677 void ^?{}( signed long long int * ), ^?{}( volatile signed long long int * ); 678 void ^?{}( unsigned long long int * ), ^?{}( volatile unsigned long long int * ); 679 void ^?{}( float * ), ^?{}( volatile float * ); 680 void ^?{}( double * ), ^?{}( volatile double * ); 681 void ^?{}( long double * ), ^?{}( volatile long double * ); 682 void ^?{}( float _Complex * ), ^?{}( volatile float _Complex * ); 683 void ^?{}( double _Complex * ), ^?{}( volatile double _Complex * ); 684 void ^?{}( long double _Complex * ), ^?{}( volatile long double _Complex * ); 685 686 // // default ctor 687 // forall( dtype DT ) void ?{}( DT ** ); 688 // forall( dtype DT ) void ?{}( const DT ** ); 689 // forall( dtype DT ) void ?{}( volatile DT ** ); 690 // forall( dtype DT ) void ?{}( const volatile DT ** ); 691 692 // // copy ctor 693 // forall( dtype DT ) void ?{}( DT **, DT* ); 694 // forall( dtype DT ) void ?{}( const DT **, DT* ); 695 // forall( dtype DT ) void ?{}( volatile DT **, DT* ); 696 // forall( dtype DT ) void ?{}( const volatile DT **, DT* ); 697 698 // // dtor 699 // forall( dtype DT ) void ^?{}( DT ** ); 700 // forall( dtype DT ) void ^?{}( const DT ** ); 701 // forall( dtype DT ) void ^?{}( volatile DT ** ); 702 // forall( dtype DT ) void ^?{}( const volatile DT ** ); 703 704 // copied from assignment section 705 // copy constructors 706 forall( ftype FT ) void ?{}( FT **, FT * ); 707 forall( ftype FT ) void ?{}( FT * volatile *, FT * ); 708 709 forall( dtype DT ) void ?{}( DT * *, DT * ); 710 forall( dtype DT ) void ?{}( DT * volatile *, DT * ); 711 forall( dtype DT ) void ?{}( const DT * *, DT * ); 712 forall( dtype DT ) void ?{}( const DT * volatile *, DT * ); 713 forall( dtype DT ) void ?{}( const DT * *, const DT * ); 714 forall( dtype DT ) void ?{}( const DT * volatile *, const DT * ); 715 forall( dtype DT ) void ?{}( volatile DT * *, DT * ); 716 forall( dtype DT ) void ?{}( volatile DT * volatile *, DT * ); 717 forall( dtype DT ) void ?{}( volatile DT * *, volatile DT * ); 718 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile DT * ); 719 720 forall( dtype DT ) void ?{}( const volatile DT * *, DT * ); 721 forall( dtype DT ) void ?{}( const volatile DT * volatile *, DT * ); 722 forall( dtype DT ) void ?{}( const volatile DT * *, const DT * ); 723 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const DT * ); 724 forall( dtype DT ) void ?{}( const volatile DT * *, volatile DT * ); 725 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile DT * ); 726 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile DT * ); 727 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile DT * ); 728 729 forall( dtype DT ) void ?{}( DT * *, void * ); 730 forall( dtype DT ) void ?{}( DT * volatile *, void * ); 731 forall( dtype DT ) void ?{}( const DT * *, void * ); 732 forall( dtype DT ) void ?{}( const DT * volatile *, void * ); 733 forall( dtype DT ) void ?{}( const DT * *, const void * ); 734 forall( dtype DT ) void ?{}( const DT * volatile *, const void * ); 735 forall( dtype DT ) void ?{}( volatile DT * *, void * ); 736 forall( dtype DT ) void ?{}( volatile DT * volatile *, void * ); 737 forall( dtype DT ) void ?{}( volatile DT * *, volatile void * ); 738 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile void * ); 739 740 forall( dtype DT ) void ?{}( const volatile DT * *, void * ); 741 forall( dtype DT ) void ?{}( const volatile DT * volatile *, void * ); 742 forall( dtype DT ) void ?{}( const volatile DT * *, const void * ); 743 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const void * ); 744 forall( dtype DT ) void ?{}( const volatile DT * *, volatile void * ); 745 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile void * ); 746 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile void * ); 747 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile void * ); 748 749 forall( dtype DT ) void ?{}( void * *, DT * ); 750 forall( dtype DT ) void ?{}( void * volatile *, DT * ); 751 forall( dtype DT ) void ?{}( const void * *, DT * ); 752 forall( dtype DT ) void ?{}( const void * volatile *, DT * ); 753 forall( dtype DT ) void ?{}( const void * *, const DT * ); 754 forall( dtype DT ) void ?{}( const void * volatile *, const DT * ); 755 forall( dtype DT ) void ?{}( volatile void * *, DT * ); 756 forall( dtype DT ) void ?{}( volatile void * volatile *, DT * ); 757 forall( dtype DT ) void ?{}( volatile void * *, volatile DT * ); 758 forall( dtype DT ) void ?{}( volatile void * volatile *, volatile DT * ); 759 forall( dtype DT ) void ?{}( const volatile void * *, DT * ); 760 forall( dtype DT ) void ?{}( const volatile void * volatile *, DT * ); 761 forall( dtype DT ) void ?{}( const volatile void * *, const DT * ); 762 forall( dtype DT ) void ?{}( const volatile void * volatile *, const DT * ); 763 forall( dtype DT ) void ?{}( const volatile void * *, volatile DT * ); 764 forall( dtype DT ) void ?{}( const volatile void * volatile *, volatile DT * ); 765 forall( dtype DT ) void ?{}( const volatile void * *, const volatile DT * ); 766 forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile DT * ); 767 768 void ?{}( void * *, void * ); 769 void ?{}( void * volatile *, void * ); 770 void ?{}( const void * *, void * ); 771 void ?{}( const void * volatile *, void * ); 772 void ?{}( const void * *, const void * ); 773 void ?{}( const void * volatile *, const void * ); 774 void ?{}( volatile void * *, void * ); 775 void ?{}( volatile void * volatile *, void * ); 776 void ?{}( volatile void * *, volatile void * ); 777 void ?{}( volatile void * volatile *, volatile void * ); 778 void ?{}( const volatile void * *, void * ); 779 void ?{}( const volatile void * volatile *, void * ); 780 void ?{}( const volatile void * *, const void * ); 781 void ?{}( const volatile void * volatile *, const void * ); 782 void ?{}( const volatile void * *, volatile void * ); 783 void ?{}( const volatile void * volatile *, volatile void * ); 784 void ?{}( const volatile void * *, const volatile void * ); 785 void ?{}( const volatile void * volatile *, const volatile void * ); 786 787 //forall( dtype DT ) void ?{}( DT * *, forall( dtype DT2 ) const DT2 * ); 788 //forall( dtype DT ) void ?{}( DT * volatile *, forall( dtype DT2 ) const DT2 * ); 789 forall( dtype DT ) void ?{}( const DT * *, forall( dtype DT2 ) const DT2 * ); 790 forall( dtype DT ) void ?{}( const DT * volatile *, forall( dtype DT2 ) const DT2 * ); 791 //forall( dtype DT ) void ?{}( volatile DT * *, forall( dtype DT2 ) const DT2 * ); 792 //forall( dtype DT ) void ?{}( volatile DT * volatile *, forall( dtype DT2 ) const DT2 * ); 793 forall( dtype DT ) void ?{}( const volatile DT * *, forall( dtype DT2 ) const DT2 * ); 794 forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * ); 795 796 forall( ftype FT ) void ?{}( FT * *, forall( ftype FT2 ) FT2 * ); 797 forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * ); 798 799 // default ctors 800 forall( ftype FT ) void ?{}( FT * * ); 801 forall( ftype FT ) void ?{}( FT * volatile * ); 802 803 forall( dtype DT ) void ?{}( DT * *); 804 forall( dtype DT ) void ?{}( DT * volatile *); 805 forall( dtype DT ) void ?{}( const DT * *); 806 forall( dtype DT ) void ?{}( const DT * volatile *); 807 forall( dtype DT ) void ?{}( volatile DT * *); 808 forall( dtype DT ) void ?{}( volatile DT * volatile *); 809 forall( dtype DT ) void ?{}( const volatile DT * *); 810 forall( dtype DT ) void ?{}( const volatile DT * volatile *); 811 812 void ?{}( void * *); 813 void ?{}( void * volatile *); 814 void ?{}( const void * *); 815 void ?{}( const void * volatile *); 816 void ?{}( volatile void * *); 817 void ?{}( volatile void * volatile *); 818 void ?{}( const volatile void * *); 819 void ?{}( const volatile void * volatile *); 820 821 // dtors 822 forall( ftype FT ) void ^?{}( FT * * ); 823 forall( ftype FT ) void ^?{}( FT * volatile * ); 824 825 forall( dtype DT ) void ^?{}( DT * *); 826 forall( dtype DT ) void ^?{}( DT * volatile *); 827 forall( dtype DT ) void ^?{}( const DT * *); 828 forall( dtype DT ) void ^?{}( const DT * volatile *); 829 forall( dtype DT ) void ^?{}( volatile DT * *); 830 forall( dtype DT ) void ^?{}( volatile DT * volatile *); 831 forall( dtype DT ) void ^?{}( const volatile DT * *); 832 forall( dtype DT ) void ^?{}( const volatile DT * volatile *); 833 834 void ^?{}( void * *); 835 void ^?{}( void * volatile *); 836 void ^?{}( const void * *); 837 void ^?{}( const void * volatile *); 838 void ^?{}( volatile void * *); 839 void ^?{}( volatile void * volatile *); 840 void ^?{}( const volatile void * *); 841 void ^?{}( const volatile void * volatile *); -
src/main.cc
r803deb1 r771b3c3 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // main.cc -- 7 // main.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T hu Dec 17 12:59:06 201513 // Update Count : 1 7911 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jan 19 16:28:13 2016 13 // Update Count : 194 14 14 // 15 15 … … 42 42 #include "InitTweak/Mutate.h" 43 43 #include "InitTweak/RemoveInit.h" 44 #include "InitTweak/FixInit.h" 44 45 //#include "Explain/GenProlog.h" 45 46 //#include "Try/Visit.h" … … 61 62 astp = false, 62 63 bresolvep = false, 64 ctorinitp = false, 63 65 exprp = false, 64 66 expraltp = false, … … 74 76 codegenp = false; 75 77 76 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Validate, };78 enum { Ast, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Validate, }; 77 79 78 80 static struct option long_opts[] = { 79 81 { "ast", no_argument, 0, Ast }, 80 82 { "before-resolver", no_argument, 0, Bresolver }, 83 { "ctorinitfix", no_argument, 0, CtorInitFix }, 81 84 { "expr", no_argument, 0, Expr }, 82 85 { "expralt", no_argument, 0, ExprAlt }, … … 99 102 100 103 opterr = 0; // prevent getopt from printing error messages 101 104 102 105 int c; 103 while ( (c = getopt_long( argc, argv, "ab efglnpqrsvyzD:", long_opts, &long_index )) != -1 ) {106 while ( (c = getopt_long( argc, argv, "abcefFglnpqrsvyzD:", long_opts, &long_index )) != -1 ) { 104 107 switch ( c ) { 105 108 case Ast: … … 110 113 case 'b': // print before resolver steps 111 114 bresolvep = true; 115 break; 116 case CtorInitFix: 117 case 'c': 118 ctorinitp = true; 112 119 break; 113 120 case Expr: … … 182 189 output = new ofstream( argv[ optind ] ); 183 190 } // if 184 191 185 192 Parser::get_parser().set_debug( grammarp ); 186 193 … … 203 210 exit( 1 ); 204 211 } // if 205 212 206 213 parse( prelude, LinkageSpec::Intrinsic ); 207 214 } // if 208 215 } // if 209 216 210 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 211 217 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 218 212 219 if ( parsep ) { 213 220 Parser::get_parser().get_parseTree()->printList( std::cout ); … … 244 251 OPTPRINT( "mutate" ) 245 252 ControlStruct::mutate( translationUnit ); 246 OPTPRINT( "fixNames" ) 253 OPTPRINT( "fixNames" ) 247 254 CodeGen::fixNames( translationUnit ); 248 OPTPRINT( "tweak " )255 OPTPRINT( "tweakInit" ) 249 256 InitTweak::tweak( translationUnit ); 250 257 … … 263 270 if ( exprp ) { 264 271 dump( translationUnit ); 272 return 0; 273 } 274 275 OPTPRINT( "fixInit" ) 276 // fix ObjectDecl - replaces ConstructorInit nodes 277 InitTweak::fix( translationUnit ); 278 if ( ctorinitp ) { 279 dump ( translationUnit ); 280 return 0; 265 281 } 266 282 … … 331 347 std::list< Declaration * > decls; 332 348 if ( noprotop ) { 333 filter( translationUnit.begin(), translationUnit.end(), 349 filter( translationUnit.begin(), translationUnit.end(), 334 350 std::back_inserter( decls ), notPrelude ); 335 351 } else {
Note:
See TracChangeset
for help on using the changeset viewer.