Ignore:
Timestamp:
Dec 16, 2014, 9:41:50 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
17cd4eb
Parents:
3848e0e
Message:

remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/ControlStruct/LabelFixer.h

    r3848e0e rd9a0e76  
    1212
    1313namespace ControlStruct {
     14    class LabelFixer : public Visitor {
     15        typedef Visitor Parent;
     16      public:
     17        LabelFixer( LabelGenerator *gen = 0 );
    1418
    15   class LabelFixer : public Visitor
    16     {
    17       typedef Visitor Parent;
     19        std::map < Label, Statement * > *resolveJumps() throw ( SemanticError );
    1820
    19     public:
    20       LabelFixer( LabelGenerator *gen = 0 );
     21        // Declarations
     22        virtual void visit( FunctionDecl *functionDecl );
    2123
    22       std::map < Label, Statement * > *resolveJumps() throw ( SemanticError );
     24        // Statements
     25        void visit( Statement *stmt );
    2326
    24       // Declarations
    25       virtual void visit(FunctionDecl *functionDecl);
     27        virtual void visit( CompoundStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     28        virtual void visit( NullStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     29        virtual void visit( ExprStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     30        virtual void visit( IfStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     31        virtual void visit( WhileStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     32        virtual void visit( ForStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     33        virtual void visit( SwitchStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     34        virtual void visit( ChooseStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     35        virtual void visit( FallthruStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     36        virtual void visit( CaseStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     37        virtual void visit( ReturnStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     38        virtual void visit( TryStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     39        virtual void visit( CatchStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     40        virtual void visit( DeclStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
     41        virtual void visit( BranchStmt *branchStmt );
    2642
    27       // Statements
    28       void visit(Statement *stmt);
     43        Label setLabelsDef( std::list< Label > &, Statement *definition );
     44        Label setLabelsUsg( Label, Statement *usage = 0 );
    2945
    30       virtual void visit(CompoundStmt *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    31       virtual void visit(NullStmt     *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    32       virtual void visit(ExprStmt     *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    33       virtual void visit(IfStmt       *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    34       virtual void visit(WhileStmt    *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    35       virtual void visit(ForStmt      *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    36       virtual void visit(SwitchStmt   *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    37       virtual void visit(ChooseStmt   *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    38       virtual void visit(FallthruStmt *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    39       virtual void visit(CaseStmt     *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    40       virtual void visit(ReturnStmt   *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    41       virtual void visit(TryStmt      *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    42       virtual void visit(CatchStmt    *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    43       virtual void visit(DeclStmt     *stmt) {  visit( (Statement *)stmt ); return Parent::visit(stmt); }
    44       virtual void visit(BranchStmt   *branchStmt);
     46      private:
     47        class Entry {
     48          public:
     49            Entry( Statement *to = 0, Statement *from = 0 );
     50            bool used() { return ( usage.empty() ); }
     51            bool defined() { return ( definition != 0 ); }
     52            bool insideLoop();
    4553
    46       Label setLabelsDef( std::list< Label > &, Statement *definition );
    47       Label setLabelsUsg( Label, Statement *usage = 0 );
     54            Label get_label() const { return label; }
     55            Statement *get_definition() const { return definition; }
     56            std::list< Statement *> &get_uses() { return usage; }
    4857
    49     private:
    50       class Entry
    51       {
    52       public:
    53         Entry( Statement *to = 0, Statement *from = 0 );
    54         bool used() { return ( usage.empty() ); }
    55         bool defined() { return ( definition != 0 ); }
    56         bool insideLoop();
     58            void add_use ( Statement *use ) { usage.push_back( use ); }
     59            void add_uses ( std::list<Statement *> uses ) { usage.insert( usage.end(), uses.begin(), uses.end() ); }
     60            void set_definition( Statement *def ) { definition = def; }
    5761
    58         Label get_label() const { return label; }
    59         Statement *get_definition() const { return definition; }
    60         std::list< Statement *> &get_uses() { return usage; }
    61 
    62         void add_use ( Statement *use ) { usage.push_back(use); }
    63         void add_uses ( std::list<Statement *> uses ) { usage.insert( usage.end(), uses.begin(), uses.end() ); }
    64         void set_definition( Statement *def ) { definition = def; }
    65 
    66         void set_label( Label lab ) { label = lab; }
    67         Label gset_label() const { return label; }
    68       private:
    69         Label label; 
    70         Statement *definition;
    71         std::list<Statement *> usage;
    72       };
     62            void set_label( Label lab ) { label = lab; }
     63            Label gset_label() const { return label; }
     64          private:
     65            Label label; 
     66            Statement *definition;
     67            std::list<Statement *> usage;
     68        };
    7369             
    74       std::map < Label, Entry *> labelTable;
    75       LabelGenerator *generator;
     70        std::map < Label, Entry *> labelTable;
     71        LabelGenerator *generator;
    7672    };
    7773} // namespace ControlStruct
    7874
    79 #endif // #ifndef LABEL_FIXER_H
     75#endif // LABEL_FIXER_H
    8076
    8177/*
Note: See TracChangeset for help on using the changeset viewer.