Changeset cc287800 for src/ControlStruct


Ignore:
Timestamp:
Nov 8, 2021, 5:28:21 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
36a05d7
Parents:
949339b (diff), 5ee153d (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 branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/ControlStruct
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    r949339b rcc287800  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ExceptVisitor.cc --
     7// ExceptTranslate.cc -- Conversion of exception control flow structures.
    88//
    99// Author           : Andrew Beach
  • src/ControlStruct/ExceptTranslate.h

    r949339b rcc287800  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ExceptTranslate.h --
     7// ExceptTranslate.h -- Conversion of exception control flow structures.
    88//
    99// Author           : Andrew Beach
    1010// Created On       : Tus Jun 06 10:13:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus May 19 11:47:00 2020
    13 // Update Count     : 5
     12// Last Modified On : Mon Nov  8 11:43:00 2020
     13// Update Count     : 6
    1414//
    1515
     
    1919
    2020class Declaration;
     21namespace ast {
     22        class TranslationUnit;
     23}
    2124
    2225namespace ControlStruct {
    2326        void translateThrows( std::list< Declaration *> & translationUnit );
     27        void translateThrows( ast::TranslationUnit & transUnit );
    2428        /* Replaces all throw & throwResume statements with function calls.
    2529         * These still need to be resolved, so call this before the reslover.
  • src/ControlStruct/LabelGenerator.cc

    r949339b rcc287800  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 11 22:23:20 2019
    13 // Update Count     : 15
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Nov  8 10:18:00 2021
     13// Update Count     : 17
    1414//
    1515
     
    1919
    2020#include "LabelGenerator.h"
     21
     22#include "AST/Attribute.hpp"
     23#include "AST/Label.hpp"
     24#include "AST/Stmt.hpp"
    2125#include "SynTree/Attribute.h"  // for Attribute
    2226#include "SynTree/Label.h"      // for Label, operator<<
     
    2428
    2529namespace ControlStruct {
    26         LabelGenerator * LabelGenerator::labelGenerator = 0;
     30
     31int LabelGenerator::current = 0;
     32LabelGenerator * LabelGenerator::labelGenerator = nullptr;
    2733
    2834        LabelGenerator * LabelGenerator::getGenerator() {
     
    4349                return l;
    4450        }
     51
     52ast::Label LabelGenerator::newLabel(
     53                const std::string & suffix, const ast::Stmt * stmt ) {
     54        assert( stmt );
     55
     56        std::ostringstream os;
     57        os << "__L" << current++ << "__" << suffix;
     58        if ( stmt && !stmt->labels.empty() ) {
     59                os << "_" << stmt->labels.front() << "__";
     60        }
     61        ast::Label ret_label( stmt->location, os.str() );
     62        ret_label.attributes.push_back( new ast::Attribute( "unused" ) );
     63        return ret_label;
     64}
     65
    4566} // namespace ControlStruct
    4667
  • src/ControlStruct/LabelGenerator.h

    r949339b rcc287800  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:20:14 2017
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Nov  8 10:16:00 2021
     13// Update Count     : 8
    1414//
    1515
     
    2121
    2222class Statement;
     23namespace ast {
     24        class Stmt;
     25        class Label;
     26}
    2327
    2428namespace ControlStruct {
    25         class LabelGenerator {
    26           public:
    27                 static LabelGenerator *getGenerator();
    28                 Label newLabel(std::string suffix, Statement * stmt = nullptr);
    29                 void reset() { current = 0; }
    30                 void rewind() { current--; }
    31           protected:
    32                 LabelGenerator(): current(0) {}
    33           private:
    34                 int current;
    35                 static LabelGenerator *labelGenerator;
    36         };
     29
     30class LabelGenerator {
     31        static int current;
     32        static LabelGenerator *labelGenerator;
     33protected:
     34        LabelGenerator() {}
     35public:
     36        static LabelGenerator *getGenerator();
     37        static Label newLabel(std::string suffix, Statement * stmt = nullptr);
     38        static ast::Label newLabel( const std::string&, const ast::Stmt * );
     39        static void reset() { current = 0; }
     40        static void rewind() { current--; }
     41};
     42
    3743} // namespace ControlStruct
    3844
  • src/ControlStruct/module.mk

    r949339b rcc287800  
    1818        ControlStruct/ExceptDecl.cc \
    1919        ControlStruct/ExceptDecl.h \
     20        ControlStruct/FixLabels.cpp \
     21        ControlStruct/FixLabels.hpp \
    2022        ControlStruct/ForExprMutator.cc \
    2123        ControlStruct/ForExprMutator.h \
     
    2628        ControlStruct/MLEMutator.cc \
    2729        ControlStruct/MLEMutator.h \
     30        ControlStruct/MultiLevelExit.cpp \
     31        ControlStruct/MultiLevelExit.hpp \
    2832        ControlStruct/Mutate.cc \
    2933        ControlStruct/Mutate.h
    3034
    31 SRC += $(SRC_CONTROLSTRUCT) ControlStruct/ExceptTranslate.cc ControlStruct/ExceptTranslate.h
     35SRC += $(SRC_CONTROLSTRUCT) \
     36        ControlStruct/ExceptTranslateNew.cpp \
     37        ControlStruct/ExceptTranslate.cc \
     38        ControlStruct/ExceptTranslate.h
     39
    3240SRCDEMANGLE += $(SRC_CONTROLSTRUCT)
    3341
Note: See TracChangeset for help on using the changeset viewer.