Changeset b7d6a36 for src/ControlStruct/LabelFixer.cc
- Timestamp:
- Feb 20, 2020, 4:15:51 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 6a490b2
- Parents:
- dca5802 (diff), 2cbfe92 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/LabelFixer.cc
rdca5802 rb7d6a36 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Mar 11 22:26:02 201913 // Update Count : 1 5911 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jan 21 10:32:00 2020 13 // Update Count : 160 14 14 // 15 15 … … 21 21 #include "ControlStruct/LabelGenerator.h" // for LabelGenerator 22 22 #include "LabelFixer.h" 23 #include "MLEMutator.h" // for M LEMutator23 #include "MLEMutator.h" // for MultiLevelExitMutator 24 24 #include "SynTree/Declaration.h" // for FunctionDecl 25 25 #include "SynTree/Expression.h" // for NameExpr, Expression, Unty... … … 44 44 45 45 void LabelFixer::postvisit( FunctionDecl * functionDecl ) { 46 PassVisitor<MLEMutator> mlemut( resolveJumps(), generator ); 47 functionDecl->acceptMutator( mlemut ); 46 PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator ); 47 // We start in the body so we can stop when we hit another FunctionDecl. 48 maybeMutate( functionDecl->statements, mlem ); 48 49 } 49 50 … … 75 76 76 77 77 // sets the definition of the labelTable entry to be the provided statement for every label in the list78 // parameter. Happens for every kind of statement78 // Sets the definition of the labelTable entry to be the provided statement for every label in 79 // the list parameter. Happens for every kind of statement. 79 80 Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) { 80 81 assert( definition != 0 ); 81 82 assert( llabel.size() > 0 ); 82 83 Entry * e = new Entry( definition );84 83 85 84 for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) { … … 87 86 l.set_statement( definition ); // attach statement to the label to be used later 88 87 if ( labelTable.find( l ) == labelTable.end() ) { 89 // all labels on this statement need to use the same entry, so this should only be created once 88 // All labels on this statement need to use the same entry, 89 // so this should only be created once. 90 90 // undefined and unused until now, add an entry 91 labelTable[ l ] = e;91 labelTable[ l ] = new Entry( definition ); 92 92 } else if ( labelTable[ l ]->defined() ) { 93 93 // defined twice, error 94 SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() ); 95 } else { 94 SemanticError( l.get_statement()->location, 95 "Duplicate definition of label: " + l.get_name() ); 96 } else { 96 97 // used previously, but undefined until now -> link with this entry 98 // Question: Is changing objects important? 97 99 delete labelTable[ l ]; 98 labelTable[ l ] = e;100 labelTable[ l ] = new Entry( definition ); 99 101 } // if 100 102 } // for 101 103 102 // produce one of the labels attached to this statement to be temporarily used as the canonical label 104 // Produce one of the labels attached to this statement to be temporarily used as the 105 // canonical label. 103 106 return labelTable[ llabel.front() ]->get_label(); 104 107 }
Note:
See TracChangeset
for help on using the changeset viewer.