Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

bool Optimizer::redirectGotos ( Instruction current,
const QString &  label 
) [protected]

Redirects any GOTOs that point at the given instruction to the given label.

Returns:
whether any GOTOs were redirected

Definition at line 412 of file optimizer.cpp.

References Instruction::inputLinks(), Instruction::isUsed(), and Instruction::setUsed().

Referenced by optimizeInstructions().

{
      if ( current->isUsed() )
            return false;
      
      current->setUsed( true );
      
      bool changed = false;
      
      const InstructionList list = current->inputLinks();
      InstructionList::const_iterator end = list.end();
      for ( InstructionList::const_iterator it = list.begin(); it != end; ++it )
      {
            Instr_goto * gotoIns = dynamic_cast<Instr_goto*>(*it);
            if ( !gotoIns || (gotoIns->label() == label) )
                  continue;
                        
//          cout << "Redirecting goto to label \"" << label << "\" : " << gotoIns->code() << endl;
            gotoIns->setLabel( label );
            changed = true;
      }
      
      return changed;
}


Generated by  Doxygen 1.6.0   Back to index