Changes in / [189243c:cc3528f]
- Location:
- src
- Files:
-
- 2 added
- 6 deleted
- 65 edited
-
CodeGen/CodeGenerator.cc (modified) (7 diffs)
-
CodeGen/FixNames.cc (modified) (4 diffs)
-
CodeGen/OperatorTable.cc (modified) (2 diffs)
-
CodeGen/OperatorTable.h (modified) (2 diffs)
-
Common/utility.h (modified) (3 diffs)
-
GenPoly/Box.cc (modified) (6 diffs)
-
GenPoly/CopyParams.cc (modified) (4 diffs)
-
GenPoly/GenPoly.cc (modified) (6 diffs)
-
GenPoly/PolyMutator.cc (modified) (3 diffs)
-
GenPoly/Specialize.cc (modified) (4 diffs)
-
InitTweak/FixGlobalInit.cc (modified) (5 diffs)
-
InitTweak/FixGlobalInit.h (modified) (2 diffs)
-
InitTweak/FixInit.cc (deleted)
-
InitTweak/FixInit.h (deleted)
-
InitTweak/GenInit.cc (deleted)
-
InitTweak/GenInit.h (deleted)
-
InitTweak/InitModel.cc (modified) (3 diffs)
-
InitTweak/RemoveInit.cc (added)
-
InitTweak/RemoveInit.h (added)
-
InitTweak/module.mk (modified) (1 diff)
-
MakeLibCfa.cc (modified) (6 diffs)
-
Makefile.in (modified) (13 diffs)
-
Parser/DeclarationNode.cc (modified) (7 diffs)
-
Parser/InitializerNode.cc (modified) (5 diffs)
-
Parser/ParseNode.h (modified) (4 diffs)
-
Parser/TypeData.cc (modified) (3 diffs)
-
Parser/parser.cc (modified) (1 diff)
-
Parser/parser.yy (modified) (3 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (2 diffs)
-
ResolvExpr/AlternativeFinder.h (modified) (3 diffs)
-
ResolvExpr/Resolver.cc (modified) (16 diffs)
-
ResolvExpr/Resolver.h (modified) (2 diffs)
-
SymTab/AddVisit.h (modified) (2 diffs)
-
SymTab/Autogen.cc (deleted)
-
SymTab/Autogen.h (deleted)
-
SymTab/Validate.cc (modified) (8 diffs)
-
SymTab/module.mk (modified) (2 diffs)
-
SynTree/AddressExpr.cc (modified) (2 diffs)
-
SynTree/ApplicationExpr.cc (modified) (3 diffs)
-
SynTree/ArrayType.cc (modified) (2 diffs)
-
SynTree/CommaExpr.cc (modified) (3 diffs)
-
SynTree/CompoundStmt.cc (modified) (4 diffs)
-
SynTree/Declaration.h (modified) (4 diffs)
-
SynTree/DeclarationWithType.cc (modified) (2 diffs)
-
SynTree/Expression.cc (modified) (12 diffs)
-
SynTree/Expression.h (modified) (3 diffs)
-
SynTree/FunctionDecl.cc (modified) (2 diffs)
-
SynTree/Initializer.cc (modified) (5 diffs)
-
SynTree/Initializer.h (modified) (7 diffs)
-
SynTree/Mutator.cc (modified) (3 diffs)
-
SynTree/Mutator.h (modified) (4 diffs)
-
SynTree/ObjectDecl.cc (modified) (4 diffs)
-
SynTree/Statement.cc (modified) (11 diffs)
-
SynTree/SynTree.h (modified) (3 diffs)
-
SynTree/TypeSubstitution.cc (modified) (3 diffs)
-
SynTree/TypeSubstitution.h (modified) (8 diffs)
-
SynTree/Visitor.cc (modified) (3 diffs)
-
SynTree/Visitor.h (modified) (4 diffs)
-
examples/array.c (modified) (3 diffs)
-
examples/array.h (modified) (3 diffs)
-
examples/rational.c (modified) (5 diffs)
-
examples/vector_int.c (modified) (3 diffs)
-
examples/vector_int.h (modified) (3 diffs)
-
examples/vector_test.c (modified) (3 diffs)
-
initialization.txt (modified) (1 diff)
-
libcfa/Makefile.am (modified) (3 diffs)
-
libcfa/Makefile.in (modified) (3 diffs)
-
libcfa/fstream.c (modified) (4 diffs)
-
libcfa/iostream.c (modified) (8 diffs)
-
libcfa/prelude.cf (modified) (3 diffs)
-
libcfa/rational (modified) (2 diffs)
-
libcfa/rational.c (modified) (4 diffs)
-
main.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r189243c rcc3528f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 1 6:01:00201613 // Update Count : 2 5512 // Last Modified On : Fri May 06 15:40:35 2016 13 // Update Count : 243 14 14 // 15 15 … … 67 67 string mangleName( DeclarationWithType *decl ) { 68 68 if ( decl->get_mangleName() != "" ) { 69 // need to incorporate scope level in order to differentiate names for destructors 70 return decl->get_scopedMangleName(); 69 return decl->get_mangleName(); 71 70 } else { 72 71 return decl->get_name(); … … 234 233 printDesignators( init->get_designators() ); 235 234 output << "{ "; 236 if ( init->begin_initializers() == init->end_initializers() ) { 237 // illegal to leave initializer list empty for scalar initializers, 238 // but always legal to have 0 239 output << "0"; 240 } else { 241 genCommaList( init->begin_initializers(), init->end_initializers() ); 242 } 235 genCommaList( init->begin_initializers(), init->end_initializers() ); 243 236 output << " }"; 244 237 } … … 258 251 case OT_POSTFIXASSIGN: 259 252 case OT_INFIXASSIGN: 260 case OT_CTOR:261 case OT_DTOR:262 253 { 263 254 assert( arg != applicationExpr->get_args().end() ); 264 255 if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 265 // remove & from first assignment/ctor argument 256 266 257 *arg = addrExpr->get_arg(); 267 258 } else { 268 // no address-of operator, so must be a pointer - add dereference269 259 UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 270 260 newExpr->get_args().push_back( *arg ); … … 293 283 break; 294 284 295 case OT_CTOR:296 case OT_DTOR:297 if ( applicationExpr->get_args().size() == 1 ) {298 // the expression fed into a single parameter constructor or destructor299 // may contain side effects - output as a void expression300 output << "((void)(";301 (*arg++)->accept( *this );302 output << ")) /* " << opInfo.inputName << " */";303 } else if ( applicationExpr->get_args().size() == 2 ) {304 // intrinsic two parameter constructors are essentially bitwise assignment305 output << "(";306 (*arg++)->accept( *this );307 output << opInfo.symbol;308 (*arg)->accept( *this );309 output << ") /* " << opInfo.inputName << " */";310 } else {311 // no constructors with 0 or more than 2 parameters312 assert( false );313 }314 break;315 316 285 case OT_PREFIX: 317 286 case OT_PREFIXASSIGN: … … 329 298 output << opInfo.symbol; 330 299 break; 331 332 300 333 301 case OT_INFIX: … … 376 344 case OT_CALL: 377 345 assert( false ); 378 379 380 case OT_CTOR:381 case OT_DTOR:382 if ( untypedExpr->get_args().size() == 1 ) {383 // the expression fed into a single parameter constructor or destructor384 // may contain side effects - output as a void expression385 output << "((void)(";386 (*arg++)->accept( *this );387 output << ")) /* " << opInfo.inputName << " */";388 } else if ( untypedExpr->get_args().size() == 2 ) {389 // intrinsic two parameter constructors are essentially bitwise assignment390 output << "(";391 (*arg++)->accept( *this );392 output << opInfo.symbol;393 (*arg)->accept( *this );394 output << ") /* " << opInfo.inputName << " */";395 } else {396 // no constructors with 0 or more than 2 parameters397 assert( false );398 }399 346 break; 400 347 -
src/CodeGen/FixNames.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixNames.cc -- 7 // FixNames.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon Apr 11 15:38:10 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 23:36:42 2015 13 13 // Update Count : 1 14 14 // … … 26 26 virtual void visit( ObjectDecl *objectDecl ); 27 27 virtual void visit( FunctionDecl *functionDecl ); 28 29 virtual void visit( CompoundStmt *compoundStmt );30 31 private:32 int scopeLevel = 1;33 34 void fixDWT( DeclarationWithType *dwt );35 28 }; 36 29 … … 40 33 } 41 34 42 void FixNames::fixDWT( DeclarationWithType *dwt ) {35 void fixDWT( DeclarationWithType *dwt ) { 43 36 if ( dwt->get_name() != "" ) { 44 37 if ( LinkageSpec::isDecoratable( dwt->get_linkage() ) ) { 45 38 dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) ); 46 dwt->set_scopeLevel( scopeLevel );47 39 } // if 48 40 } // if … … 58 50 fixDWT( functionDecl ); 59 51 } 60 61 void FixNames::visit( CompoundStmt *compoundStmt ) {62 scopeLevel++;63 Visitor::visit( compoundStmt );64 scopeLevel--;65 }66 52 } // namespace CodeGen 67 53 -
src/CodeGen/OperatorTable.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // OperatorTable.cc -- 7 // OperatorTable.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T hu Apr 14 16:48:27 201613 // Update Count : 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 23 17:41:14 2015 13 // Update Count : 5 14 14 // 15 15 … … 21 21 const OperatorInfo tableValues[] = { 22 22 { "?[?]", "", "_operator_index", OT_INDEX }, 23 { "?{}", "=", "_constructor", OT_CTOR },24 { "^?{}", "", "_destructor", OT_DTOR },25 23 { "?()", "", "_operator_call", OT_CALL }, 26 24 { "?++", "++", "_operator_postincr", OT_POSTFIXASSIGN }, -
src/CodeGen/OperatorTable.h
r189243c rcc3528f 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 24 16:17:57 201513 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 23 16:09:27 2015 13 // Update Count : 3 14 14 // 15 15 … … 22 22 enum OperatorType { 23 23 OT_INDEX, 24 OT_CTOR,25 OT_DTOR,26 24 OT_CALL, 27 25 OT_PREFIX, -
src/Common/utility.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // utility.h -- 7 // utility.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Apr 28 13:18:24 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 2 18:04:41 2015 13 13 // Update Count : 16 14 14 // … … 62 62 os << std::string( indent, ' ' ); 63 63 (*i)->print( os, indent + 2 ); 64 // need an endl after each element because it's not easy to know when each individual item should end65 64 os << std::endl; 66 65 } // if … … 129 128 } 130 129 131 template < typename T > 130 template < typename T > 132 131 std::string toString ( T value ) { 133 132 std::ostringstream os; -
src/GenPoly/Box.cc
r189243c rcc3528f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 13 1 4:51:21201612 // Last Modified On : Fri May 13 13:59:22 2016 13 13 // Update Count : 295 14 14 // … … 784 784 arg++; 785 785 } else { 786 /// xxx - should this be an assertion? 787 throw SemanticError( "unbound type variable: " + tyParm->first + " in application ", appExpr ); 786 throw SemanticError( "unbound type variable in application ", appExpr ); 788 787 } // if 789 788 } // if … … 911 910 } else if ( arg->get_results().front()->get_isLvalue() ) { 912 911 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 913 // xxx - need to test that this code is still reachable914 912 if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) { 915 913 commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) ); … … 1295 1293 } else if ( needsAdapter( function, scopeTyVars ) ) { 1296 1294 // std::cerr << "needs adapter: "; 1297 // printTyVarMap( std::cerr, scopeTyVars ); 1298 // std::cerr << *env << std::endl; 1295 // for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) { 1296 // std::cerr << i->first << " "; 1297 // } 1298 // std::cerr << "\n"; 1299 1299 // change the application so it calls the adapter rather than the passed function 1300 1300 ret = applyAdapter( appExpr, function, arg, scopeTyVars ); … … 1347 1347 } // if 1348 1348 } // if 1349 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward1350 // out of the if condition.1351 bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );1352 1349 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1353 if ( polytype|| needs ) {1350 if ( isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env ) || needs ) { 1354 1351 Expression *ret = addrExpr->get_arg(); 1355 1352 delete ret->get_results().front(); … … 1910 1907 1911 1908 std::list<Expression*> designators; 1912 objectDecl->set_init( new SingleInit( alloc, designators , false ) ); // not constructed1909 objectDecl->set_init( new SingleInit( alloc, designators ) ); 1913 1910 } 1914 1911 } -
src/GenPoly/CopyParams.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // CopyParams.cc -- 7 // CopyParams.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz11 // Last Modified By : Peter A. Buhr 12 12 // Last Modified On : Tue May 19 07:33:31 2015 13 13 // Update Count : 1 … … 29 29 public: 30 30 CopyParams(); 31 31 32 32 virtual void visit( FunctionDecl *funcDecl ); 33 33 virtual void visit( AddressExpr *addrExpr ); … … 50 50 if ( funcDecl->get_statements() ) { 51 51 funcDecl->get_statements()->accept( *this ); 52 52 53 53 if ( ! modVars.empty() ) { 54 54 std::map< std::string, DeclarationWithType* > assignOps; … … 57 57 if ( (*tyVar)->get_kind() == TypeDecl::Any ) { 58 58 assert( !(*tyVar)->get_assertions().empty() ); 59 assert( (*tyVar)->get_assertions().front()->get_name() == "?=?" );60 59 assignOps[ (*tyVar)->get_name() ] = (*tyVar)->get_assertions().front(); 61 60 } // if -
src/GenPoly/GenPoly.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenPoly.cc -- 7 // GenPoly.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon May 02 14:53:33 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 15 16:11:18 2015 13 13 // Update Count : 13 14 14 // … … 81 81 return 0; 82 82 } 83 83 84 84 Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) { 85 85 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { … … 112 112 return 0; 113 113 } 114 114 115 115 Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) { 116 116 if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) { … … 146 146 return isPolyType( type, env ); 147 147 } 148 148 149 149 Type * hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels, const TypeSubstitution *env ) { 150 150 int dummy; … … 192 192 if ( ! fn || fn->get_name() != std::string("*?") ) return 0; 193 193 expr = *untypedExpr->begin_args(); 194 } else if ( CommaExpr *commaExpr = dynamic_cast< CommaExpr* >( expr ) ) {195 // copy constructors insert comma exprs, look at second argument which contains the variable196 expr = commaExpr->get_arg2();197 continue;198 194 } else break; 199 195 … … 213 209 } 214 210 } 215 211 216 212 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) { 217 213 for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) { -
src/GenPoly/PolyMutator.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // PolyMutator.cc -- 7 // PolyMutator.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 : Mon May 02 14:50:58 201612 // Last Modified On : Fri Aug 14 15:28:50 2015 13 13 // Update Count : 11 14 14 // … … 63 63 env = expr->get_env(); 64 64 } 65 // xxx - should env be cloned (or moved) onto the result of the mutate?66 65 return expr->acceptMutator( *this ); 67 66 } else { … … 145 144 return untypedExpr; 146 145 } 147 148 146 147 149 148 Initializer *PolyMutator::mutate( SingleInit *singleInit ) { 150 149 singleInit->set_value( mutateExpression( singleInit->get_value() ) ); -
src/GenPoly/Specialize.cc
r189243c rcc3528f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 28 15:17:45201613 // Update Count : 2412 // Last Modified On : Wed Jan 20 12:40:33 2016 13 // Update Count : 18 14 14 // 15 15 … … 41 41 virtual Expression * mutate( AddressExpr *castExpr ); 42 42 virtual Expression * mutate( CastExpr *castExpr ); 43 //virtual Expression * mutate( LogicalExpr *logicalExpr );44 //virtual Expression * mutate( ConditionalExpr *conditionalExpr );45 //virtual Expression * mutate( CommaExpr *commaExpr );43 virtual Expression * mutate( LogicalExpr *logicalExpr ); 44 virtual Expression * mutate( ConditionalExpr *conditionalExpr ); 45 virtual Expression * mutate( CommaExpr *commaExpr ); 46 46 47 47 private: … … 142 142 143 143 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 144 assert( ! actual->get_results().empty() ); // using front, should have this assert144 assert( ! actual->get_results().empty() ); 145 145 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) { 146 146 FunctionType *funType; … … 212 212 } 213 213 214 // Removing these for now. Richard put these in for some reason, but it's not clear why. 215 // In particular, copy constructors produce a comma expression, and with this code the parts 216 // of that comma expression are not specialized, which causes problems. 217 218 // Expression * Specialize::mutate( LogicalExpr *logicalExpr ) { 219 // return logicalExpr; 220 // } 221 222 // Expression * Specialize::mutate( ConditionalExpr *condExpr ) { 223 // return condExpr; 224 // } 225 226 // Expression * Specialize::mutate( CommaExpr *commaExpr ) { 227 // return commaExpr; 228 // } 214 Expression * Specialize::mutate( LogicalExpr *logicalExpr ) { 215 return logicalExpr; 216 } 217 218 Expression * Specialize::mutate( ConditionalExpr *condExpr ) { 219 return condExpr; 220 } 221 222 Expression * Specialize::mutate( CommaExpr *commaExpr ) { 223 return commaExpr; 224 } 229 225 } // namespace GenPoly 230 226 -
src/InitTweak/FixGlobalInit.cc
r189243c rcc3528f 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 13 11:37:30201612 // Last Modified On : Fri May 06 15:40:48 2016 13 13 // Update Count : 2 14 14 // 15 15 16 16 #include "FixGlobalInit.h" 17 #include "InitTweak.h"18 17 #include "SynTree/Declaration.h" 19 18 #include "SynTree/Type.h" … … 43 42 UniqueName tempNamer; 44 43 FunctionDecl * initFunction; 45 FunctionDecl * destroyFunction;46 44 }; 47 45 … … 92 90 GlobalFixer fixer( name, inLibrary ); 93 91 acceptAll( translationUnit, fixer ); 94 // don't need to include function if it's empty 95 if ( fixer.initFunction->get_statements()->get_kids().empty() ) { 96 delete fixer.initFunction; 97 } else { 98 translationUnit.push_back( fixer.initFunction ); 99 } 100 if ( fixer.destroyFunction->get_statements()->get_kids().empty() ) { 101 delete fixer.destroyFunction; 102 } else { 103 translationUnit.push_back( fixer.destroyFunction ); 104 } 92 translationUnit.push_back( fixer.initFunction ); 105 93 } 106 94 107 std::string globalFunctionName( const std::string & name ) {95 std::string initName( const std::string & name ) { 108 96 // get basename 109 97 std::string ret = name.substr( 0, name.find( '.' ) ); … … 111 99 static std::string invalid = "/-"; 112 100 replace_if( ret.begin(), ret.end(), []( char c ) { return invalid.find(c) != std::string::npos; }, '_' ); 113 return ret;101 return "_init_" + ret; 114 102 } 115 103 116 104 GlobalFixer::GlobalFixer( const std::string & name, bool inLibrary ) : tempNamer( "_global_init" ) { 117 std::string fixedName = globalFunctionName( name ); 118 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Constructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) ); 119 120 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Destructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) ); 105 initFunction = new FunctionDecl( initName( name ), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Constructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) ); 121 106 } 122 107 123 108 void GlobalFixer::visit( ObjectDecl *objDecl ) { 124 std::list< Statement * > & initStatements = initFunction->get_statements()->get_kids(); 125 std::list< Statement * > & destroyStatements = destroyFunction->get_statements()->get_kids(); 109 std::list< Statement * > & statements = initFunction->get_statements()->get_kids(); 126 110 127 // if ( objDecl->get_init() == NULL ) return; 128 if ( ! tryConstruct( objDecl ) ) return; // don't construct @= or designated objects 111 if ( objDecl->get_init() == NULL ) return; 129 112 if ( objDecl->get_type()->get_isConst() ) return; // temporary: can't assign to a const variable 130 if ( objDecl->get_storageClass() == DeclarationNode::Extern ) return;131 113 // C allows you to initialize objects with constant expressions 132 114 // xxx - this is an optimization. Need to first resolve constructors before we decide … … 134 116 // if ( isConstExpr( objDecl->get_init() ) ) return; 135 117 136 if ( ArrayType * at = dynamic_cast< ArrayType * > ( objDecl->get_type() ) ) { 137 // xxx - initialize each element of the array 138 } else { 139 // steal initializer from object and attach it to a new temporary 140 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, objDecl->get_type()->clone(), objDecl->get_init() ); 141 objDecl->set_init( NULL ); 142 initStatements.push_back( new DeclStmt( noLabels, newObj ) ); 118 // steal initializer from object and attach it to a new temporary 119 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, objDecl->get_type()->clone(), objDecl->get_init() ); 120 objDecl->set_init( NULL ); 121 statements.push_back( new DeclStmt( noLabels, newObj ) ); 143 122 144 // copy constructobjDecl using temporary145 UntypedExpr * init = new UntypedExpr( new NameExpr( "?{}" ) );146 init->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );147 init->get_args().push_back( new VariableExpr( newObj ) );148 initStatements.push_back( new ExprStmt( noLabels, init ) );123 // assign (later: copy construct) objDecl using temporary 124 UntypedExpr * init = new UntypedExpr( new NameExpr( "?=?" ) ); 125 init->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) ); 126 init->get_args().push_back( new VariableExpr( newObj ) ); 127 statements.push_back( new ExprStmt( noLabels, init ) ); 149 128 150 // add destructor calls to global destroy function 151 UntypedExpr * destroy = new UntypedExpr( new NameExpr( "^?{}" ) ); 152 destroy->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) ); 153 destroyStatements.push_front( new ExprStmt( noLabels, destroy ) ); 154 } 129 // xxx- need to destruct objDecl atexit 155 130 } 156 131 -
src/InitTweak/FixGlobalInit.h
r189243c rcc3528f 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 1 6:07:47201612 // Last Modified On : Fri May 06 15:29:13 2016 13 13 // Update Count : 2 14 14 // … … 31 31 /// Apply transformations to a file name to get a valid C identifier which will be used as 32 32 /// the name of the generated initializer function. 33 std::string globalFunctionName( const std::string & name );33 std::string initName( const std::string & name ); 34 34 } // namespace 35 35 -
src/InitTweak/InitModel.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : T hu Jan 07 13:38:46 201613 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 19 16:37:08 2015 13 // Update Count : 1 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 , false ); // cannot be constructed200 init = new SingleInit( single->get_expr(), empty ); 201 201 return; 202 202 } … … 214 214 } // if 215 215 216 std::list< Expression * > desig; 217 init = new ListInit( contents, desig, false ); // cannot be constructed 216 init = new ListInit( contents ); 218 217 return; 219 218 } -
src/InitTweak/module.mk
r189243c rcc3528f 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Rob Schluntz 13 ## Last Modified On : Fri May 13 11:36:24201614 ## Update Count : 313 ## Last Modified On : Wed May 04 16:03:49 2016 14 ## Update Count : 2 15 15 ############################################################################### 16 16 17 SRC += InitTweak/GenInit.cc \ 18 InitTweak/FixInit.cc \ 19 InitTweak/FixGlobalInit.cc \ 20 InitTweak/InitTweak.cc 17 SRC += InitTweak/RemoveInit.cc \ 18 InitTweak/FixGlobalInit.cc 21 19 -
src/MakeLibCfa.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Fri Apr 22 13:54:15 201613 // Update Count : 4014 // 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 26 16:52:59 2015 13 // Update Count : 14 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 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; 79 case CodeGen::OT_CTOR: 80 // ctors don't return a value 81 if ( funcDecl->get_functionType()->get_parameters().size() == 1 ) { 82 // intrinsic default constructors should do nothing 83 // 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 assignment 88 // 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 case CodeGen::OT_DTOR: 95 // intrinsic destructors should do nothing 96 // delete newExpr; 97 break; 78 } 98 79 case CodeGen::OT_CONSTANT: 99 80 case CodeGen::OT_LABELADDRESS: … … 101 82 assert( false ); 102 83 } // 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 ); 103 95 } 104 96 105 97 void MakeLibCfa::visit( ObjectDecl* origObjDecl ) { 106 98 if ( origObjDecl->get_linkage() != LinkageSpec::Intrinsic ) return; 107 99 108 100 ObjectDecl *objDecl = origObjDecl->clone(); 109 101 assert( ! objDecl->get_init() ); 110 102 std::list< Expression* > noDesignators; 111 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators , false ) ); // cannot be constructed103 objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators ) ); 112 104 newDecls.push_back( objDecl ); 113 105 } 114 106 } // namespace LibCfa 107 108 // Local Variables: // 109 // tab-width: 4 // 110 // mode: c++ // 111 // compile-command: "make install" // 112 // End: // -
src/Makefile.in
r189243c rcc3528f 123 123 GenPoly/driver_cfa_cpp-FindFunction.$(OBJEXT) \ 124 124 GenPoly/driver_cfa_cpp-DeclMutator.$(OBJEXT) \ 125 InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) \ 126 InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) \ 125 InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) \ 127 126 InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) \ 128 InitTweak/driver_cfa_cpp-InitTweak.$(OBJEXT) \129 127 Parser/driver_cfa_cpp-parser.$(OBJEXT) \ 130 128 Parser/driver_cfa_cpp-lex.$(OBJEXT) \ … … 162 160 SymTab/driver_cfa_cpp-ImplementationType.$(OBJEXT) \ 163 161 SymTab/driver_cfa_cpp-TypeEquality.$(OBJEXT) \ 164 SymTab/driver_cfa_cpp-Autogen.$(OBJEXT) \165 162 SynTree/driver_cfa_cpp-Type.$(OBJEXT) \ 166 163 SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) \ … … 349 346 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ 350 347 GenPoly/CopyParams.cc GenPoly/FindFunction.cc \ 351 GenPoly/DeclMutator.cc InitTweak/GenInit.cc \ 352 InitTweak/FixInit.cc InitTweak/FixGlobalInit.cc \ 353 InitTweak/InitTweak.cc Parser/parser.yy Parser/lex.ll \ 348 GenPoly/DeclMutator.cc InitTweak/RemoveInit.cc \ 349 InitTweak/FixGlobalInit.cc Parser/parser.yy Parser/lex.ll \ 354 350 Parser/TypedefTable.cc Parser/ParseNode.cc \ 355 351 Parser/DeclarationNode.cc Parser/ExpressionNode.cc \ … … 368 364 SymTab/Mangler.cc SymTab/Validate.cc SymTab/FixFunction.cc \ 369 365 SymTab/ImplementationType.cc SymTab/TypeEquality.cc \ 370 SymTab/Autogen.cc SynTree/Type.cc SynTree/VoidType.cc \ 371 SynTree/BasicType.cc SynTree/PointerType.cc \ 372 SynTree/ArrayType.cc SynTree/FunctionType.cc \ 373 SynTree/ReferenceToType.cc SynTree/TupleType.cc \ 374 SynTree/TypeofType.cc SynTree/AttrType.cc \ 366 SynTree/Type.cc SynTree/VoidType.cc SynTree/BasicType.cc \ 367 SynTree/PointerType.cc SynTree/ArrayType.cc \ 368 SynTree/FunctionType.cc SynTree/ReferenceToType.cc \ 369 SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \ 375 370 SynTree/VarArgsType.cc SynTree/Constant.cc \ 376 371 SynTree/Expression.cc SynTree/TupleExpr.cc \ … … 568 563 @$(MKDIR_P) InitTweak/$(DEPDIR) 569 564 @: > InitTweak/$(DEPDIR)/$(am__dirstamp) 570 InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT): InitTweak/$(am__dirstamp) \ 571 InitTweak/$(DEPDIR)/$(am__dirstamp) 572 InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT): InitTweak/$(am__dirstamp) \ 573 InitTweak/$(DEPDIR)/$(am__dirstamp) 565 InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT): \ 566 InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp) 574 567 InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT): \ 575 InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)576 InitTweak/driver_cfa_cpp-InitTweak.$(OBJEXT): \577 568 InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp) 578 569 Parser/parser.h: Parser/parser.cc … … 683 674 SymTab/driver_cfa_cpp-TypeEquality.$(OBJEXT): SymTab/$(am__dirstamp) \ 684 675 SymTab/$(DEPDIR)/$(am__dirstamp) 685 SymTab/driver_cfa_cpp-Autogen.$(OBJEXT): SymTab/$(am__dirstamp) \686 SymTab/$(DEPDIR)/$(am__dirstamp)687 676 SynTree/$(am__dirstamp): 688 677 @$(MKDIR_P) SynTree … … 808 797 -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT) 809 798 -rm -f InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) 810 -rm -f InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) 811 -rm -f InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) 812 -rm -f InitTweak/driver_cfa_cpp-InitTweak.$(OBJEXT) 799 -rm -f InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) 813 800 -rm -f Parser/driver_cfa_cpp-DeclarationNode.$(OBJEXT) 814 801 -rm -f Parser/driver_cfa_cpp-ExpressionNode.$(OBJEXT) … … 840 827 -rm -f ResolvExpr/driver_cfa_cpp-TypeEnvironment.$(OBJEXT) 841 828 -rm -f ResolvExpr/driver_cfa_cpp-Unify.$(OBJEXT) 842 -rm -f SymTab/driver_cfa_cpp-Autogen.$(OBJEXT)843 829 -rm -f SymTab/driver_cfa_cpp-FixFunction.$(OBJEXT) 844 830 -rm -f SymTab/driver_cfa_cpp-ImplementationType.$(OBJEXT) … … 917 903 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@ 918 904 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po@am__quote@ 919 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po@am__quote@ 920 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po@am__quote@ 921 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Po@am__quote@ 905 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po@am__quote@ 922 906 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-DeclarationNode.Po@am__quote@ 923 907 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-ExpressionNode.Po@am__quote@ … … 949 933 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-TypeEnvironment.Po@am__quote@ 950 934 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Unify.Po@am__quote@ 951 @AMDEP_TRUE@@am__include@ @am__quote@SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Po@am__quote@952 935 @AMDEP_TRUE@@am__include@ @am__quote@SymTab/$(DEPDIR)/driver_cfa_cpp-FixFunction.Po@am__quote@ 953 936 @AMDEP_TRUE@@am__include@ @am__quote@SymTab/$(DEPDIR)/driver_cfa_cpp-ImplementationType.Po@am__quote@ … … 1389 1372 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o GenPoly/driver_cfa_cpp-DeclMutator.obj `if test -f 'GenPoly/DeclMutator.cc'; then $(CYGPATH_W) 'GenPoly/DeclMutator.cc'; else $(CYGPATH_W) '$(srcdir)/GenPoly/DeclMutator.cc'; fi` 1390 1373 1391 InitTweak/driver_cfa_cpp-GenInit.o: InitTweak/GenInit.cc 1392 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-GenInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo -c -o InitTweak/driver_cfa_cpp-GenInit.o `test -f 'InitTweak/GenInit.cc' || echo '$(srcdir)/'`InitTweak/GenInit.cc 1393 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po 1394 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/GenInit.cc' object='InitTweak/driver_cfa_cpp-GenInit.o' libtool=no @AMDEPBACKSLASH@ 1395 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1396 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-GenInit.o `test -f 'InitTweak/GenInit.cc' || echo '$(srcdir)/'`InitTweak/GenInit.cc 1397 1398 InitTweak/driver_cfa_cpp-GenInit.obj: InitTweak/GenInit.cc 1399 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-GenInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo -c -o InitTweak/driver_cfa_cpp-GenInit.obj `if test -f 'InitTweak/GenInit.cc'; then $(CYGPATH_W) 'InitTweak/GenInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/GenInit.cc'; fi` 1400 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po 1401 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/GenInit.cc' object='InitTweak/driver_cfa_cpp-GenInit.obj' libtool=no @AMDEPBACKSLASH@ 1402 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1403 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-GenInit.obj `if test -f 'InitTweak/GenInit.cc'; then $(CYGPATH_W) 'InitTweak/GenInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/GenInit.cc'; fi` 1404 1405 InitTweak/driver_cfa_cpp-FixInit.o: InitTweak/FixInit.cc 1406 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixInit.o `test -f 'InitTweak/FixInit.cc' || echo '$(srcdir)/'`InitTweak/FixInit.cc 1407 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po 1408 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixInit.cc' object='InitTweak/driver_cfa_cpp-FixInit.o' libtool=no @AMDEPBACKSLASH@ 1409 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1410 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixInit.o `test -f 'InitTweak/FixInit.cc' || echo '$(srcdir)/'`InitTweak/FixInit.cc 1411 1412 InitTweak/driver_cfa_cpp-FixInit.obj: InitTweak/FixInit.cc 1413 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi` 1414 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po 1415 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixInit.cc' object='InitTweak/driver_cfa_cpp-FixInit.obj' libtool=no @AMDEPBACKSLASH@ 1416 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1417 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi` 1374 InitTweak/driver_cfa_cpp-RemoveInit.o: InitTweak/RemoveInit.cc 1375 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-RemoveInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo -c -o InitTweak/driver_cfa_cpp-RemoveInit.o `test -f 'InitTweak/RemoveInit.cc' || echo '$(srcdir)/'`InitTweak/RemoveInit.cc 1376 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po 1377 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/RemoveInit.cc' object='InitTweak/driver_cfa_cpp-RemoveInit.o' libtool=no @AMDEPBACKSLASH@ 1378 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1379 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.o `test -f 'InitTweak/RemoveInit.cc' || echo '$(srcdir)/'`InitTweak/RemoveInit.cc 1380 1381 InitTweak/driver_cfa_cpp-RemoveInit.obj: InitTweak/RemoveInit.cc 1382 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-RemoveInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi` 1383 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po 1384 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/RemoveInit.cc' object='InitTweak/driver_cfa_cpp-RemoveInit.obj' libtool=no @AMDEPBACKSLASH@ 1385 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1386 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi` 1418 1387 1419 1388 InitTweak/driver_cfa_cpp-FixGlobalInit.o: InitTweak/FixGlobalInit.cc … … 1431 1400 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi` 1432 1401 1433 InitTweak/driver_cfa_cpp-InitTweak.o: InitTweak/InitTweak.cc1434 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-InitTweak.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Tpo -c -o InitTweak/driver_cfa_cpp-InitTweak.o `test -f 'InitTweak/InitTweak.cc' || echo '$(srcdir)/'`InitTweak/InitTweak.cc1435 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Po1436 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/InitTweak.cc' object='InitTweak/driver_cfa_cpp-InitTweak.o' libtool=no @AMDEPBACKSLASH@1437 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1438 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-InitTweak.o `test -f 'InitTweak/InitTweak.cc' || echo '$(srcdir)/'`InitTweak/InitTweak.cc1439 1440 InitTweak/driver_cfa_cpp-InitTweak.obj: InitTweak/InitTweak.cc1441 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-InitTweak.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Tpo -c -o InitTweak/driver_cfa_cpp-InitTweak.obj `if test -f 'InitTweak/InitTweak.cc'; then $(CYGPATH_W) 'InitTweak/InitTweak.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/InitTweak.cc'; fi`1442 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-InitTweak.Po1443 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/InitTweak.cc' object='InitTweak/driver_cfa_cpp-InitTweak.obj' libtool=no @AMDEPBACKSLASH@1444 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1445 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-InitTweak.obj `if test -f 'InitTweak/InitTweak.cc'; then $(CYGPATH_W) 'InitTweak/InitTweak.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/InitTweak.cc'; fi`1446 1447 1402 Parser/driver_cfa_cpp-parser.o: Parser/parser.cc 1448 1403 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parser.Tpo -c -o Parser/driver_cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc … … 1934 1889 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1935 1890 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SymTab/driver_cfa_cpp-TypeEquality.obj `if test -f 'SymTab/TypeEquality.cc'; then $(CYGPATH_W) 'SymTab/TypeEquality.cc'; else $(CYGPATH_W) '$(srcdir)/SymTab/TypeEquality.cc'; fi` 1936 1937 SymTab/driver_cfa_cpp-Autogen.o: SymTab/Autogen.cc1938 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Autogen.o -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo -c -o SymTab/driver_cfa_cpp-Autogen.o `test -f 'SymTab/Autogen.cc' || echo '$(srcdir)/'`SymTab/Autogen.cc1939 @am__fastdepCXX_TRUE@ $(am__mv) SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Po1940 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SymTab/Autogen.cc' object='SymTab/driver_cfa_cpp-Autogen.o' libtool=no @AMDEPBACKSLASH@1941 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1942 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SymTab/driver_cfa_cpp-Autogen.o `test -f 'SymTab/Autogen.cc' || echo '$(srcdir)/'`SymTab/Autogen.cc1943 1944 SymTab/driver_cfa_cpp-Autogen.obj: SymTab/Autogen.cc1945 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Autogen.obj -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo -c -o SymTab/driver_cfa_cpp-Autogen.obj `if test -f 'SymTab/Autogen.cc'; then $(CYGPATH_W) 'SymTab/Autogen.cc'; else $(CYGPATH_W) '$(srcdir)/SymTab/Autogen.cc'; fi`1946 @am__fastdepCXX_TRUE@ $(am__mv) SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Tpo SymTab/$(DEPDIR)/driver_cfa_cpp-Autogen.Po1947 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SymTab/Autogen.cc' object='SymTab/driver_cfa_cpp-Autogen.obj' libtool=no @AMDEPBACKSLASH@1948 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1949 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SymTab/driver_cfa_cpp-Autogen.obj `if test -f 'SymTab/Autogen.cc'; then $(CYGPATH_W) 'SymTab/Autogen.cc'; else $(CYGPATH_W) '$(srcdir)/SymTab/Autogen.cc'; fi`1950 1891 1951 1892 SynTree/driver_cfa_cpp-Type.o: SynTree/Type.cc -
src/Parser/DeclarationNode.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:38:09201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 13 16:53:17 2016 13 13 // Update Count : 161 14 14 // … … 97 97 os << endl << string( indent + 2, ' ' ) << "with initializer "; 98 98 initializer->printOneLine( os ); 99 os << " maybe constructed? " << initializer->get_maybeConstructed();100 101 99 } // if 102 100 … … 355 353 } // if 356 354 } 357 355 358 356 DeclarationNode *DeclarationNode::addQualifiers( DeclarationNode *q ) { 359 357 if ( q ) { … … 506 504 assert( false ); 507 505 } // switch 508 506 509 507 return this; 510 508 } … … 617 615 assert( a->type->kind == TypeData::Array ); 618 616 TypeData *lastArray = findLast( a->type ); 619 if ( type ) { 617 if ( type ) { 620 618 switch ( type->kind ) { 621 619 case TypeData::Aggregate: … … 661 659 } // if 662 660 } 663 661 664 662 DeclarationNode *DeclarationNode::addIdList( DeclarationNode *ids ) { 665 663 type = addIdListToType( type, ids ); … … 866 864 Type *DeclarationNode::buildType() const { 867 865 assert( type ); 868 866 869 867 switch ( type->kind ) { 870 868 case TypeData::Enum: -
src/Parser/InitializerNode.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Thu Jan 07 13:32:57 201613 // Update Count : 1314 // 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Oct 8 17:18:55 2015 13 // Update Count : 4 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 ) , maybeConstructed( true ){25 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ) { 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 ) , maybeConstructed( true ){34 : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ) { 35 35 if ( init != 0 ) 36 36 set_link(init); … … 91 91 } // if 92 92 93 return new ListInit( initlist, designlist , maybeConstructed);93 return new ListInit( initlist, designlist ); 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 , maybeConstructed);101 return new SingleInit( get_expression()->build(), designators ); 102 102 } // if 103 103 -
src/Parser/ParseNode.h
r189243c rcc3528f 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 14 15:37:52 201612 // Last Modified On : Mon Apr 11 11:50:52 2016 13 13 // Update Count : 205 14 14 // … … 185 185 // monadic 186 186 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress, 187 Ctor, Dtor,188 187 }; 189 188 … … 526 525 ExpressionNode *get_designators() const { return designator; } 527 526 528 InitializerNode *set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }529 bool get_maybeConstructed() const { return maybeConstructed; }530 531 527 InitializerNode *next_init() const { return kids; } 532 528 … … 540 536 ExpressionNode *designator; // may be list 541 537 InitializerNode *kids; 542 bool maybeConstructed;543 538 }; 544 539 -
src/Parser/TypeData.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Wed Apr 06 16:57:53201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:26:45 2016 13 13 // Update Count : 49 14 14 // … … 449 449 for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 450 450 if ( (*i)->get_kind() == TypeDecl::Any ) { 451 // add assertion parameters to `type' tyvars in reverse order452 // add dtor: void ^?{}(T *)453 FunctionType *dtorType = new FunctionType( Type::Qualifiers(), false );454 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 ) );455 (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) );456 457 // add copy ctor: void ?{}(T *, T)458 FunctionType *copyCtorType = new FunctionType( Type::Qualifiers(), false );459 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );460 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );461 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, 0, false, false ) );462 463 // add default ctor: void ?{}(T *)464 FunctionType *ctorType = new FunctionType( Type::Qualifiers(), false );465 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 ) );466 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) );467 468 // add assignment operator: T * ?=?(T *, T)469 451 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 470 452 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 ) ); … … 920 902 if ( cur->get_enumeratorValue() != NULL ) { 921 903 ObjectDecl *member = dynamic_cast<ObjectDecl *>(*members); 922 member->set_init( new SingleInit( maybeBuild< Expression >( cur->get_enumeratorValue() ) , std::list< Expression * >()) );904 member->set_init( new SingleInit( maybeBuild< Expression >( cur->get_enumeratorValue() ) ) ); 923 905 } // if 924 906 } // for -
src/Parser/parser.cc
r189243c rcc3528f 7468 7468 /* Line 1806 of yacc.c */ 7469 7469 #line 1704 "parser.yy" 7470 { (yyval.in) = (yyvsp[(2) - (2)].in) ->set_maybeConstructed( false ); }7470 { (yyval.in) = (yyvsp[(2) - (2)].in); } 7471 7471 break; 7472 7472 -
src/Parser/parser.yy
r189243c rcc3528f 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 : Wed Apr 13 16:58:43 2016 13 13 // Update Count : 1519 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 … … 1702 1702 { $$ = $2; } 1703 1703 | ATassign initializer 1704 { $$ = $2 ->set_maybeConstructed( false ); }1704 { $$ = $2; } 1705 1705 ; 1706 1706 -
src/ResolvExpr/AlternativeFinder.cc
r189243c rcc3528f 10 10 // Created On : Sat May 16 23:52:08 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Apr 20 14:24:03201612 // Last Modified On : Wed Feb 10 17:00:04 2016 13 13 // Update Count : 24 14 14 // … … 982 982 } // for 983 983 } 984 985 void AlternativeFinder::visit( ImplicitCopyCtorExpr * impCpCtorExpr ) {986 alternatives.push_back( Alternative( impCpCtorExpr->clone(), env, Cost::zero ) );987 }988 984 } // namespace ResolvExpr 989 985 -
src/ResolvExpr/AlternativeFinder.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AlternativeFinder.h -- 7 // AlternativeFinder.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 23:56:12 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Apr 19 11:44:53 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 16 23:58:43 2015 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #ifndef ALTERNATIVEFINDER_H … … 54 54 virtual void visit( NameExpr *variableExpr ); 55 55 virtual void visit( VariableExpr *variableExpr ); 56 virtual void visit( ConstantExpr *constantExpr ); 56 virtual void visit( ConstantExpr *constantExpr ); 57 57 virtual void visit( SizeofExpr *sizeofExpr ); 58 58 virtual void visit( AlignofExpr *alignofExpr ); … … 65 65 virtual void visit( CommaExpr *commaExpr ); 66 66 virtual void visit( TupleExpr *tupleExpr ); 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );68 67 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 69 68 template< typename InputIterator, typename OutputIterator > -
src/ResolvExpr/Resolver.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Fri May 13 11:36:40201613 // Update Count : 20311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 24 16:43:11 2016 13 // Update Count : 181 14 14 // 15 15 … … 25 25 #include "SymTab/Indexer.h" 26 26 #include "Common/utility.h" 27 #include "InitTweak/InitTweak.h"28 27 29 28 #include <iostream> … … 34 33 public: 35 34 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 36 35 37 36 virtual void visit( FunctionDecl *functionDecl ); 38 37 virtual void visit( ObjectDecl *functionDecl ); … … 55 54 virtual void visit( SingleInit *singleInit ); 56 55 virtual void visit( ListInit *listInit ); 57 virtual void visit( ConstructorInit *ctorInit );58 56 private: 59 57 typedef std::list< Initializer * >::iterator InitIterator; … … 61 59 void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & ); 62 60 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 63 void fallbackInit( ConstructorInit * ctorInit ); 61 64 62 std::list< Type * > functionReturn; 65 63 Type *initContext; … … 84 82 } 85 83 86 87 84 namespace { 88 85 void finishExpr( Expression *expr, const TypeEnvironment &env ) { … … 90 87 env.makeSubstitution( *expr->get_env() ); 91 88 } 92 } // namespace 93 94 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 95 global_renamer.reset(); 96 TypeEnvironment env; 97 Expression *newExpr = resolveInVoidContext( untyped, indexer, env ); 98 finishExpr( newExpr, env ); 99 return newExpr; 100 } 101 102 namespace { 89 90 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 91 global_renamer.reset(); 92 TypeEnvironment env; 93 Expression *newExpr = resolveInVoidContext( untyped, indexer, env ); 94 finishExpr( newExpr, env ); 95 return newExpr; 96 } 97 103 98 Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 104 99 TypeEnvironment env; … … 131 126 } // if 132 127 } 133 128 134 129 Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 135 130 TypeEnvironment env; … … 164 159 return newExpr; 165 160 } 166 167 } 168 161 162 } 163 169 164 void Resolver::visit( ObjectDecl *objectDecl ) { 170 165 Type *new_type = resolveTypeof( objectDecl->get_type(), *this ); … … 263 258 forStmt->set_condition( newExpr ); 264 259 } // if 265 260 266 261 if ( forStmt->get_increment() ) { 267 262 Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this ); … … 277 272 delete switchStmt->get_condition(); 278 273 switchStmt->set_condition( newExpr ); 279 274 280 275 visitor.Visitor::visit( switchStmt ); 281 276 } … … 319 314 bool isCharType( T t ) { 320 315 if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) { 321 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 316 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 322 317 bt->get_kind() == BasicType::UnsignedChar; 323 318 } … … 331 326 string n = ne->get_name(); 332 327 if (n == "0") { 333 initContext = new BasicType(Type::Qualifiers(), 328 initContext = new BasicType(Type::Qualifiers(), 334 329 BasicType::SignedInt); 335 330 } else { … … 337 332 initContext = decl->get_type(); 338 333 } 339 } else if (ConstantExpr * e = 334 } else if (ConstantExpr * e = 340 335 dynamic_cast<ConstantExpr*>(singleInit->get_value())) { 341 336 Constant *c = e->get_constant(); … … 360 355 singleInit->set_value( ce->get_arg() ); 361 356 ce->set_arg( NULL ); 362 delete ce; 357 delete ce; 363 358 } 364 359 } … … 476 471 #endif 477 472 } 478 479 // ConstructorInit - fall back on C-style initializer480 void Resolver::fallbackInit( ConstructorInit * ctorInit ) {481 // could not find valid constructor, or found an intrinsic constructor482 // fall back on C-style initializer483 delete ctorInit->get_ctor();484 ctorInit->set_ctor( NULL );485 maybeAccept( ctorInit->get_init(), *this );486 }487 488 void Resolver::visit( ConstructorInit *ctorInit ) {489 try {490 maybeAccept( ctorInit->get_ctor(), *this );491 maybeAccept( ctorInit->get_dtor(), *this );492 } catch ( SemanticError ) {493 // no alternatives for the constructor initializer - fallback on C-style initializer494 // xxx- not sure if this makes a ton of sense - should maybe never be able to have this situation?495 fallbackInit( ctorInit );496 return;497 }498 499 // found a constructor - can get rid of C-style initializer500 delete ctorInit->get_init();501 ctorInit->set_init( NULL );502 503 // intrinsic single parameter constructors and destructors do nothing. Since this was504 // implicitly generated, there's no way for it to have side effects, so get rid of it505 // to clean up generated code.506 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) {507 delete ctorInit->get_ctor();508 ctorInit->set_ctor( NULL );509 }510 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) {511 delete ctorInit->get_dtor();512 ctorInit->set_dtor( NULL );513 }514 }515 473 } // namespace ResolvExpr 516 474 -
src/ResolvExpr/Resolver.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Resolver.h -- 7 // Resolver.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:18:34 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:06:53 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 17 12:19:32 2015 13 13 // Update Count : 2 14 14 // … … 24 24 void resolve( std::list< Declaration * > translationUnit ); 25 25 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ); 26 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );27 26 } // namespace ResolvExpr 28 27 -
src/SymTab/AddVisit.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AddVisit.h -- 7 // AddVisit.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 16:14:32 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:52:42201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Apr 7 14:42:21 2016 13 13 // Update Count : 5 14 14 // … … 48 48 // maybeAccept( caseStmt->get_condition(), visitor ); 49 49 // } 50 51 template< typename Visitor >52 void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) {53 std::list< Declaration * >::iterator i = translationUnit.begin();54 while ( i != translationUnit.end() ) {55 (*i)->accept( visitor );56 std::list< Declaration * >::iterator next = i;57 next++;58 if ( ! visitor.get_declsToAdd().empty() ) {59 translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() );60 } // if61 i = next;62 } // while63 }64 65 50 } // namespace SymTab 66 51 -
src/SymTab/Validate.cc
r189243c rcc3528f 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed May 11 13:1 7:52201613 // Update Count : 2 9712 // Last Modified On : Wed May 11 13:13:16 2016 13 // Update Count : 251 14 14 // 15 15 … … 56 56 #include "MakeLibCfa.h" 57 57 #include "TypeEquality.h" 58 #include "Autogen.h"59 58 #include "ResolvExpr/typeops.h" 60 59 … … 123 122 124 123 const Indexer *indexer; 124 }; 125 126 class AutogenerateRoutines : public Visitor { 127 public: 128 /// Generates assignment operators for aggregate types as required 129 static void autogenerateRoutines( std::list< Declaration * > &translationUnit ); 130 131 std::list< Declaration * > &get_declsToAdd() { return declsToAdd; } 132 133 virtual void visit( EnumDecl *enumDecl ); 134 virtual void visit( StructDecl *structDecl ); 135 virtual void visit( UnionDecl *structDecl ); 136 virtual void visit( TypeDecl *typeDecl ); 137 virtual void visit( TraitDecl *ctxDecl ); 138 virtual void visit( FunctionDecl *functionDecl ); 139 140 virtual void visit( FunctionType *ftype ); 141 virtual void visit( PointerType *ftype ); 142 143 virtual void visit( CompoundStmt *compoundStmt ); 144 virtual void visit( SwitchStmt *switchStmt ); 145 virtual void visit( ChooseStmt *chooseStmt ); 146 // virtual void visit( CaseStmt *caseStmt ); 147 148 AutogenerateRoutines() : functionNesting( 0 ) {} 149 private: 150 template< typename StmtClass > void visitStatement( StmtClass *stmt ); 151 152 std::list< Declaration * > declsToAdd; 153 std::set< std::string > structsDone; 154 unsigned int functionNesting; // current level of nested functions 125 155 }; 126 156 … … 168 198 }; 169 199 170 class VerifyCtorDtor : public Visitor {171 public:172 /// ensure that constructors and destructors have at least one173 /// parameter, the first of which must be a pointer, and no174 /// return values.175 static void verify( std::list< Declaration * > &translationUnit );176 177 virtual void visit( FunctionDecl *funcDecl );178 };179 180 200 class CompoundLiteral : public GenPoly::DeclMutator { 181 201 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass; … … 197 217 ReturnChecker::checkFunctionReturns( translationUnit ); 198 218 mutateAll( translationUnit, compoundliteral ); 199 autogenerateRoutines( translationUnit );219 AutogenerateRoutines::autogenerateRoutines( translationUnit ); 200 220 acceptAll( translationUnit, pass3 ); 201 VerifyCtorDtor::verify( translationUnit );202 221 } 203 222 … … 209 228 type->accept( pass2 ); 210 229 type->accept( pass3 ); 230 } 231 232 template< typename Visitor > 233 void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) { 234 std::list< Declaration * >::iterator i = translationUnit.begin(); 235 while ( i != translationUnit.end() ) { 236 (*i)->accept( visitor ); 237 std::list< Declaration * >::iterator next = i; 238 next++; 239 if ( ! visitor.get_declsToAdd().empty() ) { 240 translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() ); 241 } // if 242 i = next; 243 } // while 211 244 } 212 245 … … 470 503 } 471 504 505 static const std::list< std::string > noLabels; 506 507 void AutogenerateRoutines::autogenerateRoutines( std::list< Declaration * > &translationUnit ) { 508 AutogenerateRoutines visitor; 509 acceptAndAdd( translationUnit, visitor, false ); 510 } 511 512 template< typename OutputIterator > 513 void makeScalarAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, OutputIterator out ) { 514 ObjectDecl *obj = dynamic_cast<ObjectDecl *>( member ); 515 // unnamed bit fields are not copied as they cannot be accessed 516 if ( obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL ) return; 517 518 UntypedExpr *assignExpr = new UntypedExpr( new NameExpr( "?=?" ) ); 519 520 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 521 derefExpr->get_args().push_back( new VariableExpr( dstParam ) ); 522 523 // do something special for unnamed members 524 Expression *dstselect = new AddressExpr( new MemberExpr( member, derefExpr ) ); 525 assignExpr->get_args().push_back( dstselect ); 526 527 Expression *srcselect = new MemberExpr( member, new VariableExpr( srcParam ) ); 528 assignExpr->get_args().push_back( srcselect ); 529 530 *out++ = new ExprStmt( noLabels, assignExpr ); 531 } 532 533 template< typename OutputIterator > 534 void makeArrayAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, ArrayType *array, OutputIterator out ) { 535 static UniqueName indexName( "_index" ); 536 537 // for a flexible array member nothing is done -- user must define own assignment 538 if ( ! array->get_dimension() ) return; 539 540 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ); 541 *out++ = new DeclStmt( noLabels, index ); 542 543 UntypedExpr *init = new UntypedExpr( new NameExpr( "?=?" ) ); 544 init->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) ); 545 init->get_args().push_back( new NameExpr( "0" ) ); 546 Statement *initStmt = new ExprStmt( noLabels, init ); 547 std::list<Statement *> initList; 548 initList.push_back( initStmt ); 549 550 UntypedExpr *cond = new UntypedExpr( new NameExpr( "?<?" ) ); 551 cond->get_args().push_back( new VariableExpr( index ) ); 552 cond->get_args().push_back( array->get_dimension()->clone() ); 553 554 UntypedExpr *inc = new UntypedExpr( new NameExpr( "++?" ) ); 555 inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) ); 556 557 UntypedExpr *assignExpr = new UntypedExpr( new NameExpr( "?=?" ) ); 558 559 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 560 derefExpr->get_args().push_back( new VariableExpr( dstParam ) ); 561 562 Expression *dstselect = new MemberExpr( member, derefExpr ); 563 UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?+?" ) ); 564 dstIndex->get_args().push_back( dstselect ); 565 dstIndex->get_args().push_back( new VariableExpr( index ) ); 566 assignExpr->get_args().push_back( dstIndex ); 567 568 Expression *srcselect = new MemberExpr( member, new VariableExpr( srcParam ) ); 569 UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) ); 570 srcIndex->get_args().push_back( srcselect ); 571 srcIndex->get_args().push_back( new VariableExpr( index ) ); 572 assignExpr->get_args().push_back( srcIndex ); 573 574 *out++ = new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, assignExpr ) ); 575 } 576 577 template< typename OutputIterator > 578 void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, UnionInstType *unionType, OutputIterator out ) { 579 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) ); 580 copy->get_args().push_back( new VariableExpr( dstParam ) ); 581 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) ); 582 copy->get_args().push_back( new SizeofExpr( unionType ) ); 583 584 *out++ = new ExprStmt( noLabels, copy ); 585 } 586 587 //E ?=?(E volatile*, int), 588 // ?=?(E _Atomic volatile*, int); 589 void makeEnumAssignment( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) { 590 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 591 592 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 593 assignType->get_returnVals().push_back( returnVal ); 594 595 // need two assignment operators with different types 596 FunctionType * assignType2 = assignType->clone(); 597 598 // E ?=?(E volatile *, E) 599 Type *etype = refType->clone(); 600 // etype->get_qualifiers() += Type::Qualifiers(false, true, false, false, false, false); 601 602 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), etype ), 0 ); 603 assignType->get_parameters().push_back( dstParam ); 604 605 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, etype->clone(), 0 ); 606 assignType->get_parameters().push_back( srcParam ); 607 608 // E ?=?(E volatile *, int) 609 assignType2->get_parameters().push_back( dstParam->clone() ); 610 BasicType * paramType = new BasicType(Type::Qualifiers(), BasicType::SignedInt); 611 ObjectDecl *srcParam2 = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, paramType, 0 ); 612 assignType2->get_parameters().push_back( srcParam2 ); 613 614 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 615 // because each unit generates copies of the default routines for each aggregate. 616 617 // since there is no definition, these should not be inline 618 // make these intrinsic so that the code generator does not make use of them 619 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType, 0, false, false ); 620 assignDecl->fixUniqueId(); 621 FunctionDecl *assignDecl2 = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType2, 0, false, false ); 622 assignDecl2->fixUniqueId(); 623 624 // these should be built in the same way that the prelude 625 // functions are, so build a list containing the prototypes 626 // and allow MakeLibCfa to autogenerate the bodies. 627 std::list< Declaration * > assigns; 628 assigns.push_back( assignDecl ); 629 assigns.push_back( assignDecl2 ); 630 631 LibCfa::makeLibCfa( assigns ); 632 633 // need to remove the prototypes, since this may be nested in a routine 634 for (int start = 0, end = assigns.size()/2; start < end; start++) { 635 delete assigns.front(); 636 assigns.pop_front(); 637 } // for 638 639 declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() ); 640 } 641 642 /// Clones a reference type, replacing any parameters it may have with a clone of the provided list 643 template< typename GenericInstType > 644 GenericInstType *cloneWithParams( GenericInstType *refType, const std::list< Expression* >& params ) { 645 GenericInstType *clone = refType->clone(); 646 clone->get_parameters().clear(); 647 cloneAll( params, clone->get_parameters() ); 648 return clone; 649 } 650 651 /// Creates a new type decl that's the same as src, but renamed and with only the ?=? assertion (for complete types only) 652 TypeDecl *cloneAndRename( TypeDecl *src, const std::string &name ) { 653 TypeDecl *dst = new TypeDecl( name, src->get_storageClass(), 0, src->get_kind() ); 654 655 if ( src->get_kind() == TypeDecl::Any ) { 656 // just include assignment operator assertion 657 TypeInstType *assignParamType = new TypeInstType( Type::Qualifiers(), name, dst ); 658 FunctionType *assignFunctionType = new FunctionType( Type::Qualifiers(), false ); 659 assignFunctionType->get_returnVals().push_back( 660 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, assignParamType->clone(), 0 ) ); 661 assignFunctionType->get_parameters().push_back( 662 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), assignParamType->clone() ), 0 ) ); 663 assignFunctionType->get_parameters().push_back( 664 new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, assignParamType, 0 ) ); 665 FunctionDecl *assignAssert = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignFunctionType, 0, false, false ); 666 dst->get_assertions().push_back( assignAssert ); 667 } 668 669 return dst; 670 } 671 672 Declaration *makeStructAssignment( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting ) { 673 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 674 675 // Make function polymorphic in same parameters as generic struct, if applicable 676 bool isGeneric = false; // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union) 677 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 678 std::list< Expression* > structParams; // List of matching parameters to put on types 679 TypeSubstitution genericSubs; // Substitutions to make to member types of struct 680 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 681 isGeneric = true; 682 TypeDecl *typeParam = cloneAndRename( *param, "_autoassign_" + aggregateDecl->get_name() + "_" + (*param)->get_name() ); 683 assignType->get_forall().push_back( typeParam ); 684 TypeInstType *newParamType = new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ); 685 genericSubs.add( (*param)->get_name(), newParamType ); 686 structParams.push_back( new TypeExpr( newParamType ) ); 687 } 688 689 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 ); 690 assignType->get_returnVals().push_back( returnVal ); 691 692 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, structParams ) ), 0 ); 693 assignType->get_parameters().push_back( dstParam ); 694 695 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 ); 696 assignType->get_parameters().push_back( srcParam ); 697 698 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 699 // because each unit generates copies of the default routines for each aggregate. 700 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false ); 701 assignDecl->fixUniqueId(); 702 703 for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) { 704 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) { 705 // query the type qualifiers of this field and skip assigning it if it is marked const. 706 // If it is an array type, we need to strip off the array layers to find its qualifiers. 707 Type * type = dwt->get_type(); 708 while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 709 type = at->get_base(); 710 } 711 712 if ( type->get_qualifiers().isConst ) { 713 // don't assign const members 714 continue; 715 } 716 717 if ( dwt->get_name() == "" ) { 718 // don't assign to anonymous members 719 // xxx - this is a temporary fix. Anonymous members tie into 720 // our inheritance model. I think the correct way to handle this is to 721 // cast the structure to the type of the member and let the resolver 722 // figure out whether it's valid and have a pass afterwards that fixes 723 // the assignment to use pointer arithmetic with the offset of the 724 // member, much like how generic type members are handled. 725 continue; 726 } 727 728 if ( isGeneric ) { 729 // rewrite member type in terms of the type variables on this operator 730 DeclarationWithType *fixedMember = dwt->clone(); 731 genericSubs.apply( fixedMember ); 732 733 // assign to both destination and return value 734 if ( ArrayType *array = dynamic_cast< ArrayType * >( fixedMember->get_type() ) ) { 735 makeArrayAssignment( srcParam, dstParam, fixedMember, array, back_inserter( assignDecl->get_statements()->get_kids() ) ); 736 makeArrayAssignment( srcParam, returnVal, fixedMember, array, back_inserter( assignDecl->get_statements()->get_kids() ) ); 737 } else { 738 makeScalarAssignment( srcParam, dstParam, fixedMember, back_inserter( assignDecl->get_statements()->get_kids() ) ); 739 makeScalarAssignment( srcParam, returnVal, fixedMember, back_inserter( assignDecl->get_statements()->get_kids() ) ); 740 } // if 741 } else { 742 // assign to destination 743 if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) { 744 makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) ); 745 } else { 746 makeScalarAssignment( srcParam, dstParam, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) ); 747 } // if 748 } // if 749 } // if 750 } // for 751 if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 752 753 return assignDecl; 754 } 755 756 Declaration *makeUnionAssignment( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting ) { 757 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 758 759 // Make function polymorphic in same parameters as generic union, if applicable 760 bool isGeneric = false; // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct) 761 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 762 std::list< Expression* > unionParams; // List of matching parameters to put on types 763 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 764 isGeneric = true; 765 TypeDecl *typeParam = cloneAndRename( *param, "_autoassign_" + aggregateDecl->get_name() + "_" + (*param)->get_name() ); 766 assignType->get_forall().push_back( typeParam ); 767 unionParams.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ) ) ); 768 } 769 770 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 ); 771 assignType->get_returnVals().push_back( returnVal ); 772 773 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, unionParams ) ), 0 ); 774 assignType->get_parameters().push_back( dstParam ); 775 776 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 ); 777 assignType->get_parameters().push_back( srcParam ); 778 779 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 780 // because each unit generates copies of the default routines for each aggregate. 781 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false ); 782 assignDecl->fixUniqueId(); 783 784 makeUnionFieldsAssignment( srcParam, dstParam, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) ); 785 if ( isGeneric ) makeUnionFieldsAssignment( srcParam, returnVal, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) ); 786 787 if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 788 789 return assignDecl; 790 } 791 792 void AutogenerateRoutines::visit( EnumDecl *enumDecl ) { 793 if ( ! enumDecl->get_members().empty() ) { 794 EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() ); 795 // enumInst->set_baseEnum( enumDecl ); 796 // declsToAdd.push_back( 797 makeEnumAssignment( enumDecl, enumInst, functionNesting, declsToAdd ); 798 } 799 } 800 801 void AutogenerateRoutines::visit( StructDecl *structDecl ) { 802 if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) { 803 StructInstType structInst( Type::Qualifiers(), structDecl->get_name() ); 804 structInst.set_baseStruct( structDecl ); 805 declsToAdd.push_back( makeStructAssignment( structDecl, &structInst, functionNesting ) ); 806 structsDone.insert( structDecl->get_name() ); 807 } // if 808 } 809 810 void AutogenerateRoutines::visit( UnionDecl *unionDecl ) { 811 if ( ! unionDecl->get_members().empty() ) { 812 UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() ); 813 unionInst.set_baseUnion( unionDecl ); 814 declsToAdd.push_back( makeUnionAssignment( unionDecl, &unionInst, functionNesting ) ); 815 } // if 816 } 817 818 void AutogenerateRoutines::visit( TypeDecl *typeDecl ) { 819 CompoundStmt *stmts = 0; 820 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 821 typeInst->set_baseType( typeDecl ); 822 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 ); 823 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 ); 824 if ( typeDecl->get_base() ) { 825 stmts = new CompoundStmt( std::list< Label >() ); 826 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) ); 827 assign->get_args().push_back( new CastExpr( new VariableExpr( dst ), new PointerType( Type::Qualifiers(), typeDecl->get_base()->clone() ) ) ); 828 assign->get_args().push_back( new CastExpr( new VariableExpr( src ), typeDecl->get_base()->clone() ) ); 829 stmts->get_kids().push_back( new ReturnStmt( std::list< Label >(), assign ) ); 830 } // if 831 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 832 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) ); 833 type->get_parameters().push_back( dst ); 834 type->get_parameters().push_back( src ); 835 FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false, false ); 836 declsToAdd.push_back( func ); 837 } 838 839 void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) { 840 for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) { 841 statements.insert( i, new DeclStmt( noLabels, *decl ) ); 842 } // for 843 declsToAdd.clear(); 844 } 845 846 void AutogenerateRoutines::visit( FunctionType *) { 847 // ensure that we don't add assignment ops for types defined as part of the function 848 } 849 850 void AutogenerateRoutines::visit( PointerType *) { 851 // ensure that we don't add assignment ops for types defined as part of the pointer 852 } 853 854 void AutogenerateRoutines::visit( TraitDecl *) { 855 // ensure that we don't add assignment ops for types defined as part of the context 856 } 857 858 template< typename StmtClass > 859 inline void AutogenerateRoutines::visitStatement( StmtClass *stmt ) { 860 std::set< std::string > oldStructs = structsDone; 861 addVisit( stmt, *this ); 862 structsDone = oldStructs; 863 } 864 865 void AutogenerateRoutines::visit( FunctionDecl *functionDecl ) { 866 maybeAccept( functionDecl->get_functionType(), *this ); 867 acceptAll( functionDecl->get_oldDecls(), *this ); 868 functionNesting += 1; 869 maybeAccept( functionDecl->get_statements(), *this ); 870 functionNesting -= 1; 871 } 872 873 void AutogenerateRoutines::visit( CompoundStmt *compoundStmt ) { 874 visitStatement( compoundStmt ); 875 } 876 877 void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) { 878 visitStatement( switchStmt ); 879 } 880 881 void AutogenerateRoutines::visit( ChooseStmt *switchStmt ) { 882 visitStatement( switchStmt ); 883 } 884 885 // void AutogenerateRoutines::visit( CaseStmt *caseStmt ) { 886 // visitStatement( caseStmt ); 887 // } 888 472 889 void ReturnChecker::checkFunctionReturns( std::list< Declaration * > & translationUnit ) { 473 890 ReturnChecker checker; … … 666 1083 } 667 1084 668 void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) {669 VerifyCtorDtor verifier;670 acceptAll( translationUnit, verifier );671 }672 673 void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) {674 FunctionType * funcType = funcDecl->get_functionType();675 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();676 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters();677 678 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) {679 if ( params.size() == 0 ) {680 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );681 }682 if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) {683 throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl );684 }685 if ( returnVals.size() != 0 ) {686 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );687 }688 }689 690 Visitor::visit( funcDecl );691 // original idea: modify signature of ctor/dtors and insert appropriate return statements692 // to cause desired behaviour693 // new idea: add comma exprs to every ctor call to produce first parameter.694 // this requires some memoization of the first parameter, because it can be a695 // complicated expression with side effects (see: malloc). idea: add temporary variable696 // that is assigned address of constructed object in ctor argument position and697 // return the temporary. It should also be done after all implicit ctors are698 // added, so not in this pass!699 }700 701 1085 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) { 702 1086 storageclass = objectDecl->get_storageClass(); -
src/SymTab/module.mk
r189243c rcc3528f 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 20 20 SymTab/FixFunction.cc \ 21 21 SymTab/ImplementationType.cc \ 22 SymTab/TypeEquality.cc \ 23 SymTab/Autogen.cc 22 SymTab/TypeEquality.cc -
src/SynTree/AddressExpr.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AddressExpr.cc -- 7 // AddressExpr.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 23:54:44 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Apr 26 12:35:13 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 19 16:52:51 2015 13 13 // Update Count : 6 14 14 // … … 32 32 33 33 void AddressExpr::print( std::ostream &os, int indent ) const { 34 os << "Address of:" << std::endl;34 os << std::string( indent, ' ' ) << "Address of:" << std::endl; 35 35 if ( arg ) { 36 os << std::string( indent+2, ' ' ); 37 arg->print( os, indent+2 ); 36 arg->print( os, indent+2 ); 38 37 } // if 39 38 } -
src/SynTree/ApplicationExpr.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ApplicationExpr.cc.cc -- 7 // ApplicationExpr.cc.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Apr 26 12:41:06 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 07:54:17 2015 13 13 // Update Count : 4 14 14 // … … 47 47 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 48 48 assert( function ); 49 49 50 50 for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) { 51 51 get_results().push_back( (*i)->get_type()->clone() ); … … 64 64 65 65 void ApplicationExpr::print( std::ostream &os, int indent ) const { 66 os << "Application of" << std::endl << std::string(indent, ' ');66 os << std::string( indent, ' ' ) << "Application of" << std::endl; 67 67 function->print( os, indent+2 ); 68 68 if ( ! args.empty() ) { -
src/SynTree/ArrayType.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ArrayType.cc -- 7 // ArrayType.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 : Thu May 12 14:07:16 201612 // Last Modified On : Wed Aug 12 14:19:07 2015 13 13 // Update Count : 11 14 14 // … … 51 51 if ( dimension ) { 52 52 os << " with dimension of "; 53 dimension->print( os, indent);53 dimension->print( os, 0 ); 54 54 } // if 55 55 } -
src/SynTree/CommaExpr.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // CommaExpr.cc -- 7 // CommaExpr.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon May 02 15:19:44 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 08:09:58 2015 13 13 // Update Count : 1 14 14 // … … 20 20 CommaExpr::CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname ) 21 21 : Expression( _aname ), arg1( arg1 ), arg2( arg2 ) { 22 // xxx - result of a comma expression is never an lvalue, so should set lvalue23 // to false on all result types. Actually doing this causes some strange things24 // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.25 22 cloneAll( arg2->get_results(), get_results() ); 26 // for ( Type *& type : get_results() ) {27 // type->set_isLvalue( false );28 // }29 23 } 30 24 … … 39 33 40 34 void CommaExpr::print( std::ostream &os, int indent ) const { 41 os << "Comma Expression:" << std::endl; 42 os << std::string( indent+2, ' ' ); 35 os << std::string( indent, ' ' ) << "Comma Expression:" << std::endl; 43 36 arg1->print( os, indent+2 ); 44 37 os << std::endl; 45 os << std::string( indent+2, ' ' );46 38 arg2->print( os, indent+2 ); 47 39 Expression::print( os, indent ); -
src/SynTree/CompoundStmt.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // XXX.cc -- 7 // XXX.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon May 02 15:19:17 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 23 11:37:49 2015 13 13 // Update Count : 3 14 14 // … … 18 18 #include <algorithm> 19 19 #include <functional> 20 #include "Expression.h"21 #include "Declaration.h"22 20 23 21 using std::string; 24 22 using std::endl; 25 26 class VarExprReplacer : public Visitor {27 public:28 typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;29 private:30 const DeclMap & declMap;31 public:32 VarExprReplacer( const DeclMap & declMap ) : declMap( declMap ) {}33 34 // replace variable with new node from decl map35 virtual void visit( VariableExpr * varExpr ) {36 if ( declMap.count( varExpr->get_var() ) ) {37 varExpr->set_var( declMap.at( varExpr->get_var() ) );38 }39 }40 };41 42 23 43 24 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) { … … 46 27 CompoundStmt::CompoundStmt( const CompoundStmt &other ) : Statement( other ) { 47 28 cloneAll( other.kids, kids ); 48 49 // when cloning a compound statement, we may end up cloning declarations which50 // are referred to by VariableExprs throughout the block. Cloning a VariableExpr51 // does a shallow copy, so the VariableExpr will end up pointing to the original52 // declaration. If the original declaration is deleted, e.g. because the original53 // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case,54 // find all DeclarationWithType nodes (since a VariableExpr must point to a55 // DeclarationWithType) in the original CompoundStmt and map them to the cloned56 // node in the new CompoundStmt ('this'), then replace the Declarations referred to57 // by each VariableExpr according to the constructed map. Note that only the declarations58 // in the current level are collected into the map, because child CompoundStmts will59 // recursively execute this routine. There may be more efficient ways of doing60 // this.61 VarExprReplacer::DeclMap declMap;62 std::list< Statement * >::const_iterator origit = other.kids.begin();63 for ( Statement * s : kids ) {64 assert( origit != other.kids.end() );65 if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) {66 DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( *origit );67 assert( origDeclStmt );68 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) {69 DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );70 assert( origdwt );71 declMap[ origdwt ] = dwt;72 }73 }74 }75 if ( ! declMap.empty() ) {76 VarExprReplacer replacer( declMap );77 accept( replacer );78 }79 29 } 80 30 … … 84 34 85 35 void CompoundStmt::print( std::ostream &os, int indent ) const { 86 os << "CompoundStmt" << endl ;36 os << string( indent, ' ' ) << "CompoundStmt" << endl ; 87 37 printAll( kids, os, indent + 2 ); 88 38 } -
src/SynTree/Declaration.h
r189243c rcc3528f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 1 6:26:12 201612 // Last Modified On : Fri May 06 15:39:02 2016 13 13 // Update Count : 33 14 14 // … … 22 22 #include "Parser/LinkageSpec.h" 23 23 #include "Parser/ParseNode.h" 24 #include <string>25 24 26 25 class Declaration { … … 68 67 void set_mangleName( std::string newValue ) { mangleName = newValue; } 69 68 70 std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }71 72 int get_scopeLevel() const { return scopeLevel; }73 void set_scopeLevel( int newValue ) { scopeLevel = newValue; }74 75 69 virtual DeclarationWithType *clone() const = 0; 76 70 virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0; … … 81 75 // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 82 76 std::string mangleName; 83 // need to remember the scope level at which the variable was declared, so that84 // shadowed identifiers can be accessed85 int scopeLevel = 0;86 77 }; 87 78 -
src/SynTree/DeclarationWithType.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // DeclarationWithType.cc -- 7 // DeclarationWithType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon Apr 11 15:35:27 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:08:07 2015 13 13 // Update Count : 3 14 14 // … … 23 23 24 24 DeclarationWithType::DeclarationWithType( const DeclarationWithType &other ) 25 : Declaration( other ), mangleName( other.mangleName ) , scopeLevel( other.scopeLevel ){25 : Declaration( other ), mangleName( other.mangleName ) { 26 26 } 27 27 -
src/SynTree/Expression.cc
r189243c rcc3528f 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri May 13 13:23:11201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 17:16:23 2016 13 13 // Update Count : 40 14 14 // … … 72 72 73 73 void ConstantExpr::print( std::ostream &os, int indent ) const { 74 os << "constant expression " ;74 os << std::string( indent, ' ' ) << "constant expression " ; 75 75 constant.print( os ); 76 76 Expression::print( os, indent ); 77 os << std::endl; 77 78 } 78 79 79 80 VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) { 80 assert( var );81 assert( var->get_type() );82 81 add_result( var->get_type()->clone() ); 83 82 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { … … 94 93 95 94 void VariableExpr::print( std::ostream &os, int indent ) const { 96 os << "Variable Expression: ";95 os << std::string( indent, ' ' ) << "Variable Expression: "; 97 96 98 97 Declaration *decl = get_var(); … … 123 122 124 123 void SizeofExpr::print( std::ostream &os, int indent) const { 125 os << "Sizeof Expression on: ";124 os << std::string( indent, ' ' ) << "Sizeof Expression on: "; 126 125 127 126 if (isType) … … 296 295 297 296 void CastExpr::print( std::ostream &os, int indent ) const { 298 os << "Cast of:" << std::endl << std::string( indent+2, ' ' );297 os << std::string( indent, ' ' ) << "Cast of:" << std::endl; 299 298 arg->print(os, indent+2); 300 299 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; … … 319 318 320 319 void UntypedMemberExpr::print( std::ostream &os, int indent ) const { 321 os << "UntypedMember Expression, with field: " << get_member();320 os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member(); 322 321 323 322 Expression *agg = get_aggregate(); 324 os << ", from aggregate: "; 325 if (agg != 0) { 326 os << std::string( indent + 2, ' ' ); 327 agg->print(os, indent + 2); 328 } 329 os << std::string( indent+2, ' ' ); 323 os << std::string( indent, ' ' ) << "from aggregate: "; 324 if (agg != 0) agg->print(os, indent + 2); 330 325 Expression::print( os, indent ); 331 326 } … … 350 345 351 346 void MemberExpr::print( std::ostream &os, int indent ) const { 352 os << "Member Expression, with field: " << std::endl;347 os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl; 353 348 354 349 assert( member ); … … 359 354 Expression *agg = get_aggregate(); 360 355 os << std::string( indent, ' ' ) << "from aggregate: " << std::endl; 361 if (agg != 0) { 362 os << std::string( indent + 2, ' ' ); 363 agg->print(os, indent + 2); 364 } 365 os << std::string( indent+2, ' ' ); 356 if (agg != 0) agg->print(os, indent + 2); 366 357 Expression::print( os, indent ); 367 358 } … … 381 372 382 373 void UntypedExpr::print( std::ostream &os, int indent ) const { 383 os << "Applying untyped: " << std::endl; 384 os << std::string( indent+2, ' ' ); 385 function->print(os, indent + 2); 374 os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl; 375 function->print(os, indent + 4); 386 376 os << std::string( indent, ' ' ) << "...to: " << std::endl; 387 printA ll(args, os, indent + 2);377 printArgs(os, indent + 4); 388 378 Expression::print( os, indent ); 389 379 } … … 391 381 void UntypedExpr::printArgs( std::ostream &os, int indent ) const { 392 382 std::list<Expression *>::const_iterator i; 393 for (i = args.begin(); i != args.end(); i++) { 394 os << std::string(indent, ' ' ); 383 for (i = args.begin(); i != args.end(); i++) 395 384 (*i)->print(os, indent); 396 }397 385 } 398 386 … … 405 393 406 394 void NameExpr::print( std::ostream &os, int indent ) const { 407 os << "Name: " << get_name() << std::endl;395 os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl; 408 396 Expression::print( os, indent ); 409 397 } … … 466 454 } 467 455 468 469 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {470 assert( callExpr );471 cloneAll( callExpr->get_results(), results );472 }473 474 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {475 cloneAll( other.tempDecls, tempDecls );476 cloneAll( other.returnDecls, returnDecls );477 cloneAll( other.dtors, dtors );478 }479 480 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {481 delete callExpr;482 deleteAll( tempDecls );483 deleteAll( returnDecls );484 deleteAll( dtors );485 }486 487 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {488 os << std::string( indent, ' ' ) << "Implicit Copy Constructor Expression: " << std::endl;489 assert( callExpr );490 callExpr->print( os, indent + 2 );491 os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;492 printAll(tempDecls, os, indent+2);493 os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;494 printAll(returnDecls, os, indent+2);495 Expression::print( os, indent );496 }497 498 456 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 499 457 -
src/SynTree/Expression.h
r189243c rcc3528f 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:06:49201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 17:18:06 2016 13 13 // Update Count : 21 14 14 // … … 22 22 #include "Mutator.h" 23 23 #include "Constant.h" 24 #include "Common/UniqueName.h"25 24 26 25 /// Expression is the root type for all expressions … … 560 559 }; 561 560 562 /// ImplicitCopyCtorExpr represents the application of a function to a set of parameters,563 /// along with a set of copy constructor calls, one for each argument.564 class ImplicitCopyCtorExpr : public Expression {565 public:566 ImplicitCopyCtorExpr( ApplicationExpr * callExpr );567 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );568 virtual ~ImplicitCopyCtorExpr();569 570 ApplicationExpr *get_callExpr() const { return callExpr; }571 void set_callExpr( ApplicationExpr *newValue ) { callExpr = newValue; }572 573 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }574 void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; }575 576 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }577 void set_returnDecls( std::list< ObjectDecl * > newValue ) { returnDecls = newValue; }578 579 std::list< Expression * > & get_dtors() { return dtors; }580 void set_dtors( std::list< Expression * > newValue ) { dtors = newValue; }581 582 virtual ImplicitCopyCtorExpr *clone() const { return new ImplicitCopyCtorExpr( *this ); }583 virtual void accept( Visitor &v ) { v.visit( this ); }584 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }585 virtual void print( std::ostream &os, int indent = 0 ) const;586 private:587 ApplicationExpr * callExpr;588 std::list< ObjectDecl * > tempDecls;589 std::list< ObjectDecl * > returnDecls;590 std::list< Expression * > dtors;591 };592 593 561 /// ValofExpr represents a GCC 'lambda expression' 594 562 class UntypedValofExpr : public Expression { -
src/SynTree/FunctionDecl.cc
r189243c rcc3528f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 15: 59:48201612 // Last Modified On : Fri May 06 15:41:05 2016 13 13 // Update Count : 19 14 14 // … … 100 100 if ( statements ) { 101 101 os << string( indent + 2, ' ' ) << "with body " << endl; 102 os << string( indent + 4, ' ' );103 102 statements->print( os, indent + 4 ); 104 103 } // if -
src/SynTree/Initializer.cc
r189243c rcc3528f 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 : Fri May 13 13:23:03 201613 // Update Count : 2812 // Last Modified On : Wed Aug 12 14:05:25 2015 13 // Update Count : 14 14 14 // 15 15 16 16 #include "Initializer.h" 17 17 #include "Expression.h" 18 #include "Statement.h"19 18 #include "Common/utility.h" 20 19 21 Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed) {}20 Initializer::Initializer() {} 22 21 23 22 Initializer::~Initializer() {} … … 32 31 void Initializer::print( std::ostream &os, int indent ) {} 33 32 34 SingleInit::SingleInit( Expression *v, const std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) {33 SingleInit::SingleInit( Expression *v, std::list< Expression *> &_designators ) : value ( v ), designators( _designators ) { 35 34 } 36 35 37 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value )) {36 SingleInit::SingleInit( const SingleInit &other ) : value ( other.value ) { 38 37 cloneAll(other.designators, designators ); 39 38 } … … 45 44 void SingleInit::print( std::ostream &os, int indent ) { 46 45 os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl; 47 os << std::string(indent+4, ' ' );48 46 value->print( os, indent+4 ); 49 47 50 48 if ( ! designators.empty() ) { 51 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;49 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " << std::endl; 52 50 for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ ) { 53 os << std::string(indent + 4, ' ' );54 51 ( *i )->print(os, indent + 4 ); 55 52 } … … 57 54 } 58 55 59 ListInit::ListInit( const std::list<Initializer*> &_initializers, const std::list<Expression *> &_designators, bool maybeConstructed)60 : Initializer( maybeConstructed),initializers( _initializers ), designators( _designators ) {56 ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators ) 57 : initializers( _initializers ), designators( _designators ) { 61 58 } 62 59 … … 68 65 69 66 void ListInit::print( std::ostream &os, int indent ) { 70 os << std::endl << std::string(indent, ' ') << "Compound initializer: "; 67 os << std::endl << std::string(indent, ' ') << "Compound initializer: "; 71 68 if ( ! designators.empty() ) { 72 69 os << std::string(indent + 2, ' ' ) << "designated by: ["; 73 70 for ( std::list < Expression * >::iterator i = designators.begin(); 74 71 i != designators.end(); i++ ) { 75 ( *i )->print(os, indent + 4 ); 72 ( *i )->print(os, indent + 4 ); 76 73 } // for 77 74 78 75 os << std::string(indent + 2, ' ' ) << "]"; 79 76 } // if 80 77 81 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++ ) 82 79 (*i)->print( os, indent + 2 ); 83 80 } 84 85 86 ConstructorInit::ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ) : Initializer( true ), ctor( ctor ), dtor( dtor ), init( init ) {}87 ConstructorInit::~ConstructorInit() {88 delete ctor;89 delete init;90 }91 92 ConstructorInit *ConstructorInit::clone() const {93 return new ConstructorInit( *this );94 }95 96 void ConstructorInit::print( std::ostream &os, int indent ) {97 os << std::endl << std::string(indent, ' ') << "Constructor initializer: " << std::endl;98 if ( ctor ) {99 os << std::string(indent+2, ' ');100 os << "initially constructed with ";101 ctor->print( os, indent+4 );102 } // if103 104 if ( dtor ) {105 os << std::string(indent+2, ' ');106 os << "destructed with ";107 dtor->print( os, indent+4 );108 }109 110 if ( init ) {111 os << std::string(indent+2, ' ');112 os << "with fallback C-style initializer: ";113 init->print( os, indent+4 );114 }115 }116 117 std::ostream & operator<<( std::ostream & out, Initializer * init ) {118 init->print( out );119 return out;120 }121 122 81 // Local Variables: // 123 82 // tab-width: 4 // -
src/SynTree/Initializer.h
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Tue Apr 12 13:49:13 201613 // Update Count : 1 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 09:03:48 2015 13 // Update Count : 1 14 14 // 15 15 … … 27 27 public: 28 28 // Initializer( std::string _name = std::string(""), int _pos = 0 ); 29 Initializer( bool maybeConstructed);29 Initializer( ); 30 30 virtual ~Initializer(); 31 31 … … 43 43 } 44 44 45 bool get_maybeConstructed() { return maybeConstructed; }46 47 45 virtual Initializer *clone() const = 0; 48 46 virtual void accept( Visitor &v ) = 0; … … 52 50 // std::string name; 53 51 // int pos; 54 bool maybeConstructed;55 52 }; 56 53 … … 58 55 class SingleInit : public Initializer { 59 56 public: 60 SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false);57 SingleInit( Expression *value, std::list< Expression *> &designators = *(new std::list<Expression *>()) ); 61 58 SingleInit( const SingleInit &other ); 62 59 virtual ~SingleInit(); 63 60 64 61 Expression *get_value() { return value; } 65 62 void set_value( Expression *newValue ) { value = newValue; } … … 82 79 class ListInit : public Initializer { 83 80 public: 84 ListInit( const std::list<Initializer*> &initializers,85 const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false);81 ListInit( std::list<Initializer*> &, 82 std::list<Expression *> &designators = *(new std::list<Expression *>()) ); 86 83 virtual ~ListInit(); 87 84 … … 103 100 }; 104 101 105 // ConstructorInit represents an initializer that is either a constructor expression or106 // a C-style initializer.107 class ConstructorInit : public Initializer {108 public:109 ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );110 virtual ~ConstructorInit();111 112 void set_ctor( Statement * newValue ) { ctor = newValue; }113 Statement * get_ctor() const { return ctor; }114 void set_dtor( Statement * newValue ) { dtor = newValue; }115 Statement * get_dtor() const { return dtor; }116 void set_init( Initializer * newValue ) { init = newValue; }117 Initializer * get_init() const { return init; }118 119 virtual ConstructorInit *clone() const;120 virtual void accept( Visitor &v ) { v.visit( this ); }121 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }122 virtual void print( std::ostream &os, int indent = 0 );123 124 private:125 Statement * ctor;126 Statement * dtor;127 // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback128 // if an appropriate constructor definition is not found by the resolver129 Initializer * init;130 };131 132 std::ostream & operator<<( std::ostream & out, Initializer * init );133 134 102 #endif // INITIALIZER_H 135 103 -
src/SynTree/Mutator.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:07:29201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 1 18:05:16 2016 13 13 // Update Count : 16 14 14 // … … 337 337 } 338 338 339 Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {340 impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );341 mutateAll( impCpCtorExpr->get_tempDecls(), *this );342 mutateAll( impCpCtorExpr->get_returnDecls(), *this );343 return impCpCtorExpr;344 }345 346 339 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 347 340 mutateAll( valofExpr->get_results(), *this ); … … 457 450 } 458 451 459 Initializer *Mutator::mutate( ConstructorInit *ctorInit ) {460 ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );461 ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );462 return ctorInit;463 }464 465 452 Subrange *Mutator::mutate( Subrange *subrange ) { 466 453 return subrange; -
src/SynTree/Mutator.h
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:32:00201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 1 17:26:56 2016 13 13 // Update Count : 10 14 14 // … … 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 ); … … 76 76 virtual Expression* mutate( TypeExpr *typeExpr ); 77 77 virtual Expression* mutate( AsmExpr *asmExpr ); 78 virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr );79 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 80 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); … … 97 96 virtual Initializer* mutate( SingleInit *singleInit ); 98 97 virtual Initializer* mutate( ListInit *listInit ); 99 virtual Initializer* mutate( ConstructorInit *ctorInit );100 98 101 99 virtual Subrange *mutate( Subrange *subrange ); -
src/SynTree/ObjectDecl.cc
r189243c rcc3528f 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 : Fri May 13 13:23:32 201613 // Update Count : 3012 // Last Modified On : Tue Sep 29 14:13:01 2015 13 // Update Count : 18 14 14 // 15 15 … … 19 19 #include "Expression.h" 20 20 #include "Common/utility.h" 21 #include "Statement.h"22 21 23 22 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn ) … … 59 58 os << " with initializer "; 60 59 init->print( os, indent ); 61 os << std::endl << std::string(indent, ' ');62 os << "maybeConstructed? " << init->get_maybeConstructed();63 60 } // if 64 61 65 62 if ( bitfieldWidth ) { 66 os << std::string(indent, ' ');67 63 os << " with bitfield width "; 68 64 bitfieldWidth->print( os ); … … 73 69 #if 0 74 70 if ( get_mangleName() != "") { 75 os << get_mangleName() << ": "; 76 } else 71 os << get_mangleName() << ": "; 72 } else 77 73 #endif 78 74 if ( get_name() != "" ) { -
src/SynTree/Statement.cc
r189243c rcc3528f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu May 12 13:33:18 201612 // Last Modified On : Wed Dec 09 14:09:34 2015 13 13 // Update Count : 54 14 14 // … … 43 43 44 44 void ExprStmt::print( std::ostream &os, int indent ) const { 45 os << "Expression Statement:" << endl << std::string( indent + 2, ' ' );45 os << string( indent, ' ' ) << "Expression Statement:" << endl; 46 46 expr->print( os, indent + 2 ); 47 47 } … … 110 110 111 111 void ReturnStmt::print( std::ostream &os, int indent ) const { 112 os << string ( isThrow? "Throw":"Return" ) << " Statement, returning: "; 113 if ( expr != 0 ) { 114 os << endl << string( indent+2, ' ' ); 115 expr->print( os, indent + 2 ); 116 } 112 os << std::string( indent, ' ' ) << string ( isThrow? "Throw":"Return" ) << " Statement, returning: "; 113 if ( expr != 0 ) expr->print( os ); 117 114 os << endl; 118 115 } … … 127 124 128 125 void IfStmt::print( std::ostream &os, int indent ) const { 129 os << "If on condition: " << endl ; 130 os << string( indent+4, ' ' ); 126 os << string( indent, ' ' ) << "If on condition: " << endl ; 131 127 condition->print( os, indent + 4 ); 132 128 133 os << string( indent+2, ' ' ) << "... then: " << endl; 134 135 os << string( indent+4, ' ' ); 129 os << string( indent, ' ' ) << ".... and branches: " << endl; 130 136 131 thenPart->print( os, indent + 4 ); 137 132 138 133 if ( elsePart != 0 ) { 139 os << string( indent+2, ' ' ) << "... else: " << endl;140 os << string( indent+4, ' ' );141 134 elsePart->print( os, indent + 4 ); 142 135 } // if … … 160 153 161 154 void SwitchStmt::print( std::ostream &os, int indent ) const { 162 os << "Switch on condition: ";155 os << string( indent, ' ' ) << "Switch on condition: "; 163 156 condition->print( os ); 164 157 os << endl; … … 225 218 226 219 void ChooseStmt::print( std::ostream &os, int indent ) const { 227 os << "Choose on condition: ";220 os << string( indent, ' ' ) << "Choose on condition: "; 228 221 condition->print( os ); 229 222 os << endl; … … 254 247 255 248 void WhileStmt::print( std::ostream &os, int indent ) const { 256 os << "While on condition: " << endl ;249 os << string( indent, ' ' ) << "While on condition: " << endl ; 257 250 condition->print( os, indent + 4 ); 258 251 … … 280 273 281 274 void ForStmt::print( std::ostream &os, int indent ) const { 282 os << "Labels: {";275 os << string( indent, ' ' ) << "Labels: {"; 283 276 for ( std::list<Label>::const_iterator it = get_labels().begin(); it != get_labels().end(); ++it) { 284 277 os << *it << ","; … … 290 283 os << string( indent + 2, ' ' ) << "initialization: \n"; 291 284 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) { 292 os << string( indent + 4, ' ' );293 285 (*it)->print( os, indent + 4 ); 294 286 } 295 287 296 288 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 297 if ( condition != 0 ) { 298 os << string( indent + 4, ' ' ); 289 if ( condition != 0 ) 299 290 condition->print( os, indent + 4 ); 300 }301 291 302 292 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 303 if ( increment != 0 ) { 304 os << string( indent + 4, ' ' ); 293 if ( increment != 0 ) 305 294 increment->print( os, indent + 4 ); 306 }307 295 308 296 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 309 if ( body != 0 ) { 310 os << string( indent + 4, ' ' ); 297 if ( body != 0 ) 311 298 body->print( os, indent + 4 ); 312 }313 299 314 300 os << endl; … … 328 314 329 315 void TryStmt::print( std::ostream &os, int indent ) const { 330 os << "Try Statement" << endl;316 os << string( indent, ' ' ) << "Try Statement" << endl; 331 317 os << string( indent + 2, ' ' ) << "with block: " << endl; 332 318 block->print( os, indent + 4 ); … … 392 378 393 379 void NullStmt::print( std::ostream &os, int indent ) const { 394 os << "Null Statement" << endl ;380 os << string( indent, ' ' ) << "Null Statement" << endl ; 395 381 } 396 382 -
src/SynTree/SynTree.h
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:31:36201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 1 16:47:44 2016 13 13 // Update Count : 5 14 14 // … … 81 81 class TypeExpr; 82 82 class AsmExpr; 83 class ImplicitCopyCtorExpr;84 83 class UntypedValofExpr; 85 84 class CompoundLiteralExpr; … … 105 104 class SingleInit; 106 105 class ListInit; 107 class ConstructorInit;108 106 109 107 class Subrange; -
src/SynTree/TypeSubstitution.cc
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeSubstitution.cc -- 7 // TypeSubstitution.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Apr 26 11:15:29201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:29:15 2016 13 13 // Update Count : 3 14 14 // … … 96 96 BoundVarsType::const_iterator bound = boundVars.find( inst->get_name() ); 97 97 if ( bound != boundVars.end() ) return inst; 98 98 99 99 TypeEnvType::const_iterator i = typeEnv.find( inst->get_name() ); 100 100 if ( i == typeEnv.end() ) { … … 217 217 } 218 218 219 std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub ) {220 sub.print( out );221 return out;222 }223 224 225 219 // Local Variables: // 226 220 // tab-width: 4 // -
src/SynTree/TypeSubstitution.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeSubstitution.h -- 7 // TypeSubstitution.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Apr 29 15:00:20201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:33:19 2016 13 13 // Update Count : 2 14 14 // … … 33 33 TypeSubstitution( const TypeSubstitution &other ); 34 34 virtual ~TypeSubstitution(); 35 35 36 36 TypeSubstitution &operator=( const TypeSubstitution &other ); 37 37 38 38 template< typename SynTreeClass > int apply( SynTreeClass *&input ); 39 39 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ); 40 40 41 41 void add( std::string formalType, Type *actualType ); 42 42 void add( const TypeSubstitution &other ); … … 44 44 Type *lookup( std::string formalType ) const; 45 45 bool empty() const; 46 46 47 47 template< typename FormalIterator, typename ActualIterator > 48 48 void add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ); 49 50 /// this function is unused... 49 51 50 template< typename TypeInstListIterator > 52 51 void extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result ); 53 52 54 53 void normalize(); 55 54 … … 64 63 /// Records type variable bindings from forall-statements and instantiations of generic types 65 64 template< typename TypeClass > Type *handleAggregateType( TypeClass *type ); 66 65 67 66 virtual Type* mutate(VoidType *basicType); 68 67 virtual Type* mutate(BasicType *basicType); … … 76 75 virtual Type* mutate(TupleType *tupleType); 77 76 virtual Type* mutate(VarArgsType *varArgsType); 78 77 79 78 // TODO: worry about traversing into a forall-qualified function type or type decl with assertions 80 79 81 80 void initialize( const TypeSubstitution &src, TypeSubstitution &dest ); 82 81 … … 137 136 return subCount; 138 137 } 139 138 140 139 template< typename SynTreeClass > 141 140 int TypeSubstitution::applyFree( SynTreeClass *&input ) { … … 150 149 return subCount; 151 150 } 152 151 153 152 template< typename TypeInstListIterator > 154 153 void TypeSubstitution::extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result ) { 155 // xxx - this function doesn't extract varEnv - is this intentional?156 154 while ( begin != end ) { 157 155 TypeEnvType::iterator cur = typeEnv.find( (*begin++)->get_name() ); … … 175 173 } 176 174 177 std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub );178 179 175 #endif // TYPESUBSTITUTION_H 180 176 -
src/SynTree/Visitor.cc
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:07:40201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 1 18:05:13 2016 13 13 // Update Count : 18 14 14 // … … 284 284 } 285 285 286 void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {287 maybeAccept( impCpCtorExpr->get_callExpr(), *this );288 acceptAll( impCpCtorExpr->get_tempDecls(), *this );289 acceptAll( impCpCtorExpr->get_returnDecls(), *this );290 }291 292 286 void Visitor::visit( UntypedValofExpr *valofExpr ) { 293 287 acceptAll( valofExpr->get_results(), *this ); … … 385 379 } 386 380 387 void Visitor::visit( ConstructorInit *ctorInit ) {388 maybeAccept( ctorInit->get_ctor(), *this );389 maybeAccept( ctorInit->get_init(), *this );390 }391 392 381 void Visitor::visit( Subrange *subrange ) {} 393 382 -
src/SynTree/Visitor.h
r189243c rcc3528f 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 : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:30:58201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 1 17:26:55 2016 13 13 // Update Count : 7 14 14 // … … 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 ); … … 76 76 virtual void visit( TypeExpr *typeExpr ); 77 77 virtual void visit( AsmExpr *asmExpr ); 78 virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr );79 78 virtual void visit( UntypedValofExpr *valofExpr ); 80 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); … … 97 96 virtual void visit( SingleInit *singleInit ); 98 97 virtual void visit( ListInit *listInit ); 99 virtual void visit( ConstructorInit *ctorInit );100 98 101 99 virtual void visit( Subrange *subrange ); -
src/examples/array.c
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // array.c -- 7 // array.c -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:21:52 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 18:13:52 2016 13 13 // Update Count : 3 14 14 // … … 26 26 // The first element is always at index 0. 27 27 forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) 28 elt_type * begin( array_type *array ) {28 elt_type * begin( array_type array ) { 29 29 return &array[ 0 ]; 30 30 } … … 32 32 // The end iterator should point one past the last element. 33 33 forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) 34 elt_type * end( array_type *array ) {34 elt_type * end( array_type array ) { 35 35 return &array[ last( array ) ] + 1; 36 36 } -
src/examples/array.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // array.h -- 7 // array.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:26:04201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 18:13:35 2016 13 13 // Update Count : 5 14 14 // … … 26 26 27 27 // A bounded array is an array that carries its maximum index with it. 28 trait bounded_array( otype array_type, otype elt_type | array( array_type *, elt_type ) ) {29 int last( array_type *);28 trait bounded_array( otype array_type, otype elt_type | array( array_type, elt_type ) ) { 29 int last( array_type ); 30 30 }; 31 31 … … 41 41 // return iterators corresponding to the first element and the one-past-the-end element, STL-style. 42 42 forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) 43 elt_type * begin( array_type * array);43 elt_type *begin( array_type ); 44 44 45 // The end iterator should point one past the last element.46 45 forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) 47 elt_type * end( array_type * array);46 elt_type *end( array_type ); 48 47 49 48 #endif // ARRAY_H -
src/examples/rational.c
r189243c rcc3528f 11 11 // Created On : Mon Mar 28 08:43:12 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed May 4 14:19:36201614 // Update Count : 2 413 // Last Modified On : Fri Apr 8 11:27:48 2016 14 // Update Count : 21 15 15 // 16 16 … … 20 20 21 21 int main() { 22 Rational a, b, c; 22 23 sout | "constructor" | endl; 23 Rational a = { 3 }, b = { 4 }, c; 24 a = rational( 3 ); 25 b = rational( 4 ); 26 c = rational(); 24 27 sout | a | b | c | endl; 25 a = (Rational){ 4, 8 };26 b = (Rational){ 5, 7 };28 a = rational( 4, 8 ); 29 b = rational( 5, 7 ); 27 30 sout | a | b | endl; 28 a = (Rational){ -2, -3 };29 b = (Rational){ 3, -2 };31 a = rational( -2, -3 ); 32 b = rational( 3, -2 ); 30 33 sout | a | b | endl; 31 a = (Rational){ -2, 3 };32 b = (Rational){ 3, 2 };34 a = rational( -2, 3 ); 35 b = rational( 3, 2 ); 33 36 sout | a | b | endl; 34 37 35 38 sout | "logical" | endl; 36 a = (Rational){ -2 };37 b = (Rational){ -3, 2 };39 a = rational( -2 ); 40 b = rational( -3, 2 ); 38 41 sout | a | b | endl; 39 42 sout | a == 1 | endl; … … 52 55 53 56 sout | "conversion" | endl; 54 a = (Rational){ 3, 4 };57 a = rational( 3, 4 ); 55 58 sout | widen( a ) | endl; 56 a = (Rational){ 1, 7 };59 a = rational( 1, 7 ); 57 60 sout | widen( a ) | endl; 58 a = (Rational){ 355, 113 };61 a = rational( 355, 113 ); 59 62 sout | widen( a ) | endl; 60 63 sout | narrow( 0.75, 4 ) | endl; … … 62 65 sout | narrow( 3.14159265358979, 256 ) | endl; 63 66 64 Rational x = { 1, 2 }, y = { 2 }; 67 Rational x, y; 68 x = rational( 1, 2 ); 69 y = rational( 2 ); 65 70 sout | x - y | endl; 66 71 sout | x > y | endl; … … 68 73 sout | y | denominator( y, -2 ) | y | endl; 69 74 70 Rational z = { 0, 5 }; 75 Rational z; 76 z = rational( 0, 5 ); 71 77 sout | z | endl; 72 78 73 79 sout | x | numerator( x, 0 ) | x | endl; 74 80 75 x = (Rational){ 1, MAX } + (Rational){ 1, MAX };81 x = rational( 1, MAX ) + rational( 1, MAX ); 76 82 sout | x | endl; 77 x = (Rational){ 3, MAX } + (Rational){ 2, MAX };83 x = rational( 3, MAX ) + rational( 2, MAX ); 78 84 sout | x | endl; 79 85 -
src/examples/vector_int.c
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // vector_int.c -- 7 // vector_int.c -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:27:12 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:38:05 2015 13 13 // Update Count : 3 14 14 // … … 22 22 #define DEFAULT_CAPACITY 20 23 23 24 v oid ?{}( vector_int * vec) {25 vec { DEFAULT_CAPACITY };24 vector_int vector_int_allocate() { 25 return vector_int_allocate( DEFAULT_CAPACITY ); 26 26 } 27 27 28 void ?{}( vector_int * vec, int reserve ) { 29 vec->last = -1; 30 vec->capacity = reserve; 31 vec->data = malloc( sizeof( int ) * reserve ); 28 vector_int vector_int_allocate( int reserve ) { 29 vector_int new_vector; 30 new_vector.last = -1; 31 new_vector.capacity = reserve; 32 new_vector.data = malloc( sizeof( int ) * reserve ); 33 return new_vector; 32 34 } 33 35 34 void ?{}( vector_int * vec, vector_int other ) { 35 vec->last = other.last; 36 vec->capacity = other.capacity; 37 vec->data = malloc( sizeof( int ) * other.capacity ); 38 for (int i = 0; i < vec->last; i++) { 39 vec->data[i] = other.data[i]; 40 } 41 } 42 43 void ^?{}( vector_int * vec ) { 44 free( vec->data ); 36 void vector_int_deallocate( vector_int vec ) { 37 free( vec.data ); 45 38 } 46 39 … … 63 56 // implement bounded_array 64 57 65 lvalue int ?[?]( vector_int *vec, int index ) {66 return vec ->data[ index ];58 lvalue int ?[?]( vector_int vec, int index ) { 59 return vec.data[ index ]; 67 60 } 68 61 69 int last( vector_int *vec ) {70 return vec ->last;62 int last( vector_int vec ) { 63 return vec.last; 71 64 } 72 65 -
src/examples/vector_int.h
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // vector_int.h -- 7 // vector_int.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:26:59 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:39:05 2015 13 13 // Update Count : 2 14 14 // … … 25 25 } vector_int; 26 26 27 void ?{}( vector_int * ); // allocate vector with default capacity 28 void ?{}( vector_int *, int reserve ); // allocate vector with specified capacity 29 void ?{}( vector_int * vec, vector_int other ); // copy constructor 30 void ^?{}( vector_int * ); // deallocate vector's storage 27 vector_int vector_int_allocate(); // allocate vector with default capacity 28 vector_int vector_int_allocate( int reserve ); // allocate vector with specified capacity 29 void vector_int_deallocate( vector_int ); // deallocate vector's storage 31 30 32 31 void reserve( vector_int *vec, int reserve ); // reserve more capacity … … 35 34 // implement bounded_array 36 35 37 lvalue int ?[?]( vector_int *vec, int index ); // access to arbitrary element (does not resize)38 int last( vector_int *vec ); // return last element36 lvalue int ?[?]( vector_int vec, int index ); // access to arbitrary element (does not resize) 37 int last( vector_int vec ); // return last element 39 38 40 39 #endif // VECTOR_INT_H -
src/examples/vector_test.c
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // vector_test.c -- 7 // vector_test.c -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:31:27201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 17 12:23:55 2016 13 13 // Update Count : 18 14 14 // … … 20 20 21 21 int main( void ) { 22 vector_int vec ;22 vector_int vec = vector_int_allocate(); 23 23 24 24 // read in numbers until EOF or error … … 34 34 35 35 sout | "Array elements:" | endl; 36 write( begin( &vec ), end( &vec ), sout );36 write( begin( vec ), end( vec ), sout ); 37 37 sout | endl; 38 38 39 39 sout | "Array elements reversed:" | endl; 40 write_reverse( begin( &vec ), end( &vec ), sout );40 write_reverse( begin( vec ), end( vec ), sout ); 41 41 sout | endl; 42 42 } -
src/initialization.txt
r189243c rcc3528f 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 correct42 > results from the unification engine is by feeding it an expression that43 > looks like "?=?( ((struct Y)x.y).a, 10 )", then picking out the pieces that44 > I need (namely the correct choice for a). Does this seem like a reasonable45 > 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 assignment49 operators that happen to be in scope (and which may include50 user-defined operators) to guide the type resolution.51 52 I don't think there is any way to rewrite an initializer as a single53 expression and have the resolver just do the right thing. I see the54 algorithm as:55 56 For each alternative interpretation of the designator:57 Construct an expression that casts the initializer to the type of58 the designator59 Construct an AlternativeFinder and use it to find the lowest cost60 interpretation of the expression61 Add this interpretation to a list of possibilities62 Go through the list of possibilities and pick the lowest cost63 64 As with many things in the resolver, it's conceptually simple but the65 implementation may be a bit of a pain. It fits in with functions like66 findSingleExpression, findIntegralExpression in Resolver.cc, although67 it will be significantly more complicated than any of the existing68 ones.69 70 71 -
src/libcfa/Makefile.am
r189243c rcc3528f 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## Makefile.am -- 8 ## Makefile.am -- 9 9 ## 10 10 ## Author : Peter A. Buhr … … 51 51 52 52 CFLAGS = -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2 53 CC = ${abs_top_srcdir}/src/driver/cfa 53 CC = ${abs_top_srcdir}/src/driver/cfa 54 54 55 55 # extension-less header files are overridden by default make rules => explicitly override rule … … 67 67 include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders} 68 68 69 CLEANFILES = libcfa-prelude.c70 69 MAINTAINERCLEANFILES += ${includedir}/* -
src/libcfa/Makefile.in
r189243c rcc3528f 111 111 AWK = @AWK@ 112 112 BACKEND_CC = @BACKEND_CC@ 113 CC = ${abs_top_srcdir}/src/driver/cfa 113 CC = ${abs_top_srcdir}/src/driver/cfa 114 114 CCDEPMODE = @CCDEPMODE@ 115 115 CFA_BINDIR = @CFA_BINDIR@ … … 219 219 cfaheaders = # limits 220 220 include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders} 221 CLEANFILES = libcfa-prelude.c222 221 all: all-am 223 222 … … 458 457 459 458 clean-generic: 460 -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)461 459 462 460 distclean-generic: -
src/libcfa/fstream.c
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fstream.c -- 7 // fstream.c -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon May 02 15:14:52201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 27 18:20:30 2016 13 13 // Update Count : 187 14 14 // … … 75 75 if ( fclose( (FILE *)(os->file) ) == EOF ) { 76 76 perror( IO_MSG "close output" ); 77 } // if 77 } // if 78 78 } // close 79 79 … … 140 140 if ( fclose( (FILE *)(is->file) ) == EOF ) { 141 141 perror( IO_MSG "close input" ); 142 } // if 142 } // if 143 143 } // close 144 144 … … 155 155 return is; 156 156 } // read 157 157 158 158 ifstream *ungetc( ifstream * is, char c ) { 159 159 if ( fail( is ) ) { -
src/libcfa/iostream.c
r189243c rcc3528f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // iostream.c -- 7 // iostream.c -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon May 02 15:13:55201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 30 14:00:53 2016 13 13 // Update Count : 302 14 14 // … … 184 184 } // ?|? 185 185 186 187 forall( dtype ostype | ostream( ostype ) ) 186 forall( dtype ostype | ostream( ostype ) ) 188 187 ostype * ?|?( ostype *os, ostype * (* manip)( ostype * ) ) { 189 188 return manip( os ); 190 189 } // ?|? 191 190 192 forall( dtype ostype | ostream( ostype ) ) 191 forall( dtype ostype | ostream( ostype ) ) 193 192 ostype * endl( ostype * os ) { 194 193 os | '\n'; … … 198 197 } // endl 199 198 200 forall( dtype ostype | ostream( ostype ) ) 199 forall( dtype ostype | ostream( ostype ) ) 201 200 ostype * sepOn( ostype * os ) { 202 201 sepOn( os ); … … 204 203 } // sepOn 205 204 206 forall( dtype ostype | ostream( ostype ) ) 205 forall( dtype ostype | ostream( ostype ) ) 207 206 ostype * sepOff( ostype * os ) { 208 207 sepOff( os ); … … 210 209 } // sepOff 211 210 212 forall( dtype ostype | ostream( ostype ) ) 211 forall( dtype ostype | ostream( ostype ) ) 213 212 ostype * sepEnable( ostype * os ) { 214 213 sepEnable( os ); … … 216 215 } // sepEnable 217 216 218 forall( dtype ostype | ostream( ostype ) ) 217 forall( dtype ostype | ostream( ostype ) ) 219 218 ostype * sepDisable( ostype * os ) { 220 219 sepDisable( os ); … … 336 335 } // ?|? 337 336 338 _Istream_cstrUC cstr( char * s tr ) { _Istream_cstrUC s = { str}; return s; }337 _Istream_cstrUC cstr( char * s ) { _Istream_cstrUC s = { s }; return s; } 339 338 forall( dtype istype | istream( istype ) ) 340 339 istype * ?|?( istype * is, _Istream_cstrUC cstr ) { … … 343 342 } // cstr 344 343 345 _Istream_cstrC cstr( char * s tr, int size ) { _Istream_cstrC s = { str, size }; return s; }344 _Istream_cstrC cstr( char * s, int size ) { _Istream_cstrC s = { s, size }; return s; } 346 345 forall( dtype istype | istream( istype ) ) 347 346 istype * ?|?( istype * is, _Istream_cstrC cstr ) { -
src/libcfa/prelude.cf
r189243c rcc3528f 1 1 # 2 "prelude.cf" // needed for error messages from this file 2 // -*- Mode: C -*- 3 // 2 // -*- Mode: C -*- 3 // 4 4 // Copyright (C) Glen Ditchfield 1994, 1999 5 // 5 // 6 6 // prelude.cf -- Standard Cforall Preample for C99 7 // 7 // 8 8 // Author : Glen Ditchfield 9 9 // Created On : Sat Nov 29 07:23:41 2014 … … 117 117 forall( ftype FT ) lvalue FT *?( FT * ); 118 118 119 _Bool +?( _Bool ), -?( _Bool ), ~?( _Bool ); 120 signed int +?( signed int ), -?( signed int ), ~?( signed int ); 121 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int ); 122 signed long int +?( signed long int ), -?( signed long int ), ~?( signed long int ); 123 unsigned long int +?( unsigned long int ), -?( unsigned long int ), ~?( unsigned long int ); 124 signed long long int +?( signed long long int ), -?( signed long long int ), ~?( signed long long int ); 125 unsigned long long int +?( unsigned long long int ), -?( unsigned long long int ), ~?( unsigned long long int ); 119 _Bool +?( _Bool ), -?( _Bool ), ~?( _Bool ); 120 signed int +?( signed int ), -?( signed int ), ~?( signed int ); 121 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int ); 122 signed long int +?( signed long int ), -?( signed long int ), ~?( signed long int ); 123 unsigned long int +?( unsigned long int ), -?( unsigned long int ), ~?( unsigned long int ); 124 signed long long int +?( signed long long int ), -?( signed long long int ), ~?( signed long long int ); 125 unsigned long long int +?( unsigned long long int ), -?( unsigned long long int ), ~?( unsigned long long int ); 126 126 float +?( float ), -?( float ); 127 127 double +?( double ), -?( double ); … … 627 627 ?+=?( long double _Complex *, long double _Complex ), ?+=?( volatile long double _Complex *, long double _Complex ), 628 628 ?-=?( long double _Complex *, long double _Complex ), ?-=?( volatile long double _Complex *, long double _Complex ); 629 630 631 632 633 634 // ------------------------------------------------------------635 //636 // Section ??? Constructors and Destructors637 //638 // ------------------------------------------------------------639 640 // default ctor641 void ?{}( _Bool * ), ?{}( volatile _Bool * );642 void ?{}( char * ), ?{}( volatile char * );643 void ?{}( unsigned char * ), ?{}( volatile unsigned char * );644 void ?{}( char signed * ), ?{}( volatile char signed * );645 void ?{}( int short * ), ?{}( volatile int short * );646 void ?{}( int short unsigned * ), ?{}( volatile int short unsigned * );647 void ?{}( signed int * ), ?{}( volatile signed int * );648 void ?{}( unsigned int * ), ?{}( volatile unsigned int * );649 void ?{}( signed long int * ), ?{}( volatile signed long int * );650 void ?{}( unsigned long int * ), ?{}( volatile unsigned long int * );651 void ?{}( signed long long int * ), ?{}( volatile signed long long int * );652 void ?{}( unsigned long long int * ), ?{}( volatile unsigned long long int * );653 void ?{}( float * ), ?{}( volatile float * );654 void ?{}( double * ), ?{}( volatile double * );655 void ?{}( long double * ), ?{}( volatile long double * );656 void ?{}( float _Complex * ), ?{}( volatile float _Complex * );657 void ?{}( double _Complex * ), ?{}( volatile double _Complex * );658 void ?{}( long double _Complex * ), ?{}( volatile long double _Complex * );659 660 // copy ctor661 void ?{}( _Bool *, _Bool ), ?{}( volatile _Bool *, _Bool );662 void ?{}( char *, char ), ?{}( volatile char *, char );663 void ?{}( unsigned char *, unsigned char ), ?{}( volatile unsigned char *, unsigned char );664 void ?{}( char signed *, char signed ), ?{}( volatile char signed *, char signed );665 void ?{}( int short *, int short ), ?{}( volatile int short *, int short );666 void ?{}( int short unsigned *, int short unsigned ), ?{}( volatile int short unsigned *, int short unsigned );667 void ?{}( signed int *, signed int), ?{}( volatile signed int *, signed int );668 void ?{}( unsigned int *, unsigned int), ?{}( volatile unsigned int *, unsigned int );669 void ?{}( signed long int *, signed long int), ?{}( volatile signed long int *, signed long int );670 void ?{}( unsigned long int *, unsigned long int), ?{}( volatile unsigned long int *, unsigned long int );671 void ?{}( signed long long int *, signed long long int), ?{}( volatile signed long long int *, signed long long int );672 void ?{}( unsigned long long int *, unsigned long long int), ?{}( volatile unsigned long long int *, unsigned long long int );673 void ?{}( float *, float), ?{}( volatile float *, float );674 void ?{}( double *, double), ?{}( volatile double *, double );675 void ?{}( long double *, long double), ?{}( volatile long double *, long double );676 void ?{}( float _Complex *, float _Complex), ?{}( volatile float _Complex *, float _Complex );677 void ?{}( double _Complex *, double _Complex), ?{}( volatile double _Complex *, double _Complex );678 void ?{}( long double _Complex *, long double _Complex), ?{}( volatile long double _Complex *, long double _Complex );679 680 // dtor681 void ^?{}( _Bool * ), ^?{}( volatile _Bool * );682 void ^?{}( char * ), ^?{}( volatile char * );683 void ^?{}( char unsigned * ), ^?{}( volatile char unsigned * );684 void ^?{}( char signed * ), ^?{}( volatile char signed * );685 void ^?{}( int short * ), ^?{}( volatile int short * );686 void ^?{}( int short unsigned * ), ^?{}( volatile int short unsigned * );687 void ^?{}( signed int * ), ^?{}( volatile signed int * );688 void ^?{}( unsigned int * ), ^?{}( volatile unsigned int * );689 void ^?{}( signed long int * ), ^?{}( volatile signed long int * );690 void ^?{}( unsigned long int * ), ^?{}( volatile unsigned long int * );691 void ^?{}( signed long long int * ), ^?{}( volatile signed long long int * );692 void ^?{}( unsigned long long int * ), ^?{}( volatile unsigned long long int * );693 void ^?{}( float * ), ^?{}( volatile float * );694 void ^?{}( double * ), ^?{}( volatile double * );695 void ^?{}( long double * ), ^?{}( volatile long double * );696 void ^?{}( float _Complex * ), ^?{}( volatile float _Complex * );697 void ^?{}( double _Complex * ), ^?{}( volatile double _Complex * );698 void ^?{}( long double _Complex * ), ^?{}( volatile long double _Complex * );699 700 // // default ctor701 // forall( dtype DT ) void ?{}( DT ** );702 // forall( dtype DT ) void ?{}( const DT ** );703 // forall( dtype DT ) void ?{}( volatile DT ** );704 // forall( dtype DT ) void ?{}( const volatile DT ** );705 706 // // copy ctor707 // forall( dtype DT ) void ?{}( DT **, DT* );708 // forall( dtype DT ) void ?{}( const DT **, DT* );709 // forall( dtype DT ) void ?{}( volatile DT **, DT* );710 // forall( dtype DT ) void ?{}( const volatile DT **, DT* );711 712 // // dtor713 // forall( dtype DT ) void ^?{}( DT ** );714 // forall( dtype DT ) void ^?{}( const DT ** );715 // forall( dtype DT ) void ^?{}( volatile DT ** );716 // forall( dtype DT ) void ^?{}( const volatile DT ** );717 718 // copied from assignment section719 // copy constructors720 forall( ftype FT ) void ?{}( FT **, FT * );721 forall( ftype FT ) void ?{}( FT * volatile *, FT * );722 723 forall( dtype DT ) void ?{}( DT * *, DT * );724 forall( dtype DT ) void ?{}( DT * volatile *, DT * );725 forall( dtype DT ) void ?{}( const DT * *, DT * );726 forall( dtype DT ) void ?{}( const DT * volatile *, DT * );727 forall( dtype DT ) void ?{}( const DT * *, const DT * );728 forall( dtype DT ) void ?{}( const DT * volatile *, const DT * );729 forall( dtype DT ) void ?{}( volatile DT * *, DT * );730 forall( dtype DT ) void ?{}( volatile DT * volatile *, DT * );731 forall( dtype DT ) void ?{}( volatile DT * *, volatile DT * );732 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile DT * );733 734 forall( dtype DT ) void ?{}( const volatile DT * *, DT * );735 forall( dtype DT ) void ?{}( const volatile DT * volatile *, DT * );736 forall( dtype DT ) void ?{}( const volatile DT * *, const DT * );737 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const DT * );738 forall( dtype DT ) void ?{}( const volatile DT * *, volatile DT * );739 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile DT * );740 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile DT * );741 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile DT * );742 743 forall( dtype DT ) void ?{}( DT * *, void * );744 forall( dtype DT ) void ?{}( DT * volatile *, void * );745 forall( dtype DT ) void ?{}( const DT * *, void * );746 forall( dtype DT ) void ?{}( const DT * volatile *, void * );747 forall( dtype DT ) void ?{}( const DT * *, const void * );748 forall( dtype DT ) void ?{}( const DT * volatile *, const void * );749 forall( dtype DT ) void ?{}( volatile DT * *, void * );750 forall( dtype DT ) void ?{}( volatile DT * volatile *, void * );751 forall( dtype DT ) void ?{}( volatile DT * *, volatile void * );752 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile void * );753 754 forall( dtype DT ) void ?{}( const volatile DT * *, void * );755 forall( dtype DT ) void ?{}( const volatile DT * volatile *, void * );756 forall( dtype DT ) void ?{}( const volatile DT * *, const void * );757 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const void * );758 forall( dtype DT ) void ?{}( const volatile DT * *, volatile void * );759 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile void * );760 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile void * );761 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile void * );762 763 forall( dtype DT ) void ?{}( void * *, DT * );764 forall( dtype DT ) void ?{}( void * volatile *, DT * );765 forall( dtype DT ) void ?{}( const void * *, DT * );766 forall( dtype DT ) void ?{}( const void * volatile *, DT * );767 forall( dtype DT ) void ?{}( const void * *, const DT * );768 forall( dtype DT ) void ?{}( const void * volatile *, const DT * );769 forall( dtype DT ) void ?{}( volatile void * *, DT * );770 forall( dtype DT ) void ?{}( volatile void * volatile *, DT * );771 forall( dtype DT ) void ?{}( volatile void * *, volatile DT * );772 forall( dtype DT ) void ?{}( volatile void * volatile *, volatile DT * );773 forall( dtype DT ) void ?{}( const volatile void * *, DT * );774 forall( dtype DT ) void ?{}( const volatile void * volatile *, DT * );775 forall( dtype DT ) void ?{}( const volatile void * *, const DT * );776 forall( dtype DT ) void ?{}( const volatile void * volatile *, const DT * );777 forall( dtype DT ) void ?{}( const volatile void * *, volatile DT * );778 forall( dtype DT ) void ?{}( const volatile void * volatile *, volatile DT * );779 forall( dtype DT ) void ?{}( const volatile void * *, const volatile DT * );780 forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile DT * );781 782 void ?{}( void * *, void * );783 void ?{}( void * volatile *, void * );784 void ?{}( const void * *, void * );785 void ?{}( const void * volatile *, void * );786 void ?{}( const void * *, const void * );787 void ?{}( const void * volatile *, const void * );788 void ?{}( volatile void * *, void * );789 void ?{}( volatile void * volatile *, void * );790 void ?{}( volatile void * *, volatile void * );791 void ?{}( volatile void * volatile *, volatile void * );792 void ?{}( const volatile void * *, void * );793 void ?{}( const volatile void * volatile *, void * );794 void ?{}( const volatile void * *, const void * );795 void ?{}( const volatile void * volatile *, const void * );796 void ?{}( const volatile void * *, volatile void * );797 void ?{}( const volatile void * volatile *, volatile void * );798 void ?{}( const volatile void * *, const volatile void * );799 void ?{}( const volatile void * volatile *, const volatile void * );800 801 //forall( dtype DT ) void ?{}( DT * *, forall( dtype DT2 ) const DT2 * );802 //forall( dtype DT ) void ?{}( DT * volatile *, forall( dtype DT2 ) const DT2 * );803 forall( dtype DT ) void ?{}( const DT * *, forall( dtype DT2 ) const DT2 * );804 forall( dtype DT ) void ?{}( const DT * volatile *, forall( dtype DT2 ) const DT2 * );805 //forall( dtype DT ) void ?{}( volatile DT * *, forall( dtype DT2 ) const DT2 * );806 //forall( dtype DT ) void ?{}( volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );807 forall( dtype DT ) void ?{}( const volatile DT * *, forall( dtype DT2 ) const DT2 * );808 forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );809 810 forall( ftype FT ) void ?{}( FT * *, forall( ftype FT2 ) FT2 * );811 forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * );812 813 // default ctors814 forall( ftype FT ) void ?{}( FT * * );815 forall( ftype FT ) void ?{}( FT * volatile * );816 817 forall( dtype DT ) void ?{}( DT * *);818 forall( dtype DT ) void ?{}( DT * volatile *);819 forall( dtype DT ) void ?{}( const DT * *);820 forall( dtype DT ) void ?{}( const DT * volatile *);821 forall( dtype DT ) void ?{}( volatile DT * *);822 forall( dtype DT ) void ?{}( volatile DT * volatile *);823 forall( dtype DT ) void ?{}( const volatile DT * *);824 forall( dtype DT ) void ?{}( const volatile DT * volatile *);825 826 void ?{}( void * *);827 void ?{}( void * volatile *);828 void ?{}( const void * *);829 void ?{}( const void * volatile *);830 void ?{}( volatile void * *);831 void ?{}( volatile void * volatile *);832 void ?{}( const volatile void * *);833 void ?{}( const volatile void * volatile *);834 835 // dtors836 forall( ftype FT ) void ^?{}( FT * * );837 forall( ftype FT ) void ^?{}( FT * volatile * );838 839 forall( dtype DT ) void ^?{}( DT * *);840 forall( dtype DT ) void ^?{}( DT * volatile *);841 forall( dtype DT ) void ^?{}( const DT * *);842 forall( dtype DT ) void ^?{}( const DT * volatile *);843 forall( dtype DT ) void ^?{}( volatile DT * *);844 forall( dtype DT ) void ^?{}( volatile DT * volatile *);845 forall( dtype DT ) void ^?{}( const volatile DT * *);846 forall( dtype DT ) void ^?{}( const volatile DT * volatile *);847 848 void ^?{}( void * *);849 void ^?{}( void * volatile *);850 void ^?{}( const void * *);851 void ^?{}( const void * volatile *);852 void ^?{}( volatile void * *);853 void ^?{}( volatile void * volatile *);854 void ^?{}( const volatile void * *);855 void ^?{}( const volatile void * volatile *); -
src/libcfa/rational
r189243c rcc3528f 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Wed May 4 14:11:45201615 // Update Count : 1 614 // Last Modified On : Fri Apr 8 11:38:27 2016 15 // Update Count : 15 16 16 // 17 17 … … 28 28 29 29 // constructors 30 void ?{}( Rational * r);31 void ?{}( Rational * r,long int n );32 void ?{}( Rational * r,long int n, long int d );30 Rational rational(); 31 Rational rational( long int n ); 32 Rational rational( long int n, long int d ); 33 33 34 34 // getter/setter for numerator/denominator -
src/libcfa/rational.c
r189243c rcc3528f 11 11 // Created On : Wed Apr 6 17:54:28 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed May 4 14:16:14201614 // Update Count : 2 513 // Last Modified On : Thu Apr 21 07:33:03 2016 14 // Update Count : 22 15 15 // 16 16 … … 53 53 // constructors 54 54 55 void ?{}( Rational * r) {56 r { 0, 1 };55 Rational rational() { 56 return (Rational){ 0, 1 }; 57 57 } // rational 58 58 59 void ?{}( Rational * r,long int n ) {60 r { n, 1 };59 Rational rational( long int n ) { 60 return (Rational){ n, 1 }; 61 61 } // rational 62 62 63 void ?{}( Rational * r,long int n, long int d ) {63 Rational rational( long int n, long int d ) { 64 64 long int t = simplify( &n, &d ); // simplify 65 r->numerator = n / t; 66 r->denominator = d / t; 65 return (Rational){ n / t, d / t }; 67 66 } // rational 68 67 … … 173 172 Rational narrow( double f, long int md ) { 174 173 if ( md <= 1 ) { // maximum fractional digits too small? 175 return (Rational){ f, 1}; // truncate fraction 174 Rational t = rational( f, 1 ); // truncate fraction 175 return t; 176 176 } // if 177 177 … … 199 199 k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2]; 200 200 } // for 201 return (Rational){ neg ? -h[1] : h[1], k[1] }; 201 Rational t = rational( neg ? -h[1] : h[1], k[1] ); 202 return t; 202 203 } // narrow 203 204 -
src/main.cc
r189243c rcc3528f 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 15: 59:09201612 // Last Modified On : Fri May 06 15:29:42 2016 13 13 // Update Count : 203 14 14 // … … 40 40 #include "MakeLibCfa.h" 41 41 #include "InitTweak/Mutate.h" 42 #include "InitTweak/GenInit.h" 43 #include "InitTweak/FixInit.h" 42 #include "InitTweak/RemoveInit.h" 44 43 #include "InitTweak/FixGlobalInit.h" 45 44 //#include "Explain/GenProlog.h" … … 57 56 58 57 static void parse( FILE * input, LinkageSpec::Type t, bool shouldExit = false ); 59 static void dump( std::list< Declaration * > & translationUnit , std::ostream & out = std::cout);58 static void dump( std::list< Declaration * > & translationUnit ); 60 59 61 60 bool 62 61 astp = false, 63 62 bresolvep = false, 64 bboxp = false,65 ctorinitp = false,66 63 exprp = false, 67 64 expraltp = false, … … 78 75 codegenp = false; 79 76 80 enum { Ast, B box, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };77 enum { Ast, Bresolver, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, }; 81 78 82 79 static struct option long_opts[] = { 83 80 { "ast", no_argument, 0, Ast }, 84 { "before-box", no_argument, 0, Bbox },85 81 { "before-resolver", no_argument, 0, Bresolver }, 86 { "ctorinitfix", no_argument, 0, CtorInitFix },87 82 { "expr", no_argument, 0, Expr }, 88 83 { "expralt", no_argument, 0, ExprAlt }, … … 109 104 110 105 int c; 111 while ( (c = getopt_long( argc, argv, "ab BcefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {106 while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) { 112 107 switch ( c ) { 113 108 case Ast: … … 118 113 case 'b': // print before resolver steps 119 114 bresolvep = true; 120 break;121 case 'B': // print before resolver steps122 bboxp = true;123 break;124 case CtorInitFix:125 case 'c':126 ctorinitp = true;127 115 break; 128 116 case Expr: … … 274 262 OPTPRINT( "fixGlobalInit" ); 275 263 InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep ); 276 OPTPRINT( "tweak Init" )277 InitTweak:: genInit( translationUnit );264 OPTPRINT( "tweak" ) 265 InitTweak::tweak( translationUnit ); 278 266 279 267 if ( libcfap ) { … … 291 279 if ( exprp ) { 292 280 dump( translationUnit ); 293 return 0;294 }295 296 OPTPRINT( "fixInit" )297 // fix ObjectDecl - replaces ConstructorInit nodes298 InitTweak::fix( translationUnit );299 if ( ctorinitp ) {300 dump ( translationUnit );301 return 0;302 281 } 303 282 … … 308 287 OPTPRINT( "convertLvalue" ) 309 288 GenPoly::convertLvalue( translationUnit ); 310 311 if ( bboxp ) {312 dump( translationUnit );313 return 0;314 }315 289 OPTPRINT( "box" ) 316 290 GenPoly::box( translationUnit ); … … 329 303 } catch ( SemanticError &e ) { 330 304 if ( errorp ) { 331 std::cerr << "---AST at error:---" << std::endl; 332 dump( translationUnit, std::cerr ); 333 std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl; 305 dump( translationUnit ); 334 306 } 335 307 e.print( std::cerr ); … … 353 325 } // try 354 326 355 deleteAll( translationUnit );356 327 return 0; 357 328 } // main … … 371 342 } 372 343 373 static void dump( std::list< Declaration * > & translationUnit , std::ostream & out) {344 static void dump( std::list< Declaration * > & translationUnit ) { 374 345 std::list< Declaration * > decls; 375 346 if ( noprotop ) { … … 380 351 } 381 352 382 printAll( decls, out );353 printAll( decls, std::cout ); 383 354 deleteAll( translationUnit ); 384 355 }
Note:
See TracChangeset
for help on using the changeset viewer.