- Timestamp:
- Jun 18, 2017, 9:22:22 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- f1e80d8
- Parents:
- ade20d0 (diff), 42b0d73 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 11 added
- 1 deleted
- 52 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rade20d0 r436c0de 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 10 14:45:00 201713 // Update Count : 48 412 // Last Modified On : Thu Jun 8 16:00:00 2017 13 // Update Count : 485 14 14 // 15 15 … … 112 112 113 113 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {} 114 115 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )116 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {117 //output << std::string( init );118 }119 120 CodeGenerator::CodeGenerator( std::ostream & os, char * init, int indentation, bool infunp )121 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {122 //output << std::string( init );123 }124 114 125 115 string CodeGenerator::mangleName( DeclarationWithType * decl ) { … … 918 908 } 919 909 910 void CodeGenerator::visit( ThrowStmt * throwStmt ) { 911 assertf( ! genC, "Throw statements should not reach code generation." ); 912 913 output << ((throwStmt->get_kind() == ThrowStmt::Terminate) ? 914 "throw" : "throwResume"); 915 if (throwStmt->get_expr()) { 916 output << " "; 917 throwStmt->get_expr()->accept( *this ); 918 } 919 if (throwStmt->get_target()) { 920 output << " _At "; 921 throwStmt->get_target()->accept( *this ); 922 } 923 output << ";"; 924 } 925 920 926 void CodeGenerator::visit( WhileStmt * whileStmt ) { 921 927 if ( whileStmt->get_isDoWhile() ) { -
src/CodeGen/CodeGenerator.h
rade20d0 r436c0de 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 10 10:57:00 201713 // Update Count : 5 112 // Last Modified On : Thu Jun 8 15:48:00 2017 13 // Update Count : 52 14 14 // 15 15 … … 91 91 virtual void visit( BranchStmt * ); 92 92 virtual void visit( ReturnStmt * ); 93 virtual void visit( ThrowStmt * ); 93 94 virtual void visit( WhileStmt * ); 94 95 virtual void visit( ForStmt * ); -
src/Common/PassVisitor.h
rade20d0 r436c0de 54 54 virtual void visit( BranchStmt *branchStmt ) override final; 55 55 virtual void visit( ReturnStmt *returnStmt ) override final; 56 virtual void visit( ThrowStmt *throwStmt ) override final; 56 57 virtual void visit( TryStmt *tryStmt ) override final; 57 58 virtual void visit( CatchStmt *catchStmt ) override final; … … 90 91 virtual void visit( TupleExpr *tupleExpr ) override final; 91 92 virtual void visit( TupleIndexExpr *tupleExpr ) override final; 92 virtual void visit( MemberTupleExpr *tupleExpr ) override final;93 93 virtual void visit( TupleAssignExpr *assignExpr ) override final; 94 94 virtual void visit( StmtExpr * stmtExpr ) override final; … … 140 140 virtual Statement* mutate( BranchStmt *branchStmt ) override final; 141 141 virtual Statement* mutate( ReturnStmt *returnStmt ) override final; 142 virtual Statement* mutate( ThrowStmt *throwStmt ) override final; 142 143 virtual Statement* mutate( TryStmt *returnStmt ) override final; 143 144 virtual Statement* mutate( CatchStmt *catchStmt ) override final; … … 176 177 virtual Expression* mutate( TupleExpr *tupleExpr ) override final; 177 178 virtual Expression* mutate( TupleIndexExpr *tupleExpr ) override final; 178 virtual Expression* mutate( MemberTupleExpr *tupleExpr ) override final;179 179 virtual Expression* mutate( TupleAssignExpr *assignExpr ) override final; 180 180 virtual Expression* mutate( StmtExpr * stmtExpr ) override final; … … 232 232 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } 233 233 bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); } 234 }; 234 void reset_visit() { bool* skip = skip_children_impl(pass, 0); if(skip) *skip = false; } 235 236 guard_value_impl init_guard() { 237 guard_value_impl guard; 238 auto at_cleanup = at_cleanup_impl(pass, 0); 239 if( at_cleanup ) { 240 *at_cleanup = [&guard]( cleanup_func_t && func, void* val ) { 241 guard.push( std::move( func ), val ); 242 }; 243 } 244 return guard; 245 } 246 }; 247 248 template<typename pass_type, typename T> 249 void GuardValue( pass_type * pass, T& val ) { 250 pass->at_cleanup( [ val ]( void * newVal ) { 251 * static_cast< T * >( newVal ) = val; 252 }, static_cast< void * >( & val ) ); 253 } 254 255 class WithTypeSubstitution { 256 protected: 257 WithTypeSubstitution() = default; 258 ~WithTypeSubstitution() = default; 259 260 public: 261 TypeSubstitution * env; 262 }; 263 264 class WithStmtsToAdd { 265 protected: 266 WithStmtsToAdd() = default; 267 ~WithStmtsToAdd() = default; 268 269 public: 270 std::list< Statement* > stmtsToAddBefore; 271 std::list< Statement* > stmtsToAddAfter; 272 }; 273 274 class WithShortCircuiting { 275 protected: 276 WithShortCircuiting() = default; 277 ~WithShortCircuiting() = default; 278 279 public: 280 bool skip_children; 281 }; 282 283 class WithScopes { 284 protected: 285 WithScopes() = default; 286 ~WithScopes() = default; 287 288 public: 289 at_cleanup_t at_cleanup; 290 291 template< typename T > 292 void GuardValue( T& val ) { 293 at_cleanup( [ val ]( void * newVal ) { 294 * static_cast< T * >( newVal ) = val; 295 }, static_cast< void * >( & val ) ); 296 } 297 }; 298 235 299 236 300 #include "PassVisitor.impl.h" -
src/Common/PassVisitor.impl.h
rade20d0 r436c0de 1 1 #pragma once 2 2 3 #define VISIT_START( node ) \ 4 call_previsit( node ); \ 5 if( visit_children() ) { \ 6 7 #define VISIT_END( node ) \ 8 } \ 9 return call_postvisit( node ); \ 10 11 #define MUTATE_START( node ) \ 12 call_premutate( node ); \ 13 if( visit_children() ) { \ 3 #define VISIT_START( node ) \ 4 __attribute__((unused)) \ 5 const auto & guard = init_guard(); \ 6 call_previsit( node ); \ 7 if( visit_children() ) { \ 8 reset_visit(); \ 9 10 #define VISIT_END( node ) \ 11 } \ 12 call_postvisit( node ); \ 13 14 #define MUTATE_START( node ) \ 15 __attribute__((unused)) \ 16 const auto & guard = init_guard(); \ 17 call_premutate( node ); \ 18 if( visit_children() ) { \ 19 reset_visit(); \ 14 20 15 21 #define MUTATE_END( type, node ) \ … … 18 24 19 25 20 #define VISIT_BODY( node ) \21 VISIT_START( node ); \22 Visitor::visit( node ); \23 VISIT_END( node ); \26 #define VISIT_BODY( node ) \ 27 VISIT_START( node ); \ 28 Visitor::visit( node ); \ 29 VISIT_END( node ); \ 24 30 25 31 … … 389 395 390 396 //-------------------------------------------------------------------------- 397 // ThrowStmt 398 399 template< typename pass_type > 400 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { 401 VISIT_BODY( node ); 402 } 403 404 template< typename pass_type > 405 Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { 406 MUTATE_BODY( Statement, node ); 407 } 408 409 //-------------------------------------------------------------------------- 391 410 // TryStmt 392 411 template< typename pass_type > … … 617 636 618 637 template< typename pass_type > 619 void PassVisitor< pass_type >::visit( MemberTupleExpr * node ) {620 VISIT_BODY( node );621 }622 623 template< typename pass_type >624 638 void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) { 625 639 VISIT_BODY( node ); … … 999 1013 1000 1014 template< typename pass_type > 1001 Expression * PassVisitor< pass_type >::mutate( MemberTupleExpr * node ) {1002 MUTATE_BODY( Expression, node );1003 }1004 1005 template< typename pass_type >1006 1015 Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) { 1007 1016 MUTATE_BODY( Expression, node ); -
src/Common/PassVisitor.proto.h
rade20d0 r436c0de 1 1 #pragma once 2 3 typedef std::function<void( void * )> cleanup_func_t; 4 5 class guard_value_impl { 6 public: 7 guard_value_impl() = default; 8 9 ~guard_value_impl() { 10 while( !cleanups.empty() ) { 11 auto& cleanup = cleanups.top(); 12 cleanup.func( cleanup.val ); 13 cleanups.pop(); 14 } 15 } 16 17 void push( cleanup_func_t && func, void* val ) { 18 cleanups.emplace( std::move(func), val ); 19 } 20 21 private: 22 struct cleanup_t { 23 cleanup_func_t func; 24 void * val; 25 26 cleanup_t( cleanup_func_t&& func, void * val ) : func(func), val(val) {} 27 }; 28 29 std::stack< cleanup_t > cleanups; 30 }; 31 32 typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t; 2 33 3 34 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 18 49 // Visit 19 50 template<typename pass_type, typename node_type> 20 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) {51 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) { 21 52 pass.previsit( node ); 22 53 } … … 27 58 28 59 template<typename pass_type, typename node_type> 29 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) {60 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) { 30 61 pass.postvisit( node ); 31 62 } … … 36 67 // Mutate 37 68 template<typename pass_type, typename node_type> 38 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) {69 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) { 39 70 return pass.premutate( node ); 40 71 } … … 45 76 46 77 template<typename return_type, typename pass_type, typename node_type> 47 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) {78 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) { 48 79 return pass.postmutate( node ); 49 80 } … … 54 85 // Begin/End scope 55 86 template<typename pass_type> 56 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) {87 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) { 57 88 pass.beginScope(); 58 89 } … … 63 94 64 95 template<typename pass_type> 65 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) {96 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) { 66 97 pass.endScope(); 67 98 } … … 73 104 #define FIELD_PTR( type, name ) \ 74 105 template<typename pass_type> \ 75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; }\106 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; } \ 76 107 \ 77 108 template<typename pass_type> \ … … 82 113 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) 83 114 FIELD_PTR( bool, skip_children ) 115 FIELD_PTR( at_cleanup_t, at_cleanup ) -
src/GenPoly/Box.cc
rade20d0 r436c0de 108 108 Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true ); 109 109 /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value 110 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function,Type *polyType, std::list< Expression *>::iterator &arg );110 Expression *addDynRetParam( ApplicationExpr *appExpr, Type *polyType, std::list< Expression *>::iterator &arg ); 111 111 Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 112 112 void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars ); … … 726 726 } 727 727 728 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function,Type *dynType, std::list< Expression *>::iterator &arg ) {728 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, Type *dynType, std::list< Expression *>::iterator &arg ) { 729 729 assert( env ); 730 730 Type *concrete = replaceWithConcrete( appExpr, dynType ); … … 1146 1146 if ( dynRetType ) { 1147 1147 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result(); 1148 ret = addDynRetParam( appExpr, function,concRetType, arg ); // xxx - used to use dynRetType instead of concRetType1148 ret = addDynRetParam( appExpr, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType 1149 1149 } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...? 1150 1150 // xxx - the ! needsAdapter check may be incorrect. It seems there is some situation where an adapter is applied where it shouldn't be, and this fixes it for some cases. More investigation is needed. -
src/GenPoly/Specialize.cc
rade20d0 r436c0de 93 93 } 94 94 95 bool needsTupleSpecialization( Type *formalType, Type *actualType , TypeSubstitution *env) {95 bool needsTupleSpecialization( Type *formalType, Type *actualType ) { 96 96 // Needs tuple specialization if the structure of the formal type and actual type do not match. 97 97 // This is the case if the formal type has ttype polymorphism, or if the structure of tuple types … … 112 112 113 113 bool needsSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) { 114 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType , env);114 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType ); 115 115 } 116 116 -
src/InitTweak/FixInit.cc
rade20d0 r436c0de 902 902 } 903 903 904 void InsertDtors::visit( ReturnStmt * returnStmt ) {904 void InsertDtors::visit( __attribute((unused)) ReturnStmt * returnStmt ) { 905 905 // return exits all scopes, so dump destructors for all scopes 906 906 for ( OrderedDecls & od : reverseDeclOrder ) { -
src/InitTweak/GenInit.cc
rade20d0 r436c0de 39 39 40 40 namespace InitTweak { 41 class ReturnFixer final : public GenPoly::PolyMutator { 41 namespace { 42 const std::list<Label> noLabels; 43 const std::list<Expression *> noDesignators; 44 } 45 46 class ReturnFixer : public WithStmtsToAdd, public WithScopes { 42 47 public: 43 48 /// consistently allocates a temporary variable for the return value … … 46 51 static void makeReturnTemp( std::list< Declaration * > &translationUnit ); 47 52 48 typedef GenPoly::PolyMutator Parent; 49 using Parent::mutate; 50 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 51 virtual Statement * mutate( ReturnStmt * returnStmt ) override; 53 void premutate( FunctionDecl *functionDecl ); 54 void premutate( ReturnStmt * returnStmt ); 52 55 53 56 protected: … … 131 134 132 135 void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) { 133 ReturnFixerfixer;136 PassVisitor<ReturnFixer> fixer; 134 137 mutateAll( translationUnit, fixer ); 135 138 } 136 139 137 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {140 void ReturnFixer::premutate( ReturnStmt *returnStmt ) { 138 141 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 139 142 assert( returnVals.size() == 0 || returnVals.size() == 1 ); … … 146 149 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 147 150 construct->get_args().push_back( returnStmt->get_expr() ); 148 stmtsToAdd .push_back(new ExprStmt(noLabels, construct));151 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 149 152 150 153 // return the retVal object 151 154 returnStmt->set_expr( new VariableExpr( returnVals.front() ) ); 152 155 } // if 153 return returnStmt; 154 } 155 156 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 157 ValueGuard< FunctionType * > oldFtype( ftype ); 158 ValueGuard< std::string > oldFuncName( funcName ); 156 } 157 158 void ReturnFixer::premutate( FunctionDecl *functionDecl ) { 159 GuardValue( ftype ); 160 GuardValue( funcName ); 159 161 160 162 ftype = functionDecl->get_functionType(); 161 163 funcName = functionDecl->get_name(); 162 return Parent::mutate( functionDecl );163 164 } 164 165 -
src/Parser/ExpressionNode.cc
rade20d0 r436c0de 223 223 } // build_field_name_REALDECIMALconstant 224 224 225 NameExpr * build_varref( const string *name , bool labelp) {225 NameExpr * build_varref( const string *name ) { 226 226 NameExpr *expr = new NameExpr( *name, nullptr ); 227 227 delete name; -
src/Parser/ParseNode.h
rade20d0 r436c0de 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 15:42:18201713 // Update Count : 77 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:00:00 2017 13 // Update Count : 779 14 14 // 15 15 … … 166 166 Expression * build_field_name_REALDECIMALconstant( const std::string & str ); 167 167 168 NameExpr * build_varref( const std::string * name , bool labelp = false);168 NameExpr * build_varref( const std::string * name ); 169 169 Expression * build_typevalue( DeclarationNode * decl ); 170 170 … … 393 393 Statement * build_return( ExpressionNode * ctl ); 394 394 Statement * build_throw( ExpressionNode * ctl ); 395 Statement * build_resume( ExpressionNode * ctl ); 396 Statement * build_resume_at( ExpressionNode * ctl , ExpressionNode * target ); 395 397 Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ); 396 Statement * build_catch( DeclarationNode * decl, StatementNode * stmt, bool catchAny = false);398 Statement * build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ); 397 399 Statement * build_finally( StatementNode * stmt ); 398 400 Statement * build_compound( StatementNode * first ); -
src/Parser/StatementNode.cc
rade20d0 r436c0de 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 14:59:41 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 2 22:16:40 201713 // Update Count : 32 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:03:00 2017 13 // Update Count : 329 14 14 // 15 15 … … 152 152 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr ); 153 153 } 154 154 155 Statement *build_throw( ExpressionNode *ctl ) { 155 156 std::list< Expression * > exps; 156 157 buildMoveList( ctl, exps ); 157 158 assertf( exps.size() < 2, "This means we are leaking memory"); 158 return new ReturnStmt( noLabels, !exps.empty() ? exps.back() : nullptr, true ); 159 return new ThrowStmt( noLabels, ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr ); 160 } 161 162 Statement *build_resume( ExpressionNode *ctl ) { 163 std::list< Expression * > exps; 164 buildMoveList( ctl, exps ); 165 assertf( exps.size() < 2, "This means we are leaking memory"); 166 return new ThrowStmt( noLabels, ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr ); 167 } 168 169 Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) { 170 std::list< Expression * > exps; 171 buildMoveList( ctl, exps ); 172 assertf( exps.size() < 2, "This means we are leaking memory"); 173 return new ThrowStmt( noLabels, ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr ); 159 174 } 160 175 … … 166 181 return new TryStmt( noLabels, tryBlock, branches, finallyBlock ); 167 182 } 168 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) {169 std::list< Statement * > branches; 170 buildMoveList< Statement, StatementNode >( stmt, branches );171 assert( branches.size() == 1 ); 172 return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny);183 Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) { 184 std::list< Statement * > branches; 185 buildMoveList< Statement, StatementNode >( body, branches ); 186 assert( branches.size() == 1 ); 187 return new CatchStmt( noLabels, kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() ); 173 188 } 174 189 Statement *build_finally( StatementNode *stmt ) { -
src/Parser/parser.yy
rade20d0 r436c0de 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 25 15:21:59201713 // Update Count : 2 39812 // Last Modified On : Mon Jun 12 12:59:00 2017 13 // Update Count : 2402 14 14 // 15 15 … … 193 193 %type<sn> case_value_list case_label case_label_list 194 194 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 195 %type<sn> handler_listhandler_clause finally_clause195 %type<sn> /* handler_list */ handler_clause finally_clause 196 196 197 197 // declarations … … 547 547 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 548 548 // | ANDAND IDENTIFIER // GCC, address of label 549 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 , true) ); }549 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 ) ); } 550 550 ; 551 551 … … 931 931 { $$ = new StatementNode( build_throw( $2 ) ); } 932 932 | THROWRESUME assignment_expression_opt ';' // handles reresume 933 { $$ = new StatementNode( build_ throw( $2 ) ); }933 { $$ = new StatementNode( build_resume( $2 ) ); } 934 934 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 935 { $$ = new StatementNode( build_ throw( $2) ); }935 { $$ = new StatementNode( build_resume_at( $2, $4 ) ); } 936 936 ; 937 937 938 938 exception_statement: 939 TRY compound_statement handler_ list939 TRY compound_statement handler_clause 940 940 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 941 941 | TRY compound_statement finally_clause 942 942 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 943 | TRY compound_statement handler_ listfinally_clause943 | TRY compound_statement handler_clause finally_clause 944 944 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } 945 945 ; 946 946 947 handler_list:948 handler_clause949 // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.950 | CATCH '(' ELLIPSIS ')' compound_statement951 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }952 | handler_clause CATCH '(' ELLIPSIS ')' compound_statement953 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }954 | CATCHRESUME '(' ELLIPSIS ')' compound_statement955 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }956 | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement957 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }958 ;947 //handler_list: 948 // handler_clause 949 // // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block. 950 // | CATCH '(' ELLIPSIS ')' compound_statement 951 // { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 952 // | handler_clause CATCH '(' ELLIPSIS ')' compound_statement 953 // { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 954 // | CATCHRESUME '(' ELLIPSIS ')' compound_statement 955 // { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 956 // | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement 957 // { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 958 // ; 959 959 960 960 handler_clause: 961 961 CATCH '(' push push exception_declaration pop ')' compound_statement pop 962 { $$ = new StatementNode( build_catch( $5, $8 ) ); }962 { $$ = new StatementNode( build_catch( CatchStmt::Terminate, $5, nullptr, $8 ) ); } 963 963 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 964 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }964 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); } 965 965 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 966 { $$ = new StatementNode( build_catch( $5, $8 ) ); }966 { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); } 967 967 | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 968 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }968 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); } 969 969 ; 970 970 -
src/ResolvExpr/AlternativeFinder.cc
rade20d0 r436c0de 97 97 /// Prunes a list of alternatives down to those that have the minimum conversion cost for a given return type; skips ambiguous interpretations 98 98 template< typename InputIterator, typename OutputIterator > 99 void pruneAlternatives( InputIterator begin, InputIterator end, OutputIterator out , const SymTab::Indexer &indexer) {99 void pruneAlternatives( InputIterator begin, InputIterator end, OutputIterator out ) { 100 100 // select the alternatives that have the minimum conversion cost for a particular set of result types 101 101 std::map< std::string, PruneStruct > selected; … … 183 183 ) 184 184 AltList::iterator oldBegin = alternatives.begin(); 185 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) , indexer);185 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) ); 186 186 if ( alternatives.begin() == oldBegin ) { 187 187 std::ostringstream stream; -
src/ResolvExpr/CommonType.cc
rade20d0 r436c0de 157 157 void CommonType::visit( PointerType *pointerType ) { 158 158 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) { 159 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base() , indexer) ) {159 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base()) ) { 160 160 getCommonWithVoidPointer( otherPointer, pointerType ); 161 } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base() , indexer) ) {161 } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base()) ) { 162 162 getCommonWithVoidPointer( pointerType, otherPointer ); 163 163 } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst ) -
src/ResolvExpr/PtrsCastable.cc
rade20d0 r436c0de 135 135 } 136 136 137 void PtrsCastable::visit(TraitInstType *inst) { 138 // I definitely don't think we should be doing anything here 139 } 137 void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst ) {} 140 138 141 139 void PtrsCastable::visit(TypeInstType *inst) { -
src/ResolvExpr/Unify.cc
rade20d0 r436c0de 114 114 } 115 115 116 bool isFtype( Type *type , const SymTab::Indexer &indexer) {116 bool isFtype( Type *type ) { 117 117 if ( dynamic_cast< FunctionType* >( type ) ) { 118 118 return true; … … 123 123 } 124 124 125 bool tyVarCompatible( const TypeDecl::Data & data, Type *type , const SymTab::Indexer &indexer) {125 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) { 126 126 switch ( data.kind ) { 127 127 case TypeDecl::Any: … … 131 131 // type must also be complete 132 132 // xxx - should this also check that type is not a tuple type and that it's not a ttype? 133 return ! isFtype( type , indexer) && (! data.isComplete || type->isComplete() );133 return ! isFtype( type ) && (! data.isComplete || type->isComplete() ); 134 134 case TypeDecl::Ftype: 135 return isFtype( type , indexer);135 return isFtype( type ); 136 136 case TypeDecl::Ttype: 137 137 // ttype unifies with any tuple type … … 144 144 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 145 145 assert( tyvar != openVars.end() ); 146 if ( ! tyVarCompatible( tyvar->second, other , indexer) ) {146 if ( ! tyVarCompatible( tyvar->second, other ) ) { 147 147 return false; 148 148 } // if … … 388 388 } 389 389 390 void Unify::visit( VoidType *voidType) {390 void Unify::visit( __attribute__((unused)) VoidType *voidType) { 391 391 result = dynamic_cast< VoidType* >( type2 ); 392 392 } … … 683 683 684 684 template< typename Iterator1, typename Iterator2 > 685 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode,const SymTab::Indexer &indexer ) {685 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 686 686 auto get_type = [](Type * t) { return t; }; 687 687 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { … … 733 733 flatten( flat2.get(), back_inserter( types2 ) ); 734 734 735 result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, widenMode,indexer );736 } // if 737 } 738 739 void Unify::visit( VarArgsType *varArgsType) {735 result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer ); 736 } // if 737 } 738 739 void Unify::visit( __attribute__((unused)) VarArgsType *varArgsType ) { 740 740 result = dynamic_cast< VarArgsType* >( type2 ); 741 741 } 742 742 743 void Unify::visit( ZeroType *zeroType) {743 void Unify::visit( __attribute__((unused)) ZeroType *zeroType ) { 744 744 result = dynamic_cast< ZeroType* >( type2 ); 745 745 } 746 746 747 void Unify::visit( OneType *oneType) {747 void Unify::visit( __attribute__((unused)) OneType *oneType ) { 748 748 result = dynamic_cast< OneType* >( type2 ); 749 749 } -
src/ResolvExpr/typeops.h
rade20d0 r436c0de 118 118 119 119 // in Unify.cc 120 bool isFtype( Type *type , const SymTab::Indexer &indexer);120 bool isFtype( Type *type ); 121 121 bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 122 122 bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); -
src/SymTab/Autogen.cc
rade20d0 r436c0de 262 262 // E ?=?(E volatile*, int), 263 263 // ?=?(E _Atomic volatile*, int); 264 void makeEnumFunctions( Enum Decl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {264 void makeEnumFunctions( EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) { 265 265 266 266 // T ?=?(E *, E); … … 486 486 487 487 /// generates the body of a union assignment/copy constructor/field constructor 488 void makeUnionAssignBody( FunctionDecl * funcDecl , bool isDynamicLayout) {488 void makeUnionAssignBody( FunctionDecl * funcDecl ) { 489 489 FunctionType * ftype = funcDecl->get_functionType(); 490 490 assert( ftype->get_parameters().size() == 2 ); … … 506 506 // Make function polymorphic in same parameters as generic union, if applicable 507 507 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions 508 bool isDynamicLayout = hasDynamicLayout( aggregateDecl ); // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct) 509 508 510 509 // default ctor/dtor need only first parameter 511 510 // void ?{}(T *); void ^?{}(T *); … … 533 532 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting ); 534 533 535 makeUnionAssignBody( assignDecl , isDynamicLayout);534 makeUnionAssignBody( assignDecl ); 536 535 537 536 // body of assignment and copy ctor is the same 538 makeUnionAssignBody( copyCtorDecl , isDynamicLayout);537 makeUnionAssignBody( copyCtorDecl ); 539 538 540 539 // create a constructor which takes the first member type as a parameter. … … 551 550 FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting ); 552 551 553 makeUnionAssignBody( ctor , isDynamicLayout);552 makeUnionAssignBody( ctor ); 554 553 memCtors.push_back( ctor ); 555 554 // only generate a ctor for the first field … … 578 577 EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() ); 579 578 // enumInst->set_baseEnum( enumDecl ); 580 makeEnumFunctions( enum Decl, enumInst, functionNesting, declsToAddAfter );579 makeEnumFunctions( enumInst, functionNesting, declsToAddAfter ); 581 580 } 582 581 } -
src/SymTab/ImplementationType.cc
rade20d0 r436c0de 76 76 } 77 77 78 void ImplementationType::visit(FunctionType *functionType) { 79 /// FunctionType *newType = functionType->clone(); 80 /// for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) { 81 /// i->set_type( implementationType( i->get_type(), indexer ) ); 82 /// } 83 /// for ( std::list< DeclarationWithType* >::iterator i = newType->get_parameters().begin(); i != newType->get_parameters().end(); ++i ) { 84 /// i->set_type( implementationType( i->get_type(), indexer ) ); 85 /// } 86 } 87 78 void ImplementationType::visit( __attribute__((unused)) FunctionType *functionType ) {} 88 79 void ImplementationType::visit( __attribute__((unused)) StructInstType * aggregateUseType ) {} 89 80 void ImplementationType::visit( __attribute__((unused)) UnionInstType * aggregateUseType ) {} -
src/SymTab/Indexer.cc
rade20d0 r436c0de 518 518 acceptNewScope( tupleExpr->get_result(), *this ); 519 519 maybeAccept( tupleExpr->get_tuple(), *this ); 520 }521 522 void Indexer::visit( MemberTupleExpr *tupleExpr ) {523 acceptNewScope( tupleExpr->get_result(), *this );524 maybeAccept( tupleExpr->get_member(), *this );525 maybeAccept( tupleExpr->get_aggregate(), *this );526 520 } 527 521 -
src/SymTab/Indexer.h
rade20d0 r436c0de 74 74 virtual void visit( TupleExpr *tupleExpr ); 75 75 virtual void visit( TupleIndexExpr *tupleExpr ); 76 virtual void visit( MemberTupleExpr *tupleExpr );77 76 virtual void visit( TupleAssignExpr *tupleExpr ); 78 77 virtual void visit( StmtExpr * stmtExpr ); -
src/SymTab/Mangler.cc
rade20d0 r436c0de 236 236 } 237 237 238 void Mangler::visit( ZeroType *zeroType ) {238 void Mangler::visit( __attribute__((unused)) ZeroType *zeroType ) { 239 239 mangleName << "Z"; 240 240 } 241 241 242 void Mangler::visit( OneType *oneType ) {242 void Mangler::visit( __attribute__((unused)) OneType *oneType ) { 243 243 mangleName << "O"; 244 244 } -
src/SymTab/Validate.cc
rade20d0 r436c0de 611 611 returnVals = functionDecl->get_functionType()->get_returnVals(); 612 612 } 613 void ReturnChecker::postvisit( FunctionDecl * functionDecl ) {613 void ReturnChecker::postvisit( __attribute__((unused)) FunctionDecl * functionDecl ) { 614 614 returnVals = returnValsStack.top(); 615 615 returnValsStack.pop(); -
src/SynTree/Expression.h
rade20d0 r436c0de 690 690 }; 691 691 692 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer693 class MemberTupleExpr : public Expression {694 public:695 MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );696 MemberTupleExpr( const MemberTupleExpr & other );697 virtual ~MemberTupleExpr();698 699 Expression * get_member() const { return member; }700 Expression * get_aggregate() const { return aggregate; }701 MemberTupleExpr * set_member( Expression * newValue ) { member = newValue; return this; }702 MemberTupleExpr * set_aggregate( Expression * newValue ) { aggregate = newValue; return this; }703 704 virtual MemberTupleExpr * clone() const { return new MemberTupleExpr( * this ); }705 virtual void accept( Visitor & v ) { v.visit( this ); }706 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }707 virtual void print( std::ostream & os, int indent = 0 ) const;708 private:709 Expression * member;710 Expression * aggregate;711 };712 713 692 /// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression 714 693 class TupleAssignExpr : public Expression { -
src/SynTree/Initializer.cc
rade20d0 r436c0de 33 33 } 34 34 35 void Initializer::print( std::ostream &os,int indent ) {}35 // void Initializer::print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent ) {} 36 36 37 37 SingleInit::SingleInit( Expression *v, const std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) { -
src/SynTree/Initializer.h
rade20d0 r436c0de 53 53 virtual void accept( Visitor &v ) = 0; 54 54 virtual Initializer *acceptMutator( Mutator &m ) = 0; 55 virtual void print( std::ostream &os, int indent = 0 ) ;55 virtual void print( std::ostream &os, int indent = 0 ) = 0; 56 56 private: 57 57 // std::string name; -
src/SynTree/Mutator.cc
rade20d0 r436c0de 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 30 16:45:19201713 // Update Count : 2 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Mar 8 16:36:00 2017 13 // Update Count : 23 14 14 // 15 15 … … 153 153 } 154 154 155 Statement *Mutator::mutate( ThrowStmt *throwStmt ) { 156 throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) ); 157 throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) ); 158 return throwStmt; 159 } 160 155 161 Statement *Mutator::mutate( TryStmt *tryStmt ) { 156 162 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); … … 408 414 } 409 415 410 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {411 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );412 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );413 tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );414 tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );415 return tupleExpr;416 }417 418 416 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 419 417 assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) ); -
src/SynTree/Mutator.h
rade20d0 r436c0de 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 9 14:23:23201713 // Update Count : 1 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 15:45:00 2017 13 // Update Count : 14 14 14 // 15 15 #include <cassert> … … 46 46 virtual Statement* mutate( BranchStmt *branchStmt ); 47 47 virtual Statement* mutate( ReturnStmt *returnStmt ); 48 virtual Statement* mutate( TryStmt *returnStmt ); 48 virtual Statement* mutate( ThrowStmt *throwStmt ); 49 virtual Statement* mutate( TryStmt *tryStmt ); 49 50 virtual Statement* mutate( CatchStmt *catchStmt ); 50 51 virtual Statement* mutate( FinallyStmt *catchStmt ); … … 82 83 virtual Expression* mutate( TupleExpr *tupleExpr ); 83 84 virtual Expression* mutate( TupleIndexExpr *tupleExpr ); 84 virtual Expression* mutate( MemberTupleExpr *tupleExpr );85 85 virtual Expression* mutate( TupleAssignExpr *assignExpr ); 86 86 virtual Expression* mutate( StmtExpr * stmtExpr ); -
src/SynTree/Statement.cc
rade20d0 r436c0de 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Aug 12 13:58:48 201613 // Update Count : 6 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 10:37:00 2017 13 // Update Count : 64 14 14 // 15 15 … … 101 101 } 102 102 103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr , bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP) {}104 105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) , isThrow( other.isThrow ){}103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr ) : Statement( labels ), expr( _expr ) {} 104 105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 106 106 107 107 ReturnStmt::~ReturnStmt() { … … 110 110 111 111 void ReturnStmt::print( std::ostream &os, int indent ) const { 112 os << string ( isThrow? "Throw":"Return" ) << "Statement, returning: ";112 os << "Return Statement, returning: "; 113 113 if ( expr != 0 ) { 114 114 os << endl << string( indent+2, ' ' ); … … 287 287 } 288 288 289 ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) : 290 Statement( labels ), kind(kind), expr(expr), target(target) { 291 assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." ); 292 } 293 294 ThrowStmt::ThrowStmt( const ThrowStmt &other ) : 295 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 296 } 297 298 ThrowStmt::~ThrowStmt() { 299 delete expr; 300 delete target; 301 } 302 303 void ThrowStmt::print( std::ostream &os, int indent) const { 304 if ( target ) { 305 os << "Non-Local "; 306 } 307 os << "Throw Statement, raising: "; 308 expr->print(os, indent + 4); 309 if ( target ) { 310 os << "At: "; 311 target->print(os, indent + 4); 312 } 313 } 314 289 315 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) : 290 316 Statement( labels ), block( tryBlock ), handlers( _handlers ), finallyBlock( _finallyBlock ) { … … 318 344 } 319 345 320 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) :321 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) {346 CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) : 347 Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) { 322 348 } 323 349 324 350 CatchStmt::CatchStmt( const CatchStmt & other ) : 325 Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest) {351 Statement( other ), kind ( other.kind ), decl ( maybeClone( other.decl ) ), cond ( maybeClone( other.cond ) ), body( maybeClone( other.body ) ) { 326 352 } 327 353 … … 332 358 333 359 void CatchStmt::print( std::ostream &os, int indent ) const { 334 os << "Catch Statement" << endl;360 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 335 361 336 362 os << string( indent, ' ' ) << "... catching" << endl; … … 338 364 decl->printShort( os, indent + 4 ); 339 365 os << endl; 340 } else if ( catchRest ) 341 os << string( indent + 4 , ' ' ) << "the rest" << endl; 366 } 342 367 else 343 368 os << string( indent + 4 , ' ' ) << ">>> Error: this catch clause must have a declaration <<<" << endl; -
src/SynTree/Statement.h
rade20d0 r436c0de 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Aug 12 13:57:46 201613 // Update Count : 6 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:35:00 2017 13 // Update Count : 67 14 14 // 15 15 … … 57 57 private: 58 58 std::list<Statement*> kids; 59 }; 60 61 class NullStmt : public CompoundStmt { 62 public: 63 NullStmt(); 64 NullStmt( std::list<Label> labels ); 65 66 virtual NullStmt *clone() const { return new NullStmt( *this ); } 67 virtual void accept( Visitor &v ) { v.visit( this ); } 68 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 69 virtual void print( std::ostream &os, int indent = 0 ) const; 70 71 private: 59 72 }; 60 73 … … 261 274 class ReturnStmt : public Statement { 262 275 public: 263 ReturnStmt( std::list<Label> labels, Expression *expr , bool throwP = false);276 ReturnStmt( std::list<Label> labels, Expression *expr ); 264 277 ReturnStmt( const ReturnStmt &other ); 265 278 virtual ~ReturnStmt(); … … 274 287 private: 275 288 Expression *expr; 276 bool isThrow; 277 }; 278 279 280 class NullStmt : public CompoundStmt { 281 public: 282 NullStmt(); 283 NullStmt( std::list<Label> labels ); 284 285 virtual NullStmt *clone() const { return new NullStmt( *this ); } 286 virtual void accept( Visitor &v ) { v.visit( this ); } 287 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 288 virtual void print( std::ostream &os, int indent = 0 ) const; 289 290 private: 289 }; 290 291 class ThrowStmt : public Statement { 292 public: 293 enum Kind { Terminate, Resume }; 294 295 ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr ); 296 ThrowStmt( const ThrowStmt &other ); 297 virtual ~ThrowStmt(); 298 299 Kind get_kind() { return kind; } 300 Expression * get_expr() { return expr; } 301 void set_expr( Expression * newExpr ) { expr = newExpr; } 302 Expression * get_target() { return target; } 303 void set_target( Expression * newTarget ) { target = newTarget; } 304 305 virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); } 306 virtual void accept( Visitor &v ) { v.visit( this ); } 307 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 308 virtual void print( std::ostream &os, int indent = 0 ) const; 309 private: 310 Kind kind; 311 Expression * expr; 312 Expression * target; 291 313 }; 292 314 … … 317 339 class CatchStmt : public Statement { 318 340 public: 319 CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool catchAny = false ); 341 enum Kind { Terminate, Resume }; 342 343 CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, 344 Expression *cond, Statement *body ); 320 345 CatchStmt( const CatchStmt &other ); 321 346 virtual ~CatchStmt(); 322 347 348 Kind get_kind() { return kind; } 323 349 Declaration *get_decl() { return decl; } 324 350 void set_decl( Declaration *newValue ) { decl = newValue; } 325 351 Expression *get_cond() { return cond; } 352 void set_cond( Expression *newCond ) { cond = newCond; } 326 353 Statement *get_body() { return body; } 327 354 void set_body( Statement *newValue ) { body = newValue; } … … 333 360 334 361 private: 362 Kind kind; 335 363 Declaration *decl; 364 Expression *cond; 336 365 Statement *body; 337 bool catchRest;338 366 }; 339 367 -
src/SynTree/SynTree.h
rade20d0 r436c0de 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 9 14:23:49201713 // Update Count : 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 17:00:00 2017 13 // Update Count : 9 14 14 // 15 15 … … 51 51 class BranchStmt; 52 52 class ReturnStmt; 53 class ThrowStmt; 53 54 class TryStmt; 54 55 class CatchStmt; … … 89 90 class TupleExpr; 90 91 class TupleIndexExpr; 91 class MemberTupleExpr;92 92 class TupleAssignExpr; 93 93 class StmtExpr; -
src/SynTree/TupleExpr.cc
rade20d0 r436c0de 78 78 } 79 79 80 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {81 set_result( maybeClone( member->get_result() ) ); // xxx - ???82 }83 84 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {85 }86 87 MemberTupleExpr::~MemberTupleExpr() {88 delete member;89 delete aggregate;90 }91 92 void MemberTupleExpr::print( std::ostream &os, int indent ) const {93 os << "Member Tuple Expression, with aggregate:" << std::endl;94 os << std::string( indent+2, ' ' );95 aggregate->print( os, indent+2 );96 os << std::string( indent+2, ' ' ) << "with member: " << std::endl;97 os << std::string( indent+2, ' ' );98 member->print( os, indent+2 );99 Expression::print( os, indent );100 }101 102 80 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) { 103 81 // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments -
src/SynTree/Visitor.cc
rade20d0 r436c0de 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Mar 30 16:45:25201713 // Update Count : 2 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 16:31:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 129 129 } 130 130 131 void Visitor::visit( ThrowStmt * throwStmt ) { 132 maybeAccept( throwStmt->get_expr(), *this ); 133 maybeAccept( throwStmt->get_target(), *this ); 134 } 135 131 136 void Visitor::visit( TryStmt *tryStmt ) { 132 137 maybeAccept( tryStmt->get_block(), *this ); … … 319 324 maybeAccept( tupleExpr->get_result(), *this ); 320 325 maybeAccept( tupleExpr->get_tuple(), *this ); 321 }322 323 void Visitor::visit( MemberTupleExpr *tupleExpr ) {324 maybeAccept( tupleExpr->get_result(), *this );325 maybeAccept( tupleExpr->get_member(), *this );326 maybeAccept( tupleExpr->get_aggregate(), *this );327 326 } 328 327 -
src/SynTree/Visitor.h
rade20d0 r436c0de 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 3 08:58:00 201713 // Update Count : 1 012 // Last Modified On : Thr Jun 08 15:45:00 2017 13 // Update Count : 11 14 14 // 15 15 … … 49 49 virtual void visit( BranchStmt *branchStmt ); 50 50 virtual void visit( ReturnStmt *returnStmt ); 51 virtual void visit( ThrowStmt *throwStmt ); 51 52 virtual void visit( TryStmt *tryStmt ); 52 53 virtual void visit( CatchStmt *catchStmt ); … … 85 86 virtual void visit( TupleExpr *tupleExpr ); 86 87 virtual void visit( TupleIndexExpr *tupleExpr ); 87 virtual void visit( MemberTupleExpr *tupleExpr );88 88 virtual void visit( TupleAssignExpr *assignExpr ); 89 89 virtual void visit( StmtExpr * stmtExpr ); -
src/SynTree/ZeroOneType.cc
rade20d0 r436c0de 20 20 ZeroType::ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 21 21 22 void ZeroType::print( std::ostream &os, int indent ) const {22 void ZeroType::print( std::ostream &os, __attribute__((unused)) int indent ) const { 23 23 os << "zero_t"; 24 24 } … … 28 28 OneType::OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 29 29 30 void OneType::print( std::ostream &os, int indent ) const {30 void OneType::print( std::ostream &os, __attribute__((unused)) int indent ) const { 31 31 os << "one_t"; 32 32 } -
src/Tuples/TupleExpansion.cc
rade20d0 r436c0de 354 354 maybeImpure = true; 355 355 } 356 virtual void visit( UntypedExpr * untypedExpr ) { maybeImpure = true; }356 virtual void visit( __attribute__((unused)) UntypedExpr * untypedExpr ) { maybeImpure = true; } 357 357 bool maybeImpure = false; 358 358 }; -
src/libcfa/concurrency/alarm.c
rade20d0 r436c0de 104 104 105 105 static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) { 106 assert( it );107 assert( (*it)->next == n );106 verify( it ); 107 verify( (*it)->next == n ); 108 108 109 109 (*it)->next = n->next; -
src/libcfa/concurrency/coroutine
rade20d0 r436c0de 71 71 // Suspend implementation inlined for performance 72 72 static inline void suspend() { 73 73 coroutine_desc * src = this_coroutine(); // optimization 74 74 75 75 assertf( src->last != 0, … … 91 91 coroutine_desc * dst = get_coroutine(cor); 92 92 93 93 if( unlikely(!dst->stack.base) ) { 94 94 create_stack(&dst->stack, dst->stack.size); 95 95 CtxStart(cor, CtxInvokeCoroutine); 96 96 } 97 97 98 98 // not resuming self ? 99 99 if ( src != dst ) { 100 100 assertf( dst->state != Halted , … … 103 103 src->name, src, dst->name, dst ); 104 104 105 105 // set last resumer 106 106 dst->last = src; 107 107 } // if 108 108 109 109 // always done for performance testing 110 110 CoroutineCtxSwitch( src, dst ); 111 111 } … … 114 114 coroutine_desc * src = this_coroutine(); // optimization 115 115 116 116 // not resuming self ? 117 117 if ( src != dst ) { 118 118 assertf( dst->state != Halted , … … 121 121 src->name, src, dst->name, dst ); 122 122 123 123 // set last resumer 124 124 dst->last = src; 125 125 } // if 126 126 127 127 // always done for performance testing 128 128 CoroutineCtxSwitch( src, dst ); 129 129 } -
src/libcfa/concurrency/kernel.c
rade20d0 r436c0de 311 311 // appropriate stack. 312 312 proc_cor_storage.__cor.state = Active; 313 314 313 main( &proc_cor_storage ); 314 proc_cor_storage.__cor.state = Halted; 315 315 316 316 // Main routine of the core returned, the core is now fully terminated … … 333 333 if( !thrd ) return; 334 334 335 assertf( thrd->next == NULL, "Expected null got %p", thrd->next );335 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); 336 336 337 337 lock( &systemProcessor->proc.cltr->lock ); … … 577 577 578 578 void append( __thread_queue_t * this, thread_desc * t ) { 579 assert(this->tail != NULL);579 verify(this->tail != NULL); 580 580 *this->tail = t; 581 581 this->tail = &t->next; … … 599 599 600 600 void push( __condition_stack_t * this, __condition_criterion_t * t ) { 601 assert( !t->next );601 verify( !t->next ); 602 602 t->next = this->top; 603 603 this->top = t; -
src/libcfa/concurrency/kernel_private.h
rade20d0 r436c0de 22 22 23 23 #include "alarm.h" 24 25 #include "libhdr.h" 24 26 25 27 //----------------------------------------------------------------------------- … … 66 68 67 69 static inline void enable_interrupts_noRF() { 68 unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );69 assert( prev != (unsigned short) 0 );70 __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST ); 71 verify( prev != (unsigned short) 0 ); 70 72 } 71 73 72 74 static inline void enable_interrupts() { 73 unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );74 assert( prev != (unsigned short) 0 );75 __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST ); 76 verify( prev != (unsigned short) 0 ); 75 77 if( prev == 1 && this_processor->pending_preemption ) { 76 78 ScheduleInternal( this_processor->current_thread ); -
src/libcfa/concurrency/monitor
rade20d0 r436c0de 26 26 static inline void ?{}(monitor_desc * this) { 27 27 this->owner = NULL; 28 28 this->stack_owner = NULL; 29 29 this->recursion = 0; 30 30 } … … 33 33 monitor_desc ** m; 34 34 int count; 35 36 35 monitor_desc ** prev_mntrs; 36 unsigned short prev_count; 37 37 }; 38 38 -
src/libcfa/concurrency/monitor.c
rade20d0 r436c0de 56 56 else if( this->owner == thrd) { 57 57 //We already have the monitor, just not how many times we took it 58 assert( this->recursion > 0 );58 verify( this->recursion > 0 ); 59 59 this->recursion += 1; 60 60 } … … 78 78 lock( &this->lock ); 79 79 80 thread_desc * thrd = this_thread();81 82 80 LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion); 83 assertf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );81 verifyf( this_thread() == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread(), this->owner, this->recursion ); 84 82 85 83 //Leaving a recursion level, decrement the counter … … 167 165 //Check that everything is as expected 168 166 assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors ); 169 assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );170 assertf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );167 verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count ); 168 verifyf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count ); 171 169 172 170 unsigned short count = this->monitor_count; … … 229 227 230 228 //Check that everything is as expected 231 assert( this->monitors );232 assert( this->monitor_count != 0 );229 verify( this->monitors ); 230 verify( this->monitor_count != 0 ); 233 231 234 232 unsigned short count = this->monitor_count; … … 278 276 279 277 //Check that everything is as expected 280 assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );281 assertf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );278 verifyf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors ); 279 verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count ); 282 280 283 281 unsigned short count = this->monitor_count; … … 327 325 328 326 uintptr_t front( condition * this ) { 329 LIB_DEBUG_DO( 330 if( is_empty(this) ) { 331 abortf( "Attempt to access user data on an empty condition.\n" 332 "Possible cause is not checking if the condition is empty before reading stored data." ); 333 } 327 verifyf( !is_empty(this), 328 "Attempt to access user data on an empty condition.\n" 329 "Possible cause is not checking if the condition is empty before reading stored data." 334 330 ); 335 331 return this->blocked.head->user_info; … … 491 487 492 488 void append( __condition_blocked_queue_t * this, __condition_node_t * c ) { 493 assert(this->tail != NULL);489 verify(this->tail != NULL); 494 490 *this->tail = c; 495 491 this->tail = &c->next; -
src/libcfa/containers/maybe
rade20d0 r436c0de 10 10 // Created On : Wed May 24 14:43:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 25 16:36:00 201713 // Update Count : 112 // Last Modified On : Fri Jun 16 15:42:00 2017 13 // Update Count : 2 14 14 // 15 15 … … 46 46 bool ?!=?(maybe(T) this, zero_t); 47 47 48 /* Waiting for bug#11 to be fixed. 48 49 forall(otype T) 49 50 maybe(T) maybe_value(T value); … … 51 52 forall(otype T) 52 53 maybe(T) maybe_none(); 54 */ 53 55 54 56 forall(otype T) -
src/libcfa/containers/result
rade20d0 r436c0de 10 10 // Created On : Wed May 24 14:45:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 25 16:39:00 201713 // Update Count : 112 // Last Modified On : Fri Jun 16 15:41:00 2017 13 // Update Count : 2 14 14 // 15 15 … … 55 55 bool ?!=?(result(T, E) this, zero_t); 56 56 57 /* Wating for bug#11 to be fixed. 57 58 forall(otype T, otype E) 58 59 result(T, E) result_value(T value); … … 60 61 forall(otype T, otype E) 61 62 result(T, E) result_error(E error); 63 */ 62 64 63 65 forall(otype T, otype E) -
src/libcfa/containers/result.c
rade20d0 r436c0de 74 74 forall(otype T, otype E) 75 75 bool ?!=?(result(T, E) this, zero_t) { 76 return !this.has_value;76 return this.has_value; 77 77 } 78 78 … … 100 100 forall(otype T, otype E) 101 101 E get_error(result(T, E) * this) { 102 assertf( this->has_value, "attempt to get from result without error");102 assertf(!this->has_value, "attempt to get from result without error"); 103 103 return this->error; 104 104 } -
src/libcfa/libhdr/libdebug.h
rade20d0 r436c0de 18 18 19 19 #ifdef __CFA_DEBUG__ 20 21 20 #define LIB_DEBUG_DO(x) x 21 #define LIB_NO_DEBUG_DO(x) ((void)0) 22 22 #else 23 24 23 #define LIB_DEBUG_DO(x) ((void)0) 24 #define LIB_NO_DEBUG_DO(x) x 25 25 #endif 26 27 #if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__)) 28 #define verify(x) assert(x) 29 #define verifyf(x, ...) assertf(x, __VA_ARGS__) 30 #else 31 #define verify(x) 32 #define verifyf(x, ...) 33 #endif 34 26 35 27 36 #ifdef __cforall -
src/tests/.expect/io.txt
rade20d0 r436c0de 4 4 123 5 5 6 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10 7 1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x 8 x`1`x'2'x"3"x:4:x 5 x 6 x 9 7 10 x 11 8 12 x 13 9 14 x 15 10 16 x 17 x ( 1 ) x 2 , x 3 :x: 4 6 18 A 7 19 1 2 3 4 5 6 7 8 … … 18 30 abc, $xyz 19 31 20 v(27 v[27 v{27 $27 =27 £27 ¥27 ¡27 ¿27 «27 21 25, 25. 25: 25; 25! 25? 25% 25¢ 25» 25) 25] 25} 22 25'27 25`27 25"27 25 27 25 23 27 25 24 27 25 25 27 25 27 25 26 27 32 1, 2, 3, 4 33 1, $2, $3 ", $" 34 1 2 3 " " 35 1 2 3 36 12 3 37 123 38 1 23 39 1 2 3 40 1 2 3 4 " " 41 1, 2, 3, 4 ", " 42 1, 2, 3, 4 27 43 3, 4, a, 7.2 28 44 3, 4, a, 7.2 29 45 3 4 a 7.2 30 3 4 a 7.234a7.2 46 3 4 a 7.234a7.23 4 a 7.2 31 47 3-4-a-7.2^3^4-3-4-a-7.2 -
src/tests/Makefile.am
rade20d0 r436c0de 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Thu May 25 14:39:15201714 ## Update Count : 4 313 ## Last Modified On : Thu Jun 8 07:41:43 2017 14 ## Update Count : 44 15 15 ############################################################################### 16 16 … … 20 20 21 21 if BUILD_CONCURRENCY 22 concurrent =yes23 quick_test += coroutine thread monitor24 concurrent_test =coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt22 concurrent = yes 23 quick_test += coroutine thread monitor 24 concurrent_test = coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt 25 25 else 26 26 concurrent=no … … 57 57 @+python test.py --debug=${debug} --concurrent=${concurrent} ${concurrent_test} 58 58 59 .dummy : .dummy.c 59 .dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@ 60 60 ${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@} #don't use CFLAGS, this rule is not a real test 61 61 62 dtor-early-exit-ERR1: dtor-early-exit.c 62 63 % : %.c @CFA_BINDIR@/@CFA_NAME@ 64 ${CC} ${CFLAGS} ${<} -o ${@} 65 66 dtor-early-exit-ERR1: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 63 67 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 64 68 65 dtor-early-exit-ERR2: dtor-early-exit.c 69 dtor-early-exit-ERR2: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 66 70 ${CC} ${CFLAGS} -DERR2 ${<} -o ${@} 67 71 68 declarationSpecifier: declarationSpecifier.c 72 declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@ 69 73 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 70 74 71 gccExtensions : gccExtensions.c 75 gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@ 72 76 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 73 77 74 extension : extension.c 78 extension : extension.c @CFA_BINDIR@/@CFA_NAME@ 75 79 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 76 80 77 attributes : attributes.c 81 attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@ 78 82 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 79 83 80 KRfunctions : KRfunctions.c 84 KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@ 81 85 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 82 86 83 gmp : gmp.c 87 gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@ 84 88 ${CC} ${CFLAGS} -lgmp ${<} -o ${@} 85 89 86 memberCtors-ERR1: memberCtors.c 90 memberCtors-ERR1: memberCtors.c @CFA_BINDIR@/@CFA_NAME@ 87 91 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 88 92 89 completeTypeError : completeTypeError.c 93 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@ 90 94 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
rade20d0 r436c0de 661 661 @+python test.py --debug=${debug} --concurrent=${concurrent} ${concurrent_test} 662 662 663 .dummy : .dummy.c 663 .dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@ 664 664 ${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@} #don't use CFLAGS, this rule is not a real test 665 665 666 dtor-early-exit-ERR1: dtor-early-exit.c 666 % : %.c @CFA_BINDIR@/@CFA_NAME@ 667 ${CC} ${CFLAGS} ${<} -o ${@} 668 669 dtor-early-exit-ERR1: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 667 670 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 668 671 669 dtor-early-exit-ERR2: dtor-early-exit.c 672 dtor-early-exit-ERR2: dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@ 670 673 ${CC} ${CFLAGS} -DERR2 ${<} -o ${@} 671 674 672 declarationSpecifier: declarationSpecifier.c 675 declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@ 673 676 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 674 677 675 gccExtensions : gccExtensions.c 678 gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@ 676 679 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 677 680 678 extension : extension.c 681 extension : extension.c @CFA_BINDIR@/@CFA_NAME@ 679 682 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 680 683 681 attributes : attributes.c 684 attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@ 682 685 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 683 686 684 KRfunctions : KRfunctions.c 687 KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@ 685 688 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 686 689 687 gmp : gmp.c 690 gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@ 688 691 ${CC} ${CFLAGS} -lgmp ${<} -o ${@} 689 692 690 memberCtors-ERR1: memberCtors.c 693 memberCtors-ERR1: memberCtors.c @CFA_BINDIR@/@CFA_NAME@ 691 694 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 692 695 693 completeTypeError : completeTypeError.c 696 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@ 694 697 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 695 698 -
src/tests/coroutine.c
rade20d0 r436c0de 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // fibonacci.c -- 8 // 9 // Author : Thierry Delisle 10 // Created On : Thu Jun 8 07:29:37 2017 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 8 07:37:12 2017 13 // Update Count : 5 14 // 15 1 16 #include <fstream> 2 17 #include <coroutine> 3 18 4 19 coroutine Fibonacci { 5 int fn;// used for communication20 int fn; // used for communication 6 21 }; 7 22 8 void ?{}( Fibonacci* this) {9 23 void ?{}( Fibonacci * this ) { 24 this->fn = 0; 10 25 } 11 26 12 void main( Fibonacci* this) {13 int fn1, fn2;// retained between resumes14 this->fn = 0; 15 16 suspend();// return to last resume27 void main( Fibonacci * this ) { 28 int fn1, fn2; // retained between resumes 29 this->fn = 0; // case 0 30 fn1 = this->fn; 31 suspend(); // return to last resume 17 32 18 this->fn = 1; 19 20 21 suspend();// return to last resume33 this->fn = 1; // case 1 34 fn2 = fn1; 35 fn1 = this->fn; 36 suspend(); // return to last resume 22 37 23 for ( ;; ) { 24 25 26 27 suspend();// return to last resume28 } 38 for ( ;; ) { // general case 39 this->fn = fn1 + fn2; 40 fn2 = fn1; 41 fn1 = this->fn; 42 suspend(); // return to last resume 43 } // for 29 44 } 30 45 31 int next( Fibonacci* this) {32 resume(this);// transfer to last suspend33 46 int next( Fibonacci * this ) { 47 resume( this ); // transfer to last suspend 48 return this->fn; 34 49 } 35 50 36 51 int main() { 37 Fibonacci f1, f2; 38 for ( int i = 1; i <= 10; i += 1 ) { 39 sout | next(&f1) | ' ' | next(&f2) | endl; 40 } 52 Fibonacci f1, f2; 53 for ( int i = 1; i <= 10; i += 1 ) { 54 sout | next( &f1 ) | ' ' | next( &f2 ) | endl; 55 } // for 56 } 41 57 42 return 0; 43 } 58 // Local Variables: // 59 // tab-width: 4 // 60 // compile-command: "cfa fibonacci.c" // 61 // End: // -
src/tests/identity.c
rade20d0 r436c0de 7 7 // identity.c -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 8 22:15:08 201613 // Update Count : 1 312 // Last Modified On : Thu Jun 8 08:21:32 2017 13 // Update Count : 18 14 14 // 15 15 … … 32 32 sout | "double\t\t\t" | identity( 4.1 ) | endl; 33 33 sout | "long double\t\t" | identity( 4.1l ) | endl; 34 sout | "float _Complex\t\t" | identity( -4.1F-2.0iF ) | endl; 35 sout | "double _Complex\t\t" | identity( -4.1D-2.0iD ) | endl; 36 sout | "long double _Complex\t" | identity( -4.1L-2.0iL ) | endl; 34 37 } 35 38 -
src/tests/io.c
rade20d0 r436c0de 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 21 22:36:06201713 // Update Count : 4812 // Last Modified On : Thu Jun 8 09:52:10 2017 13 // Update Count : 51 14 14 // 15 15 … … 17 17 18 18 int main() { 19 char c; 19 char c; // basic types 20 20 short int si; 21 21 unsigned short int usi; … … 32 32 double _Complex dc; 33 33 long double _Complex ldc; 34 char s1[10], s2[10]; 34 enum { size = 10 }; 35 char s1[size], s2[size]; 35 36 36 37 int x = 3, y = 5, z = 7; … … 41 42 sout | endl; 42 43 43 ifstream in; // create / open file 44 sout 45 // opening delimiters 46 | "x (" | 1 47 | "x [" | 2 48 | "x {" | 3 49 | "x =" | 4 50 | "x $" | 5 51 | "x £" | 6 52 | "x ¥" | 7 53 | "x ¡" | 8 54 | "x ¿" | 9 55 | "x «" | 10 56 | endl; 57 sout 58 // closing delimiters 59 | 1 | ", x" 60 | 2 | ". x" 61 | 3 | "; x" 62 | 4 | "! x" 63 | 5 | "? x" 64 | 6 | "% x" 65 | 7 | "¢ x" 66 | 8 | "» x" 67 | 9 | ") x" 68 | 10 | "] x" 69 | 11 | "} x" 70 | endl; 71 sout 72 // opening-closing delimiters 73 | "x`" | 1 | "`x'" | 2 74 | "'x\"" | 3 | "\"x:" | 4 75 | ":x " | 5 | " x\t" | 6 76 | "\tx\f" | 7 | "\fx\v" | 8 77 | "\vx\n" | 9 | "\nx\r" | 10 78 | "\rx" | 79 endl; 80 sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl; 81 82 ifstream in; // create / open file 44 83 open( &in, "io.data", "r" ); 45 84 46 &in | &c 47 | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli 48 | &f | &d | &ld 49 | &fc | &dc | &ldc 50 | cstr( s1 ) | cstr( s2, 10 );// C string, length unchecked and checked85 &in | &c // character 86 | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli // integral 87 | &f | &d | &ld // floating point 88 | &fc | &dc | &ldc // floating-point complex 89 | cstr( s1 ) | cstr( s2, size ); // C string, length unchecked and checked 51 90 52 sout | c | ' ' | endl 53 | si | usi | i | ui | li | uli | lli | ulli | endl// integral54 | f | d | ld | endl// floating point55 | fc | dc | ldc | endl;// complex91 sout | c | ' ' | endl // character 92 | si | usi | i | ui | li | uli | lli | ulli | endl // integral 93 | f | d | ld | endl // floating point 94 | fc | dc | ldc | endl; // complex 56 95 sout | endl; 57 sout | f | "" | d | "" | ld | endl 58 | sepDisable | fc | dc | ldc | sepEnable | endl// complex without separator59 | sepOn | s1 | sepOff | s2 | endl// local separator removal60 | s1 | "" | s2 | endl;// C string without separator96 sout | f | "" | d | "" | ld | endl // floating point without separator 97 | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator 98 | sepOn | s1 | sepOff | s2 | endl // local separator removal 99 | s1 | "" | s2 | endl; // C string without separator 61 100 sout | endl; 62 101 63 sepSet( sout, ", $" ); 102 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 64 103 sout | f | d | ld | endl 65 66 104 | fc | dc | ldc | endl 105 | s1 | s2 | endl; 67 106 sout | endl; 107 108 [int, int] t1 = [1, 2], t2 = [3, 4]; 109 sout | t1 | t2 | endl; // print tuple 110 68 111 sepSet( sout, " " ); 112 sepSet( sout, ", $" ); // set separator from " " to ", $" 113 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl; 114 sepSet( sout, " " ); // reset separator to " " 115 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl; 69 116 70 sout 71 // opening delimiters 72 | "v(" | 27 73 | "v[" | 27 74 | "v{" | 27 75 | "$" | 27 76 | "=" | 27 77 | "£" | 27 78 | "¥" | 27 79 | "¡" | 27 80 | "¿" | 27 81 | "«" | 27 82 | endl 83 // closing delimiters 84 | 25 | "," 85 | 25 | "." 86 | 25 | ":" 87 | 25 | ";" 88 | 25 | "!" 89 | 25 | "?" 90 | 25 | "%" 91 | 25 | "¢" 92 | 25 | "»" 93 | 25 | ")" 94 | 25 | "]" 95 | 25 | "}" 96 | endl 97 // opening-closing delimiters 98 | 25 | "'" | 27 99 | 25 | "`" | 27 100 | 25 | "\"" | 27 101 | 25 | " " | 27 102 | 25 | "\f" | 27 103 | 25 | "\n" | 27 104 | 25 | "\r" | 27 105 | 25 | "\t" | 27 106 | 25 | "\v" | 27 107 | endl; 117 sout | sepOn | 1 | 2 | 3 | sepOn | endl; // separator at start of line 118 sout | 1 | sepOff | 2 | 3 | endl; // locally turn off implicit separator 108 119 109 [int, int, const char *, double] t = { 3, 4, "a", 7.2 }; 120 sout | sepDisable | 1 | 2 | 3 | endl; // globally turn off implicit separation 121 sout | 1 | sepOn | 2 | 3 | endl; // locally turn on implicit separator 122 sout | sepEnable | 1 | 2 | 3 | endl; // globally turn on implicit separation 123 124 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 125 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 126 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 127 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 128 129 sout | t1 | t2 | endl; // print tuple 130 131 [int, int, const char *, double] t3 = { 3, 4, "a", 7.2 }; 110 132 sout | [ 3, 4, "a", 7.2 ] | endl; 111 sout | t | endl;133 sout | t3 | endl; 112 134 sepSetTuple( sout, " " ); 113 sout | t | endl;114 sout | sepOn | t | sepDisable | t | sepEnable | t| endl;135 sout | t3 | endl; 136 sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3 | endl; 115 137 sepSet( sout, "^" ); 116 138 sepSetTuple( sout, "-" ); 117 sout | t | 3 | 4 | t| endl;139 sout | t3 | 3 | 4 | t3 | endl; 118 140 } 119 141
Note:
See TracChangeset
for help on using the changeset viewer.