source: src/ControlStruct/LabelGenerator.cc@ af397ef8

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since af397ef8 was af68f0a, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

change all break/continue statements into goto for consistency and fix bug with labeled break

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[51587aa]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[0f8e4ac]7// LabelGenerator.cc --
[51587aa]8//
[843054c2]9// Author : Rodolfo G. Esteves
[51587aa]10// Created On : Mon May 18 07:44:20 2015
[5f2f2d7]11// Last Modified By : Peter A. Buhr
[de62360d]12// Last Modified On : Tue Jun 23 12:18:34 2015
13// Update Count : 13
[51587aa]14//
[a08ba92]15
[51b73452]16#include <iostream>
[5f2f2d7]17#include <sstream>
[51b73452]18
19#include "LabelGenerator.h"
[0f8e4ac]20#include "SynTree/Label.h"
[888cbe4]21#include "SynTree/Attribute.h"
[af68f0a]22#include "SynTree/Statement.h"
[51b73452]23
24namespace ControlStruct {
[a08ba92]25 LabelGenerator *LabelGenerator::labelGenerator = 0;
[51b73452]26
[a08ba92]27 LabelGenerator *LabelGenerator::getGenerator() {
28 if ( LabelGenerator::labelGenerator == 0 )
29 LabelGenerator::labelGenerator = new LabelGenerator();
[51b73452]30
[a08ba92]31 return labelGenerator;
32 }
[51b73452]33
[af68f0a]34 Label LabelGenerator::newLabel( std::string suffix, Statement * stmt ) {
[5f2f2d7]35 std::ostringstream os;
[27de955]36 os << "__L" << current++ << "__" << suffix;
[af68f0a]37 if ( stmt && ! stmt->get_labels().empty() ) {
38 os << "_" << stmt->get_labels().front() << "__";
39 }
[5f2f2d7]40 std::string ret = os.str();
[888cbe4]41 Label l( ret );
42 l.get_attributes().push_back( new Attribute("unused") );
43 return l;
[a08ba92]44 }
[51b73452]45} // namespace ControlStruct
[a08ba92]46
[51587aa]47// Local Variables: //
48// tab-width: 4 //
49// mode: c++ //
50// compile-command: "make install" //
51// End: //
Note: See TracBrowser for help on using the repository browser.