Changeset b21c77a for src/Common
- Timestamp:
- Jun 29, 2018, 4:14:15 PM (6 years ago)
- Branches:
- new-env
- Children:
- 184557e
- Parents:
- 97397a26 (diff), 28f3a19 (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/Common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/Debug.h
r97397a26 rb21c77a 28 28 namespace Debug { 29 29 /// debug codegen a translation unit 30 static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, __attribute__((unused)) LinkageSpec::Spec linkageFilter = LinkageSpec:: Compiler) {30 static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, __attribute__((unused)) LinkageSpec::Spec linkageFilter = LinkageSpec::Builtin ) { 31 31 #ifdef DEBUG 32 32 std::list< Declaration * > decls; -
src/Common/PassVisitor.h
r97397a26 rb21c77a 125 125 virtual void visit( InitExpr * initExpr ) override final; 126 126 virtual void visit( DeletedExpr * delExpr ) override final; 127 virtual void visit( DefaultArgExpr * argExpr ) override final; 128 virtual void visit( GenericExpr * genExpr ) override final; 127 129 128 130 virtual void visit( VoidType * basicType ) override final; … … 225 227 virtual Expression * mutate( InitExpr * initExpr ) override final; 226 228 virtual Expression * mutate( DeletedExpr * delExpr ) override final; 229 virtual Expression * mutate( DefaultArgExpr * argExpr ) override final; 230 virtual Expression * mutate( GenericExpr * genExpr ) override final; 227 231 228 232 virtual Type * mutate( VoidType * basicType ) override final; … … 258 262 259 263 private: 264 bool inFunction = false; 265 260 266 template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor ); 261 267 template<typename pass_t> friend void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor ); … … 313 319 void indexerAddUnionFwd ( UnionDecl * node ) { indexer_impl_addUnionFwd ( pass, 0, node ); } 314 320 void indexerAddTrait ( TraitDecl * node ) { indexer_impl_addTrait ( pass, 0, node ); } 315 void indexerAddWith ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith 321 void indexerAddWith ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith( pass, 0, exprs, withStmt ); } 316 322 317 323 -
src/Common/PassVisitor.impl.h
r97397a26 rb21c77a 404 404 indexerAddId( func ); 405 405 maybeAccept_impl( node->type, *this ); 406 // function body needs to have the same scope as parameters - CompoundStmt will not enter 407 // a new scope if inFunction is true 408 ValueGuard< bool > oldInFunction( inFunction ); 409 inFunction = true; 406 410 maybeAccept_impl( node->statements, *this ); 407 411 maybeAccept_impl( node->attributes, *this ); … … 434 438 indexerAddId( func ); 435 439 maybeMutate_impl( node->type, *this ); 440 // function body needs to have the same scope as parameters - CompoundStmt will not enter 441 // a new scope if inFunction is true 442 ValueGuard< bool > oldInFunction( inFunction ); 443 inFunction = true; 436 444 maybeMutate_impl( node->statements, *this ); 437 445 maybeMutate_impl( node->attributes, *this ); … … 712 720 VISIT_START( node ); 713 721 { 714 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 722 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 723 ValueGuard< bool > oldInFunction( inFunction ); 724 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } ); 715 725 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 726 inFunction = false; 716 727 visitStatementList( node->kids ); 717 728 } … … 723 734 MUTATE_START( node ); 724 735 { 725 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 736 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 737 ValueGuard< bool > oldInFunction( inFunction ); 738 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } ); 726 739 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 740 inFunction = false; 727 741 mutateStatementList( node->kids ); 728 742 } … … 828 842 VISIT_START( node ); 829 843 830 visitExpression( node->condition ); 831 node->body = visitStatement( node->body ); 844 { 845 // while statements introduce a level of scope (for the initialization) 846 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 847 maybeAccept_impl( node->initialization, *this ); 848 visitExpression ( node->condition ); 849 node->body = visitStatement( node->body ); 850 } 832 851 833 852 VISIT_END( node ); … … 838 857 MUTATE_START( node ); 839 858 840 node->condition = mutateExpression( node->condition ); 841 node->body = mutateStatement ( node->body ); 859 { 860 // while statements introduce a level of scope (for the initialization) 861 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 862 maybeMutate_impl( node->initialization, *this ); 863 node->condition = mutateExpression( node->condition ); 864 node->body = mutateStatement ( node->body ); 865 } 866 842 867 843 868 MUTATE_END( Statement, node ); … … 2074 2099 2075 2100 //-------------------------------------------------------------------------- 2101 // DefaultArgExpr 2102 template< typename pass_type > 2103 void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) { 2104 VISIT_START( node ); 2105 2106 indexerScopedAccept( node->result, *this ); 2107 maybeAccept_impl( node->expr, *this ); 2108 2109 VISIT_END( node ); 2110 } 2111 2112 template< typename pass_type > 2113 Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) { 2114 MUTATE_START( node ); 2115 2116 indexerScopedMutate( node->env, *this ); 2117 indexerScopedMutate( node->result, *this ); 2118 maybeMutate_impl( node->expr, *this ); 2119 2120 MUTATE_END( Expression, node ); 2121 } 2122 2123 //-------------------------------------------------------------------------- 2124 // GenericExpr 2125 template< typename pass_type > 2126 void PassVisitor< pass_type >::visit( GenericExpr * node ) { 2127 VISIT_START( node ); 2128 2129 indexerScopedAccept( node->result, *this ); 2130 maybeAccept_impl( node->control, *this ); 2131 for ( GenericExpr::Association & assoc : node->associations ) { 2132 indexerScopedAccept( assoc.type, *this ); 2133 maybeAccept_impl( assoc.expr, *this ); 2134 } 2135 2136 VISIT_END( node ); 2137 } 2138 2139 template< typename pass_type > 2140 Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) { 2141 MUTATE_START( node ); 2142 2143 indexerScopedMutate( node->env, *this ); 2144 indexerScopedMutate( node->result, *this ); 2145 maybeMutate_impl( node->control, *this ); 2146 for ( GenericExpr::Association & assoc : node->associations ) { 2147 indexerScopedMutate( assoc.type, *this ); 2148 maybeMutate_impl( assoc.expr, *this ); 2149 } 2150 2151 MUTATE_END( Expression, node ); 2152 } 2153 2154 //-------------------------------------------------------------------------- 2076 2155 // VoidType 2077 2156 template< typename pass_type > -
src/Common/SemanticError.cc
r97397a26 rb21c77a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 16 15:01:20201813 // Update Count : 912 // Last Modified On : Thu Jun 7 08:05:26 2018 13 // Update Count : 10 14 14 // 15 15 … … 97 97 void SemanticError( CodeLocation location, std::string error ) { 98 98 SemanticErrorThrow = true; 99 throw SemanticErrorException( location, error);99 throw SemanticErrorException( location, error ); 100 100 } 101 101
Note: See TracChangeset
for help on using the changeset viewer.