Logo Search packages:      
Sourcecode: fauhdlc version File versions

void ast::GenCode::processAlternative ( CaseAlternative node,
intermediate::Operand cmpVal,
intermediate::Label caseNext,
intermediate::Label caseOut 
) [private]

process (w. direct dispatch) to CaseAlternative

Parameters:
node CaseAlternative node.
cmpVal compare value of CaseStat node.
caseNext label to jump to for the next alternative. This might be the same as caseOut.
caseOut label to jump to after the case statement.

Definition at line 2535 of file GenCode.cpp.

References intermediate::CodeContainer::addCode(), assignExpression, container, intermediate::LabelFactory::getLabel(), ast::RegisterSet::getValue(), isTarget, ast::CaseAlternative::isVals, ast::Visitor::listTraverse(), sourceRegs, and ast::CaseAlternative::thenStats.

Referenced by visit().

{
      assert(node.isVals != NULL);
      assert(node.thenStats != NULL);

      Label *altFound = LabelFactory::getLabel("alternative_execute");

      for (std::list<Expression *>::const_iterator i = 
            node.isVals->begin(); i != node.isVals->end(); i++) {

            const Others *others = dynamic_cast<const Others*>(*i);
            if (others != NULL) {
                  Jmp *jmp = new Jmp(altFound);
                  this->container->addCode(jmp);
                  break;
            }

            this->assignExpression = false;
            this->isTarget = false;
            this->sourceRegs = RegisterSet(*this->container);
            (*i)->accept(*this);

            Operand *choice = this->sourceRegs.getValue((*i)->baseType);
            Je *je = new Je(cmpVal, choice, altFound);
            this->container->addCode(je);
      }

      Jmp *jmp = new Jmp(caseNext);
      this->container->addCode(jmp);
      this->container->addCode(altFound);

      this->sourceRegs = RegisterSet(*this->container);
      this->listTraverse(*node.thenStats);
      Jmp *jmp2 = new Jmp(caseOut);
      this->container->addCode(jmp2);
}


Generated by  Doxygen 1.6.0   Back to index