- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/LabelFixer.cc
r23b6f4d7 re766208 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // LabelFixer.cc -- 7 // LabelFixer.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 22 22 #include "SynTree/Statement.h" 23 23 #include "SynTree/Declaration.h" 24 #include " Common/utility.h"24 #include "utility.h" 25 25 26 26 #include <iostream> … … 86 86 87 87 88 // sets the definition of the labelTable entry to be the provided 88 // sets the definition of the labelTable entry to be the provided 89 89 // statement for every label in the list parameter. Happens for every kind of statement 90 90 Label LabelFixer::setLabelsDef( std::list< Label > &llabel, Statement *definition ) { … … 95 95 96 96 for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) { 97 Label & l = *i; 98 l.set_statement( definition ); // attach statement to the label to be used later 99 if ( labelTable.find( l ) == labelTable.end() ) { 97 if ( labelTable.find( *i ) == labelTable.end() ) { 100 98 // all labels on this statement need to use the same entry, so this should only be created once 101 99 // undefined and unused until now, add an entry 102 labelTable[ l] = e;103 } else if ( labelTable[ l]->defined() ) {100 labelTable[ *i ] = e; 101 } else if ( labelTable[ *i ]->defined() ) { 104 102 // defined twice, error 105 throw SemanticError( "Duplicate definition of label: " + l.get_name());103 throw SemanticError( "Duplicate definition of label: " + *i ); 106 104 } else { 107 105 // used previously, but undefined until now -> link with this entry 108 delete labelTable[ l];109 labelTable[ l] = e;106 delete labelTable[ *i ]; 107 labelTable[ *i ] = e; 110 108 } // if 111 109 } // for 112 110 113 // produce one of the labels attached to this statement to be 111 // produce one of the labels attached to this statement to be 114 112 // temporarily used as the canonical label 115 113 return labelTable[ llabel.front() ]->get_label(); 116 114 } 117 115 118 // A label was used, add it tothe table if it isn't already there116 // A label was used, add it ot the table if it isn't already there 119 117 template< typename UsageNode > 120 118 void LabelFixer::setLabelsUsg( Label orgValue, UsageNode *use ) { … … 132 130 for ( std::map< Label, Entry * >::iterator i = labelTable.begin(); i != labelTable.end(); ++i ) { 133 131 if ( ! i->second->defined() ) { 134 throw SemanticError( "Use of undefined label: " + i->first .get_name());132 throw SemanticError( "Use of undefined label: " + i->first ); 135 133 } 136 134 (*ret)[ i->first ] = i->second->get_definition();
Note:
See TracChangeset
for help on using the changeset viewer.