Changeset b21c77a for src/Common


Ignore:
Timestamp:
Jun 29, 2018, 4:14:15 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge remote-tracking branch 'origin/with_gc' into new-env

Location:
src/Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Debug.h

    r97397a26 rb21c77a  
    2828namespace Debug {
    2929        /// 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 ) {
    3131        #ifdef DEBUG
    3232                std::list< Declaration * > decls;
  • src/Common/PassVisitor.h

    r97397a26 rb21c77a  
    125125        virtual void visit( InitExpr *  initExpr ) override final;
    126126        virtual void visit( DeletedExpr *  delExpr ) override final;
     127        virtual void visit( DefaultArgExpr * argExpr ) override final;
     128        virtual void visit( GenericExpr * genExpr ) override final;
    127129
    128130        virtual void visit( VoidType * basicType ) override final;
     
    225227        virtual Expression * mutate( InitExpr *  initExpr ) override final;
    226228        virtual Expression * mutate( DeletedExpr *  delExpr ) override final;
     229        virtual Expression * mutate( DefaultArgExpr * argExpr ) override final;
     230        virtual Expression * mutate( GenericExpr * genExpr ) override final;
    227231
    228232        virtual Type * mutate( VoidType * basicType ) override final;
     
    258262
    259263private:
     264        bool inFunction = false;
     265
    260266        template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
    261267        template<typename pass_t> friend void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
     
    313319        void indexerAddUnionFwd ( UnionDecl                 * node  ) { indexer_impl_addUnionFwd ( pass, 0, node ); }
    314320        void indexerAddTrait    ( TraitDecl                 * node  ) { indexer_impl_addTrait    ( pass, 0, node ); }
    315         void indexerAddWith     ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith     ( pass, 0, exprs, withStmt ); }
     321        void indexerAddWith     ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith( pass, 0, exprs, withStmt ); }
    316322
    317323
  • src/Common/PassVisitor.impl.h

    r97397a26 rb21c77a  
    404404                        indexerAddId( func );
    405405                        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;
    406410                        maybeAccept_impl( node->statements, *this );
    407411                        maybeAccept_impl( node->attributes, *this );
     
    434438                        indexerAddId( func );
    435439                        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;
    436444                        maybeMutate_impl( node->statements, *this );
    437445                        maybeMutate_impl( node->attributes, *this );
     
    712720        VISIT_START( node );
    713721        {
    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(); } );
    715725                auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } );
     726                inFunction = false;
    716727                visitStatementList( node->kids );
    717728        }
     
    723734        MUTATE_START( node );
    724735        {
    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(); } );
    726739                auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } );
     740                inFunction = false;
    727741                mutateStatementList( node->kids );
    728742        }
     
    828842        VISIT_START( node );
    829843
    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        }
    832851
    833852        VISIT_END( node );
     
    838857        MUTATE_START( node );
    839858
    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
    842867
    843868        MUTATE_END( Statement, node );
     
    20742099
    20752100//--------------------------------------------------------------------------
     2101// DefaultArgExpr
     2102template< typename pass_type >
     2103void 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
     2112template< typename pass_type >
     2113Expression * 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
     2125template< typename pass_type >
     2126void 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
     2139template< typename pass_type >
     2140Expression * 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//--------------------------------------------------------------------------
    20762155// VoidType
    20772156template< typename pass_type >
  • src/Common/SemanticError.cc

    r97397a26 rb21c77a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 16 15:01:20 2018
    13 // Update Count     : 9
     12// Last Modified On : Thu Jun  7 08:05:26 2018
     13// Update Count     : 10
    1414//
    1515
     
    9797void SemanticError( CodeLocation location, std::string error ) {
    9898        SemanticErrorThrow = true;
    99         throw SemanticErrorException(location, error);
     99        throw SemanticErrorException( location, error );
    100100}
    101101
Note: See TracChangeset for help on using the changeset viewer.