Changeset cc32d83


Ignore:
Timestamp:
May 3, 2018, 4:10:05 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
b97ebf1
Parents:
637dd9c
Message:

Push pragma directives through the translator

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r637dd9c rcc32d83  
    887887                if ( asmStmt->get_instruction() ) asmStmt->get_instruction()->accept( *visitor );
    888888                output << " )" ;
     889        }
     890
     891        void CodeGenerator::postvisit( DirectiveStmt * dirStmt ) {
     892                output << dirStmt->directive;
    889893        }
    890894
  • src/CodeGen/CodeGenerator.h

    r637dd9c rcc32d83  
    9999                void postvisit( ExprStmt * );
    100100                void postvisit( AsmStmt * );
     101                void postvisit( DirectiveStmt * );
    101102                void postvisit( AsmDecl * );                            // special: statement in declaration context
    102103                void postvisit( IfStmt * );
  • src/Common/PassVisitor.h

    r637dd9c rcc32d83  
    7171        virtual void visit( ExprStmt * exprStmt ) override final;
    7272        virtual void visit( AsmStmt * asmStmt ) override final;
     73        virtual void visit( DirectiveStmt * dirStmt ) override final;
    7374        virtual void visit( IfStmt * ifStmt ) override final;
    7475        virtual void visit( WhileStmt * whileStmt ) override final;
     
    168169        virtual Statement * mutate( ExprStmt * exprStmt ) override final;
    169170        virtual Statement * mutate( AsmStmt * asmStmt ) override final;
     171        virtual Statement * mutate( DirectiveStmt * dirStmt ) override final;
    170172        virtual Statement * mutate( IfStmt * ifStmt ) override final;
    171173        virtual Statement * mutate( WhileStmt * whileStmt ) override final;
  • src/Common/PassVisitor.impl.h

    r637dd9c rcc32d83  
    777777
    778778//--------------------------------------------------------------------------
     779// AsmStmt
     780template< typename pass_type >
     781void PassVisitor< pass_type >::visit( DirectiveStmt * node ) {
     782        VISIT_START( node )
     783
     784        VISIT_END( node );
     785}
     786
     787template< typename pass_type >
     788Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) {
     789        MUTATE_START( node );
     790
     791        MUTATE_END( Statement, node );
     792}
     793
     794//--------------------------------------------------------------------------
    779795// IfStmt
    780796template< typename pass_type >
  • src/Parser/StatementNode.cc

    r637dd9c rcc32d83  
    321321
    322322Statement * build_directive( string * directive ) {
    323         cout << *directive << endl;
    324         return nullptr;
     323        return new DirectiveStmt( *directive );
    325324}
    326325
  • src/SynTree/Mutator.h

    r637dd9c rcc32d83  
    3939        virtual Statement * mutate( ExprStmt * exprStmt ) = 0;
    4040        virtual Statement * mutate( AsmStmt * asmStmt ) = 0;
     41        virtual Statement * mutate( DirectiveStmt * dirStmt ) = 0;
    4142        virtual Statement * mutate( IfStmt * ifStmt ) = 0;
    4243        virtual Statement * mutate( WhileStmt * whileStmt ) = 0;
  • src/SynTree/Statement.cc

    r637dd9c rcc32d83  
    9494
    9595
     96DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {}
     97
     98void DirectiveStmt::print( std::ostream &os, Indenter ) const {
     99        os << "GCC Directive:" << directive << endl;
     100}
     101
     102
    96103const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    97104
  • src/SynTree/Statement.h

    r637dd9c rcc32d83  
    126126};
    127127
     128class DirectiveStmt : public Statement {
     129        public:
     130        std::string directive;
     131
     132        DirectiveStmt( const std::string & );
     133        virtual ~DirectiveStmt(){}
     134
     135        virtual DirectiveStmt * clone() const { return new DirectiveStmt( *this ); }
     136        virtual void accept( Visitor & v ) { v.visit( this ); }
     137        virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     138        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     139};
     140
    128141class IfStmt : public Statement {
    129142  public:
  • src/SynTree/SynTree.h

    r637dd9c rcc32d83  
    4444class ExprStmt;
    4545class AsmStmt;
     46class DirectiveStmt;
    4647class IfStmt;
    4748class WhileStmt;
  • src/SynTree/Visitor.h

    r637dd9c rcc32d83  
    4141        virtual void visit( ExprStmt * exprStmt ) = 0;
    4242        virtual void visit( AsmStmt * asmStmt ) = 0;
     43        virtual void visit( DirectiveStmt * directiveStmt ) = 0;
    4344        virtual void visit( IfStmt * ifStmt ) = 0;
    4445        virtual void visit( WhileStmt * whileStmt ) = 0;
Note: See TracChangeset for help on using the changeset viewer.