Ignore:
Timestamp:
Nov 5, 2021, 1:46:46 PM (3 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
21fe17f
Parents:
77c01ec
Message:

Fix Labels pass translated. This is fix label, mult-level exit and label generator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/LabelGenerator.cc

    r77c01ec rb8ab91a  
    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  1 12:21:00 2021
     13// Update Count     : 16
    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<<
     
    4347                return l;
    4448        }
     49
     50LabelGenerator_new * LabelGenerator_new::labelGenerator = nullptr;
     51
     52LabelGenerator_new * LabelGenerator_new::getGenerator() {
     53        if ( nullptr == labelGenerator ) {
     54                labelGenerator = new LabelGenerator_new();
     55        }
     56        return labelGenerator;
     57}
     58
     59ast::Label LabelGenerator_new::newLabel(
     60                const std::string & suffix, const ast::Stmt * stmt ) {
     61        assert( stmt );
     62
     63        std::ostringstream os;
     64        os << "__L" << current++ << "__" << suffix;
     65        if ( stmt && !stmt->labels.empty() ) {
     66                os << "_" << stmt->labels.front() << "__";
     67        }
     68        ast::Label ret_label( stmt->location, os.str() );
     69        ret_label.attributes.push_back( new ast::Attribute( "unused" ) );
     70        return ret_label;
     71}
     72
    4573} // namespace ControlStruct
    4674
Note: See TracChangeset for help on using the changeset viewer.